Exemple #1
0
 /**
  * Helper function to _getXML(). Returns xml of a header.
  *
  * @param  string  Name of header
  * @param  string  Value of header
  * @param  integer Number of tabs to indent
  * @return string  XML version of input
  * @access private
  */
 function _getXML_helper($hdr_name, $hdr_value, $indent)
 {
     $htab = "\t";
     $crlf = "\r\n";
     $return = '';
     $new_hdr_value = $hdr_name != 'received' ? D3diary_Mail_mimeDecode::_parseHeaderValue($hdr_value) : array('value' => $hdr_value);
     $new_hdr_name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $hdr_name)));
     // Sort out any parameters
     if (!empty($new_hdr_value['other'])) {
         foreach ($new_hdr_value['other'] as $paramname => $paramvalue) {
             $params[] = str_repeat($htab, $indent) . $htab . '<parameter>' . $crlf . str_repeat($htab, $indent) . $htab . $htab . '<paramname>' . htmlspecialchars($paramname) . '</paramname>' . $crlf . str_repeat($htab, $indent) . $htab . $htab . '<paramvalue>' . htmlspecialchars($paramvalue) . '</paramvalue>' . $crlf . str_repeat($htab, $indent) . $htab . '</parameter>' . $crlf;
         }
         $params = implode('', $params);
     } else {
         $params = '';
     }
     $return = str_repeat($htab, $indent) . '<header>' . $crlf . str_repeat($htab, $indent) . $htab . '<headername>' . htmlspecialchars($new_hdr_name) . '</headername>' . $crlf . str_repeat($htab, $indent) . $htab . '<headervalue>' . htmlspecialchars($new_hdr_value['value']) . '</headervalue>' . $crlf . $params . str_repeat($htab, $indent) . '</header>' . $crlf;
     return $return;
 }
Exemple #2
0
 function get_list()
 {
     $count = $this->login();
     $max = 100;
     $start = $count > $max ? $count - $max : 0;
     //var_dump($count);
     if (0 == $count) {
         //	print "There doesn't seem to be any new mail.";
         return false;
     } else {
         for ($i = $count; $i > $start; $i--) {
             //variables
             $content_type = '';
             $boundary = '';
             $bodysignal = 0;
             // added override "mb_detect_order"
             $chr_order = !empty($this->mod_config['post_detect_order']) ? $this->mod_config['post_detect_order'] : 'auto';
             $mb_rtn = mb_detect_order($chr_order);
             if ($mb_rtn != true) {
                 $this->_err_msg .= "Error: INVALID DETECT ORDER '" . $chr_order . "'<br />\n";
                 mb_detect_order('auto');
             }
             $input = implode('', $this->pop3->get($i));
             // decode the mime
             $params['include_bodies'] = true;
             $params['decode_bodies'] = true;
             $params['decode_headers'] = true;
             $params['input'] = $input;
             $structure = D3diary_Mail_mimeDecode::decode($params);
             // read and check "from" address
             $from = $this->yn_read_address($structure);
             if (!$from) {
                 $this->_err_msg .= "Error: No sender address found at message #{$i}.<br />\n";
                 continue;
                 // jump through
             }
             // validate "from" address
             // user profile's email address
             // must get email of $this->req_uid not for $xoopsUser
             $ret = $this->d3dConf->func->get_xoopsuname($this->req_uid);
             $this->email = $ret['email'];
             if (strcmp($from, $this->dcfg->address) != 0 && strcmp($from, $this->email) != 0) {
                 continue;
                 // jump through
             }
             // pickup subject
             $subject = trim($structure->headers['subject']);
             //$subject = mb_convert_encoding($subject, _CHARSET, "auto");
             $subject = mb_convert_encoding($subject, _CHARSET, mb_detect_encoding($subject));
             $title = $this->myts->makeTboxData4Show($subject);
             if (empty($title)) {
                 $title = _MD_DIARY_NO_TITLE;
             }
             //date reformating
             $post_time_gmt = strtotime(trim($structure->headers['date']));
             if (!$post_time_gmt) {
                 $this->_err_msg .= "Error: There is no Date: field at message #{$i}.<br />\n";
                 continue;
             }
             $post_date = gmdate('Y-m-d H:i:s', $post_time_gmt + $this->d3dConf->server_TZ * 3600);
             $create_time = $this->myts->makeTboxData4Show($post_date);
             $post_date_gmt = gmdate('Y-m-d H:i:s', $post_time_gmt);
             $post_date_gmt = $this->myts->makeTboxData4Show($post_date_gmt);
             $this->mails[$i]['id'] = $i;
             $this->mails[$i]['title'] = $title;
             $this->mails[$i]['create_time'] = $create_time;
             $this->mails[$i]['post_date'] = $post_date;
             $this->mails[$i]['post_date_gmt'] = $post_date_gmt;
             $this->structure[$i] = $structure;
         }
         // end looping over messages
         return true;
     }
 }