Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(isset($_GET['logout'])) {
- unset($_SESSION['isAdmin']);
- $redirectUrl = "index.php";
- $redirectMessage = <<<ENDL
- Выход.
- Нажмите на ссылку, если Ваш браузер не поддерживает перенаправление:
- <a href="{$redirectUrl}">Вернуться</a>.
- ENDL;
- header("Location: {$redirectUrl}");
- include WEB_ROOT.'/lib/redirect.php';
- exit;
- }
- if($_SESSION['isAdmin']) {
- $redirectUrl = "index.php";
- $redirectMessage = <<<ENDL
- Вы уже вошли.
- Нажмите на ссылку, если Ваш браузер не поддерживает перенаправление:
- <a href="{$redirectUrl}">Вернуться</a>.
- ENDL;
- header("Location: {$redirectUrl}");
- include WEB_ROOT.'/lib/redirect.php';
- exit;
- }
- if (!defined("WEB_ROOT")) {
- define("WEB_ROOT", realpath(dirname(__FILE__)."/./"));
- }
- require_once WEB_ROOT.'/config/config.php';
- require_once WEB_ROOT.'/lib/HTML/FormPersister.php';
- ob_start(array('HTML_FormPersister', 'ob_formpersisterhandler'));
- $errors = array();
- if(isset($_POST['doSend'])) {
- $user = array();
- if(!isset($_POST['login']) || empty($_POST['login'])) {
- $errors['login'] = "Данное поле должно быть заполнено!";
- }
- else {
- $user['login'] = $_POST['login'];
- }
- if(!isset($_POST['pass']) || empty($_POST['pass'])) {
- $errors['pass'] = "Данное поле должно быть заполнено!";
- }
- else {
- $user['pass'] = $_POST['pass'];
- }
- if(empty($errors)) {
- $userId = $DATABASE->selectCell(
- 'SELECT id FROM ?_users WHERE name=? AND pass=? AND is_admin = 1', $user['login'], md5($user['pass'])
- );
- if(empty($userId)) {
- $errors['common'] = "Пользователь с такими данными не существует!";
- }
- else {
- $_SESSION['isAdmin'] = $userId;
- $redirectUrl = "index.php";
- $redirectMessage = <<<ENDL
- Вы успешно вошли.
- Нажмите на ссылку, если Ваш браузер не поддерживает перенаправление:
- <a href="{$redirectUrl}">Вернуться</a>.
- ENDL;
- header("Location: {$redirectUrl}");
- include WEB_ROOT.'/lib/redirect.php';
- exit;
- }
- }
- unset($_POST['pass']);
- }
- ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
- <title><?php echo PROJECTNAME; ?></title>
- <link rel="stylesheet" type="text/css" href="css/main.css" media="screen" />
- </head>
- <body class="main_body">
- <?php if(isset($errors['common'])) : ?>
- <div class="errors"><?php echo htmlspecialchars($errors['common']); ?></div>
- <?php endif; ?>
- <form method="post">
- <table align="center" width="300" cellpadding="0" cellspacing="1" bgcolor="#cccccc" border="0" class="t_films">
- <tr>
- <td width="30%">
- Логин:
- </td>
- <td>
- <input type="text" maxlength="50" name="login" class="i_login" />
- <?php if(isset($errors['login'])) : ?>
- <div class="errors"><?php echo htmlspecialchars($errors['login']); ?></div>
- <?php endif; ?>
- </td>
- </tr>
- <tr>
- <td>
- Пароль:
- </td>
- <td>
- <input type="password" maxlength="50" name="pass" class="i_pass" />
- <?php if(isset($errors['pass'])) : ?>
- <div class="errors"><?php echo htmlspecialchars($errors['pass']); ?></div>
- <?php endif; ?>
- </td>
- </tr>
- <tr><td> </td><td><input type="submit" name="doSend" value="Войти" /></td></tr>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement