Esempio n. 1
0
 static function get($user, $password)
 {
     $mail = new GetMail();
     $url = 'https://login.sina.com.cn/sso/login.php';
     $post = array("username" => $user, "password" => $password, 'entry' => 'freemail', 'gateway' => 0, 'encoding' => 'UTF-8', 'url' => 'http://mail.sina.com.cn/', 'returntype' => 'META');
     $opts = array(CURLOPT_FOLLOWLOCATION => true);
     $body = $mail->post($url, $post, $opts);
     preg_match("/replace\\(\"(.*?)\"\\)\\;/", $body, $out);
     $url = $out[1];
     $body = $mail->post($url, $post, $opts);
     //$body = iconv('gb2312','utf-8',$body);
     $url = "http://mail.sina.com.cn/cgi-bin/login.php";
     $body = $mail->post($url, $post, $opts);
     preg_match_all("/sid=(.*)/i", $body, $out);
     $sid = $out[1][0];
     $sid = substr($sid, 0, 32);
     //通讯录地址
     $url = "http://g1a8.mail.yeah.net/jy3/address/addrlist.jsp?sid=" . $sid . "&gid=all";
     $body = $mail->post($url, array());
     $body = iconv('gb2312', 'utf-8', $body);
     $html = str_get_html($body);
     $table = $html->find('table[class=Ibx_gTable Ibx_gTable_Con] tr');
     foreach ($table as $tr) {
         $name = $tr->find('td[class=Ibx_Td_addrName]', 0)->plaintext;
         $email = $tr->find('td[class=Ibx_Td_addrEmail]', 0)->plaintext;
         $output[$name] = $email;
     }
     return $output;
 }
Esempio n. 2
0
 static function get($user, $password)
 {
     $mail = new GetMail();
     $url = 'http://w39.mail.qq.com/cgi-bin/login';
     $post = array('f' => 'xhtmlmp', 'tfcont' => '', 'uin' => $user, 'aliastype' => '@qq.com', 'pwd' => $password, 'mss' => '1');
     $body = $mail->post($url, $post);
     preg_match("/url=(http:\\/\\/.*?)\"/", $body, $out);
     $url = $out[1];
     //解决URL
     $arr = GetMail::params($url);
     $sid = $arr['sid'];
     $host = $arr['localhost'];
     $url = $host . "/cgi-bin/addr_listall?sid=" . $sid . "&flag=star&s=search&folderid=all&pagesize=10&from=today&fun=slock&page=0&topmails=0&t=addr_listall&loc=today,,,158'";
     $body = $mail->get($url);
     $html = str_get_html($body);
     foreach ($html->find("a") as $v) {
         $o = $v->innertext;
         if (false === strpos($o, '返回')) {
             echo $o;
             exit;
         }
     }
 }
Esempio n. 3
0
 static function get($user, $password)
 {
     $mail = new GetMail();
     $url = 'https://reg.163.com/logins.jsp?type=1&product=mailyeah&url=http://entry.mail.yeah.net/cgi/ntesdoor?lightweight%3D1%26verifycookie%3D1%26style%3D-1';
     $post = array("username" => $user, "password" => $password);
     $body = $mail->post($url, $post);
     $url = "https://ssl.mail.yeah.net/entry/cgi/ntesdoor?funcid=loginone&language=-1&passtype=1&iframe=1&product=mailyeah&from=web&df=emailyeah&race=149_46_37_bj&module=&uid={$usert}&style=-1&net=t&skinid=null";
     $body = $mail->post($url, $post);
     preg_match_all("/sid=(.*)/i", $body, $out);
     $sid = $out[1][0];
     $sid = substr($sid, 0, 32);
     //通讯录地址
     $url = "http://g1a8.mail.yeah.net/jy3/address/addrlist.jsp?sid=" . $sid . "&gid=all";
     $body = $mail->post($url, array());
     $body = iconv('gb2312', 'utf-8', $body);
     $html = str_get_html($body);
     $table = $html->find('table[class=Ibx_gTable Ibx_gTable_Con] tr');
     foreach ($table as $tr) {
         $name = $tr->find('td[class=Ibx_Td_addrName]', 0)->plaintext;
         $email = $tr->find('td[class=Ibx_Td_addrEmail]', 0)->plaintext;
         $output[$name] = $email;
     }
     return $output;
 }
Esempio n. 4
0
 static function get($user, $password)
 {
     $mail = new GetMail();
     $url = 'http://reg.163.com/logins.jsp';
     $post = array("username" => $user, "password" => $password, 'verifycookie' => 1, 'style' => -1, 'product' => 'mail163', 'selType' => -1, 'secure' => 'on');
     $body = $mail->post($url, $post);
     $url = "https://ssl.mail.163.com/entry/coremail/fcg/ntesdoor2?df=webmail163&from=web&funcid=loginone&iframe=1&language=-1&net=t&passtype=1&product=mail163&race=178_37_247_gz&style=-1&uid=" . $user . "@163.com";
     $body = $mail->post($url, $post);
     preg_match_all("/sid=(.*)/i", $body, $out);
     $sid = $out[1][0];
     $sid = substr($sid, 0, 32);
     //通讯录地址
     $url = "http://g4a30.mail.163.com/jy3/address/addrlist.jsp?sid=" . $sid . "&gid=all";
     $body = $mail->post($url, array());
     $body = iconv('gb2312', 'utf-8', $body);
     $html = str_get_html($body);
     $table = $html->find('table[class=Ibx_gTable Ibx_gTable_Con] tr');
     foreach ($table as $tr) {
         $name = $tr->find('td[class=Ibx_Td_addrName]', 0)->plaintext;
         $email = $tr->find('td[class=Ibx_Td_addrEmail]', 0)->plaintext;
         $output[$name] = $email;
     }
     return $output;
 }
Esempio n. 5
0
        $atmail->auth_error();
    }
    if ($atmail->status == 2) {
        $atmail->session_error();
    }
}
if (!$atmail->Langage && !$atmail->LoginType) {
    $atmail->Language = $settings['Language'];
    $atmail->LoginType = 'xp';
}
$var['newfolder'] = $_REQUEST['NewFolder'];
$var['atmailstyle'] = $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/atmailstyle.css");
$var['atmailstyle'] .= $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/atmailstyle-form.css");
$var['mailstyle'] = $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/atmailstyle-mail.css");
// Make a new mail object, used to search and list the users folders
$mail = new GetMail(array('Username' => $atmail->username, 'Pop3host' => $atmail->pop3host, 'Password' => $auth->password, 'Type' => $atmail->MailType, 'Mode' => $atmail->Mode));
// Load an array of msgs selected to be moved
$msgs = $_REQUEST['id'];
// If a value exists in the array, start to move the messages.
if ($msgs[0]) {
    $mail->login();
    // Loop through the selected msgs to move, the new folder to move to
    // is seperated by :: . e.g 56::Trash , msg 56 from the Trash folder
    foreach ($msgs as $id) {
        if (preg_match('/::(.*)/', $id, $m)) {
            $folder = $m[1];
        }
        $id = preg_replace('/::.*/', '', $id);
        // Don't move messages if we are already in the same folder
        if ($folder == $var['newfolder']) {
            continue;
Esempio n. 6
0
<?php

if ($pref['quota_bar']) {
    $mail = new GetMail(array('Username' => $atmail->username, 'Pop3host' => $atmail->pop3host, 'Password' => $auth->password, 'Mode' => $atmail->Mode, 'Type' => $atmail->MailType));
    list($var['usedquota'], $var['totalquota']) = $mail->getquota();
    // The size of our quota in Kb
    if (!$var['totalquota']) {
        $var['totalquota'] = $atmail->UserQuota;
        $var['totalquota'] = sprintf("%2.0f", $var['totalquota']);
    }
    if ($var['usedquota'] > 0 && $var['totalquota'] > 0) {
        $var['used'] = $var['usedquota'] / $var['totalquota'] * 100;
        if ($var['used'] < 1) {
            $var['used'] = '1';
        } else {
            $var['used'] = round($var['used'], 2);
        }
    }
    $var['used_percent'] = $var['used'] ? $var['used'] : '1';
}
Esempio n. 7
0
 function get_filename()
 {
     /*
     $filename = $this->filename ? $this->filename : $this->disposition_filename;
     
     if (!$filename)
      	$filename = $this->content_name;
     
     
     // Another try
     if (!$filename && preg_match('/name=\s*(.+)/i', $this->headers['content-type'], $m)) {
     	$filename = $m[1];
     }
     */
     if (!empty($this->headers['content-disposition'])) {
         if (preg_match('/filename=\\s*(.+)$/i', $this->headers['content-disposition'], $m)) {
             $filename = $m[1];
         }
     }
     // try to get filename from Content-Type if missing from Content-Disposition
     if (empty($filename) && !empty($this->headers['content-type'])) {
         if (preg_match('/name=\\s*(.+)$/i', $this->headers['content-type'], $m)) {
             $filename = $m[1];
         }
     }
     // If part is a message forwarded as an attachment (message/rfc822)
     // Do some extra checks
     if (strpos(strtolower($this->content_type), 'message/rfc822') !== false) {
         if (empty($filename)) {
             //$filename = 'Forwarded_Message.txt';
             if (preg_match('/^Subject:(.+?)$/m', $this->body, $m)) {
                 if (preg_match('/\\s*=\\?([^\\?]+)\\?([QqBb])/', $m[1], $match)) {
                     $match[2] = strtoupper($match[2]);
                     if ($match[2] == 'Q') {
                         $m[1] = preg_replace('/\\s*=\\?([^\\?]+)\\?[Qq]\\?([^\\?]+)?\\?=/e', "GetMail::decode_language('\\1', GetMail::decode_mime_head('\\1', '\\2'))", $m[1]);
                     } else {
                         $m[1] = preg_replace('/\\s*=\\?([^\\?]+)\\?[Bb]\\?([^\\?]+)?\\?=/e', "GetMail::decode_language('\\1', base64_decode('\\2'))", $m[1]);
                     }
                     $filename = $m[1];
                 } else {
                     $filename = GetMail::decode_language($this->get_charset, $m[1]);
                 }
                 if (substr($filename, -4) != '.eml') {
                     $filename .= '.eml';
                 }
             } else {
                 $filename = 'Fowarded Message-' . rand(10000, 99999) . '.eml';
             }
         } else {
             $filename = trim($filename);
             $filename = preg_replace('/(^")|(";?$)/', '', $filename);
             if (strtolower(substr($filename, -4)) != '.eml') {
                 $filename .= '.eml';
             }
             return $filename;
         }
     }
     // Some clients break up long filenames into two parts ie filename*0="" and filename*1=""
     // lets see if this is the case and join them together.
     if (empty($filename)) {
         if (preg_match_all('/filename(\\*\\d+)="(.+?)"/i', $this->headers['content-disposition'], $m, PREG_PATTERN_ORDER)) {
             $filename = join('', $m[2]);
         }
     }
     // Some clients break up long filenames into two parts ie filename*0="" and filename*1=""
     // lets see if this is the case and join them together.
     if (empty($filename)) {
         if (preg_match_all('/name(\\*\\d+)="(.+?)"/i', $this->headers['content-type'], $m, PREG_PATTERN_ORDER)) {
             $filename = join('', $m[2]);
         }
     }
     if (empty($filename)) {
         return '';
     }
     // clean up filename
     $filename = trim($filename);
     $filename = preg_replace('/(^")|(";?$)/', '', $filename);
     return $filename;
 }
Esempio n. 8
0
 /**
  * Parse it as a MIME message
  *
  * @param int $id message id
  * @param string $folder
  * @param string [$nopersonalities]
  * @param string [$cache]
  *
  * @access public
  */
 function reademail($id, $folder, $nopersonalities = null, $cache = null, $path = null)
 {
     global $atmail, $domains, $pref;
     // Load our temporary filename
     $this->tmpdir = "{$pref['user_dir']}/tmp/" . $this->Username . '@' . $this->Pop3host . "/";
     // Create our temporary directory, if its missing, init in Global.php
     if (!is_dir($this->tmpdir)) {
         mkdir($this->tmpdir, 0777);
     }
     if (!$this->File && $cache) {
         $this->File = GetMail::check_cache($atmail->tmpdir . "/{$this->SessionID}-{$cache}.data");
         // Set to blank if the cache no longer exists
         //if(!file_exists($this->File))
         //	$this->File = '';
     }
     // Read our email from the server
     if (!is_string($this->File)) {
         if (!$nopersonalities && isset($atmail)) {
             $this->FromField = $atmail->loadpersonalities();
         }
         $status = $this->mail->login();
         // We have an error while logging in. Tell the user
         if ($status) {
             $this->status = $status;
             return;
         }
         if (is_null($path)) {
             $this->path = $this->mail->get($id, $folder, '', $cache);
         } else {
             $this->path = $path;
         }
         $this->mail->quit();
         if ($this->Type == 'imap') {
             $this->MessageState = $this->mail->MessageState;
         }
         // User has specified the msg from the spellchecker
     } else {
         if (file_exists($atmail->tmpdir . "/{$this->File}")) {
             $this->path = $atmail->tmpdir . "/{$this->File}";
             $this->MessageState = 'o';
         } else {
             if (file_exists($this->File)) {
                 $this->path = $this->File;
                 $this->MessageState = 'o';
             }
         }
     }
     // Just to be sure nobody is reading below a directory
     $this->path = str_replace('../', '', $this->path);
     $this->parser = new MailParser();
     if (!is_dir($this->tmpdir)) {
         mkdir($this->tmpdir, 0777);
     }
     // Users have their own mime-tmp directory
     if (!$this->parser->output_dir($this->tmpdir)) {
         catcherror("Could not parse message to temp directory '{$this->tmpdir}' -\n\t        Check the directory exists with permissions to write");
     }
     if (!$this->parser->parse_open($this->path)) {
         $this->txt = array_pop($this->parser->errors);
         return;
     }
     if ($this->rawemail) {
         $this->rawbody = $this->parser->stringify();
         $this->rawbody = str_replace("\r/", "\r\n", $this->rawbody);
         return;
     }
     if ($this->head) {
         $this->headers = $this->parser->stringify_header();
         $this->headers = str_replace(array('<', '>'), array('&lt;', '&gt;'), $this->headers);
     }
     $this->Charset = $this->parser->get_charset();
     // Get any mail headers
     $this->from = $this->parser->get_header_field('From');
     $this->replyto = $this->parser->get_header_field('Reply-To');
     if (preg_match('/(.*?)<.*?>/', $this->from, $match)) {
         $this->username = $match[1];
     }
     // Default to our previous subject in msg, if it does not exist. e.g , reading
     // a msg with multiple attachments
     $this->subject = $this->parser->get_header_field('Subject');
     if ($this->subject == '') {
         $this->subject = 'No Subject';
     }
     $this->cc = $this->parser->get_header_field('CC');
     $this->bcc = $this->parser->get_header_field('BCC');
     $this->to = $this->parser->get_header_field('To');
     $this->VideoMail = $this->quote_header($this->parser->get_header_field('X-VideoMail'));
     if ($this->VideoMail) {
         $this->VideoMail .= "/mini";
     }
     // Quote any ISO headers
     foreach (array('from', 'replyto', 'subject', 'to', 'cc', 'bcc') as $field) {
         // Store the encoding of the email-message
         if (preg_match('/\\s*=\\?([^\\?]+)\\?([QqBb])/', $this->{$field}, $match)) {
             $this->Encoding = $match[1];
             if (strtoupper($match[2]) == 'Q') {
                 $this->{$field} = preg_replace('/\\s*=\\?([^\\?]+)\\?[Qq]\\?([^\\?]+)?\\?=/e', "\$this->mail->decode_language('\\1', GetMail::decode_mime_head('\\1', stripslashes('\\2')))", $this->{$field});
             } else {
                 $this->{$field} = preg_replace('/\\s*=\\?([^\\?]+)\\?[Bb]\\?([^\\?]+)?\\?=/e', "\$this->mail->decode_language('\\1', base64_decode('\\2'))", $this->{$field});
             }
         } else {
             $this->{$field} = $this->mail->decode_language($this->Charset, $this->{$field});
         }
     }
     $this->date = $this->parser->get_header_field('Date');
     $date = $this->date ? $this->date : 'today';
     $date = $this->mail->calc_timezone($date);
     $time = strtotime($date);
     if ($this->Language == "japanese") {
         setlocale(LC_TIME, 'ja_JP.UTF-8', 'en_US');
         $this->date = strftime("{$this->mail->DateFormat} %a {$this->mail->TimeFormat}", $time);
     } else {
         setlocale(LC_TIME, strtolower($this->Language), 'en_US');
         $this->date = strftime("%a " . $this->mail->DateFormat . " " . $this->mail->TimeFormat, $time);
         $this->date = iconv('iso-8859-1', "UTF-8", $this->date);
     }
     // Take away the timezone and seconds
     $this->date = preg_replace('/:\\d\\d \\+?-?\\d{4}.*/', '', $this->date);
     $this->ctype = $this->parser->get_header_field('Content-Type');
     list($this->mimetype) = explode(';', $this->ctype);
     $this->mimetype = strtolower(trim($this->mimetype));
     if ($this->mimetype == 'text/html') {
         $this->type = 'HTML Msg';
     } elseif ($this->mimetype == 'multipart/alternative') {
         $this->type = 'Embeded HTML/Text';
     } elseif (strpos($this->mimetype, 'multipart') !== false) {
         $this->type = 'Attachments';
     } else {
         $this->type = 'Text';
     }
     // If we are using the maildir format, the message-id number if the unique id
     if ($this->mail->Type == 'file' && $domains[$this->Pop3host]) {
         $this->UIDL = $id;
         $this->UIDL = preg_replace('/cur\\/|new\\//', '', $this->UIDL);
     } else {
         if (!($this->UIDL = $this->parser->get_header_field('x-uidl'))) {
             $this->UIDL = $this->parser->get_header_field('message-id');
         }
         // Make the UIDL header from the Subject/Date if the Message-ID or XUIDL does not exist
         if (!$this->UIDL) {
             $this->UIDL = md5($this->subject . $this->parser->get_header_field('date'));
         }
     }
     // Take away illegal characters from the UIDL
     $this->UIDL = str_replace("'", '"', $this->UIDL);
     $this->UIDL = str_replace('"', '', $this->UIDL);
     $this->UIDL = preg_replace('/:.*/', '', $this->UIDL);
     $this->UIDL = str_replace(array("\n", "\r", ' ', ':', '+', '<', '>', '*', '|', '\\', '/', '&gt;', '&lt;'), '', $this->UIDL);
     if ($this->Type == 'pop3' || $this->Type == 'imap') {
         $this->EmailCache = $this->UIDL;
     }
     // Take away any newlines from the UIDL
     $this->UIDL = trim($this->UIDL);
     // Set the email priority as Normal, otherwise find the value in the header(s)
     $this->priority = 'Normal';
     if (substr($this->parser->get_header_field('x-priority'), 0, 1) == 1 || $this->parser->get_header_field('X-MSMail-Priority') == 'High' || $this->parser->get_header_field('Importance') == 'High') {
         $this->priority = 'High';
     }
     if (substr($this->parser->get_header_field('x-priority'), 0, 1) == 5 || $this->parser->get_header_field('X-MSMail-Priority') == 'Low' || $this->parser->get_header_field('Importance') == 'Low') {
         $this->priority = 'Low';
     }
     if (preg_match("/{$this->emailexp}/", $this->from, $match)) {
         $this->emailfrom = $match[1];
     }
     $this->emailfrom = str_replace(array('&gt;', '&lt;'), '', $this->emailfrom);
     // Cleaup the email, take away " signs, which close the HTML input tag
     //$this->to = preg_replace('/"(.*?),(.*?)"/', '$1 $2', $this->to);
     //$this->cc = preg_replace('/"(.*?),(.*?)"/', '$1 $2', $this->cc);
     //$this->to = str_replace('"', "'", $this->to);
     //$this->cc = str_replace('"', "'", $this->cc);
     //$this->bcc = str_replace('"', "'", $this->bcc);
     //$this->ctype = $this->parser->get_header_field('Content-Type');
     // See if we are permitted to display images in messages
     if (isset($atmail)) {
         $this->DisplayImages = $atmail->load_displayimages();
         if ($atmail->DisplayImages == '2') {
             $atmail->DisplayImages = $atmail->load_abook_emails($this->emailfrom);
         }
     }
     $this->dump_entity();
     if (isset($this->multiparttxt) && !empty($this->multiparttxt)) {
         $this->multiparttxt = $atmail->escape_jscript($this->multiparttxt);
     }
     if (isset($this->html) && !empty($this->html)) {
         $this->html = $atmail->escape_jscript($this->html);
         if (isset($this->multiparttxt)) {
             $this->html .= $this->multiparttxt;
         }
     }
     if (isset($this->txt) && !empty($this->txt)) {
         $this->txt = $atmail->escape_jscript($this->txt);
         if (isset($this->multiparttxt)) {
             $this->txt .= $this->multiparttxt;
         }
     }
     $this->scan_inline();
     // Fix an error where certain messages cannot be displayed ( e.g Apple mailers as multipart msgs )
     if (!$this->html && !$this->txt) {
         $this->txt = $this->multiparttxt;
     }
 }
Esempio n. 9
0
 function createuser($user = null)
 {
     global $pref, $atmail, $settings, $domains;
     // If we are using LDAP, grab the user details via the LDAP server
     if ($pref['ldap_auth']) {
         $ldapuser = $this->ldap_auth_populate($this->username);
         // LDAP mod ---  changed user[FirstName], & user[LastName] to user[Industry], & user[Occupation]
         $user['Industry'] = $ldapuser['FirstName'];
         $user['Occupation'] = $ldapuser['LastName'];
         $user['RealName'] = $ldapuser['RealName'];
         //echo $user['FirstName'] . ":" . $user['LastName'] . "\n";
     }
     if (!$pref['crypt'] || !$atmail->isset_chk($domains[$this->pop3host])) {
         // Plaintext password
         $pass = $this->password;
     } else {
         // Encrypt the password
         $pass = crypt($this->password);
     }
     $this->SessionID = session_id();
     // Load our table names
     $atmail->db->table_names($this->Account);
     // Log the time we created the account
     $time = time();
     // Specify the 'default' user group if none exists
     if (!$user['UGroup']) {
         $user['UGroup'] = 'Default';
     }
     // Purge any invalid entries in the DB
     $atmail->db->sqldo("delete from UserSession where Account=?", $this->Account);
     // Create a new SessionID for the user
     $query = "INSERT INTO UserSession (Account, Password, SessionID, LastLogin, PasswordMD5, SessionData) VALUES(?, ?, ?, ?, ?, ?)";
     $data = array($this->Account, $pass, $this->SessionID, $time, md5($pass), '');
     $res = $atmail->db->sqldo($query, $data);
     if ($res != 1) {
         return -1;
     }
     $settings['UseSSL'] = 0;
     // Select the MailType - SQL or Flatfile
     // All functions are based on what type of account the user has
     if (!$domains[$this->pop3host]) {
         $settings['MailType'] = $_REQUEST['MailType'];
         if (strpos($settings['MailType'], 's')) {
             $settings['UseSSL'] = 1;
             $settings['MailType'] = str_replace('s', '', $settings['MailType']);
         }
     } elseif ($pref['sql_type'] && $domains[$this->pop3host]) {
         $settings['MailType'] = 'sql';
     } elseif (!$pref['sql_type'] && $domains[$this->pop3host]) {
         $settings['MailType'] = 'file';
     }
     if ($pref['sql_type']) {
         $settings['Mode'] = 'sql';
     } else {
         $settings['Mode'] = 'file';
     }
     if (!$user['UserQuota']) {
         $user['UserQuota'] = $settings['UserQuota'];
     }
     // Build an SQL query for the new User
     $query = "INSERT INTO Users (UGroup, Address, BirthDay, BirthMonth, BirthYear, City, Country, TelHome,\r\n\t\t\t\t  FaxHome, TelWork, FaxWork, TelMobile, TelPager, FirstName, Gender, Industry, LastName,\r\n\t\t\t\t  Occupation, OtherEmail, PasswordQuestion, PostCode, State, DateCreate, UserStatus,\r\n\t\t\t\t  Account, MailDir, UserQuota) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, {$atmail->db->NOW},\r\n\t\t\t\t  ?, ?, ?, ?)";
     if (empty($user['BirthYear'])) {
         $user['BirthYear'] = 0;
     }
     $data = array($user['UGroup'], $user['Address'], $user['BirthDay'], $user['BirthMonth'], $user['BirthYear'], $user['City'], $user['Country'], $user['TelHome'], $user['FaxHome'], $user['TelWork'], $user['FaxWork'], $user['TelMobile'], $user['TelPager'], $user['FirstName'], $user['Gender'], $user['Industry'], $user['LastName'], $user['Occupation'], $user['OtherEmail'], $user['PasswordQuestion'], $user['PostCode'], $user['State'], $pref['UserStatus'], $this->Account, $user['MailDir'], $user['UserQuota']);
     if ($atmail->db->sqldo($query, $data) != 1) {
         return -1;
     }
     // Build the query
     $insert = '';
     $values = '';
     $data = array();
     // Insert the users settings
     foreach ($settings as $key => $value) {
         if ($key == 'UserQuota') {
             continue;
         }
         $insert .= Filter::cleanSqlFieldNames($key) . ',';
         $values .= '?,';
         // Insert custom preferences for account, depending on the
         // new user form
         if ($key == "RealName") {
             $data[] = $user['FirstName'] . ' ' . $user['LastName'];
         } elseif ($key == "LoginType") {
             $data[] = $user['LoginType'];
         } elseif ($key == "Service") {
             $data[] = $user['Service'];
         } elseif ($key == "ReplyTo" && $atmail->isset_chk($_REQUEST['email'])) {
             $data[] = $_REQUEST['email'];
         } elseif ($key == "ReplyTo" && !$atmail->isset_chk($_REQUEST['email'])) {
             $data[] = $this->Account;
         } elseif ($key == "Language" && $atmail->isset_chk($_REQUEST['Language'])) {
             $data[] = $_REQUEST['Language'];
         } else {
             $data[] = $value;
         }
     }
     $user_settings = $atmail->db->get('UserSettings');
     $query = "INSERT INTO {$user_settings} ({$insert} Account) values ({$values} ?)";
     $data[] = $this->Account;
     if ($atmail->db->sqldo($query, $data) != 1) {
         return -1;
     }
     list($this->username, $this->pop3host) = explode('@', $this->Account);
     require_once 'GetMail.php';
     //'Username' 'Pop3host' 'Type' 'Mode'
     $mail = new GetMail(array('Username' => $this->username, 'Pop3host' => $this->pop3host, 'Type' => $settings['MailType'], 'Mode' => 'sql', 'UseSSL' => $settings['UseSSL']));
     $mail->login();
     // Create the users default folders
     $folders = array('Inbox', 'Sent', 'Trash', 'Drafts', 'Spam');
     foreach ($folders as $folder) {
         $mail->newfolder($folder);
     }
     return 1;
 }
Esempio n. 10
0
// Make a new UIDL if one does not exist
if (!$var['UIDL']) {
    $var['UIDL'] = time() . getmypid() . rand(0, 9000) . $atmail->genkey();
    $var['UIDL'] = preg_replace('/\\..*/', '', $var['UIDL']);
}
// Find which EmailBox to save into
if ($_REQUEST['Draft']) {
    $var['msgbox'] = 'Drafts';
} else {
    $var['msgbox'] = 'Sent';
}
// Build the message to send . Add the headers, message body and UIDL
$sendmsg = new SendMsg(array('Account' => "{$atmail->username}@{$atmail->pop3host}", 'EmailTo' => $var['emailto'], 'EmailFrom' => $var['emailfrom'], 'EmailCC' => $var['emailcc'], 'EmailBCC' => $var['emailbcc'], 'EmailSubject' => $var['emailsubject'], 'EmailPriority' => $var['emailpriority'], 'ContentType' => $var['contype'], 'XMailer' => "AtMail {$pref['version']}", 'EmailBox' => $var['msgbox'], 'EmailUIDL' => $var['UIDL'], 'Unique' => $var['unique'], 'X-Origin' => $_SERVER['REMOTE_ADDR'], 'EmailMessage' => $_REQUEST['emailmessage'], 'SessionID' => $auth->SessionID, 'PGPappend' => $atmail->PGPappend, 'PGPsign' => $atmail->PGPsign, 'SMIMEencrypt' => $var['SMIMEencrypt'], 'SMIMEsign' => $var['SMIMEsign'], 'Charset' => $var['Charset'], 'ReadReceipt' => $var['ReadReceipt'], 'ReplyFwd' => $var['type'], 'VideoStream' => $var['VideoStream']));
// Save the message into the Sent users folder
// Create a new mail object
$mail = new GetMail(array('Username' => $atmail->username, 'Pop3host' => $atmail->pop3host, 'Password' => $auth->password, 'Type' => $atmail->MailType, 'Mode' => $atmail->Mode));
$mail->login();
// Build the email message to send
$sendmsg->buildmsg();
// Exit if no message defined
if (!$sendmsg->mime) {
    $atmail->end();
}
// If the user chooses to save the message
if ($sendmsg->EmailBox == 'Drafts') {
    // Print the draft save message
    $var['msg'] = $atmail->parse("html/{$atmail->Language}/msg/savedraft.html");
} else {
    // Send the email-message via SMTP
    $sendmsg->deliver();
    // Display a different notification in the email display to the browser ( depending if Sent or Drafts folder )
Esempio n. 11
0
    function buildmsg()
    {
        global $pref, $brand, $atmail;
        // Save UTF-8 versions of the strings, which are sent to the browser
        $this->RawEmailSubject = $this->EmailSubject;
        // Format the date correctly
        $this->Date = date('r');
        // return an error if To: field contains only , or ;
        if (strlen($this->EmailTo) == 0 || !preg_match('/\\@/', $this->EmailTo) && preg_match('/,/', $this->EmailTo) && $this->EmailBox != "Draft") {
            return $this->smtperror("Please specify an email in the To: field {$this->EmailTo}");
        }
        // Do not test if the email has a @ symbol, if a user specifies an add-recipients > group , the format is
        // Groupname Group , there is no email address with an @
        // return an error if To: field is empty or contains no email addresses
        // if ((strlen($this->EmailTo) == 0 || !(preg_match('/\@/', $this->EmailTo)))
        //     && $this->EmailBox != "Draft" )
        // {
        //             return $this->smtperror("Please specify an email in the To: field $this->EmailTo");
        // }
        // return an error if CC string contains characters but no email addresses
        //if (strlen($this->EmailCC) > 0)
        //{
        //           return $this->smtperror("Please specify an email in the CC: field $this->EmailCC");
        //}
        // return an error if BCC string contains characters but no email addresses
        //if (strlen($this->EmailBcc) > 0)
        //   {
        //           return $this->smtperror("Please specify an email in the BCC: field $this->EmailBcc");
        //   }
        // Read our attachment directory
        $dir = $atmail->tmpdir;
        // If we don't have a valid directory ( e.g new account via webadmin , use user_dir )
        if (!is_dir($atmail->tmpdir)) {
            $dir = $pref['user_dir'];
        }
        if (!file_exists($dir)) {
            mkdir($dir, 0777);
        }
        $dh = opendir($dir);
        if (!is_resource($dh)) {
            catcherror("Cannot read attachment dir: {$this->tmpdir}");
        }
        if (!$atmail->isset_chk($this->Unique)) {
            $this->Unique = "0";
        }
        $acc = preg_quote($this->Account, '/');
        $unique = preg_quote($this->Unique, '/');
        while (false !== ($file = readdir($dh))) {
            if (preg_match("/^{$acc}-{$unique}-cid:(.+?)-name:(.+?)\$/", $file, $m)) {
                $this->inlineimages[] = array('filename' => "{$dir}/{$file}", 'cid' => $m[1], 'name' => $m[2]);
            } elseif (preg_match("/^{$acc}-{$unique}/", $file)) {
                $this->attach($file);
                $this->EmailAttach++;
            }
        }
        closedir($dh);
        // Add our message footer, only for outgoing messages
        if (preg_match('/plain/', $this->ContentType) && $this->EmailBox != 'Drafts') {
            if (isset($brand[$_SERVER['HTTP_HOST']]["footer_msg"])) {
                $pref['footer_msg'] = $brand[$_SERVER['HTTP_HOST']]["footer_msg"];
            }
            // Take away any HTML characters
            $pref['footer_msg'] = str_replace(array('<hr>', '<HR>'), '---- ', $pref['footer_msg']);
            $pref['footer_msg'] = strip_tags($pref['footer_msg']);
            // Clean the footer_msg and make it CLF clean
            $pref['footer_msg'] = str_replace("\r", '', $pref['footer_msg']);
            // Evaluate any $vars
            $pref['domain'] = $this->Pop3host;
            //$pref['footer_msg'] = preg_replace('/(\$[0-9A-Za-z\-_\[\]>]+)/e', '$1', $pref['footer_msg']);
            $pref['footer_msg'] = preg_replace('/(\\$pref[0-9A-Za-z\\-_\\[\\]>]+)/e', '$1', $pref['footer_msg']);
            if (strlen($this->VideoStream) > 0) {
                $this->EmailMessage = "Video mail attached:\nTo view please see: http://{$pref['videomail_server']}/videomail/view/{$this->VideoStream}/\n\n" . $this->EmailMessage;
            }
            // Only add the footer message if it is not already at bottom of email
            if (!empty($pref['footer_msg']) && strpos($this->EmailMessage, $pref['footer_msg']) !== strlen($this->EmailMessage) - strlen($pref['footer_msg'])) {
                $this->EmailMessage .= "\r\n{$pref['footer_msg']}";
            }
        } elseif (preg_match('/html/', $this->ContentType) && $this->EmailBox != 'Drafts') {
            if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'gecko') !== false) {
                // Create links from plain urls
                //$this->EmailMessage = preg_replace('/(?<!href="|\')(http:\/\/[^\s<>\'"]+)(?!/i', '<a href="$1">$1</a>', $this->EmailMessage);
                $this->EmailMessage = preg_replace('/(?<!\'|"|>|&gt;)(http:\\/\\/[^\\s<>\'"]+)/i', '<a href="$1">$1</a>', $this->EmailMessage);
            }
            // Create 'real' newlines from <BR>'s
            $this->EmailMessage = str_replace(array('<BR>', '<br>'), "<br>\r\n", $this->EmailMessage);
            // Evaluate any $vars
            $pref['domain'] = $this->Pop3host;
            if ($brand[$_SERVER['HTTP_HOST']]["footer_msg"]) {
                $pref['footer_msg'] = $brand[$_SERVER['HTTP_HOST']]["footer_msg"];
            }
            // Evaluate any $vars
            $pref['footer_msg'] = preg_replace('/(\\$pref[0-9A-Za-z\\-_\\[\\]>]+)/e', '$1', $pref['footer_msg']);
            // Clean the footer_msg and make it CLF clean
            $pref['footer_msg'] = str_replace("\r", '', $pref['footer_msg']);
            if (!empty($pref['footer_msg']) && strpos($this->EmailMessage, $pref['footer_msg']) !== strlen($this->EmailMessage) - strlen($pref['footer_msg'])) {
                $this->EmailMessage .= "<BR>{$pref['footer_msg']}";
            }
            if (strlen($this->VideoStream) > 0) {
                $this->EmailMessage = <<<EOF
<HTML><table width="100%" style="border: 1px solid #468BC7;">
<tr>
<td style="background-color: #D8E7F5; padding: 3px;" nowrap>
Video Mail Attached. To view in your browser click the link below:<br>
<a href="http://{$pref['videomail_server']}/videomail/view/{$this->VideoStream}/">http://{$pref['videomail_server']}/videomail/view/{$this->VideoStream}/</a>
</td>
</tr>
</table>
<br>
{$this->EmailMessage}
</HTML>
EOF;
            } else {
                // Append <HTML> tags to make Spamassassin score less
                $this->EmailMessage = "<HTML>\n" . $this->EmailMessage . "</HTML>\n";
            }
        }
        /* disabled for now
        		// Create a new PGP object if required
        		if ($this->PGPsign || $this->PGPappend)
        		{
        			$userWrkDir = ($atmail->MailDir) ? $atmail->MailDir : $atmail->tmpdir;
        		    $ownFile = $atmail->tmpdir . ".ht.".$this->SessionID;
        
        			$pgp = new PGP( array('wrkDir' => "$userWrkDir/pgp", 'ownFile' => $ownFile) );
        
        			// Automatically sign the mail with the users PGP key, only if our pass-phrase is available
        			if ($this->PGPsign && file_exists($pgp->ownFile))
        			{
        				$rec = array();
        				$this->EmailMessage = $pgp->encrypt($this->EmailFrom, $rec , $this->EmailMessage, "s");
        			}
        
        			// Automatically append the users PGP key to an outgoing message
        			if ($this->PGPappend)
        			{
        				// Load a temporary var containing for PGP public key
        				$msgTmp = $pgp->retrieveAsciiPub();
        
        				// Turn newlines into <BR>'s for the HTML emails
        				if ( strpos($this->ContentType, 'html') !== false )
        					$msgTmp = nl2br($msgTmp);
        
        				// Append the PGP public key to the email message
        		    	$this->EmailMessage .= $msgTmp;
        			}
        
        		}
                */
        // The from Header is our ReplyTo if specified in the settings, only if we are the default account
        if ($this->ReplyTo && $this->Account == $this->EmailFrom) {
            $this->EmailFrom = $this->ReplyTo;
        }
        $rfc822 = new Mail_RFC822();
        foreach (array('EmailTo', 'EmailCC', 'EmailBCC') as $type) {
            if ($this->{$type} != '') {
                //remove leading semi-colon
                $this->{$type} = preg_replace('/^\\s*;\\s*/', '', $this->{$type});
                $this->{$type} = str_replace(array(';', ' Shared Group', ' Group'), array(',', '@SharedGroup', '@Group'), $this->{$type});
                // Remove "smart quotes" (aka dumb quotes)
                $smartquotes = array('“', '”', '‘', '’', "�", "�", "�", "�", chr(147), chr(148), chr(146), 'R20;', 'R21;', 'R17;', 'R16;');
                $this->{$type} = str_replace($smartquotes, '"', $this->{$type});
                // Optionally encode the users name in the header
                preg_match_all('/(?<=")(.+?)(?=" <)/', $this->{$type}, $m, PREG_SET_ORDER);
                if (is_array($m[0])) {
                    foreach ($m[0] as $match) {
                        $this->{$type} = str_replace($match, $this->encodeUTF8($match), $this->{$type});
                    }
                }
                //$this->$type = preg_replace('/(?<=")(.+?)(?=" <)/e', '$this->encodeUTF8(\'$1\')', $this->$type);
                $groups = $rfc822->parseAddressList($this->{$type}, null, false, true);
                $this->{$type} = '';
                foreach ($groups as $group) {
                    if (is_string($group)) {
                        preg_match('/(.*?)<(.*?)>/', $group, $m);
                        $name = trim($m[1]);
                        $mail = $m[2];
                    } else {
                        $name = $group->personal;
                        // Replace ", ' and , from the name, cleanup and parse the address below
                        //$name = str_replace(array('"', ','), '', $name);
                        $mail = $group->mailbox . '@' . $group->host;
                    }
                    // insert recipients from shared groups
                    if (strpos($mail, 'Shared Group') !== false) {
                        preg_match('/(.*?)Shared Group/', $mail, $match);
                        $this->{$type} .= $match[1] . "SharedGroup, ";
                    } elseif (preg_match('/(.+?)Group$/i', $mail, $match)) {
                        $this->{$type} .= $match[1] . "Group, ";
                    } elseif (strlen($name) > 0) {
                        $address = "{$name} <{$mail}>";
                        $this->{$type} .= $address . ", ";
                        $this->AddRecipients .= "{$mail}, ";
                    } else {
                        $address = "<{$mail}>";
                        $this->{$type} .= $address . ", ";
                        $this->AddRecipients .= "{$mail}, ";
                    }
                }
            }
            // Remove the trailing comma @ the end of the text
            $this->{$type} = preg_replace('/, $/', '', $this->{$type});
        }
        $this->AddRecipients = preg_replace('/, $/', '', $this->AddRecipients);
        // If there is a video-message prepend "VideoMail:" in the subject
        if ($this->VideoStream && !preg_match('/VideoMail:/i', $this->EmailSubject)) {
            $this->EmailSubject = "VideoMail: " . $this->EmailSubject;
        }
        // Decode our RealName and EmailSubject from UTF8 -> Charset
        $this->RealName = GetMail::encode_language($this->Charset, $this->RealName);
        $this->EmailSubject = GetMail::encode_language($this->Charset, $this->EmailSubject);
        // If we are not using the standard charset, encoding the email-subject with the subject ( base64 for quoted printed encoding)
        // Only encode if the output contains non ASCII characters
        $this->EmailMessage = str_replace("\r", '', $this->EmailMessage);
        if (preg_match('/iso/i', $this->Charset)) {
            if ($this->_check_if_contain_utf8($this->EmailSubject)) {
                $this->EmailSubject = MIME_Words::encode_mimeword($this->EmailSubject, "Q", $this->Charset);
            }
            if ($this->_check_if_contain_utf8($self->RealName)) {
                $this->RealName = MIME_Words::encode_mimeword($this->RealName, "Q", $this->Charset);
            }
            $this->EmailMessage = GetMail::encode_language($this->Charset, $this->EmailMessage);
        } else {
            if ($this->_check_if_contain_utf8($this->EmailSubject)) {
                $this->EmailSubject = MIME_Words::encode_mimeword($this->EmailSubject, "B", $this->Charset);
            }
            if ($this->_check_if_contain_utf8($this->RealName)) {
                $this->RealName = MIME_Words::encode_mimeword($this->RealName, "B", $this->Charset);
            }
            $this->EmailMessage = GetMail::encode_language($this->Charset, $this->EmailMessage);
        }
        $this->mime->setSubject($this->EmailSubject);
        $this->RealName = trim($this->RealName);
        if (strlen($this->RealName) > 0 && $pref['allow_FullName']) {
            $this->mime->setFrom("{$this->RealName} <{$this->EmailFrom}>");
        } else {
            $this->mime->setFrom($this->EmailFrom);
        }
        // Convert back any @Mail created links that redirect through parse.php
        // and javascript.opencompose() (only if replying to or forwarding a msg)
        if ($this->ReplyFwd == 'reply' || $this->ReplyFwd == 'forward') {
            $this->_cleanLinks();
        }
        // If user is using the HTML editor, send a HTML message otherwise plain txt
        if (strpos($this->ContentType, 'html') !== false) {
            $this->mime->headers(array('To' => str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailTo), 'Reply-To' => $this->ReplyTo, 'Content-Type' => "multipart/related; charset=\"{$this->Charset}\"", 'X-Mailer' => $this->XMailer, 'X-Origin' => $this->X_Origin, 'X-Atmail-Account' => $this->Account, 'Date' => $this->Date));
            // Now create the text/plain part also
            require_once 'class.html2text.inc';
            $html2text = new html2text($this->EmailMessage);
            $txt = $html2text->get_text();
            $txt = preg_replace('/^\\s*BODY\\s*\\{.+?\\}/s', '', $txt);
            $html = $this->EmailMessage;
            // Cleanup PGP block if one exists
            if (strpos($this->EmailMessage, '-----BEGIN PGP MESSAGE-----') !== false) {
                $html = PGP::cleanPgpBlock($this->EmailMessage, 'message');
                $txt = PGP::cleanPgpBlock($txt, 'message');
            }
            // Cleanup PGP block if one exists
            if (strpos($this->EmailMessage, '-----BEGIN PGP PUBLIC KEY BLOCK-----') !== false) {
                $html = PGP::cleanPgpBlock($this->EmailMessage, 'pubkey');
                $txt = PGP::cleanPgpBlock($txt, 'pubkey');
            }
            // add the text/html part
            $this->mime->setHTMLBody($html);
            $this->mime->setTXTBody($txt);
        } else {
            $this->mime->headers(array('To' => str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailTo), 'Reply-To' => $this->ReplyTo, 'Content-Type' => "text/plain; charset=\"{$this->Charset}\"", 'X-Origin' => $this->X_Origin, 'X-Atmail-Account' => $this->Account, 'Date' => $this->Date));
            $this->mime->setTXTBody($this->EmailMessage);
        }
        // Append our X-Video mail message
        if (strlen($this->VideoStream) > 0) {
            $this->mime->headers(array('X-VideoMail' => "http://{$pref['videomail_server']}/videomail/view/{$this->VideoStream}"));
        }
        // Added support for CC / BCC messages
        if ($this->EmailCC) {
            $this->mime->addCc(str_replace(array('@SharedGroup', '@Group'), array(' Shared Group', ' Group'), $this->EmailCC));
        }
        $messageid = "<{$_SERVER['REMOTE_PORT']}." . time() . "@{$this->Pop3host}>";
        $this->mime->headers(array('Message-ID' => $messageid));
        // Replace the X-Mailer with our custom copy
        $this->mime->headers(array('X-Mailer' => $this->XMailer));
        if ($this->ReadReceipt) {
            // Define the Read-receipt if toggled on - Split over two calls, all in one seemed to fail
            $this->mime->headers(array('X-Confirm-Reading-To' => $this->ReplyTo));
            $this->mime->headers(array('Return-Receipt-To' => $this->ReplyTo));
            $this->mime->headers(array('Disposition-Notification-To' => $this->ReplyTo));
        }
        if ($this->EmailPriority) {
            $this->mime->headers(array('X-Priority' => $this->EmailPriority));
            if ($this->EmailPriority == 5) {
                $this->mime->headers(array('X-MSMail-Priority' => 'Low'));
            }
            if ($this->EmailPriority == 1) {
                $this->mime->headers(array('X-MSMail-Priority' => 'High'));
            }
        }
        $TypeFor = array('txt' => 'text/plain', 'sh' => 'text/x-sh', 'csh' => 'text/x-csh', 'pm' => 'text/x-perl', 'pl' => 'text/x-perl', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'xbm' => 'image/xbm', 'eml' => 'message/rfc822');
        /*
        	    // attach any messages forwarded as attachments
        	    $names = array();
        	    $i = 1;
        	    foreach ($this->emailPaths as $path) {
        	        $fh = fopen($path, 'r');
        	        while (false !== $line = fgets($fh)) {
        	           if (preg_match('/^subject:\s*(.+)/i', $line, $m)) {
        	               $name = GetMail::quote_header($m[1]);
        
        	               while (in_array($name, $names)) {
        	                   if ($i == 1)
        	                       $name = "{$name}_1";
        	                   else
            	                   $name = preg_replace('/_\d+$/', $name, "_$i");
        
            	               $i++;
        	               }
        
        	               $names[] = $name;
        	               $name = "$name.eml";
        	               break;
        	           }
            }
        	        $this->mime->addAttachment($path, 'message/rfc822', $name);
        	    }
        */
        // We have attachments in our folder
        if ($this->EmailAttach) {
            // Loop through each attachment
            foreach ($this->attachname as $file) {
                if (strpos($file, $this->Account) === false) {
                    continue;
                }
                $name = $file;
                // Strip the filename header with our account, rand and pid prefix
                $name = preg_replace("/^{$this->Account}-\\d+-/", '', $name);
                // strip the .safe extension
                $name = preg_replace('/\\.safe$/', '', $name);
                // Find the extension of the file
                if (preg_match('/\\.(\\w+)$/', $name, $match)) {
                    $ext = $match[1];
                }
                // Language encode if we contain different characters
                if ($this->_check_if_contain_utf8($name)) {
                    $name = MIME_Words::encode_mimeword(GetMail::encode_language('UTF-8', $name), "B", 'UTF-8');
                }
                // Attach the file to the message
                $ext = strtolower($ext);
                $type = $TypeFor[$ext] ? $TypeFor[$ext] : 'application/octet-stream';
                $this->mime->addAttachment($atmail->tmpdir . "/{$file}", $type, $name) || catcherror("Cannot attach filename to message : {$name}");
            }
        }
        // Add CID images
        foreach ($this->inlineimages as $image) {
            // Find the extension of the file
            if (preg_match('/\\.(\\w+)$/', $image['name'], $match)) {
                $ext = $match[1];
            }
            $type = $TypeFor[$ext];
            $this->mime->addHtmlImage($image['filename'], $type, $image['name'], true, $image['cid']);
        }
        $this->body = $this->mime->get(array('text_encoding' => 'quoted-printable', 'html_encoding' => 'quoted-printable'));
        $this->headers = trim($this->mime->txtHeaders());
    }
Esempio n. 12
0
    if ($handle = opendir($pref['install_dir'] . '/tmp/')) {
        while (false !== ($file_name = readdir($handle))) {
            if ($file_name != "." && $file_name != ".." && $file_name != '.htaccess' && is_file($file_name)) {
                if (strtotime("+ 180 seconds") > fileatime($file_name)) {
                    unlink($file_name);
                }
            }
        }
        closedir($handle);
    }
    // If we have expunge on logout ( e.g PDMF IMAP server)
    if ($pref['expunge_logout'] == '1') {
        $atmail->status = $auth->getuser($atmail->SessionID);
        $atmail->loadprefs(1);
        require_once 'GetMail.php';
        $mail = new GetMail(array('Username' => $atmail->username, 'Pop3host' => $atmail->pop3host, 'Password' => $auth->password, 'Mode' => $atmail->Mode, 'Type' => $atmail->MailType));
        if ($atmail->MailType == 'imap') {
            $mail->login();
            $folders = $mail->listfolders();
            // Create a new folder-tree element
            $mail->newfolder_tree();
            // Loop through each of the folders
            foreach ($folders as $folder) {
                $mail->expunge($folder);
            }
        }
    }
    session_destroy();
}
$var['Ajax'] = '1';
$var['error'] = $_REQUEST['error'];
Esempio n. 13
0
 function quote_header($header)
 {
     // Detect if we may need decoding (avoid regex later if not)
     if (strpos($header, '?=')) {
         $headerParts = preg_split('/,|;/', $header);
         $decode = true;
     } else {
         // Catch a Non-Standard(?) MIME charset encoding
         // This was required for a client who got many emails with
         // this type of encoding
         if (preg_match('/^(ISO-8859-\\d+)\'.*?\'(.+)/i', $header, $m)) {
             return iconv($m[1], 'UTF-8', rawurldecode($m[2]));
         }
         $headerParts = array($header);
         $decode = false;
     }
     $decoded = '';
     foreach ($headerParts as $h) {
         if ($decode && preg_match('/\\s*=\\?([^\\?]+)\\?([QqBb])/', $h, $m)) {
             if (strtoupper($m[2]) == 'Q') {
                 $h = preg_replace('/\\s*=\\?([^\\?]+)\\?[Qq]\\?([^\\?]+)?\\?=/e', 'GetMail::decode_language(\'$1\', GetMail::decode_mime_head(\'$1\', \'$2\'))', $h);
             } else {
                 $h = preg_replace('/\\s*=\\?([^\\?]+)\\?[Bb]\\?([^\\?]+)?\\?=/e', 'GetMail::decode_language(\'$1\', base64_decode(\'$2\'))', $h);
             }
         } else {
             $h = GetMail::decode_language('', $h);
         }
         //$header = preg_replace('/(.+?)<(.*?)>/', '$1&lt;$2&gt;', $h);
         $h = str_replace(array('<', '>'), array('&lt;', '&gt;'), $h);
         $h = trim($h);
         $decoded .= $h;
     }
     return $decoded;
 }
Esempio n. 14
0
require_once 'header.php';
require_once 'Global.php';
require_once 'ReadMsg.php';
require_once 'SendMsg.php';
require_once 'Session.php';
session_start();
if (isset($_REQUEST['DisplayImages']) && $_REQUEST['DisplayImages'] == 1) {
    $_SESSION['DisplayImages'][] = $_REQUEST['id'];
}
$var = array();
$atmail = new AtmailGlobal();
$auth =& $atmail->getAuthObj();
// If we are exporting an email, pring the correct header, otherwise proceed as normal
if (isset($_REQUEST['rawemail'])) {
    require_once 'GetMail.php';
    $getmail = new GetMail();
    $time = time($getmail->calc_timezone(time()));
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: message/rfc822; name=\"rawemail-{$time}.eml");
    header("Content-Disposition: attachment; filename=\"rawemail-{$time}.eml");
    header('Content-Transfer-Encoding: binary');
    header("Pragma: ");
} else {
    $atmail->httpheaders();
}
$atmail->status = $auth->getuser($atmail->SessionID);
$atmail->username = $auth->username;
$atmail->pop3host = $auth->pop3host;
// check for language version
if (!$atmail->Language) {
    $atmail->Language = $pref['Language'];
Esempio n. 15
0
function util_info()
{
    global $mail, $atmail, $var, $domains;
    $mail->login();
    $reload = false;
    // We keep the folder info in session to speed up page loading as
    // when we have large folders this can take a while. Data stays valid
    // for 15 minutes
    //if (isset($_SESSION['folderinfo']) && ($_SESSION['folderinfo']['created'] < (time() - 900))) {
    //	unset($_SESSION['folderinfo']);
    //}
    $var['delim'] = $mail->Deliminator;
    if (isset($_REQUEST['renamefolder']) && !empty($_REQUEST['curname']) && !empty($_REQUEST['foldername'])) {
        if ($_REQUEST['curname'] != 'Sent' && $_REQUEST['curname'] != 'Trash' && $_REQUEST['curname'] != 'Drafts' && $_REQUEST['curname'] != 'Spam') {
            // Cannot change parent name
            if (false !== ($pos = strrpos($_REQUEST['curname'], $mail->Deliminator))) {
                $parent = substr($_REQUEST['curname'], 0, $pos);
                $new_folder = $parent . $mail->Deliminator . $_REQUEST['foldername'];
            } else {
                $new_folder = $_REQUEST['foldername'];
            }
            $mail->renamefolder(str_replace('/', $mail->Deliminator, $_REQUEST['curname']), str_replace('/', $mail->Deliminator, $new_folder));
            $reload = true;
            //$_SESSION['folderinfo'][$new_folder] = $_SESSION['folderinfo'][$_REQUEST['curname']];
            //unset($_SESSION['folderinfo'][$_REQUEST['curname']]);
        }
    }
    // The user selects to create a new mailbox
    if ($_REQUEST['creatembox']) {
        $folder = $_REQUEST['foldername'];
        $mail->newfolder($folder);
        // Add the folder to the session data if required
        //if (isset($_SESSION['folderinfo']) && !preg_match('^(inbox|spam|trash|drafts|sent)$/i', $folder)) {
        //	$_SESSION['folderinfo'][$folder]['msgs'] = 0;
        //	$_SESSION['folderinfo'][$folder]['size'] = 0;
        //}
        $reload = true;
    } elseif ($_REQUEST['delete']) {
        $del = urldecode($_REQUEST['delete']);
        if ($_REQUEST['purge'] == 1) {
            $mail->purgefolder($del);
        } else {
            $mail->delfolder($del);
        }
        // Update the folder data in the session if required
        //if (isset($_SESSION['folderinfo']) && preg_match('/^(inbox|spam|trash|drafts|sent)$/i', $del)) {
        //	$_SESSION['folderinfo'][$del]['msgs'] = 0;
        //	$_SESSION['folderinfo'][$del]['size'] = 0;
        //} elseif (isset($_SESSION['folderinfo'])) {
        //	unset($_SESSION['folderinfo'][$del]);
        //	unset($_SESSION['folderinfo'][$del]);
        //}
        if ($_REQUEST['purge'] != 1 && $del != 'Trash' && $del != 'Spam') {
            // Delete any message filters that match the foldername
            $sort_subject = $atmail->getsort('EmailSubject', 'hash');
            foreach ($sort_subject as $k => $v) {
                if ($v == $del) {
                    $atmail->delsort($k, 'EmailSubject');
                }
            }
            $sort_email = $atmail->getsort('EmailAddress', 'hash');
            foreach ($sort_email as $k => $v) {
                if ($v == $del) {
                    $atmail->delsort($k, 'EmailAddress');
                }
            }
        }
        $reload = true;
    } elseif ($_REQUEST['spamadd']) {
        $atmail->addspamer();
    } elseif ($_REQUEST['spamdel']) {
        $atmail->delspamer();
    } elseif ($_REQUEST['addsort']) {
        $atmail->addsort();
    } elseif ($_REQUEST['delsort']) {
        $atmail->delsort(base64_decode($_REQUEST['delete_sort']), $_REQUEST['type']);
    }
    // Find the folder names , size and number of messages
    $folders = $mail->listfolders();
    // sort the folders by name
    $folders = GetMail::_sort_folders($folders);
    // Make a select box with the foldernames
    $var['folderbox'] = $var['renamefolderbox'] = $mail->folder_select('Inbox', $folders, false);
    // Remove System folders from rename options
    $patterns = array("<option value=\"Trash\">Trash</option>", "<option value=\"Spam\">Spam</option>", "<option value=\"Drafts\">Drafts</option>", "<option value=\"Sent\">Sent</option>");
    $var['renamefolderbox'] = str_replace($patterns, '', $var['renamefolderbox']);
    $var['renamefolderbox'] = '<option value="">--</option>' . $var['renamefolderbox'];
    $var['folderbox'] = str_replace("value=\"Trash\"", "value=\"Trash\" selected", $var['folderbox']);
    //$var['folderbox'] = preg_replace('/<option value="erase">.*?<\/option>/', '', $var['folderbox']);
    //$var['folderbox'] = preg_replace('/<option value="" style=\'color: gray;\'>.*?<\/option>/', '', $var['folderbox']);
    // Translate the mailbox folders into another language
    $var['folderbox'] = Language::folder_language($var['folderbox'], $atmail->Language, null);
    //list($var['usedquota'], $var['totalquota']) = $mail->getquota();
    // The size of our quota in Kb
    /*
    if (!$var['totalquota'])
    {
    	$var['totalquota'] = $atmail->UserQuota;
    	$var['totalquota'] = sprintf("%2.0f", $var['totalquota']);
    }
    
    if ($var['usedquota'] > 0 && $var['totalquota'] > 0)
    {
    	$var['used'] = ( $var['usedquota'] / $var['totalquota']) * 100;
    
    	if ($var['used'] < 1)
    		$var['used'] = '1%';
    	else
    		$var['used'] = round($var['used'], 2) . '%';
    }
    
    $var['used_percent'] = $var['used']? $var['used'] : '1%';
    */
    foreach ($folders as $folder) {
        // Retrieve the foldername without any / extension
        $folderlink = $mail->folder_getlink($folder);
        list($num, $size) = $mail->sizefolder($folderlink);
        // Get the data from the session if it exists
        //if (isset($_SESSION['folderinfo'][$folder]) && $_SESSION['folderinfo'][$folder]['msgs'] > 0) {
        //	$num = $_SESSION['folderinfo'][$folder]['msgs'];
        //	$size = $_SESSION['folderinfo'][$folder]['size'];
        //} else {
        // Implement cache function soon - Read the size for the moment
        //	list( $num, $size ) = $mail->sizefolder($folderlink);
        //	$_SESSION['folderinfo'][$folder] = array('msgs' => $num, 'size' => $size);
        //	$_SESSION['folderinfo']['created'] = time();
        //}
        // Skip Inbox for the POP3 protocol
        if (strtoupper($folder) == 'INBOX' && !$domains[$atmail->pop3host] && $atmail->MailType == 'pop3') {
            continue;
        }
        // Change the display language, depending on the user language login
        $foldername = Language::folder_language($folder, $atmail->Language, 1);
        $var['folders'] .= $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/foldertr.html", array('Folder' => $folder, 'FolderLink' => $folderlink, 'FolderName' => $foldername, 'Size' => $size, 'MsgNum' => $num, 'SystemFolder' => $mail->isAtmailFolder($folder)));
    }
    // Make a select box with our list of spammers
    //$var['spam_select'] = $atmail->spam_select();
    $var['sort_email'] = $atmail->getsort('EmailAddress');
    $var['sort_subj'] = $atmail->getsort('EmailSubject');
    // Translate the mailbox folders into another language
    $var['sort_email'] = $mail->folder_select_lang($var['sort_email'], $atmail->Language, 1);
    $var['sort_subj'] = $mail->folder_select_lang($var['sort_subj'], $atmail->Language, 1);
    $var['reloadFolders'] = isset($_REQUEST['noreload']) || $reload == false ? 'false' : 'true';
    print $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/folders.html", $var);
}
Esempio n. 16
0
$var['flag'] = $_REQUEST['Flag'];
$var['XML'] = $_REQUEST['XML'];
$var['suffix'] = '_ajax';
// Make sure we are ordering the query with an allowed field
if ($var['sort'] != "EmailFrom" && $var['sort'] != "EmailTo" && $var['sort'] != "EmailSubject" && $var['sort'] != "EmailAttach" && $var['sort'] != "EmailDate" && $var['sort'] != "id" && $var['sort'] != "EmailSize") {
    $atmail->end();
}
// Load an array of msgs selected to be moved
$msgs = $_REQUEST['id'];
if (!is_array($msgs)) {
    settype($msgs, 'array');
}
if (isset($_REQUEST['msgmove'])) {
    $msgmove = $_REQUEST['msgmove'];
}
$mail = new GetMail(array('Username' => $atmail->username, 'Pop3host' => $atmail->pop3host, 'Password' => $auth->password, 'Type' => $atmail->MailType, 'Mode' => $atmail->Mode));
$status = $mail->login();
// We have an error while logging in. Tell the user
if ($status) {
    print $atmail->parse("html/{$atmail->Language}/auth_misc.html", array('status' => "Remote mail-server not responding - Check connection - {$status}"));
    $mail->quit();
    $atmail->end();
}
// Receive the list of mailbox folders
$folders = GetMail::_sort_folders($mail->listfolders());
// Make sure the requested folder exists (help avoid XSS etc)
if (!empty($var['folder']) && !in_array($var['folder'], $folders)) {
    die("requested folder does not exist");
}
$fol = array();
// Create the select box for moving messages to another folder
Esempio n. 17
0
 function quote_header($header)
 {
     if (preg_match('/\\s*=\\?([^\\?]+)\\?([QqBb])/', $header, $m)) {
         if (strtoupper($m[2]) == 'Q') {
             $header = preg_replace('/\\s*=\\?([^\\?]+)\\?[Qq]\\?([^\\?]+)?\\?=/e', 'GetMail::decode_language(\'$1\', GetMail::decode_mime_head(\'$1\', \'$2\'))', $header);
         } else {
             $header = preg_replace('/\\s*=\\?([^\\?]+)\\?[Bb]\\?([^\\?]+)?\\?=/e', 'GetMail::decode_language(\'$1\', base64_decode(\'$2\'))', $header);
         }
     } else {
         $header = GetMail::decode_language('', $header);
     }
     $header = preg_replace('/(.+?)<(.*?)>/', '$1&lt;$2&gt;', $header);
     $header = str_replace(array('<', '>'), '', $header);
     $header = trim($header);
     return $header;
 }