Skip to content

Instantly share code, notes, and snippets.

@carl-alberto
Created January 22, 2021 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carl-alberto/93cd944098f5acfc75ba134f7962d650 to your computer and use it in GitHub Desktop.
Save carl-alberto/93cd944098f5acfc75ba134f7962d650 to your computer and use it in GitHub Desktop.
pagespeed detection script
<?php
function bot_detected() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
if(strlen(strstr($u_agent,"Lighthouse")) > 0 ){
return false;
} elseif(strlen(strstr($u_agent,"GTmetrix")) > 0 ){
return false;
} else {
// var_dump( $_SERVER['HTTP_USER_AGENT'] );
return true;
}
}
if ( bot_detected() ) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment