I'm attempting to write a script that will search my logfiles for exploit attempts. I know its not a great script... Does anybody have any suggestions on how I should go about it? My server is running linux with apache. Below I do a simple grep command and print the output to a browser. Is there a better command to use? How would you format it and print it out to a browser. Thanks for any suggestions.

<?php
$Exploit[] = " cmd.exe ";
$Exploit[] = " system32 ";
$Exploit[] = " scripts ";
$Exploit[] = " %2f ";
$Exploit[] = " %5c ";
$Exploit[] = " formmail.php ";

print "<pre>";

foreach ( $Exploit as $val )
{
system( "cd ../../../logs ; grep -n $val error_log ", $return );

}
print "</pre>";
?>