forked from josephernest/TinyAnalytics
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtracker.php
21 lines (20 loc) · 796 Bytes
/
tracker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
function summarize($force = false)
{
$lastsummarize = realpath(dirname(__FILE__)) . '/.lastsummarize';
if (!file_exists($lastsummarize) || ((time() - file_get_contents($lastsummarize)) > 3600) || $force)
{
include_once(realpath(dirname(__FILE__)) . '/summarize.php');
return true;
}
else
return false;
}
function record_visit($sitename)
{
$logfile = realpath(dirname(__FILE__)) . '/logs/' . $sitename . '.log';
$txt = time() . "\t" . $_SERVER['REMOTE_ADDR'] . "\t" . $_SERVER['REQUEST_URI'] . "\t" . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '') . "\t" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . PHP_EOL;
file_put_contents($logfile, $txt, FILE_APPEND);
summarize();
}
?>