break; case "addbadword": if ($READ_ONLY_MODE === FALSE && $DEMO_MODE === FALSE && isset($_POST['word'])) { bad_word_add($_POST['word']); } show_bad_words_admin(); break; case "logout": // Kill session and force expire of session cookie on client $_SESSION = array(); if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 7200, '/'); } session_destroy(); // Redirect back to login page relative_location('../login.php'); exit; default: die('Invalid action.'); } } else { show_entries_admin(); } function show_logout_button() { ?> <div> <form method="post" action="index.php"> <p> <input type="hidden" name="action" value="logout" /> <input type="submit" value="Выход" class="submit" />
require_once dirname(__FILE__) . '/config.php'; require_once dirname(__FILE__) . '/strings.php'; $login_error = FALSE; if (isset($_POST['username']) && isset($_POST['password'])) { // Check credentials $username = $_POST['username']; $password = $_POST['password']; if ($username === $ADMIN_USERNAME && $password === $ADMIN_PASSWORD) { // Start session session_start(); $_SESSION['username'] = $username; $_SESSION['admin'] = "TRUE"; session_write_close(); // Redirect to admin page global $ADMIN_FOLDER; relative_location($ADMIN_FOLDER . "/"); exit; } else { $login_error = "Неправильный пароль."; } } // Render login page include_from_template('header.php'); ?> <?php if ($login_error !== FALSE) { echo "<p class=\"errorMessage\">" . htmlspecialchars_default($login_error) . "</p>"; } ?>