<?PHP
ini_set("display_errors",0);
error_reporting(E_ALL); 

# Фильтрация глобальных переменных :
$_SERVER['HTTP_HOST'] = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
$_SERVER['HTTP_USER_AGENT'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? trim( $_SERVER['HTTP_USER_AGENT'] ) : null;
$_SERVER['HTTP_REFERER'] = isset( $_SERVER['HTTP_REFERER'] ) && filter_var( $_SERVER['HTTP_REFERER'], FILTER_VALIDATE_URL ) ? trim( $_SERVER['HTTP_REFERER'] ) : null;

# Счетчик
function TimerSet(){
	list($seconds, $microSeconds) = explode(' ', microtime());
	return $seconds + (float) $microSeconds;
}

$start_counter = TimerSet();

# Старт сессии
@session_start();
# Старт буфера
@ob_start();
# Константа для Include
define("beerman", true);

function check_xss() {
	$url = html_entity_decode( urldecode( $_SERVER['QUERY_STRING'] ) );
	$url = str_replace( "\\", "/", $url );
	if(isset($url) && (strpos( $url, '<' ) !== false) || (strpos( $url, '>' ) !== false) || (strpos( $url, '"' ) !== false) || (strpos( $url, './' ) !== false) || (strpos( $url, '../' ) !== false) || (strpos( $url, '\'' ) !== false) || (strpos( $url, '.php' ) !== false) ) {
		die("Hacking attempt!");
	}
	$url = html_entity_decode( urldecode( $_SERVER['REQUEST_URI'] ) );
	$url = str_replace( "\\", "/", $url );
	if(isset($url) && (strpos( $url, '<' ) !== false) || (strpos( $url, '>' ) !== false) || (strpos( $url, '"' ) !== false) || (strpos( $url, '\'' ) !== false) ) {
		die("Hacking attempt!");
	}
}
check_xss();

# Тут вставляем в куки ID referera
if(isset($_GET["r"])){
$_rid = (intval($_GET["r"]) > 0) ? intval($_GET["r"]) : 1; 
setcookie("referer",$_rid,time()+2592000);
}
#откуда пришел
if($_SERVER['HTTP_REFERER'] != ''){
setcookie("ref_site",$_SERVER['HTTP_REFERER'],time()+2592000);
}
if(!isset($_COOKIE["vblock1"])) setcookie("vblock1","0",time()+2592000);
if(!isset($_COOKIE["vblock2"])) setcookie("vblock2","0",time()+2592000);
if(!isset($_COOKIE["vblock3"])) setcookie("vblock3","0",time()+2592000);
if(!isset($_COOKIE["vblock4"])) setcookie("vblock4","0",time()+2592000);
if(!isset($_COOKIE["vblock5"])) setcookie("vblock5","0",time()+2592000);

require_once('profilaction.php');

if(!isset($_SESSION["username"]) and !isset($_SESSION["iduser"])){
$p_array = array('/comp.php','/top20.php','/support.php','/comp_day.php','/contact.php','/blacklist.php','/policy.php','/faq.php','/tos.php','/register.php','/login.php','/index.php','/news.php','/profit.php','/pay_money.php','/wall_user.php','/stat-reyt.php','/add_dinam_bez.php');
if (!in_array($_SERVER['PHP_SELF'], $p_array)) {
header('Location: /index.html');
}
}

require_once($_SERVER['DOCUMENT_ROOT'].'/sfb.php');

include_once('blocks/head.php');
?>