Created
July 13, 2011 04:01
-
-
Save supercleanse/1079697 to your computer and use it in GitHub Desktop.
Pretty Link Robot detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function is_robot(&$click,&$browsecap,$header='') | |
{ | |
global $prli_utils, $prli_click, $prli_options; | |
$ua_string = trim(urldecode($click->browser)); | |
$btype = trim($click->btype); | |
// Yah, if the whole user agent string is missing -- wtf? | |
if(empty($ua_string)) | |
return 1; | |
// If we're doing extended tracking and the Browser type | |
// was unidentifiable then it's most likely a bot | |
if( isset($prli_options->extended_tracking) and | |
$prli_options->extended_tracking == 'extended' and | |
empty($btype) ) | |
return 1; | |
// Some bots actually say they're bots right up front let's get rid of them asap | |
if(preg_match("#(bot|Bot|spider|Spider|crawl|Crawl)#",$ua_string)) | |
return 1; | |
$crawler = $browsecap['crawler']; | |
// If php_browsecap tells us its a bot, let's believe him | |
if($crawler == 1) | |
return 1; | |
return 0; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment