Patch code to cleanup PHP Errors + fix Whitelist/Blacklist errors

diff -dbp mailscanner/filter.inc /var/www/html/mailscanner/filter.inc
*** mailscanner/filter.inc  2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/filter.inc    2013-01-02 08:23:41.271575521 -0500
*************** WHERE
*** 173,179 ****
   }
  
   function CreateSQL() {
!   $sql .= "AND ".$_SESSION['global_filter']."\n";
    if(count($this->item)>0) {
     foreach($this->item as $key=>$val) {
      // If LIKE selected - place wildcards either side of the query string
--- 173,179 ----
   }
  
   function CreateSQL() {
!   $sql = "AND ".$_SESSION['global_filter']."\n";
    if(count($this->item)>0) {
     foreach($this->item as $key=>$val) {
      // If LIKE selected - place wildcards either side of the query string
*************** WHERE
*** 213,219 ****
  
   function DisplayForm() {
    // Form
!   $return .= '<form action="'.$_SERVER[PHP_SELF].'">'."\n";
  
    // Table
    $return .= '<table width="100%">'."\n";
--- 213,219 ----
  
   function DisplayForm() {
    // Form
!   $return = '<form action="'.$_SERVER['PHP_SELF'].'">'."\n";
  
    // Table
    $return .= '<table width="100%">'."\n";
diff -dbp mailscanner/functions.php /var/www/html/mailscanner/functions.php
*** mailscanner/functions.php   2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/functions.php 2013-01-02 07:50:15.648573619 -0500
***************
*** 21,27 ****
  */
  
  // Set error level (some distro's have php.ini set to E_ALL)
! error_reporting(E_ALL ^ E_NOTICE);
  
  // Read in MailWatch configuration file
  if(!(@include_once('conf.php'))==true) {
--- 21,28 ----
  */
  
  // Set error level (some distro's have php.ini set to E_ALL)
! #error_reporting(E_ALL ^ E_NOTICE);
! unset($link);
  
  // Read in MailWatch configuration file
  if(!(@include_once('conf.php'))==true) {
*************** include "postfix.inc";
*** 62,68 ****
  // define('VIRUS_REGEX', '<<your regexp here>>');
  // define('VIRUS_REGEX', '/(\S+) was infected by (\S+)/');
  
! if(!defined(VIRUS_REGEX)) {
   switch($scanner=get_primary_scanner()) {
    case 'none':
     define('VIRUS_REGEX', '/^Dummy$/');
--- 63,69 ----
  // define('VIRUS_REGEX', '<<your regexp here>>');
  // define('VIRUS_REGEX', '/(\S+) was infected by (\S+)/');
  
! if(!defined('VIRUS_REGEX')) {
   switch($scanner=get_primary_scanner()) {
    case 'none':
     define('VIRUS_REGEX', '/^Dummy$/');
*************** echo '<link rel="StyleSheet" type="text/
*** 185,192 ****
    echo '<meta http-equiv="refresh" content="'.$refresh.'">'."\n";
   }
   
! $message_id=$_GET['id'];
! if(!$message_id){ $message_id =" ";}
  $message_id = safe_value($message_id);
  $message_id = htmlentities($message_id);
  $message_id = trim($message_id, " ");
--- 186,193 ----
    echo '<meta http-equiv="refresh" content="'.$refresh.'">'."\n";
   }
   
! $message_id =" ";
! if (isset($_GET['id'])) { $message_id=$_GET['id']; }
  $message_id = safe_value($message_id);
  $message_id = htmlentities($message_id);
  $message_id = trim($message_id, " ");
*************** while($row = mysql_fetch_object($sth)) {
*** 564,570 ****
   if(!DISTRIBUTED_SETUP) { $nav['quarantine.php'] = "Quarantine"; }
   $nav['reports.php']  = "Reports";
   $nav['other.php']    = "Tools/Links";
!  if($_SESSION['user_type'] === A){$nav['sf_version.php'] = "Software Versions";}
   if(SHOW_DOC == 'true'){$nav['docs.php'] = "Documentation";}
   $nav['logout.php']   = "Logout";
   $table_width = round(100/count($nav));
--- 565,571 ----
   if(!DISTRIBUTED_SETUP) { $nav['quarantine.php'] = "Quarantine"; }
   $nav['reports.php']  = "Reports";
   $nav['other.php']    = "Tools/Links";
!  if($_SESSION['user_type'] === 'A'){$nav['sf_version.php'] = "Software Versions";}
   if(SHOW_DOC == 'true'){$nav['docs.php'] = "Documentation";}
   $nav['logout.php']   = "Logout";
   $table_width = round(100/count($nav));
*************** echo '</html>'."\n";
*** 690,697 ****
  
  }
  
- 
  function dbconn() {
   $link = mysql_connect(DB_HOST,DB_USER,DB_PASS)
          or die ("Could not connect to database: ".mysql_error());
   mysql_select_db(DB_NAME) or die("Could not select db: ".mysql_error());
--- 691,698 ----
  
  }
  
  function dbconn() {
+  global $link;
   $link = mysql_connect(DB_HOST,DB_USER,DB_PASS)
          or die ("Could not connect to database: ".mysql_error());
   mysql_select_db(DB_NAME) or die("Could not select db: ".mysql_error());
*************** function dbconn() {
*** 699,704 ****
--- 700,706 ----
  }
  
  function dbclose(){
+   global $link;
    If ($link) {
    mysql_close($link);
        }
*************** function parse_conf_dir($conf_dir){
*** 1041,1047 ****
              if($file !=="."){
                  if($file !==".."){
                      $file_name = $conf_dir.$file;
!                   if(!is_array($array_output1)){
                        $array_output1 = array();
                          $array_output1 = parse_conf_file($file_name);
                    }else{
--- 1043,1049 ----
              if($file !=="."){
                  if($file !==".."){
                      $file_name = $conf_dir.$file;
!                   if(!isset($array_output1) || !is_array($array_output1)){
                        $array_output1 = array();
                          $array_output1 = parse_conf_file($file_name);
                    }else{
*************** function get_conf_include_folder() {
*** 1132,1139 ****
--- 1134,1143 ----
      }
      # expand %var% variables
      if(preg_match("/(%.+%)/",$regs[2],$match)) {
+      if (isset($var[$match[1]])) {
        $regs[2] = preg_replace("/%.+%/",$var[$match[1]],$regs[2]);
       }
+     }
      if((strtolower($regs[1])) == (strtolower($name))) {
       fclose($fh) or die($php_errormsg);
       if(is_file($regs[2])) {
*************** function get_conf_include_folder() {
*** 1152,1160 ****
  
  // Parse conf files
  function parse_conf_file($name){
!   
    // open each file and read it
!   $fh = fopen($name.$file,'r')
    or die("Cannot open MailScanner configuration file");
    while (!feof($fh)) {
   
--- 1156,1164 ----
  
  // Parse conf files
  function parse_conf_file($name){
!   $array_output=array();
    // open each file and read it
!   $fh = fopen($name,'r')
    or die("Cannot open MailScanner configuration file");
    while (!feof($fh)) {
   
*************** function db_colorised_table($sql, $table
*** 1261,1267 ****
   require_once('Mail/mimeDecode.php');
  
   // Ordering
!  $orderby = $_GET['orderby'];
   switch(strtoupper($_GET['orderdir'])) {
    case 'A':
     $orderdir='ASC';
--- 1265,1274 ----
   require_once('Mail/mimeDecode.php');
  
   // Ordering
!  $orderby = "";
!  if (isset($_GET['orderby'])) { $orderby = $_GET['orderby']; }
!  $orderdir = 'ASC';
!  if (isset($_GET['orderdir'])) {
   switch(strtoupper($_GET['orderdir'])) {
    case 'A':
     $orderdir='ASC';
*************** function db_colorised_table($sql, $table
*** 1270,1275 ****
--- 1277,1283 ----
     $orderdir='DESC';
     break;
   }
+  }
   if(!empty($orderby)) {
    if(($p = stristr($sql,'ORDER BY')) !== false) {
     // We already have an existing ORDER BY clause
*************** echo $pager->links;
*** 1733,1739 ****
       echo '<tr class="mcp">'."\n";
       break;
      default:
!     if($fieldname['sascore']==''){
        '<tr class="mcp">'."\n";
      }else{
       echo '<tr >'."\n";
--- 1741,1747 ----
       echo '<tr class="mcp">'."\n";
       break;
      default:
!     if(isset($fieldname['sascore']) && $fieldname['sascore']==''){
        '<tr class="mcp">'."\n";
      }else{
       echo '<tr >'."\n";
*************** function get_microtime() {
*** 2028,2038 ****
  }
  
  function page_creation_timer() {
!  if(!isset($GLOBALS[pc_start_time])) {
!   $GLOBALS[pc_start_time] = get_microtime();
   } else {
    $pc_end_time = get_microtime();
!   $pc_total_time = $pc_end_time - $GLOBALS[pc_start_time];
    printf("Page generated in %f seconds\n", $pc_total_time);
   }
  }
--- 2036,2046 ----
  }
  
  function page_creation_timer() {
!  if(!isset($GLOBALS['pc_start_time'])) {
!   $GLOBALS['pc_start_time'] = get_microtime();
   } else {
    $pc_end_time = get_microtime();
!   $pc_total_time = $pc_end_time - $GLOBALS['pc_start_time'];
    printf("Page generated in %f seconds\n", $pc_total_time);
   }
  }
diff -dbp mailscanner/geoip_update.php /var/www/html/mailscanner/geoip_update.php
*** mailscanner/geoip_update.php    2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/geoip_update.php  2012-12-30 14:50:33.335022804 -0500
*************** ob_flush();
*** 91,97 ****
        
        
        // PROXY for curl
!       if(USE_PROXY == true){
        $proxy_server = "".PROXY_SERVER."";
        $proxy_port = "".PROXY_PORT."";
        $proxy_type = "".PROXY_TYPE."";
--- 91,97 ----
        
        
        // PROXY for curl
!       if(USE_PROXY == 'true'){
        $proxy_server = "".PROXY_SERVER."";
        $proxy_port = "".PROXY_PORT."";
        $proxy_type = "".PROXY_TYPE."";
*************** ob_flush();
*** 130,136 ****
          curl_setopt($curl_var2, CURLOPT_FILE,$fp2);
  
        // PROXY for curl
!       if(USE_PROXY == true){
        $proxy_server = "".PROXY_SERVER."";
        $proxy_port = "".PROXY_PORT."";
        $proxy_type = "".PROXY_TYPE."";
--- 130,136 ----
          curl_setopt($curl_var2, CURLOPT_FILE,$fp2);
  
        // PROXY for curl
!       if(USE_PROXY == 'true'){
        $proxy_server = "".PROXY_SERVER."";
        $proxy_port = "".PROXY_PORT."";
        $proxy_type = "".PROXY_TYPE."";
diff -dbp mailscanner/lists.php /var/www/html/mailscanner/lists.php
*** mailscanner/lists.php   2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/lists.php 2013-01-02 08:18:15.764578183 -0500
*************** session_start();
*** 26,47 ****
  require('./login.function.php');
  
  html_start("Whitelist/Blacklist",0,false,false);
  
! $url_type = $_GET['type'];
! $url_type = htmlentities($url_type);
! $url_type = safe_value($url_type);
  
! $url_to = $_GET['to'];
! $url_to = htmlentities($url_to);
! $url_to = safe_value($url_to);
  
! $url_host = $_GET['host'];
! $url_host = htmlentities($url_host);
! $url_host = safe_value($url_host);
  
! $url_from = $_GET['from'];
! $url_from = htmlentities($url_from);
! $url_from = safe_value($url_from);
  
  $url_submit = $_GET['submit'];
  $url_submit = htmlentities($url_submit);
--- 26,65 ----
  require('./login.function.php');
  
  html_start("Whitelist/Blacklist",0,false,false);
+ $w=$b=$url_list=$touser=$todomain=$url_submit=$url_type="";
  
! if (isset($_GET['submit'])) {
  
! if (isset($_GET['type'])) {
!   $url_type = $_GET['type'];
!   $url_type = htmlentities($url_type);
!   $url_type = safe_value($url_type);
! } else {
!   $url_type = 'f';
! }
  
! if (isset($_GET['to'])) {
!   $url_to = $_GET['to'];
!   $url_to = htmlentities($url_to);
!   $url_to = safe_value($url_to);
! }
  
! if (isset($_GET['host'])) {
!   $url_host = $_GET['host'];
!   $url_host = htmlentities($url_host);
!   $url_host = safe_value($url_host);
! }
! 
! if (isset($_GET['entry'])) {
!   $url_from = $_GET['entry'];
!   $url_from = htmlentities($url_from);
!   $url_from = safe_value($url_from);
! }
! if (isset($_GET['from'])) {
!   $url_from = $_GET['from'];
!   $url_from = htmlentities($url_from);
!   $url_from = safe_value($url_from);
! }
  
  $url_submit = $_GET['submit'];
  $url_submit = htmlentities($url_submit);
*************** $url_list = $_GET['list'];
*** 51,69 ****
  $url_list = htmlentities($url_list);
  $url_list = safe_value($url_list);
  
! $url_domain = $_GET['domain'];
! $url_domain = htmlentities($url_domain);
! $url_domain = safe_value($url_domain);
  
! $url_id = $_GET['id'];
! $url_id = htmlentities($url_id);
! $url_id = safe_value($url_id);
  
  // Split user/domain if necessary (from detail.php)
  if(preg_match('/(\S+)@(\S+)/',$url_to,$split)) {
   $touser = $split[1];
   $todomain = $split[2];
  }
  
  // Type
  switch($url_type) {
--- 69,92 ----
  $url_list = htmlentities($url_list);
  $url_list = safe_value($url_list);
  
! if (isset($_GET['to'])) {
!   $url_domain = $_GET['domain'];
!   $url_domain = htmlentities($url_domain);
!   $url_domain = safe_value($url_domain);
! }
  
! if (isset($_GET['id'])) {
!   $url_id = $_GET['id'];
!   $url_id = htmlentities($url_id);
!   $url_id = safe_value($url_id);
! }
  
  // Split user/domain if necessary (from detail.php)
  if(preg_match('/(\S+)@(\S+)/',$url_to,$split)) {
   $touser = $split[1];
   $todomain = $split[2];
  }
+ }
  
  // Type
  switch($url_type) {
*************** if($url_submit == 'Add') {
*** 168,174 ****
    $sql .= '(\''.mysql_escape_string($to_address);
    $sql .= '\',\''.mysql_escape_string($todomain);
    $sql .= '\',\''.mysql_escape_string($from).'\')';
!   @dbquery($sql);
    audit_log("Added ".$from." to ".$list." for ".$to_address);
    unset($from);
    unset($url_list);
--- 191,198 ----
    $sql .= '(\''.mysql_escape_string($to_address);
    $sql .= '\',\''.mysql_escape_string($todomain);
    $sql .= '\',\''.mysql_escape_string($from).'\')';
! error_log($sql);
!   dbquery($sql);
    audit_log("Added ".$from." to ".$list." for ".$to_address);
    unset($from);
    unset($url_list);
*************** function build_table($sql,$list) {
*** 229,235 ****
   }
  }
  
! 
  echo '
  <form action="'.$_SERVER['PHP_SELF'].'">
  <table cellspacing="1" class="mail">
--- 253,259 ----
   }
  }
  
! $w=$b=$url_list=$from="";
  echo '
  <form action="'.$_SERVER['PHP_SELF'].'">
  <table cellspacing="1" class="mail">
diff -dbp mailscanner/reports.php /var/www/html/mailscanner/reports.php
*** mailscanner/reports.php 2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/reports.php   2013-01-02 08:22:08.070579695 -0500
*************** session_start();
*** 29,35 ****
  require('login.function.php');
  
  // Checking to see if there are any filters
! if(!is_object($_SESSION["filter"])) {
   $filter = new Filter;
   $_SESSION["filter"] = $filter;
  } else {
--- 29,35 ----
  require('login.function.php');
  
  // Checking to see if there are any filters
! if(!isset($_SESSION['filter']) || !is_object($_SESSION["filter"])) {
   $filter = new Filter;
   $_SESSION["filter"] = $filter;
  } else {
*************** html_start("Reports","0",false,false);
*** 43,48 ****
--- 43,49 ----
  $dirname = "".MAILWATCH_HOME."/".CACHE_DIR."";
  
  // Add filters and save them
+ if (isset($_GET['action'])) {
  switch(strtolower($_GET["action"])) {
   case "add":
    $filter->Add($_GET["column"], $_GET["operator"], $_GET["value"]);
*************** switch(strtolower($_GET["action"])) {
*** 70,75 ****
--- 71,77 ----
    $filter->Delete($_GET['filter']);
    break;
  }
+ }
  
  // add the session filters to the variables
  $_SESSION["filter"] = $filter;
diff -dbp mailscanner/rep_top_mail_relays.php /var/www/html/mailscanner/rep_top_mail_relays.php
*** mailscanner/rep_top_mail_relays.php 2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_mail_relays.php   2013-01-02 08:25:18.546575382 -0500
*************** $graph = new PieGraph(800,385,0,false);
*** 90,96 ****
  $graph->SetShadow();
  $graph->img->SetAntiAliasing();
  $graph->title->Set("Top 10 Mail Relays");
! //$graph->legend->SetLayout(LEGEND_HOR);
  $graph->legend->Pos(0.52,0.87,'center');
  
  $p1 = new PiePlot3d($data);
--- 90,96 ----
  $graph->SetShadow();
  $graph->img->SetAntiAliasing();
  $graph->title->Set("Top 10 Mail Relays");
! //$graph->legend->SetLayout('LEGEND_HOR');
  $graph->legend->Pos(0.52,0.87,'center');
  
  $p1 = new PiePlot3d($data);
*************** $p1->SetTheme('sand');
*** 98,105 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 98,105 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_recipient_domains_by_quantity.php /var/www/html/mailscanner/rep_top_recipient_domains_by_quantity.php
*** mailscanner/rep_top_recipient_domains_by_quantity.php   2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_recipient_domains_by_quantity.php 2013-01-02 08:25:27.091820141 -0500
*************** $p1->SetTheme('sand');
*** 82,89 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 82,89 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_recipient_domains_by_volume.php /var/www/html/mailscanner/rep_top_recipient_domains_by_volume.php
*** mailscanner/rep_top_recipient_domains_by_volume.php 2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_recipient_domains_by_volume.php   2013-01-02 08:25:33.564584697 -0500
*************** $p1->SetTheme('sand');
*** 82,89 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 82,89 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_recipients_by_quantity.php /var/www/html/mailscanner/rep_top_recipients_by_quantity.php
*** mailscanner/rep_top_recipients_by_quantity.php  2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_recipients_by_quantity.php    2013-01-02 08:25:40.004782517 -0500
*************** $p1->SetTheme('sand');
*** 84,91 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 84,91 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_recipients_by_volume.php /var/www/html/mailscanner/rep_top_recipients_by_volume.php
*** mailscanner/rep_top_recipients_by_volume.php    2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_recipients_by_volume.php  2013-01-02 08:25:46.340567437 -0500
*************** $p1->SetTheme('sand');
*** 85,92 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 85,92 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_sender_domains_by_quantity.php /var/www/html/mailscanner/rep_top_sender_domains_by_quantity.php
*** mailscanner/rep_top_sender_domains_by_quantity.php  2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_sender_domains_by_quantity.php    2013-01-02 08:25:51.973824914 -0500
*************** $p1->SetTheme('sand');
*** 82,89 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 82,89 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_sender_domains_by_volume.php /var/www/html/mailscanner/rep_top_sender_domains_by_volume.php
*** mailscanner/rep_top_sender_domains_by_volume.php    2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_sender_domains_by_volume.php  2013-01-02 08:25:57.653694696 -0500
*************** $p1->SetTheme('sand');
*** 82,89 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 82,89 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_senders_by_quantity.php /var/www/html/mailscanner/rep_top_senders_by_quantity.php
*** mailscanner/rep_top_senders_by_quantity.php 2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_senders_by_quantity.php   2013-01-02 08:24:37.048571104 -0500
*************** $p1->SetTheme('sand');
*** 91,98 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 91,98 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_senders_by_volume.php /var/www/html/mailscanner/rep_top_senders_by_volume.php
*** mailscanner/rep_top_senders_by_volume.php   2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_senders_by_volume.php 2013-01-02 08:26:06.732916744 -0500
*************** $p1->SetTheme('sand');
*** 85,92 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 85,92 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp mailscanner/rep_top_viruses.php /var/www/html/mailscanner/rep_top_viruses.php
*** mailscanner/rep_top_viruses.php 2012-04-24 08:15:18.000000000 -0400
--- /var/www/html/mailscanner/rep_top_viruses.php   2013-01-02 08:26:17.008577919 -0500
*************** $p1->SetTheme('sand');
*** 91,98 ****
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout(LEGEND_VER);
! $graph->legend->Pos(0.25,0.20,center);
  
  $graph->Add($p1);
  $graph->Stroke($filename);
--- 91,98 ----
  $p1->SetLegends($data_names);
  
  $p1->SetCenter(0.73,0.4);
! $graph->legend->SetLayout('LEGEND_VER');
! $graph->legend->Pos(0.25,0.20,'center');
  
  $graph->Add($p1);
  $graph->Stroke($filename);
diff -dbp tools/Sendmail_queue/mailq.php /usr/local/bin/mailq.php
*** tools/Sendmail_queue/mailq.php    2012-04-24 08:15:18.000000000 -0400
--- /usr/local/bin/mailq.php    2012-12-30 15:02:19.228017442 -0500
*************** if(flock($fl, LOCK_EX + LOCK_NB)) {
*** 41,46 ****
--- 41,47 ----
   foreach($queue as $table_name=>$queuedir) {
    // Clear the output array
    unset($output);
+   $output=array();
    if($dh=@opendir($queuedir)) {
     while(false !== ($file = readdir($dh))) {
      if ($MTA == "exim") {
diff -dbp tools/Cron_jobs/db_clean.php /usr/local/bin/db_clean.php
*** tools/Cron_jobs/db_clean.php    2012-04-24 08:15:18.000000000 -0400
--- /usr/local/bin/db_clean.php 2012-12-31 08:28:21.531024916 -0500
***************
*** 1,4 ****
! #!/usr/bin/php -qn
  <?php
  /*
   MailWatch for MailScanner
--- 1,4 ----
! #!/usr/bin/php -q
  <?php
  /*
   MailWatch for MailScanner
*************** dbquery("DELETE LOW_PRIORITY FROM maillo
*** 38,47 ****
   // Cleaning the mta_log and optionally the mta_log_id table
   $sqlcheck = "Show tables like 'mtalog_ids'";
   $tablecheck = dbquery($sqlcheck);
  if ($mta == 'postfix' && mysql_num_rows($tablecheck) > 0){ //version for postfix
  dbquery("delete i.*, m.* from mtalog as m inner join mtalog_ids as i on i.smtp_id = m.msg_id where m.timestamp < (now() - INTERVAL ".RECORD_DAYS_TO_KEEP." DAY)");
  }else{
! dbquery("delete * from mtalog where timestamp < (now() - INTERVAL ".RECORD_DAYS_TO_KEEP." DAY)");
  }
  
  // Clean the audit log
--- 38,48 ----
   // Cleaning the mta_log and optionally the mta_log_id table
   $sqlcheck = "Show tables like 'mtalog_ids'";
   $tablecheck = dbquery($sqlcheck);
+ $mta = get_conf_var('mta');
  if ($mta == 'postfix' && mysql_num_rows($tablecheck) > 0){ //version for postfix
  dbquery("delete i.*, m.* from mtalog as m inner join mtalog_ids as i on i.smtp_id = m.msg_id where m.timestamp < (now() - INTERVAL ".RECORD_DAYS_TO_KEEP." DAY)");
  }else{
! dbquery("delete from mtalog where timestamp < (now() - INTERVAL ".RECORD_DAYS_TO_KEEP." DAY)");
  }
  
  // Clean the audit log