RedRabbit
Мой дом здесь!
- Регистрация
- 11 Июл 2008
- Сообщения
- 607
- Реакции
- 256
Google CDN images
Писал для себя.
Писал для себя.
Код:
<?php
function isBot(&$botname = ''){
$bots = array(
'rambler','googlebot','aport','yahoo','msnbot','turtle','mail.ru','omsktele',
'yetibot','picsearch','sape.bot','sape_context','gigabot','snapbot','alexa.com',
'megadownload.net','askpeter.info','igde.ru','ask.com','qwartabot','yanga.co.uk',
'scoutjet','similarpages','oozbot','shrinktheweb.com','aboutusbot','followsite.com',
'dataparksearch','google-sitemaps','appEngine-google','feedfetcher-google',
'liveinternet.ru','xml-sitemaps.com','agama','metadatalabs.com','h1.hrn.ru',
'googlealert.com','seo-rus.com','yaDirectBot','yandeG','yandex',
'yandexSomething','Copyscape.com','AdsBot-Google','domaintools.com',
'Nigma.ru','bing.com','dotnetdotcom','Googlebot-Mobile','Googlebot-Image','Mediapartners-Google','MSNBot-NewsBlogs','MSNBot-Products','MSNBot-Media','Slurp Yahoo! Slurp'
);
foreach($bots as $bot)
if(stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false){
$botname = $bot;
return true;
}
return false;
}
if( !isBot() ) {
if(@file_get_contents('http://googledrive.com/host/ID/')){
//echo "есть\t";
//echo $_SERVER['SERVER_NAME'];
//echo $_SERVER['HTTP_USER_AGENT'];
function google_cdn_img($content) {
$content = preg_replace( '/(<img)(.+?)(src=")(.+?images.+?)(".+?)>/', '$1$2$3$4$5 onError="this.onerror=null;this.src=\'$4\';">', $content );
$content = preg_replace( '/(<img)(.+?)(src=")(.+?images\/)(.+?)(".+?>)/', '$1$2$3http://googledrive.com/host/ID', $content );
return $content;
}
add_filter('the_content', 'google_cdn_img');
}
else {
//echo "нет.";
}
}