devWhiz Posted September 6, 2011 Share Posted September 6, 2011 well I was wanting to make scripts to put on my site and then only let a few people use the site by the ip address, what would be the best way to allow only certain people to use the script on the site, based on the ip? Thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 6, 2011 Share Posted September 6, 2011 Note, that there is no fool-proof way to do this since IP addresses can be spoofed. Plus, it may not be a good idea if your users have dynamic IP addresses from their host. Their IP address can change without warning, leaving them without access. $allowed_ips = array('123.123.123.123', '125.125.125.125', '1.2.3.4', '11.22.33.44'); $user_ip = $_SERVER['REMOTE_ADDR']; if(!in_array($user_ip, $allowed_ips)) { //User's IP not in allowed list echo "Go away"; exit(); } else { //Show page } Quote Link to comment Share on other sites More sharing options...
codefossa Posted September 6, 2011 Share Posted September 6, 2011 New File: ".htaccess" # The following goes in it. <files file.php> order deny,allow deny from all allow from 127.0.0.1 </files> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.