note 91834 added to function.fputs

From: Date: Sat, 27 Jun 2009 11:33:00 +0000
Subject: note 91834 added to function.fputs
Groups: php.notes 
Request: Send a blank email to php-notes+get-157628@lists.php.net to get a copy of this message
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. ---- Server IP: 92.48.74.199 Probable Submitter: 62.56.63.137 ---- Manual Page -- http://www.php.net/manual/en/function.fputs.php Edit -- https://master.php.net/note/edit/91834 Del: integrated -- https://master.php.net/note/delete/91834/integrated Del: useless -- https://master.php.net/note/delete/91834/useless Del: bad code -- https://master.php.net/note/delete/91834/bad+code Del: spam -- https://master.php.net/note/delete/91834/spam Del: non-english -- https://master.php.net/note/delete/91834/non-english Del: in docs -- https://master.php.net/note/delete/91834/in+docs Del: other reasons-- https://master.php.net/note/delete/91834 Reject -- https://master.php.net/note/reject/91834 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157628) next »