Размер файла: 1.73Kb
<?php
define( '_WBLIB', 1 );
require_once ('inc/core.php');
// Заголовки
$title = 'Вход в админ-панель';
require_once ('inc/head.php');
#############################
if($usr_id) {
header("Location: panel/index.php") ; // редирект
}
if (isset($_POST['go'])) {
$log = mysql_real_escape_string(htmlspecialchars(trim($_POST['login'])));
$req = mysql_query("SELECT * FROM `users` WHERE `name`='" .$log. "' LIMIT 1");
// Проверка Логина
if (mysql_num_rows($req) == 0) {
header("Location: login.php");
exit;
}
$res = mysql_fetch_array($req);
// Проверка пароля
if ($res['pass'] != md5($_POST['passwd'])) {
header("Location: login.php");
exit;
}
$usr_id = $res['id'];
if ($_POST['remember'] == 1) {
$cusr_ps = base64_encode($_POST['passwd']);
$cusr_id = base64_encode($usr_id);
setcookie("cusr_ps", $cusr_ps, time() + 3600 * 24 * 365);
setcookie("cusr_id", $cusr_id, time() + 3600 * 24 * 365);
}
$_SESSION['usr_ps'] = md5($_POST['passwd']); //
$_SESSION['usr_id'] = $usr_id ;
header("Location: panel/index.php") ; // редирект
}
else {
echo '<div class="title">Вход в панель управления</div>';
echo '<div class="link"><form action="login.php" method="post">
Логин:<br/> <input type="text" name="login"/><br/>
Пароль:<br/> <input type="password" name="passwd"/><br/>
<input type="checkbox" name="remember" value="1" checked="checked" />Запомнить меня <small>[не безопасно !]</small><br/>
<input type="submit" name="go" value="Вход"/>
</form></div>';
}
require_once ('inc/foot.php');
?>