Created
April 29, 2012 06:14
-
-
Save mebcomputers/2534033 to your computer and use it in GitHub Desktop.
php: visitor log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filename = 'log.txt'; | |
$timestamp = date('l d F Y H:i:s'); | |
$u_agent = $_SERVER['HTTP_USER_AGENT']; | |
$ub = ''; | |
if(preg_match('/MSIE/i',$u_agent)) | |
{ | |
$ub = "Internet Explorer"; | |
} | |
elseif(preg_match('/Firefox/i',$u_agent)) | |
{ | |
$ub = "Mozilla Firefox"; | |
} | |
elseif(preg_match('/Safari/i',$u_agent)) | |
{ | |
$ub = "Apple Safari"; | |
} | |
elseif(preg_match('/Chrome/i',$u_agent)) | |
{ | |
$ub = "Google Chrome"; | |
} | |
elseif(preg_match('/Flock/i',$u_agent)) | |
{ | |
$ub = "Flock"; | |
} | |
elseif(preg_match('/Opera/i',$u_agent)) | |
{ | |
$ub = "Opera"; | |
} | |
elseif(preg_match('/Netscape/i',$u_agent)) | |
{ | |
$ub = "Netscape"; | |
} | |
$log = $timestamp . ' ' . 'IPAddress:'. ' ' . $_SERVER['REMOTE_ADDR'] . ' ' . 'Referer:'. ' ' . $_SERVER['REQUEST_URI'] . ' ' . 'Browser:'. ' ' . $ub . ' ' . 'Username:'. ' ' . $username; | |
$stream = fopen("log.txt","a+"); | |
fwrite($stream,$log ."\n"); | |
fclose($stream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment