Файл: pages/vhod.php
Строк: 63
<?php # Created by Up
include_once '../sistem/start.php';
include_once $config['OTS'].'sistem/config.php';
include_once $config['OTS'].'sistem/function.php';
include_once $config['OTS'].'sistem/db.php';
include_once $config['OTS'].'sistem/users.php';
if(isset($_SESSION['id']) and isset($_SESSION['pass']) and $_SESSION['id']>=1)
{
header('location: '.$config['home'].'/pages/adm.php');
exit;
}
$error='';
if(isset($_POST['go_vhod']))
{
if(!$error=get_rand($_POST['code']))
{
if(!empty($_POST['mail']))
{
if(!empty($_POST['pass']))
{
unset($_SESSION['rand']);
$brauser=mysql_real_escape_string(substr(htmlspecialchars($_SERVER['HTTP_USER_AGENT']),0,100));
$mail=mysql_real_escape_string(htmlspecialchars(strtolower($_POST['mail'])));
$pass=md5(trim($_POST['pass']));
if(mysql_num_rows($sql=mysql_query('SELECT * FROM `users` where `mail`=''.$mail.'' and `pass`=''.$pass.'' LIMIT 1;'))==1)
{
$arr=mysql_fetch_assoc($sql);
$time=(time()+(60*60*24*30*12));
SetCookie('pass',base64_encode(str_cr($arr['pass'],$arr['crypt_key'])),$time);
SetCookie('id',$arr['id'],$time);
$_SESSION['pass']=$arr['pass'];
$_SESSION['id']=$arr['id'];
$_SESSION['adm_rezim']=1;
mysql_unbuffered_query('UPDATE `users` SET `brauser`=''.$brauser.'' WHERE `id`=''.$arr['id'].'' LIMIT 1;');
header('location: '.$config['home'].'/pages/adm.php');
exit;
}
else
$error='Не верный логин или пароль!';
}
else
$error='Не введен пароль!';
}
else
$error='Не введен E-Mail адрес!';
}
}
$config['TITLE']='Авторизация';
include_once $config['OTS'].'sistem/head.php';
print empty($error)?'':'<span class="err">'.$error.'</span><br />';
print '<form action="vhod.php" method="POST">';
print 'E-Mail:<br /><input type="text" name="mail" value="" /><br />';
print 'Пароль:<br /><input type="password" name="pass" value="" /><br />';
print 'Код с картинки:<br /><img src="'.$config['home'].'/in/code_'.session_id().'.gif" alt="Загрузка..." /><br /><input type="text" size="6" name="code" value="" /><br />';
print '<input type="submit" class="submit" name="go_vhod" value="Авторизация" /><br /></form>';
print '<a href="vspomnit.php">Забыли пароль</a>?<br />';
print '<a href="reg.php">Регистрация</a><br />';
include_once $config['OTS'].'sistem/foot.php';
?>