dan.coop3r
11-12-2007, 09:35 AM
Hi. Im currently stuck trying to work out a way to do this:
I need to compare the time array within the loop each time the code passes through it, too the previous time array value. And if the time is less than 7 minutes do not continue with the if statement. If it is more go with it!
<?php
$filename = 'logs/'. 'ex'. date('ymd'). '.log'; // Filename Checker
$fp = fopen($filename, "r"); //Open the server log
$content = fread($fp, filesize($filename)); // Read the server log
$content = explode("\n", $content); // explode into array
$content = array_reverse($content ); // reverse the array
$n =0;
foreach ($content as $key=>$value)
{
$bits = explode(" ", $value);
@$request = $bits[5]; // Get cs uri stem
@$log_client = $bits[9]; // Get client ip
@$log_time = $bits[1]; // Get client time
$mylogtime = $log_time;
$find = 'booked/excursions/index.php';
if (strpos($request, $find) == true) //SURELY IN HERE I SHOULD USE $array[$key - 1]?? comparing $mylogtime and $log_time ??
{
print_r("$request ");
$uniquepages[] = $log_client;
$n++;
echo "$mylogtime<br/>";
}
else
{
}
}
echo "<br/>Page views for '$find' = $n<br/><br/>";
echo "Unique page views =". count(array_unique($uniquepages));
fclose($fp);
?>
So any help would be appreciatted!
Thanks eon201
I need to compare the time array within the loop each time the code passes through it, too the previous time array value. And if the time is less than 7 minutes do not continue with the if statement. If it is more go with it!
<?php
$filename = 'logs/'. 'ex'. date('ymd'). '.log'; // Filename Checker
$fp = fopen($filename, "r"); //Open the server log
$content = fread($fp, filesize($filename)); // Read the server log
$content = explode("\n", $content); // explode into array
$content = array_reverse($content ); // reverse the array
$n =0;
foreach ($content as $key=>$value)
{
$bits = explode(" ", $value);
@$request = $bits[5]; // Get cs uri stem
@$log_client = $bits[9]; // Get client ip
@$log_time = $bits[1]; // Get client time
$mylogtime = $log_time;
$find = 'booked/excursions/index.php';
if (strpos($request, $find) == true) //SURELY IN HERE I SHOULD USE $array[$key - 1]?? comparing $mylogtime and $log_time ??
{
print_r("$request ");
$uniquepages[] = $log_client;
$n++;
echo "$mylogtime<br/>";
}
else
{
}
}
echo "<br/>Page views for '$find' = $n<br/><br/>";
echo "Unique page views =". count(array_unique($uniquepages));
fclose($fp);
?>
So any help would be appreciatted!
Thanks eon201