| Tutorials Main Latest Tutorials Popular Tutorials Top Rated Tutorials |
| Login to See your Favorite Tutorials |
| Description: User Agent Banner | |
| Version: 1.0 | |
| Added on: 24 February 2007 | |
| Author: unkonw | |
| Difficulty Level: Very Easy | |
| Views: 323 | |
Ever had those annoying search bots or weird 'webcrawlers' creeping into your website and ripping you of your bandwidth? Heres a simple solution to eliminate these threats.
| Code: |
|
$agent = array("badbot1", "badbot2", "badbot3"); for($i=0;$i < sizeof($agent);$i++){ if(!empty($agent[$i])){ if(eregi($agent[$i], $_SERVER['HTTP_USER_AGENT'])){die();} } } |
| Code: |
|
$agent = array("badbot1", "badbot2", "badbot3"); This is the agent array. You add as many of the agents you want to 'block' from entering your site in this list. You can add as many as you want. Code: for($i=0;$i < sizeof($agent);$i++){ if(!empty($agent[$i])){ if(eregi($agent[$i], $_SERVER['HTTP_USER_AGENT'])){die();} } } |