30000) { fseek($fh, -30000, SEEK_END); $line = fgets($fh, 4096); } $lastlines = array(); $event = array(); while($line = fgets($fh, 4096)) { $line = trim($line); if($line == "") { continue; } if(strncmp($line, "** Alert ", 9) == 0) { if(strncmp($event, "** Alert ", 9) == 0) { array_push($lastlines, $event); } unset($event); $event = array(); $event[] = htmlspecialchars($line); } else { $event[] = htmlspecialchars($line); } } fclose($fh); $lastlines = array_reverse($lastlines); $myhost = gethostname(); if($myhost === FALSE) { $myhost = ""; } echo ' OSSEC '.$myhost.' RSS Feed http://ossec.net OSSEC RSS Feed for '.$myhost.' en-us '.date("r", $timelp).' '.date("r", $timelp).' (C) OSSEC.net 2008-2011 OSSEC.net RSS feed 30 dcid@ossec.net OSSEC Alert Feed http://www.ossec.net/img/ossec_logo.jpg http://ossec.net '; foreach($lastlines as $myentry) { echo $myentry; if(preg_match("/^.. Alert (\d+)\./", $myentry[0], $regs, PREG_OFFSET_CAPTURE, 0)) { $myunixtime = $regs[1][0]; } else { continue; } echo ' '.$myentry[2]." ,from ".substr($myentry[1], 20).' http://ossec.net '.$myentry[0].' \n"; } echo ' ]]> '.date("r", $myunixtime).' '; } echo ' '; ?>