$graph->Stroke($filename); } // HTML code to display the graph echo "<TABLE BORDER=\"0\" CELLPADDING=\"10\" CELLSPACING=\"0\" WIDTH=\"100%\">"; echo "<TR>"; echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScannr Logo\"></TD>"; echo "</TR>"; echo "<TR>"; // Check Permissions to see if the file has been written and that apache to read it. if (is_readable($filename)) { echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>"; } else { echo "<TD ALIGN=\"CENTER\"> File isn't readable. Please make sure that " . CACHE_DIR . " is readable and writable by MailWatch."; } echo "</TR>"; echo "<TR>"; echo "<TD ALIGN=\"CENTER\">"; echo "<TABLE WIDTH=\"500\">"; echo "<TR BGCOLOR=\"#F7CE4A\">"; echo "<TH>Domain</TH>"; echo "<TH>Count</TH>"; echo "<TH>Size</TH>"; echo "</TR>"; for ($i = 0; $i < count($data); $i++) { echo "<TR BGCOLOR=\"#EBEBEB\">\n <TD>{$data_names[$i]}</TD>\n <TD ALIGN=\"RIGHT\">" . number_format($data[$i]) . "</TD>\n <TD ALIGN=\"RIGHT\">" . format_mail_size($data_size[$i]) . "</TD>\n</TR>\n"; } echo "\n </TABLE>\n </TD>\n</TR>\n</TABLE>"; // Add footer html_end(); // Close any open db connections dbclose();
echo "<TR>"; echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . IMAGES_DIR . "mailscannerlogo.gif\" ALT=\"MailScanner Logo\"></TD>"; echo "</TR>"; echo "<TR>"; // Check Permissions to see if the file has been written and that apache to read it. if (is_readable($filename)) { echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>"; } else { echo "<TD ALIGN=\"CENTER\"> File isn't readable. Please make sure that " . CACHE_DIR . " is readable and writable by MailWatch."; } echo "</TR>"; echo "<TR>"; echo "<TD ALIGN=\"CENTER\">"; echo "<TABLE WIDTH=\"500\">"; echo "<TR BGCOLOR=\"#F7CE4A\">"; echo " <TH>Hostname</TH>"; echo " <TH>IP Address</TH>"; echo " <TH>Country</TH>"; echo " <TH>Messages</TH>"; echo " <TH>Viruses</TH>"; echo " <TH>Spam</TH>"; echo " <TH>Volume</TH>"; echo " </TR>"; for ($i = 0; $i < count($data_names); $i++) { echo "\n <TR BGCOLOR=\"#EBEBEB\">\n <TD>{$data_names[$i]}</TD>\n <TD>{$data_ip[$i]}</TD>\n <TD>{$data_geoip[$i]}</TD>\n <TD ALIGN=\"RIGHT\">" . number_format($data[$i]) . "</TD>\n\n <TD ALIGN=\"RIGHT\">" . number_format($data_virus[$i]) . "</TD>\n\n <TD ALIGN=\"RIGHT\">" . number_format($data_spam[$i]) . "</TD>\n\n <TD ALIGN=\"RIGHT\">" . format_mail_size($data_size[$i]) . "</TD></TR>\n"; } echo "\n </TABLE>\n </TD>\n</TR>\n</TABLE>"; // Add footer html_end(); // Close any open db connections dbclose();
} echo " <TD ALIGN=\"RIGHT\">" . format_mail_size($data_total_size[$i] * $size_info['formula']) . "</TD>\n"; echo " <TD><BR></TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format(isset($data_total_unknown_users[$i]) ? $data_total_unknown_users[$i] : 0) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format(isset($data_total_unresolveable[$i]) ? $data_total_unresolveable[$i] : 0) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format(isset($data_total_rbl[$i]) ? $data_total_rbl[$i] : 0) . "</TD>\n"; echo "</TR>\n"; } echo " <TR BGCOLOR=\"#F7CE4A\">\n"; echo " <TH ALIGN=\"RIGHT\">Totals</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_mail)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_virii)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_virii) / mailwatch_array_sum($data_total_mail) * 100, 1) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_spam)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_spam) / mailwatch_array_sum($data_total_mail) * 100, 1) . "</TH>\n"; if ($is_MCP_enabled === true) { echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_mcp)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_mcp) / mailwatch_array_sum($data_total_mail) * 100, 1) . "</TH>\n"; } echo " <TH ALIGN=\"RIGHT\">" . format_mail_size(mailwatch_array_sum($data_total_size) * $size_info['formula']) . "</TH>\n"; echo " <TD><BR></TD>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_unknown_users)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_unresolveable)) . "</TH>\n"; echo " <TH ALIGN=\"RIGHT\">" . number_format(mailwatch_array_sum($data_total_rbl)) . "</TH>\n"; echo "</TR>\n"; echo "</TABLE>\n"; echo "</TABLE>\n"; // Add footer html_end(); // Close any open db connections dbclose();
# Row colorings if ($row->virusinfected == 'Y' || $row->nameinfected == "Y" || $row->otherinfected == "Y") { echo " <TR CLASS=\"infected\">\n"; } elseif ($row->isspam == 'Y') { echo " <TR CLASS=\"spam\">\n"; } elseif ($row->iswhitelisted == 'Y') { echo " <TR CLASS=\"whitelisted\">\n"; } else { echo " <TR>"; } echo " <TD>" . $row->datetime . "</TD>\n"; echo " <TD>" . $row->id . "</TD>\n"; echo " <TD>" . htmlentities($row->from_address) . "</TD>\n"; echo " <TD>" . str_replace(",", "<BR />", htmlentities($row->to_address)) . "</TD>\n"; echo " <TD class=\"subject\" width=\"10\">" . htmlentities($row->subject) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . format_mail_size($row->size) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . $row->sascore . "</TD>\n"; echo " <TD>" . $status . "</TD>\n"; echo " </TR>\n"; } echo " <TR><TD COLSPAN=8>\n"; echo " <TABLE WIDTH=100% BORDER=0><TR>\n"; // Previous page link // tgf - Don't show a Prev link on the first page. if ($data['current'] != '1') { printf('<TD ALIGN="CENTER"><A HREF="%s?offset=%d"><<Prev</A></TD><TD ALIGN="CENTER">', sanitizeInput($_SERVER['PHP_SELF']), $data['prev']); } else { printf('<TD ALIGN="CENTER"> </TD><TD ALIGN="CENTER">'); } // Links to each page foreach ($data['pages'] as $page => $start) {
function luser_html_start($title, $refresh = 0, $cacheable = true) { global $luser; if (!$cacheable) { // Cache control (as per PHP website) header("Expires: Sat, 10 May 2003 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); } ?> <HTML> <HEAD> <TITLE>MailWatch for MailScanner - <?php echo $title; ?> </TITLE> <LINK REL="StyleSheet" TYPE="text/css" HREF="../style.css"> <?php if ($refresh > 0) { echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"{$refresh}\">"; } ?> </HEAD> <BODY> <TABLE BORDER=0 CELLPADDING=5 WIDTH=100%> <TR> <TD ALIGN="LEFT"><IMG SRC="../images/mailscannerlogo.gif"></TD> <?php if (MAILQ) { echo " <TD ALIGN=\"RIGHT\" VALIGN=\"TOP\" WIDTH=20%>\n"; $inq = mysql_result(dbquery("SELECT COUNT(*) FROM inq"), 0); $outq = mysql_result(dbquery("SELECT COUNT(*) FROM outq"), 0); echo " <TABLE BORDER=0 CLASS=\"MAIL\" WIDTH=200>\n"; echo " <THEAD><TH ALIGN=\"CENTER\" COLSPAN=2>Mail Queue</TH></THEAD>\n"; echo " <TR><TD><A HREF=\"mailq.php?queue=inq\">Inbound Queue:</A></TD><TD>" . $inq . "</TD>\n"; echo " <TR><TD><A HREF=\"mailq.php?queue=outq\">Outbound Queue:</A></TD><TD>" . $outq . "</TD>\n"; echo " </TABLE>\n"; echo " </TD>\n"; } echo '<TD WIDTH="20%" ALIGN="RIGHT">'; $sth = dbquery("\n SELECT\n COUNT(*) AS processed,\n SUM(CASE WHEN virusinfected>0 THEN 1 ELSE 0 END) AS virii,\n ROUND((SUM(CASE WHEN virusinfected>0 THEN 1 ELSE 0 END)/COUNT(*))*100,1) AS viriipercent,\n SUM(CASE WHEN nameinfected>0 THEN 1 ELSE 0 END) AS blockedfiles,\n ROUND((SUM(CASE WHEN nameinfected>0 THEN 1 ELSE 0 END)/COUNT(*))*100,1) AS blockedfilespercent,\n SUM(CASE WHEN otherinfected>0 THEN 1 ELSE 0 END) AS otherinfected,\n ROUND((SUM(CASE WHEN otherinfected>0 THEN 1 ELSE 0 END)/COUNT(*))*100,1) AS otherinfectedpercent,\n SUM(CASE WHEN isspam>0 THEN 1 ELSE 0 END) AS spam,\n ROUND((SUM(CASE WHEN isspam>0 THEN 1 ELSE 0 END)/COUNT(*))*100,1) AS spampercent,\n SUM(CASE WHEN ishighspam>0 THEN 1 ELSE 0 END) AS highspam,\n ROUND((SUM(CASE WHEN ishighspam>0 THEN 1 ELSE 0 END)/COUNT(*))*100,1) AS highspampercent,\n SUM(size) AS size \n FROM\n maillog\n WHERE\n date = CURRENT_DATE()\n and to_address='{$luser}'\n"); while ($row = mysql_fetch_object($sth)) { echo "<TABLE BORDER=0 CLASS=\"mail\" WIDTH=200>\n"; echo " <THEAD><TH ALIGN=\"CENTER\" COLSPAN=3>Today's Totals for {$luser}</TH></THEAD>\n"; echo " <TR><TD>Processed:</TD><TD ALIGN=\"RIGHT\">" . $row->processed . "</TD><TD ALIGN=\"RIGHT\">" . format_mail_size($row->size) . "</TD></TR>\n"; echo " <TR><TD>Spam:</TD><TD ALIGN=\"RIGHT\">{$row->spam}</TD><TD ALIGN=\"RIGHT\">{$row->spampercent}%</TD></TR>\n"; echo " <TR><TD>High Scoring Spam:</TD><TD ALIGN=\"RIGHT\">{$row->highspam}</TD><TD ALIGN=\"RIGHT\">{$row->highspampercent}%</TD></TR>\n"; echo " <TR><TD>Virii:</TD><TD ALIGN=\"RIGHT\">{$row->virii}</TD><TD ALIGN=\"RIGHT\">{$row->viriipercent}%</TR>\n"; echo " <TR><TD>Top Virus:</TD><TD COLSPAN=\"3\" ALIGN=\"RIGHT\">" . return_todays_top_virus() . "</TD></TR>\n"; echo " <TR><TD>Blocked files:</TD><TD ALIGN=\"RIGHT\">{$row->blockedfiles}</TD><TD ALIGN=\"RIGHT\">{$row->blockedfilespercent}%</TD></TR>\n"; echo " <TR><TD>Others:</TD><TD ALIGN=\"RIGHT\">{$row->otherinfected}</TD><TD ALIGN=\"RIGHT\">{$row->otherinfectedpercent}%</TD></TR>\n"; echo "</TABLE>\n"; } ?> </TD> </TR> <TR> <TD COLSPAN=<?php echo MAILQ ? 3 : 2; ?> > <TABLE CLASS="navigation" WIDTH=100%> <TR ALIGN=CENTER> <TD><A HREF="luser_login.php?reqtype=logout">Log Out</A></TD> <TD WIDTH=20%><A HREF="docs.php">Documentation</A></TD> </TR> </TABLE> </TD> </TR> <TR> <TD COLSPAN=3> <?php return $refresh; }
} $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'); } $row[$f] = preg_replace("/<br \\/>/", "<br>", $row[$f]); } if ($fieldn == __('saautolearn04')) { if (($autolearn = sa_autolearn($row[$f])) !== false) { $row[$f] = $yes . " ({$autolearn})";
/** * @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">'; } } }
echo " <TD ALIGN=\"CENTER\"><IMG SRC=\"" . $filename . "\" ALT=\"Graph\"></TD>"; } else { echo "<TD ALIGN=\"CENTER\"> File isn't readable. Please make sure that " . CACHE_DIR . " is readable and writable by MailWatch."; } echo " </TR>\n"; echo " <TR>\n"; echo " <TD ALIGN=\"CENTER\">\n"; echo "<TABLE BORDER=\"0\" WIDTH=\"500\">\n"; echo " <TR BGCOLOR=\"#F7CE4A\">\n"; echo " <TH>Date</TH>\n"; echo " <TH>Mail</TH>\n"; echo " <TH>Spam</TH>\n"; echo " <TH>Virus</TH>\n"; echo " <TH>Volume</TH>\n"; echo " </TR>\n"; for ($i = 0; $i < count($data_total_mail); $i++) { echo "<TR BGCOLOR=\"#EBEBEB\">\n"; echo " <TD ALIGN=\"CENTER\">{$data_labels[$i]}</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format($data_total_mail[$i]) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format($data_total_spam[$i]) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . number_format($data_total_virii[$i]) . "</TD>\n"; echo " <TD ALIGN=\"RIGHT\">" . format_mail_size($data_total_size[$i] * $size_info['formula']) . " </TD>\n"; echo "</TR>\n"; } echo "</TABLE>\n"; echo "</TR>\n"; echo "</TABLE>"; // Add footer html_end(); // Close any open db connections dbclose();