function test_decodes_iso_8859_1_rfc2047_q_encoding()
 {
     $this->assertEquals("this is some text", wp_iso_descrambler("=?iso-8859-1?q?this=20is=20some=20text?="));
 }
Example #2
0
     $content_transfer_encoding = explode(';', $content_transfer_encoding);
     $content_transfer_encoding = $content_transfer_encoding[0];
 }
 if ($content_type == 'multipart/alternative' && false !== strpos($line, 'boundary="') && '' == $boundary) {
     $boundary = trim($line);
     $boundary = explode('"', $boundary);
     $boundary = $boundary[1];
 }
 if (preg_match('/Subject: /i', $line)) {
     $subject = trim($line);
     $subject = substr($subject, 9, strlen($subject) - 9);
     // Captures any text in the subject before $phone_delim as the subject
     if (function_exists('iconv_mime_decode')) {
         $subject = iconv_mime_decode($subject, 2, get_option('blog_charset'));
     } else {
         $subject = wp_iso_descrambler($subject);
     }
     $subject = explode($phone_delim, $subject);
     $subject = $subject[0];
 }
 /*
  * Set the author using the email address (From or Reply-To, the last used)
  * otherwise use the site admin.
  */
 if (!$author_found && preg_match('/^(From|Reply-To): /', $line)) {
     if (preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches)) {
         $author = $matches[0];
     } else {
         $author = trim($line);
     }
     $author = sanitize_email($author);
Example #3
0
 function getlist($mail_server, $mail_port, $mail_user, $mail_pass, $max = 10)
 {
     $maillists = array();
     $phone_delim = '::';
     $pop3 = new POP3();
     if (!$pop3->connect($mail_server, $mail_port) || !$pop3->user($mail_user) || !($count = $pop3->pass($mail_pass))) {
         $pop3->quit();
         $this->error = 0 === $count ? 'There doesn&#8217;t seem to be any new mail.' : $pop3->ERROR;
         return false;
     }
     $this->count = $count;
     var_dump($count);
     //if($count > $max )$count = $max;
     for ($i = $count; $i > $count - 1; $i--) {
         $message = $pop3->get($i);
         /*foreach($message as $m=>$n){
               //$n=iconv_mime_decode($n, 2, "gbk");
               $n=base64_decode($n);
               $n=mb_convert_encoding($n, 'gbk', 'gbk');
               var_dump($n);
               if(strpos($n,'http://bbs.scol.com.cn/member.php')!==FALSE){
                  var_dump($n);
               }
               if(strpos($n,'(如果上面不')!==FALSE){
                  var_dump($n);
               }
             
               //$n=mb_convert_encoding($n, 'gbk', 'gbk');
           
               
           }*/
         /*for($j=0;$j<=sizeof($message);$j++){
               $message[$j]=base64_decode($message[$j]);
           }*/
         var_dump(base64_decode($message[42]));
         var_dump(substr(base64_decode($message[41]), 12));
         var_dump(substr(base64_decode($message[42]), 0, -12));
         $bf = substr(base64_decode($message[41]), 17);
         $af = trim(substr(base64_decode($message[42]), 0, -20));
         //$url=substr(base64_decode($message[43]),12)+substr(base64_decode($message[44]),0,-12);
         var_dump($bf . $af);
         $all = str_replace("\n", '', $bf . $af);
         $all = str_replace(">", "", $all);
         $all = str_replace("&amp;", "&", $all);
         //$snoopy->fetch($bf.$af);
         //$re =mb_convert_encoding($snoopy->results,"utf-8","gbk");
         //print_r($re);
         //sleep(10);
         //echo "。";
         //echo "<br/>";
         $bodysignal = false;
         $boundary = '';
         $charset = '';
         $content = '';
         $content_type = '';
         $content_transfer_encoding = '';
         $post_author = 1;
         foreach ((array) $message as $line) {
             //var_dump($line);
             // body signal
             if (strlen($line) < 3) {
                 $bodysignal = true;
             }
             if ($bodysignal) {
                 $content .= $line;
             } else {
                 if (preg_match('/Content-Type: /i', $line)) {
                     $content_type = trim($line);
                     $content_type = substr($content_type, 14, strlen($content_type) - 14);
                     $content_type = explode(';', $content_type);
                     if (!empty($content_type[1])) {
                         $charset = explode('=', $content_type[1]);
                         $charset = !empty($charset[1]) ? trim($charset[1]) : '';
                     }
                     $content_type = $content_type[0];
                 }
                 if (preg_match('/Content-Transfer-Encoding: /i', $line)) {
                     $content_transfer_encoding = trim($line);
                     $content_transfer_encoding = substr($content_transfer_encoding, 27, strlen($content_transfer_encoding) - 27);
                     $content_transfer_encoding = explode(';', $content_transfer_encoding);
                     $content_transfer_encoding = $content_transfer_encoding[0];
                 }
                 if ($content_type == 'multipart/alternative' && false !== strpos($line, 'boundary="') && '' == $boundary) {
                     $boundary = trim($line);
                     $boundary = explode('"', $boundary);
                     $boundary = $boundary[1];
                 }
                 if (preg_match('/Subject: /i', $line)) {
                     $subject = trim($line);
                     $subject = substr($subject, 9, strlen($subject) - 9);
                     // Captures any text in the subject before $phone_delim as the subject
                     if (function_exists('iconv_mime_decode')) {
                         $subject = iconv_mime_decode($subject, 2, "UTF-8");
                     } else {
                         $subject = wp_iso_descrambler($subject);
                     }
                     $subject = explode($phone_delim, $subject);
                     $subject = $subject[0];
                 }
                 // Set the author using the email address (From or Reply-To, the last used)
                 // otherwise use the site admin
                 if (preg_match('/(From|Reply-To): /', $line)) {
                     if (preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches)) {
                         $author = $matches[0];
                     } else {
                         $author = trim($line);
                     }
                 }
                 if (preg_match('/Date: /i', $line)) {
                     // of the form '20 Mar 2002 20:32:37'
                     $ddate = trim($line);
                 }
                 if (preg_match('/member.php?mod=activate/i', $line)) {
                     // of the form '20 Mar 2002 20:32:37'
                     $lj = trim($line);
                 }
             }
         }
         //$subject = trim($subject);
         $post_data = compact('ddate', 'author', 'subject', 'lj', 'all');
         $maillists[] = $post_data;
         /*
         if(!$pop3->delete($i)) {
         	echo '<p>' . sprintf(__('Oops: %s'), esc_html($pop3->ERROR)) . '</p>';
         	$pop3->reset();
         	exit;
         } else {
         	echo '<p>' . sprintf(__('Mission complete.  Message <strong>%s</strong> deleted.'), $i) . '</p>';
         }
         */
     }
     $pop3->quit();
     $this->result = $maillists;
     return $maillists;
 }