<?php 


class stat{
		public function plus(){	
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
		require_once  MODEL.'stat.class.php';
		$obj = new stat_model();
                $obj -> plus();
		
		Template::run(__CLASS__, 'plus');
	}
	
		public function minus(){	
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
		require_once  MODEL.'stat.class.php';
		$obj = new stat_model();
		$obj -> minus();
		
		Template::run(__CLASS__, 'minus');
	}

		public function graphic(){
		if(isset($_GET['get'])){
			Template::run(__CLASS__, 'graphic');
		}
	}
			public function browser(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
			Template::head(Protect::title('Статистика по браузерам '.$title['url']));
			Template::run(__CLASS__, 'browser');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}
		public function week(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
			Template::head(Protect::title('Статистика по дням '.$title['url']));
			Template::run(__CLASS__, 'week');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}
	
			public function ip(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
			Template::head(Protect::title('Статистика по ip '.$title['url']));
			Template::run(__CLASS__, 'ip');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}
				public function hours(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
			Template::head(Protect::title('Статистика по часам '.$title['url']));
			Template::run(__CLASS__, 'hours');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}
	
					public function online(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
Template::head(Protect::title('Статистика по онлайну '.$title['url']));
			Template::run(__CLASS__, 'online');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}

	public function index(){
		if(isset($_GET['get']) && Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) == true){
			$title = Core::query("SELECT * FROM `user_sites` WHERE `id` = ?", array($_GET['get'])) -> fetch();
                        Template::head(Protect::title($title['title']));
			Template::run(__CLASS__, 'index');
			Template::foot();
		}else{
			Core::redirect('/cabinet', 'Сайт не найден');
		}
	}
}
?>