コード例 #1
0
 function &getdisplayableBody($_bodyParts)
 {
     $bodyParts = $_bodyParts;
     $webserverURL = $GLOBALS['phpgw_info']['server']['webserver_url'];
     $nonDisplayAbleCharacters = array('[\\016]', '[\\017]', '[\\020]', '[\\021]', '[\\022]', '[\\023]', '[\\024]', '[\\025]', '[\\026]', '[\\027]', '[\\030]', '[\\031]', '[\\032]', '[\\033]', '[\\034]', '[\\035]', '[\\036]', '[\\037]');
     $body = '';
     #_debug_array($bodyParts); exit;
     foreach ($bodyParts as $singleBodyPart) {
         if (!empty($body)) {
             $body .= '<hr style="border:dotted 1px silver;">';
         }
         #_debug_array($singleBodyPart['charSet']);
         $singleBodyPart['body'] = $this->botranslation->convert($singleBodyPart['body'], strtolower($singleBodyPart['charSet']));
         //error_log($singleBodyPart['body']);
         #$CharSetUsed = mb_detect_encoding($singleBodyPart['body'] . 'a' , strtoupper($singleBodyPart['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1');
         if ($singleBodyPart['mimeType'] == 'text/plain') {
             $newBody = $singleBodyPart['body'];
             $newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper($this->displayCharset));
             // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
             if (empty($newBody)) {
                 $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
             }
             #$newBody	= $this->bofelamimail->wordwrap($newBody, 90, "\n");
             // search http[s] links and make them as links available again
             // to understand what's going on here, have a look at
             // http://www.php.net/manual/en/function.preg-replace.php
             // create links for websites
             $newBody = preg_replace("/((http(s?):\\/\\/)|(www\\.))([\\w,\\-,\\/,\\?,\\=,\\.,&amp;,!\n,!&gt;,\\%,@,\\*,#,:,~,\\+]+)/ie", "'<a href=\"{$webserverURL}/redirect.php?go='.@htmlentities(urlencode('http\$3://\$4\$5'),ENT_QUOTES,\"{$this->displayCharset}\").'\" target=\"_blank\"><font color=\"blue\">\$2\$4\$5</font></a>'", $newBody);
             // create links for ftp sites
             $newBody = preg_replace("/((ftp:\\/\\/)|(ftp\\.))([\\w\\.,-.,\\/.,\\?.,\\=.,&amp;]+)/i", "<a href=\"ftp://\$3\$4\" target=\"_blank\"><font color=\"blue\">ftp://\$3\$4</font></a>", $newBody);
             // create links for email addresses
             $this->parseEmail($newBody);
             $newBody = $this->highlightQuotes($newBody);
             $newBody = nl2br($newBody);
         } else {
             $newBody = $singleBodyPart['body'];
             $newBody = $this->highlightQuotes($newBody);
             bofelamimail::getCleanHTML($newBody);
             // create links for websites
             #$newBody = preg_replace("/(?<!\>)((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\*,#,:,~,\+]+)/ie",
             #	"'<a href=\"$webserverURL/redirect.php?go='.htmlentities(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody);
             $newBody = preg_replace("/(?<!>|\\/|\")((http(s?):\\/\\/)|(www\\.))([\\w,\\-,\\/,\\?,\\=,\\.,&amp;,!\n,\\%,@,\\*,#,:,~,\\+]+)/ie", "'<a href=\"{$webserverURL}/redirect.php?go='.@htmlentities(urlencode('http\$3://\$4\$5'),ENT_QUOTES,\"{$this->displayCharset}\").'\" target=\"_blank\"><font color=\"blue\">\$2\$4\$5</font></a>'", $newBody);
             // create links for websites
             $newBody = preg_replace("/href=(\"|\\')((http(s?):\\/\\/)|(www\\.))([\\w,\\-,\\/,\\?,\\=,\\.,&amp;,!\n,\\%,@,\\(,\\),\\*,#,:,~,\\+]+)(\"|\\')/ie", "'href=\"{$webserverURL}/redirect.php?go='.@htmlentities(urlencode('http\$4://\$5\$6'),ENT_QUOTES,\"{$this->displayCharset}\").'\" target=\"_blank\"'", $newBody);
             // create links for ftp sites
             $newBody = preg_replace("/href=(\"|\\')((ftp:\\/\\/)|(ftp\\.))([\\w\\.,-.,\\/.,\\?.,\\=.,&amp;]+)(\"|\\')/i", "href=\"ftp://\$4\$5\" target=\"_blank\"", $newBody);
             // create links for inline images
             $linkData = array('menuaction' => 'felamimail.uidisplay.displayImage', 'uid' => $this->uid, 'mailbox' => base64_encode($this->mailbox));
             $imageURL = $GLOBALS['phpgw']->link('/index.php', $linkData);
             $newBody = preg_replace("/(\"|\\')cid:(.*)(\"|\\')/iUe", "'\"{$imageURL}&cid='.base64_encode('\$2').'&partID='.urlencode({$this->partID}).'\"'", $newBody);
             // create links for email addresses
             $linkData = array('menuaction' => 'felamimail.uicompose.compose');
             $link = $GLOBALS['phpgw']->link('/index.php', $linkData);
             $newBody = preg_replace("/href=(\"|\\')mailto:([\\w,\\-,\\/,\\?,\\=,\\.,&amp;,!\n,\\%,@,\\*,#,:,~,\\+]+)(\"|\\')/ie", "'href=\"{$link}&send_to='.base64_encode('\$2').'\"'", $newBody);
             #print "<pre>".htmlentities($newBody)."</pre><hr>";
             // replace emails within the text with clickable links.
             $this->parseEmail($newBody);
         }
         $body .= $newBody;
         #print "<hr><pre>$body</pre><hr>";
     }
     // create links for windows shares
     // \\\\\\\\ == '\\' in real life!! :)
     $body = preg_replace("/(\\\\\\\\)([\\w,\\\\,-]+)/i", "<a href=\"file:\$1\$2\" target=\"_blank\"><font color=\"blue\">\$1\$2</font></a>", $body);
     $body = preg_replace($nonDisplayAbleCharacters, '', $body);
     return $body;
 }
コード例 #2
0
 static function _getCleanHTML($_body)
 {
     static $nonDisplayAbleCharacters = array('[\\016]', '[\\017]', '[\\020]', '[\\021]', '[\\022]', '[\\023]', '[\\024]', '[\\025]', '[\\026]', '[\\027]', '[\\030]', '[\\031]', '[\\032]', '[\\033]', '[\\034]', '[\\035]', '[\\036]', '[\\037]');
     bofelamimail::getCleanHTML($_body);
     $_body = preg_replace($nonDisplayAbleCharacters, '', $_body);
     return $_body;
 }
コード例 #3
0
 static function mergeProfileData($mergeInTo, $toMerge)
 {
     if (is_array($toMerge) && count($toMerge) > 0) {
         $allkeys = array_unique(array_keys($mergeInTo) + array_keys($toMerge));
         foreach ($allkeys as $i => $key) {
             if (!array_key_exists($key, $mergeInTo) && array_key_exists($key, $toMerge) && !empty($toMerge[$key])) {
                 $mergeInTo[$key] = $toMerge[$key];
             } else {
                 if (array_key_exists($key, $toMerge) && !empty($toMerge[$key])) {
                     switch ($key) {
                         case 'ea_imap_server':
                         case 'ea_imap_type':
                         case 'ea_imap_port':
                         case 'ea_imap_tsl_encryption':
                         case 'ea_imap_tsl_auth':
                             if (strlen($toMerge['ea_imap_server']) > 0) {
                                 $mergeInTo[$key] = $toMerge[$key];
                             }
                             break;
                         case 'ea_smtp_port':
                         case 'ea_smtp_type':
                         case 'ea_smtp_server':
                             if (strlen($toMerge['ea_smtp_server']) > 0) {
                                 $mergeInTo[$key] = $toMerge[$key];
                             }
                             break;
                         case 'ea_default_signature':
                             $testVal = $toMerge['ea_default_signature'];
                             bofelamimail::getCleanHTML($testVal);
                             if (strlen($testVal) > 10 || $testVal != '<br>' || $testVal != '<br />') {
                                 $mergeInTo[$key] = $toMerge[$key];
                             }
                             break;
                         default:
                             $mergeInTo[$key] = $toMerge[$key];
                     }
                 }
             }
         }
     }
     return $mergeInTo;
 }