<?php
/*
In progress by HaZe as of 11-16-11
It gets the IP from the user, even behind a PHP proxy (VPNs are still hidden).
*/
if (getenv("HTTP_X_FORWARDED_FOR")) {
$ipaddress = getenv("HTTP_X_FORWARDED_FOR");
} else {
$ipaddress = getenv("REMOTE_ADDR");
}
$localdate = date("l j F Y g:ia", time() - date("Z"));
$useragent = $_SERVER['HTTP_USER_AGENT'];
$referer = $_SERVER['HTTP_REFERER'];
$page = $_SERVER['REQUEST_URI'];
$useragent = strip_tags($useragent);
$varlog = fopen("access-log-php.html", "a");
// Write data
fwrite($varlog, $ipaddress);
fwrite($varlog, "<br>");
fwrite($varlog, $localdate);
fwrite($varlog, "<br>");
fwrite($varlog, $page);
fwrite($varlog, "<br>");
fwrite($varlog, $useragent);
fwrite($varlog, "<br>");
fwrite($varlog, $referer);
fwrite($varlog, "<br><br>");
// Close file
fclose($varlog);
?>
You can try this, just add it to the index page if it's PHP, or better yet, pop it in the "Header.html" file as a PHP function.
Every time it loads it will give you the user's IP, referrer, user agent, and page viewed.
Crudely, save this where it needs to go, for one hour, then cut and paste the file it generates (access-log-php.html) to a place where it won't be edited. You can look inside and count how many hits.
Alternatively, set up a PHP SQL function where it increments by one, and stores to a table on a database, for one hour.
PHP is the way to go, though.