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?

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.