Getting Visitors' IPs AND Avatar Names

Don Sam Stormrage
by Don Sam Stormrage · 46 posts
13 years ago in PHP
Posted 3 years ago
Oh thanks you. I always wondered where I found that PHP script that I used in my project since all that time. But I have modified it a bit to store all the visitors in a log file instead of sending an email each time someone visited my profile. Easier then to work with some regex filtering on that logfile and update my database if needed.
Posted 3 years ago
The original script is working fine if you don't mind to get spammed by emails every time someone visited your profile.

Anyway here is my version of this script for those who wish another way than getting emails.
Obviously you need to change the path where this script will save the logfile.
Also I formated a bit the output so it will also include the date when you got a visitor.
The HTML part is the same as the OP. Nothing changed there.
You may need to create an empty logfile if the script doesn't work straight out of the box the first time.

Code
<?php
$ip = getenv(REMOTE_ADDR);
$avi = $_GET['AviName'];
$datenow = date('Y-m-d H:i:s');
$file = '/path/to/the/logfile';
$message = "[".$datenow."] -- ".$avi." visited your homepage with IP: ".$ip."\n";
file_put_contents($file, $message, FILE_APPEND | LOCK_EX);
?>
Posted 6 months ago
god dammm that is hard to do it
Posted 6 months ago
Thanks loads, i have been meaning to find this tool actually, i was shocked when someone did that to me through imvu and got me thinking and now i understand it, Le me try it out!!!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT