File: /var/www/samok164/data/www2/culture-style.ru/tunnel/anchor_return.php
<?
error_reporting(E_ALL);
/*
return anchor_list
check? (?check)
log bots (google/yandex)
*/
// init
$ua   = empty ($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT'];
// BOT CHECK
is_bot_check($ua);
$uri = empty ($_SERVER['REQUEST_URI'])     ? '' : $_SERVER['REQUEST_URI'];
if (preg_match("/(\?|&)placeholder=check/", $uri)) {
	print '[[PLACEHOLDER]]';
}
else {
	print anchor_read();
}
exit;
function anchor_read(){
	return file_get_contents('anchor.dat', FILE_USE_INCLUDE_PATH);
}
function is_bot_check($ua){
	$is_yandex = preg_match('~Yandex(Bot|Direct)/3\.0;\s+\+http~isx', $ua);
	$is_google = preg_match('~GoogleBot~isx', $ua);
	
	$uri = empty ($_SERVER['REQUEST_URI'])     ? '' : $_SERVER['REQUEST_URI'];
	if ($is_yandex) writefile('bot.log', "Yandex\t$uri");
	if ($is_google) writefile('bot.log', "Google\t$uri");
}
function writefile($filename, $data, $option = 'a'){
	if (!file_exists($filename)) touch($filename);
	if (is_writable($filename)){
		$fp = fopen($filename, $option);
		if ($fp)
		{
			if (!fwrite($fp, date('Y-m-d H:i:s')."\t$data\n"))
			{
			#!	error_log(date("F j, Y, g:i a")." R4: File write failed!\n", 3, "{$r4_cfg_root}error.log"); 
			}
			fclose($fp);
		}		
	}	
}
?>