Login Register






PHP Unique Visitor IP Grabber filter_list
Author
Message
PHP Unique Visitor IP Grabber #1
I see there's quite a few IP grabbers, but have yet to come across a "unique visitor" one. Since I'm new to the forums, and thought I'd share something, so here it is.

PHP Code:
<?php $BlockedIPs = Array('Your IP here'); $Unique = 1; $Time = Date("g:i a") . ' on ' . Date("m/d/Y"); $IP = $_SERVER['REMOTE_ADDR']; $Port = $_SERVER['REMOTE_PORT']; $Data = "Received at $Time\nIP Address: $IP\nAccessed through Port $Port\nhttp://www.ip-tracker.org/locator/ip-lookup.php?ip=$IP\n\n"; $Log = 'ip_log.txt'; $Contents = File_Get_Contents($Log); If($Unique == 1){ If(!strpos($Contents, $IP)){ If(!In_Array($IP, $BlockedIPs)){ $File = FOpen($Log, 'a+'); FWrite($File, $Data); FClose($File); } } Else{ Die('An unexpected error has occurred.'); } } ElseIf($Unique == 0){ $File = FOpen($Log, 'a+'); FWrite($File, $Data); FClose($File); } ?>

It's somewhat simple, but it does the trick. I tried to shorten that as best as I could, but hope everyone likes it.

Update:
I've updated the "If(!strpos" statement, as it wasn't functional.
(This post was last modified: 10-21-2013, 07:11 PM by rektosaurus.)
[Image: siggy.php?uid=66857]

Reply





Messages In This Thread
PHP Unique Visitor IP Grabber - by Crime - 10-18-2013, 08:44 PM