I love my dog Sasha because she never judges me. :)
Vicky

Recent updates

The “I Love” Project

Every year since 2010 I have decided to celebrate my domain's birthday on the 11th October with some kind of project. Last year, it was the 'Love is...' Project and you submitted your definitions of love. This year, you shared what it is that you love.

On the 9th October 2011, this layout was put up with a rotation above the sidebar with chosen submissions. Read more...

Further links

PHP: Logging ip

If you have a cPanel or a domain it might be easy to look in your logs through there, for the ip addresses of people who have visited your site.

This tutorial is for those on subdomains or who don’t have that sort of access. Unfortunately though, this tutorial requires that PHP be allowed on your server, and that your pages have a .php extension.

Example

Your IP has been logged. It is 38.107.179.236

About the code

The code is obviously in PHP. It allows the ip addresses of your visitors to be displayed in a file, along with the time and date that they visited. Their ip address is also linked to an ip locator site so you can find their rough location.

The time that is displayed is your server time. For added measure, the timezone in comparison to GMT time is displayed so you can compare it with your own time.

Beforehand

Know where you are going to place the text as displayed above. You do have the option of turning off the text.

Create a new, empty file, and name it ip.html. Upload it to your server.

CHMOD the file (or change the permissions) to 777. This will make the file writable so that the ip addresses can be logged.

The code

Paste this code on the page in which you want the ips to be logged. You can put it on every page.

<?php

$logfile= '/ABSOLUTEPATH/ip.html';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails=  date("F j, Y, g:i a O T") . ': ' .
'<a href=http://www.geobytes.com/IpLocator.htm?GetLocation&ipaddress='.$_SERVER['REMOTE_ADDR'].'>'
.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "a"); 
fwrite($fp, $logdetails);
fwrite($fp, "<br>");
fclose($fp); 

echo("Your IP has been logged. It is $IP"); 

?>

It is important that you include your absolute path. Refer to PHP Includes: Extra for a brief look on this.

The date variable in bold can be edited. However it is highly recommended that you do not. For more information on that, visit php.net/date.

You may change the text for the echo variable. This is what is printed on the page. $IP is the variable that will show the ip address. You can remove this.

If you don’t want to inform the visitor, remove that line altogether.

Making sure it works

Make sure you have uploaded ip.html, as well as the file in which you placed the code.

Visit the page you put the code on. If there is an error, make sure you have not edited anything further than what is in bold. Also make sure that you are not using any double quotes (). If you are, place a backslash (\) before each one you use.

Visit yoursite.com/ip.html, and the ip addresses should be logged!