7

log

write_log
SYNOPSIS

write_log($logfile, $textline=false)

DESCRIPTION
CODE
  1. require_once 'clientipaddress.php';
  2. require_once 'validateipaddress.php';
  3.  
  4. function write_log($logfile, $textline=false) {
  5.     global $log_dir;
  6.  
  7.     $ipaddress = client_ip_address();
  8.  
  9.     if (!validate_ip_address($ipaddress)) {
  10.         return false;
  11.     }
  12.  
  13.     $timestamp=date('Y-m-d H:i:s');
  14.  
  15.     $logmsg="$timestamp $ipaddress";
  16.     if ($textline) {
  17.         $logmsg .= "\t$textline";
  18.     }
  19.     $logmsg.="\n";
  20.  
  21.     $file = isset($log_dir) ? ($log_dir . DIRECTORY_SEPARATOR . $logfile) : $logfile;
  22.  
  23.     $r = @file_put_contents($file, $logmsg, FILE_APPEND);
  24.  
  25.     return $r;
  26. }
SEE ALSO

track, clientipaddress, validateipaddress

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].