Jump to content

ip logger exlude my ip


SN1P3R_85

Recommended Posts

I made a very simple ip logger for my website, It just records the ip of everyone who connects to my main page, and then records the date and time. I visit my site so often, that 90% of the ip's in the ip log are mine. I want to exclude my ip from being logged among the other ip's, but i still want to log my somewhere else. I tried a few different things, but i can't seem to get any of them to work. This is my code that logs all ips.

<?php

 

putenv("TZ=America/Los_Angeles");

 

$ip = $_SERVER['REMOTE_ADDR'] . " conneced on " . date('l jS \of F Y \a\t h:i:s A') . ".\n\n";

 

$handle = fopen("visitor_ip.txt", "a+");

 

fwrite($handle, $ip);

fclose($handle);

 

?>

 

Link to comment
https://forums.phpfreaks.com/topic/122280-ip-logger-exlude-my-ip/
Share on other sites

do this:

 

putenv("TZ=America/Los_Angeles");

 

$my_ip = "copy and paste your ip address";

 

if($_SERVER['REMOTE_ADDR'] != $my_ip){

 

$ip = $_SERVER['REMOTE_ADDR'] . " connected on " . date('l jS \of F Y \a\t h:i:s A') . ".\n\n";

 

$handle = fopen("visitor_ip.txt", "a+");

fwrite($handle, $ip);

fclose($handle);

}

well I did a script to log ips as well with me I'm behind a router so when I used $_SERVER['SERVER_ADDR']; it just used my router ip I had to set a variable to my ip and then have it check to make sure it wasn't that ip

 

if ($ip == $myip) {

echo 'welcome Server Admin';

}

else {

$do = "insert into db(IP, Time) values($ip, $Time)"; //+the query

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.