
Herzlich willkommen im Archiv vom ABAKUS Online Marketing Forum
Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.
Code: Alles auswählen
<?
function isGoogleClick() {
if(stripos($_SERVER['HTTP_REFERER'], '.google.') !== false &&
preg_match('{^[a-z]+://[^.]*\.google\.}i’, $_SERVER[‘HTTP_REFERER’]))
return true;
if(stripos($_SERVER[‘HTTP_USER_AGENT’], ‘Googlebot’) !== false) {
$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if(stripos($host, 'googlebot') !== false) return true;
}
return false;
}
$google=isGoogleClick();
echo $google;
?>
Code: Alles auswählen
<?php
// functions
function is_bot() {
if (
strpos($_SERVER['HTTP_USER_AGENT'], 'bot') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Bot') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'crawl') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Crawl') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'search') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'get') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'spider') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'find') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'java') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Java') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Google') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'yahoo') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'ask') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'contaxe') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'libwww-perl') !== false ||
) {
return true;
}
return false;
}
function is_view_allowed() {
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], '.google.') !== false) {
return true;
}
else if (is_bot()) {
return true;
}
return false;
}
// check auth
if (!is_view_allowed()) {
exit('Normaler Besucher ohne Google-Referer.');
}
?>
Code: Alles auswählen
Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
Code: Alles auswählen
//main functions
if (!function_exists('stripos')) {
function stripos($haystack, $needle, $offset=0) {
return strpos(strtolower($haystack), strtolower($needle), $offset);
}
}
function stripos2($haystack, $needle, $offset=0) {
return strpos(strtolower($haystack), $needle, $offset);
}
// test functions
function is_bot1() { // 0.70
if(preg_match('#(bot|crawl|search|get|spider|find|java|google|yahoo|ask|contaxe|yandex)#', $_SERVER['HTTP_USER_AGENT'])) {
return true;
}
return false;
}
function is_bot2() { // 1.27
foreach (array('bot', 'crawl', 'search', 'get', 'spider', 'find', 'java', 'google', 'yahoo', 'ask', 'contaxe', 'yandex') as $bot) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
return true;
}
}
return false;
}
function is_bot3() { // 1.13
if (
stripos($_SERVER['HTTP_USER_AGENT'], 'bot') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'crawl') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'search') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'get') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'spider') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'find') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'java') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'google') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'yahoo') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'ask') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'contaxe') !== false ||
stripos($_SERVER['HTTP_USER_AGENT'], 'yandex') !== false
) {
return true;
}
return false;
}
function is_bot4() { // 0.53
foreach (array('bot', 'crawl', 'search', 'get', 'spider', 'find', 'java', 'google', 'yahoo', 'ask', 'contaxe', 'yandex') as $bot) {
if (strpos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
return true;
}
}
return false;
}
function is_bot5() { // 0.34
if (
strpos($_SERVER['HTTP_USER_AGENT'], 'bot') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Bot') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'crawl') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Crawl') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'search') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'get') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'spider') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'find') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'java') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Java') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Google') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'yahoo') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'ask') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'contaxe') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false
) {
return true;
}
return false;
}
function is_bot6() { // 0.84
if(preg_match('#(bot|Bot|crawl|Crawl|search|get|spider|find|java|Java|Google|yahoo|ask|contaxe|Yandex)#', $_SERVER['HTTP_USER_AGENT'])) {
return true;
}
return false;
}
function is_bot7() { // 0.43
if (
strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'bot') !== false ||
strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'crawl') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'search') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'get') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'spider') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'find') !== false ||
strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'java') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Google') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'yahoo') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'ask') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'contaxe') !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false
) {
return true;
}
return false;
}
function is_bot8() { // 1.10
if (
stripos2($_SERVER['HTTP_USER_AGENT'], 'bot') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'crawl') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'search') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'get') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'spider') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'find') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'java') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'google') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'yahoo') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'ask') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'contaxe') !== false ||
stripos2($_SERVER['HTTP_USER_AGENT'], 'yandex') !== false
) {
return true;
}
return false;
}
Nein ist er nicht. Denn mein Code ist trotz der Erkennung von verschiedenen Suchmaschinen viel schneller als Deiner. Und selbst wenn Du nur Google zulassen wolltest, könntest Du die Funktion einfach auf das reduzieren:JohnBi hat geschrieben:Ok, das mag sein, da mich aber andere Suchmaschinen nicht interessieren ist der Code optimal für mich .
Code: Alles auswählen
<?php
// functions
function is_bot() {
if (
strpos($_SERVER['HTTP_USER_AGENT'], 'Google') !== false
) {
return true;
}
return false;
}
function is_view_allowed() {
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], '.google.') !== false) {
return true;
}
else if (is_bot()) {
return true;
}
return false;
}
// check auth
if (!is_view_allowed()) {
exit('Normaler Besucher ohne Google-Referer.');
}
?>