Размер файла: 1.86Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729 */
/* Site: http://ticlove.ru */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/../_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/../_inc/function.php'); ?>
<?php
if (isset($_POST['action']))
{
$login = mysql_real_escape_string(trim($_POST['login']));
$pass = mysql_real_escape_string(trim($_POST['pass']));
$sql = mysql_query("SELECT * FROM `q_users` WHERE `login` = '".$login."' AND `pass` = '".md5($pass)."' LIMIT 1;");
if (empty($login)) $error = 'Введите логин';
else if (empty($pass)) $error = 'Введите пароль';
else if (mysql_num_rows($sql) == false) $error = 'Логин или пароль неверны';
if (empty($error))
{
$user = mysql_fetch_array($sql);
if ($_POST['save'] == 1)
{
$id = base64_encode($user['id_user']);
$p = base64_encode($pass);
$date_end = (time() + (3600 * 24 * 365));
setcookie('auth_id', $id, $date_end, '/', $_SERVER["HTTP_HOST"]);
setcookie('auth_pass', $p, $date_end, '/', $_SERVER["HTTP_HOST"]);
}
$_SESSION['auth_id'] = $user['id_user'];
$error = '<script type="text/javascript">location="/";</script>';
}
else
{
$date_end = (time() - (3600 * 24 * 365));
setcookie('auth_id', $id, $date_end, '/', $_SERVER["HTTP_HOST"]);
setcookie('auth_pass', $p, $date_end, '/', $_SERVER["HTTP_HOST"]);
}
echo $error;
}
?>