<?php
ob_start();
require_once '../inc/mysqli.php';
include '../inc/functions.php';

$title = 'Админка';

include '../inc/head.php';
echo '<div class="left-menu">';

if($_COOKIE['auth'] == true){
	
	echo '<div class="main-block">
	<div class="block-title"><h1>Статистика</h1><img src="'.URL.'style/img/title.png" alt=""></div>';
	
}else{
	
	if(!empty($_POST['password'])){
		if(set('admin', $db) != $_POST['password']){
			header('Location: /admin/'); exit;
		}
		
		setcookie('auth', true, time()+(((60*60)*24)*365), '/');
		header('Location: /admin/');
	}
	
	echo '<div class="main-block">
	<div class="block-title"><h1>Авторизация</h1><img src="'.URL.'style/img/title.png" alt=""></div>
	<form action="" method="POST">
	<input class="form-control" style="max-width:250px" type="password" name="password" placeholder="Пароль">
	<input class="btn btn-lg btn-primary" name="submit" type="submit" value="войти">
	</form>';
}

echo '</div></div>';
include '../inc/right.php';
include '../inc/foot.php';
?>