function recode_header($header, $basecharset) { if (strpos($header, "=?") === false) { return to_utf8($header, $basecharset); } return preg_replace_callback("/=\\?(.+?)\\?([qb])\\?(.+?)(\\?=|\$)/i", function ($m) { return decode_header($m[1], $m[2], $m[3]); }, $header); }
$smarty->assign('TO_MAIL', $replyToInfo['name'] . "<" . $webmail->reply_to[0] . ">" . ","); $smarty->assign('IDLISTS', $replyToInfo['id'] . '@' . $replyToInfo['fieldId'] . '|'); } else { $smarty->assign('TO_MAIL', $replyToInfo['name'] . "<" . $webmail->reply_to[0] . ">" . ","); } //$smarty->assign('BCC_MAIL',$webmail->to[0]); if (preg_match("/RE:/i", $webmail->subject)) { $smarty->assign('SUBJECT', $webmail->subject); } else { $smarty->assign('SUBJECT', "RE: " . $webmail->subject); } } elseif ($_REQUEST["forward"] == "true") { //added for attachment handling $attachment_links = array(); for ($i = 0; $i < count($webmail->attname); $i++) { $attachment_links[$i] = $webmail->anchor_arr[$i] . decode_header($webmail->attname[$i]) . "</a></br>"; } $smarty->assign('webmail_attachments', $attachment_links); if (preg_match("/FW:/i", $webmail->subject)) { $smarty->assign('SUBJECT', $webmail->subject); } else { $smarty->assign('SUBJECT', "FW: " . $webmail->subject); } } $smarty->assign('DESCRIPTION', $webmail->replyBody()); $focus->mode = ''; } global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $disp_view = getView($focus->mode);
$jfv_subject = str_ireplace('?shift_jis?', '?SJIS-win?', $email->subject); } elseif (strtoupper(substr($email->subject, 0, 8)) == "=?EUC-JP" && @mb_convert_encoding(1, 'eucJP-win')) { $jfv_subject = str_ireplace('?euc-jp?', '?eucJP-win?', $email->subject); } else { $jfv_subject = $email->subject; } $jfv_default_internal_enc = mb_internal_encoding(); mb_internal_encoding("UTF-8"); $subject = mb_decode_mimeheader($jfv_subject); mb_internal_encoding($jfv_default_internal_enc); } else { //JFV END $subject = utf8_decode(utf8_encode(imap_utf8($email->subject))); // JFV } //JFV END $from = decode_header($email->from); $to = decode_header($email->to[0]); $cc = decode_header($email->cc_header); $date = decode_header($email->date); for ($i = 0; $i < count($email->attname); $i++) { $attachment_links .= $email->anchor_arr[$i] . decode_header($email->attname[$i]) . "</a></br> "; } $content['body'] = $email->body; $content['attachtab'] = $email->attachtab; $smarty->assign('FROM_MAIL', $from); $smarty->assign('TO_MAIL', trim($to, ",") . ","); $smarty->assign('SUBJECT', $subject); $smarty->assign('DESCRIPTION', $content['body']); $smarty->display('PrintEmail.tpl'); }
} if ($fieldn == __('from04')) { $row[$f] = htmlentities($row[$f]); $output = '<table class="sa_rules_report" cellspacing="0"><tr><td>' . $row[$f] . '</td>' . "\n"; if (LISTS) { $output .= '<td align="right">[<a href="' . $listurl . '&type=f&list=w">' . __('addwl04') . '</a> | <a href="' . $listurl . '&type=f&list=b">' . __('addbl04') . '</a>]</td>' . "\n"; } $output .= '</tr></table>' . "\n"; $row[$f] = $output; } if ($fieldn == __('to04')) { $row[$f] = htmlspecialchars($row[$f]); $row[$f] = str_replace(",", "<br>", $row[$f]); } if ($fieldn == __('subject04')) { $row[$f] = htmlspecialchars(getUTF8String(decode_header($row[$f]))); } if ($fieldn == __('spamrep04')) { $row[$f] = format_spam_report($row[$f]); } if ($fieldn == __('size04')) { $row[$f] = format_mail_size($row[$f]); } if ($fieldn == __('msgheaders04')) { if (version_compare(phpversion(), "5.4", ">=")) { $row[$f] = nl2br(str_replace(array("\n", "\t"), array("<br>", " "), htmlentities($row[$f], ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE))); } else { $row[$f] = nl2br(str_replace(array("\n", "\t"), array("<br>", " "), htmlentities($row[$f]))); } if (function_exists('iconv_mime_decode')) { $row[$f] = iconv_mime_decode(utf8_decode($row[$f]), 2, 'UTF-8');
/** * @param $sql * @param bool|string $table_heading * @param bool $pager * @param bool $order * @param bool $operations */ function db_colorised_table($sql, $table_heading = false, $pager = false, $order = false, $operations = false) { require_once __DIR__ . '/lib/pear/Mail/mimeDecode.php'; // Ordering $orderby = null; $orderdir = ''; if (isset($_GET['orderby'])) { $orderby = sanitizeInput($_GET['orderby']); switch (strtoupper($_GET['orderdir'])) { case 'A': $orderdir = 'ASC'; break; case 'D': $orderdir = 'DESC'; break; } } if (!empty($orderby)) { if (($p = stristr($sql, 'ORDER BY')) !== false) { // We already have an existing ORDER BY clause $p = "ORDER BY\n " . $orderby . ' ' . $orderdir . ',' . substr($p, strlen('ORDER BY') + 2); $sql = substr($sql, 0, strpos($sql, 'ORDER BY')) . $p; } else { // No existing ORDER BY - disable feature $order = false; } } if ($pager) { require_once __DIR__ . '/lib/pear/Pager.php'; if (isset($_GET['offset'])) { $from = intval($_GET['offset']); } else { $from = 0; } // Remove any ORDER BY clauses as this will slow the count considerably if ($pos = strpos($sql, "ORDER BY")) { $sqlcount = substr($sql, 0, $pos); } // Count the number of rows that would be returned by the query $sqlcount = "SELECT COUNT(*) " . strstr($sqlcount, "FROM"); $rows = mysql_result(dbquery($sqlcount), 0); // Build the pager data $pager_options = array('mode' => 'Sliding', 'perPage' => MAX_RESULTS, 'delta' => 2, 'totalItems' => $rows); $pager = @Pager::factory($pager_options); //then we fetch the relevant records for the current page list($from, $to) = $pager->getOffsetByPageId(); echo '<table cellspacing="1" class="mail" > <tr> <th colspan="5">' . __('disppage03') . ' ' . $pager->getCurrentPageID() . ' ' . __('of03') . ' ' . $pager->numPages() . ' - ' . __('records03') . ' ' . $from . ' ' . __('to0203') . ' ' . $to . ' ' . __('of03') . ' ' . $pager->numItems() . '</th> </tr> <tr> <td align="center">' . "\n"; //show the links echo $pager->links; echo '</td> </tr> </table> </tr> <tr> <td colspan="4">'; // Re-run the original query and limit the rows $limit = $from - 1; $sql .= " LIMIT {$limit}," . MAX_RESULTS; $sth = dbquery($sql); $rows = mysql_num_rows($sth); $fields = mysql_num_fields($sth); // Account for extra operations column if ($operations !== false) { $fields++; } } else { $sth = dbquery($sql); $rows = mysql_num_rows($sth); $fields = mysql_num_fields($sth); // Account for extra operations column if ($operations !== false) { $fields++; } } if ($rows > 0) { if ($operations !== false) { // Start form for operations echo '<form name="operations" action="./do_message_ops.php" method="POST">' . "\n"; } echo '<table cellspacing="1" width="100%" class="mail">' . "\n"; // Work out which columns to display for ($f = 0; $f < $fields; $f++) { if ($f == 0 && $operations !== false) { // Set up display for operations form elements $display[$f] = true; $orderable[$f] = false; // Set it up not to wrap - tricky way to leach onto the align field $align[$f] = 'center" style="white-space:nowrap'; $fieldname[$f] = 'Ops<br><a href="javascript:SetRadios(\'S\')">S</a> <a href="javascript:SetRadios(\'H\')">H</a> <a href="javascript:SetRadios(\'F\')">F</a> <a href="javascript:SetRadios(\'R\')">R</a>'; continue; } $display[$f] = true; $orderable[$f] = true; $align[$f] = false; // Set up the mysql column to account for operations if ($operations !== false) { $colnum = $f - 1; } else { $colnum = $f; } switch ($fieldname[$f] = mysql_field_name($sth, $colnum)) { case 'host': $fieldname[$f] = "Host"; if (DISTRIBUTED_SETUP) { $display[$f] = true; } else { $display[$f] = false; } break; case 'timestamp': $fieldname[$f] = __('datetime03'); $align[$f] = "center"; break; case 'datetime': $fieldname[$f] = __('datetime03'); $align[$f] = "center"; break; case 'id': $fieldname[$f] = "ID"; $orderable[$f] = false; $align[$f] = "center"; break; case 'id2': $fieldname[$f] = "#"; $orderable[$f] = false; $align[$f] = "center"; break; case 'size': $fieldname[$f] = __('size03'); $align[$f] = "right"; break; case 'from_address': $fieldname[$f] = __('from03'); break; case 'to_address': $fieldname[$f] = __('to03'); break; case 'subject': $fieldname[$f] = __('subject03'); break; case 'clientip': if (defined('DISPLAY_IP') && DISPLAY_IP) { $fieldname[$f] = "Client IP"; } $display[$f] = true; break; case 'archive': $display[$f] = false; break; case 'isspam': $display[$f] = false; break; case 'ishighspam': $display[$f] = false; break; case 'issaspam': $display[$f] = false; break; case 'isrblspam': $display[$f] = false; break; case 'spamwhitelisted': $display[$f] = false; break; case 'spamblacklisted': $display[$f] = false; break; case 'spamreport': $display[$f] = false; break; case 'virusinfected': $display[$f] = false; break; case 'nameinfected': $display[$f] = false; break; case 'otherinfected': $display[$f] = false; break; case 'report': $display[$f] = false; break; case 'ismcp': $display[$f] = false; break; case 'ishighmcp': $display[$f] = false; break; case 'issamcp': $display[$f] = false; break; case 'mcpwhitelisted': $display[$f] = false; break; case 'mcpblacklisted': $display[$f] = false; break; case 'mcpreport': $display[$f] = false; break; case 'hostname': $fieldname[$f] = 'Host'; $display[$f] = true; break; case 'date': $fieldname[$f] = 'Date'; break; case 'time': $fieldname[$f] = 'Time'; break; case 'headers': $display[$f] = false; break; case 'sascore': if (get_conf_truefalse('UseSpamAssassin')) { $fieldname[$f] = __('sascore03'); $align[$f] = "right"; } else { $display[$f] = false; } break; case 'mcpsascore': if (get_conf_truefalse('MCPChecks')) { $fieldname[$f] = __('mcpscore03'); $align[$f] = "right"; } else { $display[$f] = false; } break; case 'status': $fieldname[$f] = "Status"; $orderable[$f] = false; break; case 'message': $fieldname[$f] = "Message"; break; case 'attempts': $fieldname[$f] = "Tries"; $align[$f] = "right"; break; case 'lastattempt': $fieldname[$f] = "Last"; $align[$f] = "right"; break; } } // Table heading if (isset($table_heading) && $table_heading != "") { // Work out how many columns are going to be displayed $column_headings = 0; for ($f = 0; $f < $fields; $f++) { if ($display[$f]) { $column_headings++; } } echo ' <tr>' . "\n"; echo ' <th colspan="' . $column_headings . '">' . $table_heading . '</th>' . "\n"; echo ' </tr>' . "\n"; } // Column headings echo '<tr>' . "\n"; for ($f = 0; $f < $fields; $f++) { if ($display[$f]) { if ($order && $orderable[$f]) { // Set up the mysql column to account for operations if ($operations !== false) { $colnum = $f - 1; } else { $colnum = $f; } echo " <th>\n"; echo " {$fieldname[$f]} (<a href=\"?orderby=" . mysql_field_name($sth, $colnum) . "&orderdir=a" . subtract_multi_get_vars(array('orderby', 'orderdir')) . "\">A</a>/<a href=\"?orderby=" . mysql_field_name($sth, $colnum) . "&orderdir=d" . subtract_multi_get_vars(array('orderby', 'orderdir')) . "\">D</a>)\n"; echo " </th>\n"; } else { echo ' <th>' . $fieldname[$f] . '</th>' . "\n"; } } } echo ' </tr>' . "\n"; // Rows $jsRadioCheck = ''; $jsReleaseCheck = ''; for ($r = 0; $r < $rows; $r++) { $row = mysql_fetch_row($sth); if ($operations !== false) { // Prepend operations elements - later on, replace REPLACEME w/ message id array_unshift($row, '<input name="OPT-REPLACEME" type="RADIO" value="S"> <input name="OPT-REPLACEME" type="RADIO" value="H"> <input name="OPT-REPLACEME" type="RADIO" value="F"> <input name="OPTRELEASE-REPLACEME" type="checkbox" value="R">'); } // Work out field colourings and mofidy the incoming data as necessary // and populate the generate an overall 'status' for the mail. $status_array = array(); $infected = false; $highspam = false; $spam = false; $whitelisted = false; $blacklisted = false; $mcp = false; $highmcp = false; for ($f = 0; $f < $fields; $f++) { if ($operations !== false) { if ($f == 0) { // Skip the first field if it is operations continue; } $field = mysql_field_name($sth, $f - 1); } else { $field = mysql_field_name($sth, $f); } switch ($field) { case 'id': // Store the id for later use $id = $row[$f]; // Create a link to detail.php $row[$f] = '<a href="detail.php?id=' . $row[$f] . '">' . $row[$f] . '</a>' . "\n"; break; case 'id2': // Store the id for later use $id = $row[$f]; // Create a link to detail.php as [<link>] $row[$f] = "[<a href=\"detail.php?id={$row[$f]}\">#</a>]"; break; case 'from_address': $row[$f] = htmlentities($row[$f]); if (FROMTO_MAXLEN > 0) { $row[$f] = trim_output($row[$f], FROMTO_MAXLEN); } break; case 'clientip': $clientip = $row[$f]; if (defined('RESOLVE_IP_ON_DISPLAY') && RESOLVE_IP_ON_DISPLAY === true) { if (net_match('10.0.0.0/8', $clientip) || net_match('172.16.0.0/12', $clientip) || net_match('192.168.0.0/16', $clientip)) { $host = 'Internal Network'; } elseif (($host = gethostbyaddr($clientip)) == $clientip) { $host = 'Unknown'; } $row[$f] .= " ({$host})"; } break; case 'to_address': $row[$f] = htmlentities($row[$f]); if (FROMTO_MAXLEN > 0) { // Trim each address to specified size $to_temp = explode(",", $row[$f]); $num_to_temp = count($to_temp); for ($t = 0; $t < $num_to_temp; $t++) { $to_temp[$t] = trim_output($to_temp[$t], FROMTO_MAXLEN); } // Return the data $row[$f] = implode(",", $to_temp); } // Put each address on a new line $row[$f] = str_replace(",", "<br>", $row[$f]); break; case 'subject': $row[$f] = htmlspecialchars(getUTF8String(decode_header($row[$f]))); if (SUBJECT_MAXLEN > 0) { $row[$f] = trim_output($row[$f], SUBJECT_MAXLEN); } break; case 'isspam': if ($row[$f] == 'Y' || $row[$f] > 0) { $spam = true; array_push($status_array, 'Spam'); } break; case 'ishighspam': if ($row[$f] == 'Y' || $row[$f] > 0) { $highspam = true; } break; case 'ismcp': if ($row[$f] == 'Y' || $row[$f] > 0) { $mcp = true; array_push($status_array, 'MCP'); } break; case 'ishighmcp': if ($row[$f] == 'Y' || $row[$f] > 0) { $highmcp = true; } break; case 'virusinfected': if ($row[$f] == 'Y' || $row[$f] > 0) { $infected = true; array_push($status_array, 'Virus'); } break; case 'report': // IMPORTANT NOTE: for this to work correctly the 'report' field MUST // appear after the 'virusinfected' field within the SQL statement. if (preg_match("/VIRUS_REGEX/", $row[$f], $virus)) { foreach ($status_array as $k => $v) { if ($v = preg_replace('/Virus/', "Virus (" . return_virus_link($virus[2]) . ")", $v)) { $status_array[$k] = $v; } } } break; case 'nameinfected': if ($row[$f] == 'Y' || $row[$f] > 0) { $infected = true; array_push($status_array, 'Bad Content'); } break; case 'otherinfected': if ($row[$f] == 'Y' || $row[$f] > 0) { $infected = true; array_push($status_array, 'Other'); } break; case 'size': $row[$f] = format_mail_size($row[$f]); break; case 'spamwhitelisted': if ($row[$f] == 'Y' || $row[$f] > 0) { $whitelisted = true; array_push($status_array, 'W/L'); } break; case 'spamblacklisted': if ($row[$f] == 'Y' || $row[$f] > 0) { $blacklisted = true; array_push($status_array, 'B/L'); } break; case 'clienthost': $hostname = gethostbyaddr($row[$f]); if ($hostname == $row[$f]) { $row[$f] = "(Hostname lookup failed)"; } else { $row[$f] = $hostname; } break; case 'status': // NOTE: this should always be the last row for it to be displayed correctly // Work out status if (count($status_array) == 0) { $status = "Clean"; } else { $status = join("<br>", $status_array); } $row[$f] = $status; break; } } // Now add the id to the operations form elements if ($operations !== false) { $row[0] = str_replace("REPLACEME", $id, $row[0]); $jsRadioCheck .= " document.operations.elements[\"OPT-{$id}\"][val].checked = true;\n"; $jsReleaseCheck .= " document.operations.elements[\"OPTRELEASE-{$id}\"].checked = true;\n"; } // Colorise the row switch (true) { case $infected: echo '<tr class="infected">' . "\n"; break; case $whitelisted: echo '<tr class="whitelisted">' . "\n"; break; case $blacklisted: echo '<tr class="blacklisted">' . "\n"; break; case $highspam: echo '<tr class="highspam">' . "\n"; break; case $spam: echo '<tr class="spam">' . "\n"; break; case $highmcp: echo '<tr class="highmcp">' . "\n"; break; case $mcp: echo '<tr class="mcp">' . "\n"; break; default: if (isset($fieldname['mcpsascore']) && $fieldname['mcpsascore'] != '') { echo '<tr class="mcp">' . "\n"; } else { echo '<tr >' . "\n"; } break; } // Display the rows for ($f = 0; $f < $fields; $f++) { if ($display[$f]) { if ($align[$f]) { echo ' <td align="' . $align[$f] . '">' . $row[$f] . '</td>' . "\n"; } else { echo ' <td >' . $row[$f] . '</td>' . "\n"; } } } echo ' </tr>' . "\n"; } echo '</table>' . "\n"; // Javascript function to clear radio buttons if ($operations !== false) { echo "\n<script type='text/javascript'>\n function ClearRadios() {\n var e=document.operations.elements\n for(i=0; i<e.length; i++) {\n if (e[i].type=='radio' || e[i].type=='checkbox') {\n e[i].checked=false;\n }\n }\n }\n\n function SetRadios(p) {\n var val;\n var values = {\n 'S' : 0,\n 'H' : 1,\n 'F' : 2,\n 'R' : 3\n };\n switch (p) {\n case 'S':\n case 'H':\n case 'F':\n val = values[p];\n {$jsRadioCheck}\n break;\n case 'R':\n {$jsReleaseCheck}\n break;\n case 'C':\n ClearRadios();\n break;\n default:\n return;\n }\n }\n</script>\n <p> <a href=\"javascript:SetRadios('S')\">S</a>\n <a href=\"javascript:SetRadios('H')\">H</a>\n <a href=\"javascript:SetRadios('F')\">F</a>\n <a href=\"javascript:SetRadios('R')\">R</a>\n or <a href=\"javascript:SetRadios('C')\">Clear</a> all</p>\n <p><input type='SUBMIT' name='SUBMIT' value='Learn'></p>\n </form>\n <p><b>S</b> = Spam <b>H</b> = Ham <b>F</b> = Forget <b>R</b> = Release" . "\n"; } echo '<br>' . "\n"; if ($pager) { require_once __DIR__ . '/lib/pear/Pager.php'; if (isset($_GET['offset'])) { $from = intval($_GET['offset']); } else { $from = 0; } // Remove any ORDER BY clauses as this will slow the count considerably if ($pos = strpos($sql, "ORDER BY")) { $sqlcount = substr($sql, 0, $pos); } // Count the number of rows that would be returned by the query $sqlcount = "SELECT COUNT(*) " . strstr($sqlcount, "FROM"); $rows = mysql_result(dbquery($sqlcount), 0); // Build the pager data $pager_options = array('mode' => 'Sliding', 'perPage' => MAX_RESULTS, 'delta' => 2, 'totalItems' => $rows); $pager = @Pager::factory($pager_options); //then we fetch the relevant records for the current page list($from, $to) = $pager->getOffsetByPageId(); echo '<table cellspacing="1" class="mail" > <tr> <th colspan="5">' . __('disppage03') . ' ' . $pager->getCurrentPageID() . ' ' . __('of03') . ' ' . $pager->numPages() . ' - ' . __('records03') . ' ' . $from . ' ' . __('to0203') . ' ' . $to . ' ' . __('of03') . ' ' . $pager->numItems() . '</th> </tr> <tr> <td align="center">' . "\n"; //show the links echo $pager->links; echo '</td> </tr> </table> </tr> <tr> <td colspan="4">'; } } }
$to .= '<' . $email->to[$p] . '>'; } else { $to .= $email->to[$p]; } } // JFV END $cc = decode_header($email->cc_header); $date = decode_header($email->date); for ($i = 0; $i < count($email->attname); $i++) { //JFV adjust attachment link for full view mail // $attachment_links .= $email->anchor_arr[$i].decode_header($email->attname[$i])."</a></br> "; $attachment_links .= "</br> " . $email->anchor_arr[$i] . decode_header($email->attname[$i]) . "</a> " . $email->att_details[$i]['size'] . "K"; if ($attachment_links_short != '') { $attachment_links_short .= ","; } $attachment_links_short .= " " . $email->anchor_arr[$i] . decode_header($email->attname[$i]) . "</a>"; } $content['body'] = $email->body; $content['attachtab'] = $email->attachtab; if (!$_REQUEST['fullview']) { $class_str = 'class="tableHeadBg"'; } else { $class_str = 'style="font-size:15px"'; } ?> <script src="modules/Webmails/Webmails.js" type="text/javascript"></script> <script src="include/js/general.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="themes/<?php echo vtlib_purify($_REQUEST['theme']); ?> /webmail.css">
$parts[$temp_z]->type = 0; } $temp_y = $temp_z + 1; $parts_number = '_' . $temp_y; $parts_type_main = strtolower($type[$parts[$temp_z]->type]); $parts_type["{$parts_number}"] = $parts_type_main . '/' . strtolower($parts[$temp_z]->subtype); $parts_encoding["{$parts_number}"] = $encoding[$parts[$temp_z]->encoding]; $parts_size["{$parts_number}"] = $parts[$temp_z]->bytes; if (strtolower($parts[$temp_z]->disposition) == "attachment") { $temp_b = $parts[$temp_z]->dparameters; if (is_array($temp_b) || is_object($temp_b)) { reset($temp_b); while (list(, $temp_p) = each($temp_b)) { if ($temp_p->attribute == "FILENAME") { $xp_attachments .= decode_header($temp_p->value) . ' [' . ceil($parts[$temp_z]->bytes / 1024) . ' KB]' . $line_break; $parts_filename["{$parts_number}"] = decode_header($temp_p->value); $parts_filesize["{$parts_number}"] = $parts[$temp_z]->bytes; } } } } /* if there are inline parts dig deeper */ if ($parts_type_main == 'multipart') { $parts_sub = $parts[$temp_z]->parts; $parts_sub_count = count($parts_sub); for ($temp_s = 0; $temp_s < $parts_sub_count; $temp_s++) { $temp_t = $temp_s + 1; $parts_sub_number = $parts_number . '.' . $temp_t; $parts_subtype_main = strtolower($type[$parts_sub[$temp_s]->type]); $parts_type["{$parts_sub_number}"] = $parts_subtype_main . '/' . strtolower($parts_sub[$temp_s]->subtype); $parts_encoding["{$parts_sub_number}"] = strtolower($encoding[$parts_sub[$temp_s]->encoding]);