Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Complete User Logger
#1
PHP Code:
<?php
//Get IP address
$IP=$_SERVER['REMOTE_ADDR'];

//Get hostname via IP
$hostname gethostbyaddr($_SERVER['REMOTE_ADDR']);

//Get their user agent. 
$agent $_SERVER['HTTP_USER_AGENT']; 

// Referer, how they got to your website
$ref $_SERVER['HTTP_REFERER']; 

//Get page being viewed
$page $_SERVER['REQUEST_URI'];

//Determine logfile,can also write to database
$logfile 'iplog.txt';

//Determine date in ... format
$date date("r");

//Retrieve XML data from hostip.info
$xml file_get_contents("http://api.hostip.info/?ip=".$IP);

//Get city information from XML
$city preg_match("@<Hostip>(\s)*<gml:name>(.*?)</gml:name>@si",$xml);

//Get country information from XML
$country preg_match("@<countryName>(.*?)</countryName>@si",$xml);

//Open logfile to append
$fp fopen($logfile"a"); 

//Write data into logfile
fwrite($fp"IP: $IP - Date: $date - City: $city - Country: $country - Page viewed: $page \n Hostname: $hostname\n UserAgent: $agent \n Referrer: $ref \n\n\n");

//Close logfile
fclose($fp);

?>
I am your Father
Reply


Messages In This Thread
Complete User Logger - by h1r0n - 10-09-2009, 08:59 PM
RE: Complete User Logger - by Bartdevil - 10-10-2009, 01:29 AM
RE: Complete User Logger - by h1r0n - 10-13-2009, 02:33 AM
RE: Complete User Logger - by immi - 10-13-2009, 02:42 AM
RE: Complete User Logger - by h1r0n - 10-13-2009, 04:51 AM
RE: Complete User Logger - by Legion - 10-13-2009, 06:22 AM
RE: Complete User Logger - by Gaijin - 10-13-2009, 06:48 AM
RE: Complete User Logger - by Legion - 10-13-2009, 07:52 AM
RE: Complete User Logger - by Akshay* - 10-13-2009, 08:00 AM
RE: Complete User Logger - by Socrates - 10-13-2009, 03:43 PM
RE: Complete User Logger - by El Zorro - 10-13-2009, 03:50 PM
RE: Complete User Logger - by h1r0n - 10-14-2009, 03:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My ip logger with email and html logging option ELY_M 7 3,340 12-13-2010, 10:41 PM
Last Post: Bursihido
  User Management Script - User Cake Support 9 5,623 05-13-2010, 03:21 PM
Last Post: Julie
  1x1 pixel IP Logger Nyx- 22 6,279 04-16-2010, 03:27 AM
Last Post: .:xX[ThunderStorm]Xx:.
  IP Logger brett7 8 1,897 10-10-2009, 07:01 AM
Last Post: brett7

Forum Jump:


Users browsing this thread: 2 Guest(s)