Page 1 of 1
Ip Logger
Posted: Sun Sep 07, 2003 6:16 pm
by Shiro
Any of you know how I could make an Ip Logger that will log the Ip's Into a php file that will only let me view the ip's? Because im Making it echo into a admin panel page and if they dont have my ip then it will give them an error saying Your not an admin.
Posted: Sun Sep 07, 2003 6:57 pm
by evilmonkey
well one thing you could do if you have user logins is set a usergroup, and set one to admin. If you're an admin, it will admit you, otherwise tell you something like access denied.
As for the logger itself, all you gotta do is write the line $REMOTE_ADDR to a file with write permissions (777). Not that hard.
Good luck.
Posted: Sun Sep 07, 2003 6:59 pm
by Shiro
Thanks,
I wasnt thinking, the only thing I was worried about was the public being able to view the Ip's that were logged but i just made 770 which wont let the public view

Posted: Mon Sep 08, 2003 6:01 am
by Aaron
Heres some useful logging variables
Code: Select all
$currentPage = @$_REQUEST['currentPage'];
$ip = getenv("REMOTE_ADDR");
$host = @GetHostByAddr($ip);
$real_host=chop($host);
if($real_host)
{$host_arr=explode(".", $real_host);
$count=count($host_arr);
if($count > 1)
{if(intval($host_arr[$count-1])!=0)
{$host=substr($real_host,0,strrpos($real_host,".")).".*";}
else
{$host = "*".strstr($real_host, ".");}}
else
{$host=$real_host;}}
else
{$host="";}
$browser = $HTTP_USER_AGENT;
$referer = getenv("HTTP_REFERER");
$qstring = $QUERY_STRING;