note 74203 added to function.fwrite

From: Date: Thu, 29 Mar 2007 19:52:57 +0000
Subject: note 74203 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-124929@lists.php.net to get a copy of this message
This is a simple function I wrote that uses the fopen and fwrite functions to log the actions of users... very useful for tracking your members on your site. <?php function loguser($reason,$ext = "db"){ if(!is_dir("logs")): mkdir("logs","0493"); endif; $fp = fopen("logs/".date("m-d-y").".".$ext, "a+"); fwrite($fp, "<strong>".date("g:i:s A")."</strong>: ".$reason."<br/>"); } ?> To use this, just call the function like so: <? loguser($_SERVER["REMOTE_ADDR"]." attempted to create another account.","html"); ?> The second parameter can be changed to anything that would support HTML. If you leave out the second extension, then it automatically uses the .db extension, which works excellent for me. Hope this helps. Paul ---- Server IP: 64.71.164.2 Probable Submitter: 70.167.85.213 ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- https://master.php.net/note/edit/74203 Del: integrated -- https://master.php.net/note/delete/74203/integrated Del: useless -- https://master.php.net/note/delete/74203/useless Del: bad code -- https://master.php.net/note/delete/74203/bad+code Del: spam -- https://master.php.net/note/delete/74203/spam Del: non-english -- https://master.php.net/note/delete/74203/non-english Del: in docs -- https://master.php.net/note/delete/74203/in+docs Del: other reasons-- https://master.php.net/note/delete/74203 Reject -- https://master.php.net/note/reject/74203 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124929) next »