echo 'Back to main page'; $logpath='/some/path/to/logs/http/access.log'; $searchfield =$_GET["s"]; if ($searchfield==""){ $matches403=greplines("/403/"); showtop($matches403,"Top 403s",10); echo "\n\n"; $matches404=greplines("/404/"); showtop($matches404,"Top 404s",10); echo "\n\n Path transversals:\n\n"; $matches=greplines("/\.\.\/\.\.\//"); showlines($matches); echo "\n\n Password grabs:\n\n"; $matches=greplines("/\/etc\/passwd/"); showlines($matches); echo "\n\n RFIs:\n\n"; $matches=greplines("/page\=http\:\/\//"); showlines($matches); } else{ $output=greplines("~".$searchfield."~"); showlines($output); } function showlines($lines){ //echo $lines; if(is_array($lines)){ foreach($lines as $line){ echo $line; } } else { echo "Empty grep or some error"; } } function showtop($somearray,$label,$number){ foreach ($somearray as $line) { $fields=explode(" -",$line); $ipcounts[$fields[0]]++; } natsort($ipcounts); $ipcounts=array_reverse($ipcounts); $ipcountnames=array_keys($ipcounts); echo '
| '.$label.' | ||
| '.$ipcounts[$ipcountnames[$i]]. ' | '.$ipcountnames[$i]. ' | Info |