Created
October 30, 2018 16:25
-
-
Save nmngt/3f793a1e1689225ae160be52bb823f9a to your computer and use it in GitHub Desktop.
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 | |
/** | |
* prueft, ob der Zugriff von einem Page Analyzer, wie Google PageSPeed Insights, | |
* aus erfolgt. | |
* | |
* Da wir keinen Einfluss auf den Brwoser-Cache der Google Analytics JS haben, | |
* spielen wir kein Google Analytics aus, wenn ein Page Analyzer auf die Seite | |
* zugreift. Das verschönert unsere Werte ;-) | |
* | |
* @param string $ua User-Agent | |
* | |
* @return bool true, wenn ein PageAnalyzer erkannt wird | |
*/ | |
function is_pageanalyzer($ua){ | |
if( ! isset($ua)){ | |
return false; | |
} | |
// Google PageSpeed Insights | |
if(strpos($ua, 'Speed Insights') !== false){ | |
return true; | |
} | |
// GTmetrix | |
if(strpos($ua, 'gtmetrix.com') !== false){ | |
return true; | |
} | |
if(strpos($ua, 'Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0') !== false){ | |
return true; | |
} | |
// PINGdom | |
if(strpos($ua, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') !== false){ | |
return true; | |
} | |
// else: normaler Besucher | |
return false; | |
} |
Author
nmngt
commented
Oct 30, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment