Forum Moderators: coopster
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
$uri = $_SERVER['REQUEST_URI'];
$user = $_SERVER['PHP_AUTH_USER'];
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$dtime = date('r');
if($ref == ""){
$ref = "None";
}
if($user == ""){
$user = "None";
}
$entry_line = "$dtime - IP: $ip ¦ URL: $uri ¦ Referrer: $ref
";
$fp = fopen("somefolder/sometextfile.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
?>
I now have problem... I want to see TOTAL number of visitors on the top... Can someone help? I think that is only one line of code but I don't know it:(
Please someone helo me...
Thank you very much.
you're right about this one line :D
On Linux you can just count the lines in the file:
$iLines = `cat sometextfile.txt ¦ wc -l`;
if you have a windows system, i couldn't think of something with only one line of code. but i found smth what works.
$fp = fopen("sometextfile.txt", "r");
while (!feof($fp)) {
$sFile .= fgets($fp, 4096);
}
fclose($fp);
$aLines = explode("\n", $sFile);
echo count($aLines);
hope this helps
barn
and this file would execute the code i posted before.
btw does your script log every request? because then it wouldn't be visitors it would be requests. its not even PIs because hits from robots don't count as Pageimpressions.
barn