Код:
<?php
set_magic_quotes_runtime(0);
define('BEGIN_TRANSACTION', 1);
define('END_TRANSACTION', 2);
require_once("mysql.php");
$sql = new sql_db;
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
if(isset($_POST['Start'])) $start=$_POST['Start'];
if(isset($_POST['End'])) $end=$_POST['End'];
$pattern = "/^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).+([0-9]{2})\/([A-Za-z]{3})\/([0-9]{4}):([0-9]{2}):([0-9]{2}):([0-9]{2}).+\"POST.(\/.*)\s.*\"\s+([0-9]{1,3}).([0-9]*)/";
$pattern1 = "/([0-9]{4})\-([0-9]{2})-([0-9]{2})\s([0-9]{2}):([0-9]{2}):([0-9]{2})/";
$form = "
Время вводится в формате YYYY-MM-DD hh:mm:ss (YYYY - год, ММ - месяц, DD - день месяца, hh:mm:ss - час, минута и секунда)</p>
****<form action=\"".$PHP_SELF."\" method=\"post\">\n
****Дата от: <input type=\"text\" maxlength=\"19\" name=\"Start\" size=\"40\" *value=\"".$start."\">
****Дата до: <input type=\"text\" maxlength=\"19\" name=\"End\" size=\"40\" value=\"".$end."\">
****подстрока URL: <input type=\"text\" maxlength=\"255\" size=\"35\" name=\"Page\">
****<input type=\"submit\" value=\"Send\" name=\"Submit\">
****</form>";
if(isset($_POST['Submit']) && $_POST['Submit'] ="Send"){
****$error = FALSE;
// *
****if (isset($_POST['Start']) && $_POST['Start'] !="" && !preg_match($pattern1,$_POST['Start'],$stmatch)){
*$start = $_POST['Start'];
*$error = true;
*$err_mess = "Неправильно заполнено поле \"Время от: \"!";
****}
****if (isset($_POST['End']) && $_POST['End'] !="" && !preg_match($pattern1,$_POST['End'],$enmatch)){
*$end = $_POST['End'];
*$error = true;
*$err_mess = "Неправильно заполнено поле \"Время до: \"!";
****}
****if($error == false){
*$fp = fopen("access.log","r");
*$i = 0;
*while (!feof ($fp)) {
* * *$buffer = fgets($fp);
* *if(preg_match($pattern,$buffer,$matches)){
* *if(!is_numeric($matches[3])){
* *****$matches[3] = eregi_replace("Jan","1",$matches[3]);
* *****$matches[3] = eregi_replace("Feb","2",$matches[3]);
* *****$matches[3] = eregi_replace("Mar","3",$matches[3]);
* *****$matches[3] = eregi_replace("Apr","4",$matches[3]);
* *****$matches[3] = eregi_replace("May","5",$matches[3]);
* *****$matches[3] = eregi_replace("Jun","6",$matches[3]);
* *****$matches[3] = eregi_replace("Jul","7",$matches[3]);
* *****$matches[3] = eregi_replace("Sep","9",$matches[3]);
* *****$matches[3] = eregi_replace("Oct","10",$matches[3]);
* *****$matches[3] = eregi_replace("Nov","11",$matches[3]);
* *****$matches[3] = eregi_replace("Dec","12",$matches[3]);
* *****$matches[3] = eregi_replace("Aug","8",$matches[3]);
* *}
* *$time = gmmktime($matches[5],$matches[6],$matches[7],$matches[3],$matches[2],$matches[4]);
* *****if(preg_match("/^(\/.*)(\?.*)/",$matches[8],$mat)){
* * *$link = $mat[1];
* *****$get = $mat[2];
* *****} else {
* *****$link = $matches[8];
* *****$get = "";
* *}
* *$req = $matches[9];
* *$size = $matches[10];
* *$params[] = $matches[1].",".$time.",".$link.",".$req.",".$size.",".$get;
* *$i++;
* *}
*}
*fclose ($fp);
****}
} *else {
****$text = $form;
}
****if($stmatch) {
*$st_time = gmmktime($stmatch[4],$stmatch[5],$stmatch[6],$stmatch[2],$stmatch[3],$stmatch[1]);
****}
****if($enmatch) $en_time = gmmktime($enmatch[4],$enmatch[5],$enmatch[6],$enmatch[2],$enmatch[3],$enmatch[1]);
****if(isset($_POST['Page']) && $_POST['Page'] !="") $url = "/".$_POST['Page'];
****
****for($j=0;$j<$i;$j++){
*list($ip,$time,$link,$req,$size,$get) = explode(",",$params[$j]);
*if($req != 200) continue;
*if(is_numeric($st_time) && ($time < $st_time)) continue;
*if(is_numeric($en_time) && ($en_time < $time)) continue;
*if($url && $url != $link) continue;
*$sQuerry[] = $ip.",".$time.",".$link.",".$req.",".$size.",".$get;
****}
****
$res = $sql -> sql_db($host,$user,$pass,$db, "");
****if($res){
****
*$trun1 = "TRUNCATE TABLE `ip`";
*$trun2 = "TRUNCATE TABLE `url`";
*$trun3 = "TRUNCATE TABLE `request`";
*
*$sql -> sql_query($trun1,1);
*$sql -> sql_query($trun2,1);
*$sql -> sql_query($trun3,1);
*foreach($sQuerry as $val){
*****list($ip,$time,$link,$req,$size,$get) = explode(",",$val);
*****$sq1 = "INSERT INTO ip (`ip_id`, `address`) VALUES ('', '".$ip."')";
*****$sq2 = "INSERT INTO url (`link_id`, `link`) VALUES ('', '".$link."')";
*****$sq3 = "INSERT INTO request (`id`, `time`,`ip_id`, `link_id`, `get`, `size`) VALUES ('', '".$time."', '".$ip."','".$link."','".$get."','".$size."')";
*****$sql -> sql_query($sq1,2);
*****$sql -> sql_query($sq2,2);
*****$sql -> sql_query($sq3,2);
*}
****}
?>
mysql.php не буду сюда вставлять так как он не очень то и нужен тут +/