Support Forums
Complete User Logger - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Complete User Logger (/showthread.php?tid=991)

Pages: 1 2


Complete User Logger - h1r0n - 10-09-2009

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);

?>



RE: Complete User Logger - Bartdevil - 10-10-2009

Lol, not a bad script. Smile


RE: Complete User Logger - h1r0n - 10-13-2009

(10-13-2009, 02:14 AM)immi Wrote: Thats cool Yeye

if useful give a rep... xD


RE: Complete User Logger - immi - 10-13-2009

(10-13-2009, 02:33 AM)n1tr0b Wrote: if useful give a rep... xD

Board Message Wrote:Sorry we require 100 posts in order to give reputation.

Sad
Any ways, I gave 5 Stars in rating ;)


RE: Complete User Logger - h1r0n - 10-13-2009

(10-13-2009, 02:42 AM)immi Wrote:
Board Message Wrote:Sorry we require 100 posts in order to give reputation.

Sad
Any ways, I gave 5 Stars in rating ;)

thx... but if ya got 100 posts up... sure to give a rep.. xD


RE: Complete User Logger - Legion - 10-13-2009

This logs nothing it just takes some info and stores it in variables.


RE: Complete User Logger - Gaijin - 10-13-2009

(10-13-2009, 06:22 AM)Legion Wrote: This logs nothing it just takes some info and stores it in variables.

Well actually it does saves to the logs file.
PHP Code:
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"); 

But he isn't handling errors so if the script isn't allowed to open/create/write files, it won't output any error messages and the file will not be written.


RE: Complete User Logger - Legion - 10-13-2009

Spoke to early I did not see the scroll bar it is out of my monitor. lol


RE: Complete User Logger - Akshay* - 10-13-2009

Well that's nice.


RE: Complete User Logger - Socrates - 10-13-2009

So it logs everyone who logs in on the network?