Advertisement
Guest User

sa_debug.php

a guest
Apr 12th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. <?php
  2. /*
  3.  MailWatch for MailScanner
  4.  Copyright (C) 2003  Steve Freegard (smf@f2s.com)
  5.  
  6.  This program is free software; you can redistribute it and/or modify
  7.  it under the terms of the GNU General Public License as published by
  8.  the Free Software Foundation; either version 2 of the License, or
  9.  (at your option) any later version.
  10.  
  11.  This program is distributed in the hope that it will be useful,
  12.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  GNU General Public License for more details.
  15.  
  16.  You should have received a copy of the GNU General Public License
  17.  along with this program; if not, write to the Free Software
  18.  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. */
  20.  
  21. require_once("./functions.php");
  22. authenticate('A');
  23. html_start("SpamAssassin Lint");
  24.   // File is local
  25.   if(!isset($_GET['filename'])) {
  26.    die("No input filename");
  27.   } else {
  28.    // SECURITY - strip off any potential nasties
  29.    $_GET['filename'] = preg_replace('[\.\/|\.\.\/]','',$_GET['filename']);
  30.    $filename = get_conf_var('QuarantineDir')."/".$_GET['filename'];
  31.    if(!@file_exists($filename)) {
  32.     die("Error: file not found\n");
  33.    }
  34.   }
  35. echo "running ".SA_DIR.'spamassassin --use-ignores -x -D < '.$filename.' 2>&1';
  36. if(!$fp = popen(SA_DIR.'spamassassin -x -D < '.$filename.' 2>&1','r')) {
  37.  die("Cannot open pipe");
  38. } else {
  39.  audit_log('Run SpamAssassin Debug on '.$filename);
  40. }
  41.  
  42.  
  43.  
  44. echo "<TABLE CLASS=\"mail\" BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=\"100%\">\n";
  45. echo " <THEAD>\n";
  46. echo "  <TH COLSPAN=2>SpamAssassin Debug E-mail</TH>\n";
  47. echo " </THEAD>\n";
  48. // Start timer
  49. $start = get_microtime();
  50. $last = false;
  51. while($line = fgets($fp,2096)) {
  52.  ##### AJOS1 CHANGE #####
  53. #ORIG# $line = eregi_replace("\n","",$line);
  54. ##### AJOS1 CHANGE #####
  55. $line = preg_replace("/\n/i","",$line);
  56.  if($line !== "" && $line !== " ") {
  57.   $timer = get_microtime();
  58.   $linet = $timer-$start;
  59.   if(!$last) { $last = $linet; }
  60.   echo "<!-- Timer: $timer, Line Start: $linet -->\n";
  61.   echo "    <TR>\n";
  62. if(($pos = strpos($line, 'dbg: check: tests=')) or ($pos = strpos($line, 'dbg: check: subtests=')) or ($pos = strpos($line, 'dbg: timing:'))) {
  63.     $line = substr($line, 0, $pos) . '<br>' . implode('<br>', explode(',',substr($line,$pos)));
  64. } else {
  65.     $line = htmlspecialchars($line);
  66. }
  67.   echo "     <TD>".$line."</TD>\n";
  68.   $thisone = $linet-$last;
  69.   $last = $linet;
  70.   if($thisone>=2) {
  71.    echo "     <TD CLASS=\"lint_5\">".round($thisone,5)."</TD>\n";
  72.   } elseif($thisone>=1.5) {
  73.     echo "     <TD CLASS=\"lint_4\">".round($thisone,5)."</TD>\n";
  74.   } elseif($thisone>=1) {
  75.     echo "     <TD CLASS=\"lint_3\">".round($thisone,5)."</TD>\n";
  76.   } elseif($thisone>=0.5) {
  77.     echo "     <TD CLASS=\"lint_2\">".round($thisone,5)."</TD>\n";
  78.   } elseif($thisone<0.5) {
  79.     echo "     <TD CLASS=\"lint_1\">".round($thisone,5)."</TD>\n";
  80.   }
  81.   echo "    </TR>\n";
  82.  
  83.   if(substr($line,0,1) == 'X') {
  84.     break;
  85.   }
  86.  }
  87. }
  88. pclose($fp);
  89. echo "   <TR>\n";
  90. echo "    <TD><B>Finish - Total Time<B></TD>\n";
  91. echo "    <TD ALIGN=\"RIGHT\"><B>".round(get_microtime()-$start,5)."</B></TD>\n";
  92. echo "   </TR>\n";
  93. echo "</TABLE>\n";
  94.  
  95. html_end();
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement