List Info

Thread: note 74203 added to function.fwrite




note 74203 added to function.fwrite
user name
2007-03-29 14:52:57
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  -- h
ttps://master.php.net/note/delete/74203/integrated
Del: useless     -- http
s://master.php.net/note/delete/74203/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/74203/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74203
Reject      -- https://mast
er.php.net/note/reject/74203
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )