Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- MailWatch for MailScanner
- Copyright (C) 2003 Steve Freegard (smf@f2s.com)
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- require_once("./functions.php");
- authenticate('A');
- html_start("SpamAssassin Lint");
- // File is local
- if(!isset($_GET['filename'])) {
- die("No input filename");
- } else {
- // SECURITY - strip off any potential nasties
- $_GET['filename'] = preg_replace('[\.\/|\.\.\/]','',$_GET['filename']);
- $filename = get_conf_var('QuarantineDir')."/".$_GET['filename'];
- if(!@file_exists($filename)) {
- die("Error: file not found\n");
- }
- }
- echo "running ".SA_DIR.'spamassassin --use-ignores -x -D < '.$filename.' 2>&1';
- if(!$fp = popen(SA_DIR.'spamassassin -x -D < '.$filename.' 2>&1','r')) {
- die("Cannot open pipe");
- } else {
- audit_log('Run SpamAssassin Debug on '.$filename);
- }
- echo "<TABLE CLASS=\"mail\" BORDER=0 CELLPADDING=1 CELLSPACING=1 WIDTH=\"100%\">\n";
- echo " <THEAD>\n";
- echo " <TH COLSPAN=2>SpamAssassin Debug E-mail</TH>\n";
- echo " </THEAD>\n";
- // Start timer
- $start = get_microtime();
- $last = false;
- while($line = fgets($fp,2096)) {
- ##### AJOS1 CHANGE #####
- #ORIG# $line = eregi_replace("\n","",$line);
- ##### AJOS1 CHANGE #####
- $line = preg_replace("/\n/i","",$line);
- if($line !== "" && $line !== " ") {
- $timer = get_microtime();
- $linet = $timer-$start;
- if(!$last) { $last = $linet; }
- echo "<!-- Timer: $timer, Line Start: $linet -->\n";
- echo " <TR>\n";
- if(($pos = strpos($line, 'dbg: check: tests=')) or ($pos = strpos($line, 'dbg: check: subtests=')) or ($pos = strpos($line, 'dbg: timing:'))) {
- $line = substr($line, 0, $pos) . '<br>' . implode('<br>', explode(',',substr($line,$pos)));
- } else {
- $line = htmlspecialchars($line);
- }
- echo " <TD>".$line."</TD>\n";
- $thisone = $linet-$last;
- $last = $linet;
- if($thisone>=2) {
- echo " <TD CLASS=\"lint_5\">".round($thisone,5)."</TD>\n";
- } elseif($thisone>=1.5) {
- echo " <TD CLASS=\"lint_4\">".round($thisone,5)."</TD>\n";
- } elseif($thisone>=1) {
- echo " <TD CLASS=\"lint_3\">".round($thisone,5)."</TD>\n";
- } elseif($thisone>=0.5) {
- echo " <TD CLASS=\"lint_2\">".round($thisone,5)."</TD>\n";
- } elseif($thisone<0.5) {
- echo " <TD CLASS=\"lint_1\">".round($thisone,5)."</TD>\n";
- }
- echo " </TR>\n";
- if(substr($line,0,1) == 'X') {
- break;
- }
- }
- }
- pclose($fp);
- echo " <TR>\n";
- echo " <TD><B>Finish - Total Time<B></TD>\n";
- echo " <TD ALIGN=\"RIGHT\"><B>".round(get_microtime()-$start,5)."</B></TD>\n";
- echo " </TR>\n";
- echo "</TABLE>\n";
- html_end();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement