<?php

include '../inc/head.php';

if(isset($_SESSION['auth']) and $_SESSION['auth']==1){

echo '
<div style="padding:1px 5px 1px 5px;font-weight:bold;font-size:11px;background:#eee;margin-bottom:1px;">Админка</div>
<a href="/?">Главная</a><br>
<a href="?act=exit">Выход</a><br>
';

if($_GET['act']=="exit"){

unset($_SESSION['login']);
unset($_SESSION['password']);
unset($_SESSION['auth']);

}


}else{

switch($_GET['act']){

default:

echo '
<div style="padding:1px 5px 1px 5px;font-weight:bold;font-size:11px;background:#eee;margin-bottom:1px;">Вход в админку</div>
<form action="?act=enter" method="post">
Логин<br>
<input name="login"/><br>
Пароль<br>
<input name="password"/><br>
<input type="submit" value="Вход"/>
</form>
';

break;

case 'enter':

$login = $_POST['login'];
$password = $_POST['password'];

if(empty($login) or empty($password)){

header ("Location: /?"); exit;

}


if($login=="3KZO" && $password=="123456789"){

$_SESSION['login']=$user['login'];
$_SESSION['password']=$user['password'];
$_SESSION['auth']=1;

header ("Location: /index.php"); exit;

}else{

header ("Location: /?"); exit;

}

break;

}

}

include '../inc/foot.php';

?>