Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 376
0 Users 13 Guests Online

Secure Admin Section(Using IP)

So this will make it so that You have to be on one computer to enter your admin Section. Now If you do alot of traveling, or update your site when you're out lots. Possibly just have this protecting certain pages, And leave the Add news pages with default log in?

Code
$accept = array ("127", "0", "0", "1");

Put the ip that you want to be able to see the page here. Edit this.

Code
$remote = explode(".", $REMOTE_ADDR);
$match = 1;
for ($i = 0; $i < sizeof($accept); $i++) {
if($remote[$i] != $accept[$i]) {
$match = 0;

Now this will check to see if you IP is the same as the Specified one. Leave this.

Code
if ($match) {
echo "Access Granted";
} else {
echo "Access Forbidden";
}

If the IP does match. It echos "Access Granted" So you would edit that to show the admin part. If they do not match. It will show "Access Forbidden". You could leave that blank. And have this as a option at the bottom of the Admin Page to possibly edit site data? For example. Site Title or Site Slogan?

Here is the code after its all put together

Code
<?
$accept = array ("127", "0", "0", "1"); // IP Address that is allowed to see site
$remote = explode(".", $REMOTE_ADDR);
$match = 1;
for ($i = 0; $i < sizeof($accept); $i++) {
if($remote[$i] != $accept[$i]) {
$match = 0;
}
}
if ($match) {
echo "Access Granted";
} else {
echo "Access Forbidden";
}
?>


Hope someone will be able to use this!
Stupidkid
Author:
Views:
2453
Rating:
Posted on Sunday 11th May 2008 at 10:38 AM
Enros
Enros
I made this script ages ago >.<....

Also another thing.
Its used for static IP adresses u newbs.


And I think it is a very good way of securing something...

Try getting into it...
Posted on Sunday 4th May 2008 at 02:13 PM
Jackboy
Jackboy
If your only doing it for one IP why not just do:

PHP Code
1
2
3
4
$ip = '00.00.00.0';
if ($_SERVER[REMOTE_ADDR] != $ip){
die ("Unauthorised"); }


Sorry not tested, but why have you gone so complex for something so basic.

Fair enough you need the arrays if doing a multiple IP permission script. But i feel it would be easier to have all allowed ips in a mysql database.

@Darklight19
Some people have static IP's
Posted on Saturday 19th April 2008 at 12:50 PM
cyruswu
cyruswu
This is seriously the worstest way of securing the admin panel.

What if? You have logmeinfree and someone controls your pc. Also, someone else can go on a different accont and broswe.

You should add a thing to check if it's an admin and do other checks.
Posted on Friday 18th April 2008 at 07:40 PM
darklight19
darklight19
This is a bad way to secure an admin sections because IPs change.