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
#2
Lol, not a bad script. Smile
Reply
#3
(10-13-2009, 02:14 AM)immi Wrote: Thats cool Yeye

if useful give a rep... xD
I am your Father
Reply
#4
(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 ;)
Reply
#5
(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
I am your Father
Reply
#6
This logs nothing it just takes some info and stores it in variables.
Reply
#7
(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.
Reply
#8
Spoke to early I did not see the scroll bar it is out of my monitor. lol
Reply
#9
Well that's nice.
[Image: 2d75599e9a.png]:superman:
Reply
#10
So it logs everyone who logs in on the network?
Reply


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: 5 Guest(s)