note 74203 deleted from function.fwrite by googleguy

From: Date: Tue, 22 Oct 2013 06:44:21 +0000
Subject: note 74203 deleted from function.fwrite by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196619@lists.php.net to get a copy of this message
Note Submitter: chaobreederxl at gmail dot com ---- 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

« previous php.notes (#196619) next »