<?
require_once ('system/func.php');
noauth();

$title='Авторизация';
require_once ('system/header.php');
if(isset($_REQUEST['auth']))
{
$name = text($_POST['login']);
$pass = text($_POST['password']);
$sql = mysql_fetch_array(mysql_query("SELECT `login`,`password` FROM `users` WHERE `login` = '".mysql_real_escape_string($name)."' and `password`='".md5($pass)."' LIMIT 1"));
if (empty($name)) msg ('Введите Логин');
else if (empty($pass)) msg ('Введите Пароль');
elseif($sql == 0) msg('Такой пользователь не найден');

else
{


setcookie('login', $name, time()+86400*365, '/');
setcookie('password', _hash(sha1($pass.'123abc')), time()+86400*365, '/');
$_SESSION['msg'] = "Авторизация успешна";
header('Location: /');
exit();
}
}
?>
<div class="mess_blue">Авторизация</div>
<div class="block-border-top"></div>
<div class="auth_logo"></div>
<form class="cont_ent" action="" method="post">
<div class="mess_text">Введите логин</div>
<input class="form_text" type="text" name="login" maxlength="10" value="" placeholder="" />
<div class="mess_text">Введите пароль</div>
<input class="form_text" type="password" name="password" maxlength="20" value="" placeholder="" />
<input type="submit" class="btn_login" name="auth" value="Авторизация">
</form>
<a href="/pass.aspx" class="btn" title="Забыли пароль ?"><div class="icn mail"></div>Забыли пароль ?</a>

<?


require_once ('system/footer.php');
?>