Jump to content

Log Ip Addresses


smerny

Recommended Posts

Sort of a PHP/MySQL question I guess.... but what is the best way to log all the IPs a user has used to log in?For example, a game I play keeps logs of all the IP's a user has logged into, and all the users that have logged in under the IP... this is an example of a log from that game... it keeps track of all the times, IPs, and Browsers used to log in for each player.Login HistoryTime IP Address Browser8 hrs, 45 min ago 163.150.137.68 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)9 hrs, 6 min ago 163.150.137.68 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)9 hrs, 52 min ago 163.150.137.68 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)11 hrs, 46 min ago 163.150.137.68 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)19 hrs, 59 min ago 71.104.129.32 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1

Link to comment
Share on other sites

function logIP() {$ipLog="./log/ip_log.html"; // permission to write world required (0777)$ip = $_SERVER['REMOTE_ADDR'];$from = $_SERVER['HTTP_USER_AGENT']; // added Browser information$date = date ("l dS \of F Y h:i:s A"); // required escape backslash$log = fopen($ipLog, "a+");if (fputs($log, "Logged IP address: $ip - Date : $date - Using : $from\n")) {		fclose($log);		return true; // if successful write	} else {		return false; // if write not successful	}}

A log function I wrote... Might help.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...