function find_config_xml() { global $g, $debug; $disks = get_disks(); // Safety check. if (!is_array($disks)) { return; } $boot_disk = get_boot_disk(); exec("/bin/mkdir -p /tmp/mnt/cf"); foreach ($disks as $disk) { $slices = get_disk_slices($disk); if (is_array($slices)) { foreach ($slices as $slice) { if ($slice == "") { continue; } if (stristr($slice, $boot_disk)) { if ($debug) { echo "\nSkipping boot device slice {$slice}"; } continue; } echo " {$slice}"; // First try msdos fs if ($debug) { echo "\n/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n"; } $result = exec("/sbin/mount -t msdosfs /dev/{$slice} /tmp/mnt/cf 2>/dev/null"); // Next try regular fs (ufs) if (!$result) { if ($debug) { echo "\n/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null \n"; } $result = exec("/sbin/mount /dev/{$slice} /tmp/mnt/cf 2>/dev/null"); } $mounted = trim(exec("/sbin/mount | /usr/bin/grep -v grep | /usr/bin/grep '/tmp/mnt/cf' | /usr/bin/wc -l")); if ($debug) { echo "\nmounted: {$mounted} "; } if (intval($mounted) > 0) { // Item was mounted - look for config.xml file $config_location = discover_config($slice); if ($config_location) { if (test_config($config_location)) { // We have a valid configuration. Install it. echo " -> found config.xml\n"; echo "Backing up old configuration...\n"; backup_config(); echo "Restoring [{$slice}] {$config_location}...\n"; restore_backup($config_location); echo "Cleaning up...\n"; exec("/sbin/umount /tmp/mnt/cf"); exit; } } exec("/sbin/umount /tmp/mnt/cf"); } } } } }
/** * @param $title * @param int $refresh * @param bool|true $cacheable * @param bool|false $report * @return Filter|int */ function html_start($title, $refresh = 0, $cacheable = true, $report = false) { if (!$cacheable) { // Cache control (as per PHP website) header("Expires: Sat, 10 May 2003 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, M d Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); } else { // calc an offset of 24 hours $offset = 3600 * 48; // calc the string in GMT not localtime and add the offset $expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"; //output the HTTP header Header($expire); header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=1"); header("Pragma: cache"); } //security headers header('X-XSS-Protection: 1; mode=block'); header('X-Frame-Options: SAMEORIGIN'); header('X-Content-Type-Options: nosniff'); echo page_creation_timer(); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' . "\n"; echo '<html>' . "\n"; echo '<head>' . "\n"; echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n"; echo '<link rel="shortcut icon" href="images/favicon.png" >' . "\n"; echo '<script type="text/javascript">'; echo '' . java_time() . ''; //$current_url = "".MAILWATCH_HOME."/status.php"; //if($_SERVER['SCRIPT_FILENAME'] == $active_url){ echo '' . row_highandclick() . ''; echo '</script>'; if ($report) { echo '<title>MailWatch Filter Report: ' . $title . ' </title>' . "\n"; echo '<link rel="StyleSheet" type="text/css" href="./style.css">' . "\n"; if (!isset($_SESSION["filter"])) { require_once __DIR__ . '/filter.inc'; $filter = new Filter(); $_SESSION["filter"] = $filter; } else { // Use existing filters $filter = $_SESSION["filter"]; } audit_log('Ran report ' . $title); } else { echo '<title>MailWatch for Mailscanner - ' . $title . '</title>' . "\n"; echo '<link rel="StyleSheet" type="text/css" href="style.css">' . "\n"; } if ($refresh > 0) { echo '<meta http-equiv="refresh" content="' . $refresh . '">' . "\n"; } if (isset($_GET['id'])) { $message_id = sanitizeInput($_GET['id']); } else { $message_id = " "; } $message_id = safe_value($message_id); $message_id = htmlentities($message_id); $message_id = trim($message_id, " "); echo '</head>' . "\n"; echo '<body onload="updateClock(); setInterval(\'updateClock()\', 1000 )">' . "\n"; echo '<table border="0" cellpadding="5" width="100%">' . "\n"; echo '<tr>' . "\n"; echo '<td>' . "\n"; echo '<table border="0" cellpadding="0" cellspacing="0">' . "\n"; echo '<tr>' . "\n"; echo '<td align="left"><a href="index.php" class="logo"><img src="' . IMAGES_DIR . MW_LOGO . '" alt="MailWatch for MailScanner"></a></td>' . "\n"; echo '</tr>' . "\n"; echo '<tr>' . "\n"; echo '<td valign="bottom" align="left" class="jump">' . "\n"; echo '<form action="./detail.php">' . "\n"; echo '<p>' . __('jumpmessage03') . '<input type="text" name="id" value="' . $message_id . '"></p>' . "\n"; echo '</form>' . "\n"; echo '</table>' . "\n"; echo '<table cellspacing="1" class="mail">' . "\n"; echo '<tr><td class="heading" align="center">' . __('cuser03') . '</td><td class="heading" align="center">' . __('cst03') . '</td></tr>' . "\n"; echo '<tr><td>' . $_SESSION['fullname'] . '</td><td><span id="clock"> </span></td></tr>' . "\n"; echo '</table>' . "\n"; echo '</td>' . "\n"; echo '<td align="left" valign="top">' . "\n"; echo ' <table border="0" cellpadding="1" cellspacing="1" class="mail">' . "\n"; echo ' <tr> <th colspan="2">' . __('colorcodes03') . '</th> </tr>' . "\n"; echo ' <tr> <td>' . __('badcontentinfected03') . '</TD> <td class="infected"></TD> </TR>' . "\n"; echo ' <tr> <td>Spam</td> <td class="spam"></td> </tr>' . "\n"; echo ' <tr> <td>High Spam</td> <td class="highspam"></td> </tr>' . "\n"; if (get_conf_truefalse('mcpchecks')) { echo ' <tr> <td>MCP</td> <td class="mcp"></td> </tr>' . "\n"; echo ' <tr> <td>High MCP</td><td class="highmcp"></td></tr>' . "\n"; } echo ' <tr> <td>' . __('whitelisted03') . '</td> <td class="whitelisted"></td> </tr>' . "\n"; echo ' <tr> <td>' . __('blacklisted03') . '</td> <td class="blacklisted"></td> </tr>' . "\n"; echo ' <tr> <td>' . __('notverified03') . '</td> <td class="notscanned"></td> </tr>' . "\n"; echo ' <tr> <td>' . __('clean03') . '</td> <td></td> </tr>' . "\n"; echo ' </table>' . "\n"; echo ' </td>' . "\n"; if (!DISTRIBUTED_SETUP && ($_SESSION['user_type'] == 'A' || $_SESSION['user_type'] == 'D')) { echo ' <td align="center" valign="top">' . "\n"; // Status table echo ' <table border="0" cellpadding="1" cellspacing="1" class="mail" width="200">' . "\n"; echo ' <tr><th colspan="3">Status</th></tr>' . "\n"; // MailScanner running? if (!DISTRIBUTED_SETUP) { $no = '<span class="yes"> NO </span>' . "\n"; $yes = '<span class="no"> YES </span>' . "\n"; exec("ps ax | grep MailScanner | grep -v grep", $output); if (count($output) > 0) { $running = $yes; $procs = count($output) - 1 . " children"; } else { $running = $no; $procs = count($output) . " proc(s)"; } echo ' <tr><td>MailScanner:</td><td align="center">' . $running . '</td><td align="right">' . $procs . '</td></tr>' . "\n"; // is MTA running $mta = get_conf_var('mta'); exec("ps ax | grep {$mta} | grep -v grep | grep -v php", $output); if (count($output) > 0) { $running = $yes; } else { $running = $no; } $procs = count($output) . " proc(s)"; echo ' <tr><td>' . ucwords($mta) . ':</td><td align="center">' . $running . '</td><td align="right">' . $procs . '</td></tr>' . "\n"; } // Load average if (file_exists("/proc/loadavg") && !DISTRIBUTED_SETUP) { $loadavg = file("/proc/loadavg"); $loadavg = explode(" ", $loadavg[0]); $la_1m = $loadavg[0]; $la_5m = $loadavg[1]; $la_15m = $loadavg[2]; echo ' <tr><td>Load Average:</td><td align="right" colspan="2"><table width="100%" class="mail" cellpadding="0" cellspacing="0"><tr><td align="center">' . $la_1m . '</td><td align="center">' . $la_5m . '</td><td align="center">' . $la_15m . '</td></tr></table></td>' . "\n"; } elseif (file_exists("/usr/bin/uptime") && !DISTRIBUTED_SETUP) { $loadavg = shell_exec('/usr/bin/uptime'); $loadavg = explode(" ", $loadavg); $la_1m = rtrim($loadavg[count($loadavg) - 3], ","); $la_5m = rtrim($loadavg[count($loadavg) - 2], ","); $la_15m = rtrim($loadavg[count($loadavg) - 1]); echo ' <tr><td>Load Average:</td><td align="right" colspan="2"><table width="100%" class="mail" cellpadding="0" cellspacing="0"><tr><td align="center">' . $la_1m . '</td><td align="center">' . $la_5m . '</td><td align="center">' . $la_15m . '</td></tr></table></td>' . "\n"; } // Mail Queues display $incomingdir = get_conf_var('incomingqueuedir'); $outgoingdir = get_conf_var('outgoingqueuedir'); // Display the MTA queue // Postfix if mta = postfix if ($mta == 'postfix' && $_SESSION['user_type'] == 'A') { if (is_readable($incomingdir) && is_readable($outgoingdir)) { $inq = postfixinq(); $outq = postfixallq() - $inq; echo ' <tr><td colspan="3" class="heading" align="center">Mail Queues</td></tr>' . "\n"; echo ' <tr><td colspan="2"><a href="postfixmailq.php">Inbound:</a></td><td align="right">' . $inq . '</td>' . "\n"; echo ' <tr><td colspan="2"><a href="postfixmailq.php">Outbound:</a></td><td align="right">' . $outq . '</td>' . "\n"; } else { echo ' <tr><td colspan="3">Please verify read permissions on ' . $incomingdir . ' and ' . $outgoingdir . '</td></tr>' . "\n"; } // else use mailq which is for sendmail and exim } elseif (MAILQ && $_SESSION['user_type'] == 'A') { $inq = mysql_result(dbquery("SELECT COUNT(*) FROM inq WHERE " . $_SESSION['global_filter']), 0); $outq = mysql_result(dbquery("SELECT COUNT(*) FROM outq WHERE " . $_SESSION['global_filter']), 0); echo ' <tr><td colspan="3" class="heading" align="center">Mail Queues</td></tr>' . "\n"; echo ' <tr><td colspan="2"><a href="mailq.php?queue=inq">Inbound:</a></td><td align="right">' . $inq . '</td>' . "\n"; echo ' <tr><td colspan="2"><a href="mailq.php?queue=outq">Outbound:</a></td><td align="right">' . $outq . '</td>' . "\n"; } // drive display if ($_SESSION['user_type'] == 'A') { echo ' <tr><td colspan="3" class="heading" align="center">' . __('freedspace03') . '</td></tr>' . "\n"; foreach (get_disks() as $disk) { $free_space = disk_free_space($disk['mountpoint']); $total_space = disk_total_space($disk['mountpoint']); if (round($free_space / $total_space, 2) <= 0.1) { $percent = '<span style="color:red">'; } else { $percent = '<span>'; } $percent .= ' ['; $percent .= round($free_space / $total_space, 2) * 100; $percent .= '%] '; $percent .= '</span>'; echo ' <tr><td>' . $disk['mountpoint'] . '</td><td colspan="2" align="right">' . formatSize($free_space) . $percent . '</td>' . "\n"; } } echo ' </table>' . "\n"; echo ' </td>' . "\n"; } echo '<td align="center" valign="top">' . "\n"; $sql = "\n SELECT\n COUNT(*) AS processed,\n SUM(\n CASE WHEN (\n (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n AND (ismcp=0 OR ismcp IS NULL)\n AND (ishighmcp=0 OR ishighmcp IS NULL)\n ) THEN 1 ELSE 0 END\n ) AS clean,\n ROUND((\n SUM(\n CASE WHEN (\n (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n AND (ismcp=0 OR ismcp IS NULL)\n AND (ishighmcp=0 OR ishighmcp IS NULL)\n ) THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS cleanpercent,\n SUM(\n CASE WHEN\n virusinfected>0\n THEN 1 ELSE 0 END\n ) AS viruses,\n ROUND((\n SUM(\n CASE WHEN\n virusinfected>0\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS viruspercent,\n SUM(\n CASE WHEN\n nameinfected>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n ) AS blockedfiles,\n ROUND((\n SUM(\n CASE WHEN\n nameinfected>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS blockedfilespercent,\n SUM(\n CASE WHEN\n otherinfected>0\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n ) AS otherinfected,\n ROUND((\n SUM(\n CASE WHEN\n otherinfected>0\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS otherinfectedpercent,\n SUM(\n CASE WHEN\n isspam>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n ) AS spam,\n ROUND((\n SUM(\n CASE WHEN\n isspam>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS spampercent,\n SUM(\n CASE WHEN\n ishighspam>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n THEN 1 ELSE 0 END\n ) AS highspam,\n ROUND((\n SUM(\n CASE WHEN\n ishighspam>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS highspampercent,\n SUM(\n CASE WHEN\n ismcp>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n AND (ishighmcp=0 OR ishighmcp IS NULL)\n THEN 1 ELSE 0 END\n ) AS mcp,\n ROUND((\n SUM(\n CASE WHEN\n ismcp>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n AND (ishighmcp=0 OR ishighmcp IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS mcppercent,\n SUM(\n CASE WHEN\n ishighmcp>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n ) AS highmcp,\n ROUND((\n SUM(\n CASE WHEN\n ishighmcp>0\n AND (virusinfected=0 OR virusinfected IS NULL)\n AND (nameinfected=0 OR nameinfected IS NULL)\n AND (otherinfected=0 OR otherinfected IS NULL)\n AND (isspam=0 OR isspam IS NULL)\n AND (ishighspam=0 OR ishighspam IS NULL)\n THEN 1 ELSE 0 END\n )/COUNT(*))*100,1\n ) AS highmcppercent,\n SUM(size) AS size\n FROM\n maillog\n WHERE\n date = CURRENT_DATE()\n AND\n " . $_SESSION['global_filter'] . "\n"; $sth = dbquery($sql); while ($row = mysql_fetch_object($sth)) { echo '<table border="0" cellpadding="1" cellspacing="1" class="mail" width="200">' . "\n"; echo ' <tr><th align="center" colspan="3">' . __('todaystotals03') . '</th></tr>' . "\n"; echo ' <tr><td>' . __('processed03') . ':</td><td align="right">' . number_format($row->processed) . '</td><td align="right">' . format_mail_size($row->size) . '</td></tr>' . "\n"; echo ' <tr><td>' . __('cleans03') . ':</td><td align="right">' . number_format($row->clean) . '</td><td align="right">' . $row->cleanpercent . '%</td></tr>' . "\n"; echo ' <tr><td>' . __('viruses03') . ':</td><td align="right">' . number_format($row->viruses) . '</td><td align="right">' . $row->viruspercent . '%</tr>' . "\n"; echo ' <tr><td>Top Virus:</td><td colspan="2" align="right" style="white-space:nowrap">' . return_todays_top_virus() . '</td></tr>' . "\n"; echo ' <tr><td>' . __('blockedfiles03') . ':</td><td align="right">' . number_format($row->blockedfiles) . '</td><td align="right">' . $row->blockedfilespercent . '%</td></tr>' . "\n"; echo ' <tr><td>' . __('others03') . ':</td><td align="right">' . number_format($row->otherinfected) . '</td><td align="right">' . $row->otherinfectedpercent . '%</td></tr>' . "\n"; echo ' <tr><td>Spam:</td><td align="right">' . number_format($row->spam) . '</td><td align="right">' . $row->spampercent . '%</td></tr>' . "\n"; echo ' <tr><td style="white-space:nowrap">' . __('hscospam03') . ':</td><td align="right">' . number_format($row->highspam) . '</td><td align="right">' . $row->highspampercent . '%</td></tr>' . "\n"; if (get_conf_truefalse('mcpchecks')) { echo ' <tr><td>MCP:</td><td align="right">' . number_format($row->mcp) . '</td><td align="right">' . $row->mcppercent . '%</td></tr>' . "\n"; echo ' <tr><td style="white-space:nowrap">' . __('hscomcp03') . ':</td><td align="right">' . number_format($row->highmcp) . '</td><td align="right">' . $row->highmcppercent . '%</td></tr>' . "\n"; } echo '</table>' . "\n"; } // Navigation links - put them into an array to allow them to be switched // on or off as necessary and to allow for the table widths to be calculated. $nav = array(); $nav['status.php'] = __('recentmessages03'); if (LISTS) { $nav['lists.php'] = __('lists03'); } if (!DISTRIBUTED_SETUP) { $nav['quarantine.php'] = __('quarantine03'); } $nav['reports.php'] = __('reports03'); $nav['other.php'] = __('toolslinks03'); if (SHOW_SFVERSION == true) { if ($_SESSION['user_type'] === 'A') { $nav['sf_version.php'] = __('softwareversions03'); } } if (SHOW_DOC == true) { $nav['docs.php'] = __('documentation03'); } $nav['logout.php'] = __('logout03'); //$table_width = round(100 / count($nav)); //Navigation table echo ' </td>' . "\n"; echo ' </tr>' . "\n"; echo '<tr>' . "\n"; echo '<td colspan="4">' . "\n"; echo '<ul id="menu" class="yellow">' . "\n"; // Display the different words foreach ($nav as $url => $desc) { $active_url = "" . MAILWATCH_HOME . "/" . $url . ""; if ($_SERVER['SCRIPT_FILENAME'] == $active_url) { echo "<li class=\"active\"><a href=\"{$url}\">{$desc}</a></li>\n"; } else { echo "<li><a href=\"{$url}\">{$desc}</a></li>\n"; } } echo ' </ul> </td> </tr> <tr> <td colspan="4">'; if ($report) { $return_items = $filter; } else { $return_items = $refresh; } return $return_items; }