HEX
Server: Apache/2.4.6 (CloudLinux) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16
System: Linux s1.gigspace.ru 3.10.0-962.3.2.lve1.5.77.el7.x86_64 #1 SMP Mon Dec 12 07:06:14 EST 2022 x86_64
User: samok164 (6070)
PHP: 7.2.34
Disabled: NONE
Upload Files
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);
		}		
	}	
}


?>