Block badAgents on site


Hits: 1875  

PHP is very powerful language to block bad agents. Below is the code to avoid webspider using PHP in_array().

<?php
$badAgents
= array(‘Acunetix Web Vulnerability Scanner’, ‘Bot\ mailto:craftbot@yahoo.com’, ‘ChinaClaw’, ‘Custo’, ‘DISCo’, ‘Download\ Demon’, ‘eCatch’, ‘EirGrabber’, ‘EmailSiphon’, ‘EmailWolf’, ‘Express\ WebPictures’, ‘ExtractorPro’, ‘EyeNetIE’, ‘FlashGet’, ‘GetRight’, ‘GetWeb!’, ‘Go!Zilla’, ‘Go-Ahead-Got-It’, ‘GrabNet’, ‘Grafula’, ‘HMView’, ‘HTTrack’, ‘Image\ Stripper’, ‘Image\ Sucker’, ‘Indy\ Library’, ‘InterGET’, ‘Internet\ Ninja’, ‘JetCar’, ‘JOC\ Web\ Spider’, ‘larbin’, ‘LeechFTP’, ‘Mass\ Downloader’, ‘MIDown\ tool’, ‘Mister\ PiX’, ‘Navroad’, ‘NearSite’, ‘NetAnts’, ‘NetSpider’, ‘Net\ Vampire’, ‘NetZIP’, ‘Octopus’, ‘Offline\ Explorer’, ‘Offline\ Navigator’, ‘PageGrabber’, ‘Papa\ Foto’, ‘pavuk’, ‘pcBrowser’, ‘RealDownload’, ‘ReGet’, ‘SiteSnagger’, ‘SmartDownload’, ‘SuperBot’, ‘SuperHTTP’, ‘Surfbot’, ‘tAkeOut’, ‘Teleport\ Pro’, ‘VoidEYE’, ‘Web\ Image\ Collector’, ‘Web\ Sucker’, ‘WebAuto’, ‘WebCopier’, ‘WebFetch’, ‘WebGo\ IS’, ‘WebLeacher’, ‘WebReaper’, ‘WebSauger’, ‘Website\ eXtractor’, ‘Website\ Quester’, ‘WebStripper’, ‘WebWhacker’, ‘WebZIP’, ‘Wget’, ‘Widow’, ‘WWWOFFLE’, ‘Xaldon\ WebSpider’, ‘Zeus’);
if(
in_array($_SERVER[‘HTTP_USER_AGENT’],$badAgents)) {
exit();
}
?>
 

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch