Wednesday, November 25, 2009

Creating Admin with 1 IP Access

Each website must have an admin page. Page admin here means the web pages that are used by webmasters to manage content and web interface. Surely we would not want if the admin page is known by other parties. Using your username and password fine. But did not rule out another user will try mecoba login security that you created.

In addition to using the username and password, there are other ways to secure the admin page. Namely by limiting the IP Address. So only certain IP address that can open the pages of this admin. Ah, after a long story, of course you can not wait to find out how to create a secure admin page.

First of all, you need to know your IP address. To find out, you can use the following command:


print? IP you:?. $ HTTP_SERVER_VARS [ 'REMOTE_ADDR'];
?>

If so, then in the admin section, for example you put in the folder? Administrator / index.php?, You type the following command at the beginning of the script:


$ ip =? 127.0.0.1? / / Ip which has been noted previously
if ($ HTTP_SERVER_VARS [ 'REMOTE_ADDR']! = $ ip) (
header (? location: .. / index.php);
) Else (
Setcookie (? Ip?, $ Ip);)
?>

Then for every other web page, (which is also found in the administrator folder) you add the following command:


$ ip =? $ _COOKIE [? ip?];? / / Call cookies ip
if ($ HTTP_SERVER_VARS [ 'REMOTE_ADDR']! = $ ip) (
print? You do not have rights to access this page .....!!!!?;
) Else (
/ / Display your menu
)
?>

Do not forget to do the call or session cookies for the username and password you created. The above examples are only for calling cookies to IP Address. You can also create more than 1 IP Address that can access your admin. Of course by using the database.

CREATE TABLE `web_saya`. Tb_admin `` (
`id` BIGINT (20) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`ip` VARCHAR (30) NOT NULL
) ENGINE = MyISAM

INSERT INTO `web_saya`. Tb_admin `` (
`id`,
`ip`
)
VALUES (
NULL, '127 .0.0.1 '
);

Config.php

$ host =? localhost?;
$ user =? root?;
$ pass =??;
$ conn = mysql_connect ($ host, $ user, $ pass) or die (? Check the host name, user, or pass ..?);
$ pilih_db = mysql_select_db (? web_saya?);
?>

Then in the index.php located in the folder administrator, you type the following script:

Index.php


Include (? Config.php?);
$ ip = $ HTTP_SERVER_VARS [ 'REMOTE_ADDR'];
$ valid_ip = mysql_query (? tb_admin SELECT * FROM WHERE ip =? $ ip??);
if (! = $ valid_ip) (
print? You do not have rights to access this page!?;
) Else (
/ / Display your admin menu
)
?>

With the above script, you can enter more than 1 IP address that can access your admin page ..

Good luck ....

No comments:

Post a Comment