<?php 


class count_model{
	public function update(){
function browser(){
$HTTP_B = $_SERVER['HTTP_USER_AGENT'];
$opera_mobi_if = strpos($HTTP_B,'Opera Mobi');
$Opera_if = strpos($HTTP_B,'Presto');
$Firefox_if = strpos($HTTP_B,'Firefox');
$Chrome_if = strpos($HTTP_B,'Chrome');
$safari_if = strpos($HTTP_B,'Safari');
$MSIE_if = strpos($HTTP_B,'MSIE');
$BlackBerry_if = strpos($HTTP_B,'BlackBerry');
$operaMini_if = strpos($HTTP_B,'Opera Mini');
$Netscape_if = strpos($HTTP_B,'Netscape');
$Ucweb_if = strpos($HTTP_B,'UCBrowser');
$Amaya_if = strpos($HTTP_B,'Amaya');
$Avant_Browser_if = strpos($HTTP_B,'Avant Browser');
$IE_MOB_if = strpos($HTTP_B,'IEMobile');
$Sea_Monkey_if = strpos($HTTP_B,'SeaMonkey');

if ($operaMini_if)		$us_browser='Opera Mini';//+
elseif ($Opera_if)		$us_browser='Opera';//+
elseif ($opera_mobi_if)	$us_browser='Opera Mobi';//+
elseif ($Firefox_if)		$us_browser='Mozilla Firefox';//+
elseif ($MSIE_if)		        $us_browser='IE';
elseif ($BlackBerry_if)	$us_browser='BlackBerry';
elseif ($Chrome_if)		$us_browser='Chrome';//+
elseif ($Ucweb_if)		$us_browser='UC Browser';//+
elseif ($Amaya_if)		$us_browser='Amaya';//+
elseif ($Avant_Browser_if)	$us_browser='Avant Browser';//+
elseif ($safari_if)		$us_browser='Safari';//+
elseif ($Netscape_if)		$us_browser='Netscape';
elseif ($IE_MOB_if)		$us_browser='IE Mobile';
elseif ($Sea_Monkey_if)	$us_browser='SeaMonkey';
else	                                $us_browser='Неизвестный';
return $us_browser;					
}
		$site = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
		if($site['ban']==0 ){
		if(Core::count("SELECT COUNT(*) FROM `ip` WHERE `ip` = ? && `id_site` = ?", array($_SERVER['REMOTE_ADDR'], $site['id'])) == false){
			Core::query("INSERT INTO `ip` SET `br`=?, `hit` = '1', `time` = '".time()."', `time_last` = '".time()."', `ip` = ?, `id_site` = ?", array(browser(), $_SERVER['REMOTE_ADDR'], $site['id']));
			Core::query("UPDATE `user_sites` SET `host` = '".($site['host'] + 1)."' WHERE `id` = ?", array($site['id']));
		}else{
		$ip = Core::query("SELECT * FROM `ip` WHERE `ip` = ? && `id_site` = ?", array($_SERVER['REMOTE_ADDR'], $site['id'])) -> fetch();
		Core::query("UPDATE `ip` SET `br`=?, `time` = '".time()."', `hit` = '".($ip['hit'] + 1)."'  WHERE `ip` = ? && `id_site` = ?", array(browser(), $_SERVER['REMOTE_ADDR'], $site['id']));
		}
		Core::query("UPDATE `user_sites` SET `hit` = '".($site['hit'] + 1)."' WHERE `id` = ?", array($site['id']));
		}
	}
}
?>