Skip to content

Instantly share code, notes, and snippets.

@supercleanse
Created July 13, 2011 04:01
Show Gist options
  • Save supercleanse/1079697 to your computer and use it in GitHub Desktop.
Save supercleanse/1079697 to your computer and use it in GitHub Desktop.
Pretty Link Robot detection
<?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