
| Tutorials Main Latest Tutorials Popular Tutorials Top Rated Tutorials |
| Login to See your Favorite Tutorials |
| Description: This tutorial will help prevent hackers from gaining access to admin.php | |
| Version: 1.0 | |
| Added on: 08 July 2007 | |
| Author: Anna | |
| Difficulty Level: Easy | |
| Views: 1175 | |
| Rating: 10.0 (1 Vote) | |
Most hackers will go for the authors table and attempt to gain entry through the admin accounts.
Here is an interesting workaround (fix) to thwart this method of hack.
Create a file, call it whatever you like (authority.php for this 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'; |