Jump to content

Limit access to page to only local ip (192.168.1.xx)


farkewie

Recommended Posts

Hi i need to restrict access to a page so only people connected to my router can access them,

 

here is my code but it just always says not ok.

PS: the "echo" is just for testing purpose

 


<?php
echo $_SERVER['REMOTE_ADDR'];

if (($_SERVER['REMOTE_ADDR']) == '192.168.1.\255'){
echo "ok";
}
else {
echo "not ok";
}
?>

 

also i include 2 php files in my main page how do i stop people accessing them directly?

Its not a massive security issue,

 

i just dont want to login from home when its set as my homepage, and at the same time i dont want to have too easy access from outside,

 

i dont have a registered domain or anything at home so noone should "stumble" apon it.

 

 

@phpQuestioner

 

The 'REMOTE_ADDR' comes from the TCP/IP packet and cannot be faked. It is the address that the web server will send the response back to.

 

You can easily get a different IP address or go through a web proxy to hide your real IP address, but the IP address in the TCP/IP packet is a true address at the time the pack was created.

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.