Reply to mailserver logfile analyser

Your name:

Reply:


Posted by Woldhekkie on 03/02/05 16:56

Our mailserver writes a logfile every day, but it takes hours to analyse it
manualy.

I (newby) am trying to write a php script that reads the the logfile line by
line and try to get a top 50 of spammers/clients that mail too much...

I can get line by line all information like email-adres, from , to , bytes
send , but how to store it in a array ?
If a line is read and the emailadres already pressent in the array, it
should not ad this emailadress again, but add a counter +1

In the end i want an array containing all emailadreses and how often they
were counted.

This is how far i get: (sorry, it is in Dutch)
It shows all from and to emailadresses. Not bad for a newby, but it took one
week to do.....

<?php
$fp="";$line="";$aantal=0;

echo "<TABLE BORDER=3>";
echo "<TR><TD ALIGN=\"center\"> From:</TD><TD
ALIGN=\"center\">To:</TD></TR>";
if($fp = fopen("C:\smtp\SMTP-Activity-050226.log","r")) {
while (!feof ($fp)) {
$line = fgets($fp, 4096);
if(strstr($line,"SMTP-IN")) {
if(strstr($line,"MAIL FROM" )) {
$aantal++;
$start=strpos($line,"<");
$end=strpos($line,">");
$from=str_replace(">", " ", str_replace("<", " ",
substr($line,$start,$end-$start)));
echo "<TR><TD>".$from."</TD>";
}
if(strstr($line,"RCPT TO" )) {
$start=strpos($line,"<");
$end=strpos($line,">");
echo "<TD>" . str_replace(">", " ", str_replace("<", " ",
substr($line,$start,$end-$start)))."</TD>";
}
}
}
echo "</TR></TABLE>";
fclose($fp);
}
echo "Totaal aantal: $aantal <BR>";
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация