<?
//PERFORMANCE test
if($CONF->SHOW_PGT==true) {
	function GetMicroTime() {
	    list($usec, $sec) = explode(" ",microtime());
	    return (float)$usec+(float)$sec;
	}
	$SYS_TIME_START=GetMicroTime();
}


//FORCE www.
if($CRON!=true && $CONF->FORCE_DOMAIN_WWW==true && !stristr($_SERVER['HTTP_HOST'],'www.') && !LOCALHOST) { header('Location: https://www.'.DOMAIN.URL, false, 301); exit; }

if($CRON!=true) {
	header("Strict-Transport-Security: max-age=31536000; preload");

	if($_SERVER['HTTPS']!='on' || $_SERVER['SERVER_PORT']!=443 || !stristr($_SERVER['HTTP_HOST'],'www.')) {
		header('Location: https://www.'.DOMAIN.URL, false, 301); exit;
	}
}


//CORRECT 1st domain[]
if($CONF->FORCE_DOMAIN_PRIMARY==true && !LOCALHOST && DOMAIN!=$CONF->SYS_DOMAINS[0] && $_POST['master_com']!=true) { header('Location: https://www.'.$CONF->SYS_DOMAINS[0].URL, false, 301); exit; }



if($SKIP_SESSION_START!=true) {
	if(!empty($_GET['SID'])) @session_id($_GET['SID']);
	session_start();
	define('SID', session_id());
}
require_once(LIBS_PATH.'/system/error_handler.php');



//GET browser info
$agent=strtolower($_SERVER['HTTP_USER_AGENT']);
$known_browsers = array("firefox", "msie", "opera", "chrome", "safari", "mozilla", "seamonkey", "konqueror", "netscape", "gecko", "navigator", "mosaic", "lynx", "amaya", "omniweb", "avant", "camino", "flock", "aol");
foreach($known_browsers as $browser) {
	if(preg_match("#($browser)[/ ]?([0-9.]*)#", $agent, $match)) {
		$name=$match[1];
		$version=$match[2];
		if($name=='msie') $name='ie';
		if($name=='safari' && preg_match("#(version)[/ ]?([0-9.]*)#", $agent, $match)) $version=$match[2];
		break;
	}
}
$full_name=ucfirst($name);
if($name=='ie') $full_name='Internet Explorer';

$CONF->BROWSER['name']=$name;
$CONF->BROWSER['full_name']=$full_name;
$CONF->BROWSER['version']=$version;
$CONF->BROWSER['major_version']=(int)$version;
$CONF->BROWSER['agent']=$_SERVER['HTTP_USER_AGENT'];
$CONF->MAC = (stristr($_SERVER['HTTP_USER_AGENT'], 'macintosh') || stristr($_SERVER['HTTP_USER_AGENT'], 'mac os x') ? 1:0);
$CONF->MAC_MOBILE = (($CONF->MAC && stristr($_SERVER['HTTP_USER_AGENT'], 'mobile/')) ? 1:0);
if($CONF->MAC==true) $CONF->BROWSER['special'].=' [MAC]';
if($CONF->MAC_MOBILE==true) $CONF->BROWSER['special'].=' [MOB]';
?>