Difficulty: 1/10
Assumed Knowledge: Copy & Paste / Min. HTML & PHP Knowledge
Recommended Programs: Notepad++, FileZilla
Code:
<?php
//By Unlucky @ Rune-Server (alessandroricciardi.com)
$agent = $_SERVER['HTTP_USER_AGENT']; //this tells you if they are using Windows 7, Mac, etc
$ip = $_SERVER['REMOTE_ADDR']; //IP address
$time = date('l jS \of F Y g:i:s A'); //Time, date, EG: "Wednesday 3rd of August 2011 11:31:47 AM"
$referer = getenv ('HTTP_REFERER'); //Tells you what site they came from (if it was linked)
$fp = fopen('other/iplog.htm', 'a'); // editing file
if ($ip != 'REPLACEIP') { // add your IP in the REPLACEIP area.
// this is so it does not log your visits every time.
fwrite($fp, '<strong>Referer</strong>: '.$referer.' <strong>IP</strong>: <a href="http://whois.domaintools.com/' .$ip. '">' .$ip. '</a> <strong>Date</strong>: ' .$time. ' <br><strong>Agent</strong>: ' .$agent. '<br><br>');
fclose($fp);
//writing files
}
?>
Name this file anything.php (iplogger, ipgrabber, etc would be efficient)
Save this in a folder, name it "other". You can rename it to something else but change it in the codes I've given you.
Code:
<?php
include( "other/anything.php" );
?>
Add this in EVERY PAGE you want to have logged. Remember that the page must be named .php
For example, www.test.com/hey.php
- - - -
Yes there is already a tutorial on this but it is very over complicated. This is simple and takes about 2 minutes.
There are better/cleaner ways of doing this but I wrote this at least a year ago and decided to release on here from my website. Very useful at times.
- - - -
Any questions or problems let me know here.
I will be posting a tutorial on how to make a site so that you only need to edit one file to effect the rest of the web pages hosted. Instead of editing every other page.