From ChekMate Security Group
<?
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Michael Earls |
| |
| 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. |
+-------------------------------------------------------------------------+
| php-syslog-ng: php4 mysql syslog-ng |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Michael Earls, any |
| questions or comments regarding this code should be directed to: |
| - michael@michaelearls.com |
+-------------------------------------------------------------------------+
| - vermeer - http://www.vermeer.org/ |
+-------------------------------------------------------------------------+
*/
$contents .= "<pre><font size=2 face=verdana><b>Syslog Tracking History</b>\n\n";
$contents .= "\n\n<b>Log File: Today</b>\n\n";
$dir = "tracking";
$fp=fopen("tracking.txt","r");
while(!feof($fp)) {
$line=fgets($fp,256);
list($linedate,$lineuser) = split(" - ",$line);
if ($lineuser <> "") {
$dataexists = 1;
if ($startdate[$lineuser] == "") { $startdate[$lineuser] = $linedate; }
if ($linedate > $enddate[$lineuser]) { $enddate[$lineuser]= $linedate; }
$count[$lineuser] = $count[$lineuser] + 1;
}
}
fclose($fp);
if ($dataexists) {
while(list($user,$value) = each($startdate)) {
$contents .= " $user accessed syslog between $startdate[$user] and $enddate[$user] a total of $count[$user] time(s).\n";
}
}
unset ($dataexists);
unset ($startdate);
unset ($enddate);
unset ($count);
$h=opendir($dir);
while($file=readdir($h)){
if(substr($file,-4)=='.txt'){
$path=$dir.'/'.$file;
$contents .= "\n\n<b>Log File: $file</b>\n\n";
$fp=fopen($path,"r");
while(!feof($fp)) {
$line=fgets($fp,256);
list($linedate,$lineuser) = split(" - ",$line);
if ($lineuser <> "") {
$dataexists = 1;
if ($startdate[$lineuser] == "") { $startdate[$lineuser] = $linedate; }
if ($linedate > $enddate[$lineuser]) { $enddate[$lineuser]= $linedate; }
$count[$lineuser] = $count[$lineuser] + 1;
}
}
fclose($fp);
if ($dataexists) {
while(list($user,$value) = each($startdate)) {
$contents .= " $user accessed syslog between $startdate[$user] and $enddate[$user] a total of $count[$user] time(s).\n";
}
}
}
unset ($dataexists);
unset ($startdate);
unset ($enddate);
unset ($count);
}
closedir($h);
print "$contents\n";
?>