note 91834 deleted from function.fputs by danbrown
| From: | danbrown@php.net | Date: | Sat, 11 Dec 2010 18:59:20 +0000 |
| Subject: | note 91834 deleted from function.fputs by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-174799@lists.php.net to get a copy of this message | ||
Note Submitter: ontheroadagain4 at excite dot com
----
Building on camillord's example above, a little tool I produced to get an idea which pages are
most popularly being viewed. Adds to an 'activity.log'. Warning! - involves British Summer
Time offset, obviously not applicable if you don't live in Britain LOL
<?php
// British Summer Daylight Saving Time! true = use dst ; false = don't. < This also based on
another example elsewhere (see date())
$dst = true;
// $dst = false;
$datetime = strtotime("now");
if ($dst && date('I')) $datetime += 3600; // +1hr offset
$txUser = $_COOKIE["txName"] ? $_COOKIE["txName"] : "Unknown";
$fileContainer = "activity.log";
$filePointer = fopen($fileContainer, "a");
$logMsg = $txUser . ", " . $_SERVER["REMOTE_ADDR"] . "; " .
gmdate("r", $datetime) . " " . $_SERVER["PHP_SELF"] . "\n";
fputs($filePointer, $logMsg);
fclose($filePointer);
?>
Result is a growing list of visitors in the form e.g.:
Fred Blogs, 12.345.678.901; Fri, 26 Jun 2009 10:59:16 +0000 /testpage3.php
Probably not a good idea if you have lots of hits as it can get quite big quite quickly. The name
(if exists) comes from a saved cookie where user has used a contact form for instance.