
| Tutorials Main Latest Tutorials Popular Tutorials Top Rated Tutorials |
| Login to See your Favorite Tutorials |
| Description: This is a little work around to prevent any one except you from accessing admin.php | |
| Version: 1.0 | |
| Added on: 31 January 2008 | |
| Author: Not Known | |
| Difficulty Level: Easy | |
| Views: 14008 | |
| Rating: 9.3 (4 Votes) | |
If you didn't know one of the ways a hacker will try to gain entry to your site is by gaining access to the nuke_authors table (admin users) and add his own details, then login to your admin area and create havoc !
An easy way to stop this is by only alowing your IP access to your admin.php like so,
Create a file, call it whatever you like (authority.php for example)
In that file place the following code
| Code: |
| <?php
//This function returns True if visitor IP is allowed. //Otherwise it returns False function CheckAccess() { //allowed IP. Change it to your static IP $allowedip = '127.0.0.1'; $ip = $_SERVER['REMOTE_ADDR']; return ($ip == $allowedip); } ?> |
| Code: |
| require_once('mainfile.php'); |
| Code: |
| require_once('authority.php'); |
| Code: |
| if(isset($aid)) {
if($aid AND (!isset($admin) OR empty($admin)) AND $op!='login') { unset($aid); unset($admin); die('Access Denied'); } } |
| Code: |
| //include file with CheckAccess implementation
if (!CheckAccess()) { //show the access denied message and exit script echo 'Access denied!'; exit; } //access granted, normal flow echo 'OK'; |