Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-type: text/html; charset=utf-8');
- error_reporting(E_ALL);
- session_start();
- $users = array('stas' => '40bd001563085fc35165329ea1ff5c5ecbdbbeef');
- $codes = unserialize(file_get_contents('touch.txt');
- if(empty($_SESSION['username']))
- {
- if(empty($_POST['ok']))
- {
- $content = '<label>Логин<input name="username"></label><br>
- <label>Пароль<input type="password" name="password"></label><br>
- <input type="submit" name="ok" value="Во имя Стаса!!!">';
- }
- else
- {
- foreach($users as $username => $password)
- if($username == $_POST['username'] && $password == sha1($_POST['password']))
- $_SESSION['username'] = $username;
- if(empty($_SESSION['username']))
- {
- header('HTTP/1.1 404 Not Found');
- die('404');
- }
- else
- header('location: ' . $_SERVER['HTTP_REFERER']);
- }
- }
- else
- {
- if(!empty($_POST['leave']))
- {
- session_unset();
- session_destroy();
- header('location: ' . $_SERVER['HTTP_REFERER']);
- }
- if(empty($_POST['role']))
- {
- $content = 'Welcome home, ' . $_SESSION['username'] . '! Choose your fate<br>
- <input type="submit" name="role" value="admin"> 
- <input type="submit" name="role" value="student"> 
- <input type="submit" name="role" value="teacher"> ';
- }
- else
- {
- if(!empty($_POST['code']) && !empty($_POST['role']) && array_key_exists($_POST['role'], $codes))
- {
- if($codes[$_POST['role']] == sha1($_POST['code']))
- $content = '42';
- else
- {
- header('HTTP/1.1 404 Not Found');
- die('404');
- }
- }
- else
- {
- $content = 'Для получения доступа к источнику вечной радости и вселенской мудрости введите сверхсекретный суперкод<br>
- <input type="password" name="code">
- <input type="hidden" name="role" value="' . $_POST['role'] . '">
- <input type="submit" name="ok" value="Заглотнуть космической энергии">';
- }
- }
- $content .= '<input type="submit" name="leave" value="пс, парень, не хочешь начать с чистого листа?" style="position: absolute; right: 0; top: 0">';
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Стас ван лав!!!11 <333</title>
- </head>
- <body style="text-align: center; padding-top: 200px">
- <form action="" method="post">
- <?php echo $content; ?>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment