function show_bad_word_add_form() { global $MAX_BAD_WORD_LENGTH; ?> <form method="post" action="index.php"> <fieldset> <legend><?php echo htmlspecialchars_default("Добавить слово"); ?> </legend> <p> <label for="word">Слово:</label> <input type="text" name="word" id="word" maxlength="<?php echo htmlspecialchars_default($MAX_BAD_WORD_LENGTH); ?> " class="inputText" /> </p> <input type="hidden" name="action" value="addbadword" class="submit" /> <input type="submit" value="Добавить" class="submit" /> </fieldset> </form> <?php }
function show_entry_count() { echo htmlspecialchars_default(get_guestbook_entries_count()); }
function guestbook_add($entry) { global $READ_ONLY_MODE; global $dbs_error; if (guestbook_validate($entry)) { if ($READ_ONLY_MODE === TRUE) { $dbs_error = htmlspecialchars_default("This guestbook is in read-only mode."); return FALSE; } $now = gmstrftime(time()); $ipaddress = $_SERVER['REMOTE_ADDR']; if (is_flood_detected($ipaddress)) { global $ERROR_MSG_FLOOD_DETECTED; $dbs_error = htmlspecialchars_default($ERROR_MSG_FLOOD_DETECTED); return FALSE; } $entry_stripped = array_map("strip_tags", $entry); $entry_encoded = array_map("rawurlencode", $entry_stripped); // Create file if it does not exist if (!file_exists(guestbook_file_path())) { if (touch(guestbook_file_path()) === FALSE) { $dbs_error = htmlspecialchars_default("Unable to create guestbook file in data folder."); return FALSE; } } // Get existing entries if (guestbook_open_for_read() === FALSE) { // Acquires shared lock on guestbook file $dbs_error = htmlspecialchars_default("Unable to open guestbook file for reading."); return FALSE; } $oldContents = @file_get_contents(guestbook_file_path()); guestbook_close(); // Releases shared lock if ($oldContents === FALSE) { $dbs_error = htmlspecialchars_default("Unable to get guestbook file contents."); return FALSE; } $nextId = guestbook_next_id(); if (guestbook_open_for_writing() === FALSE) { $dbs_error = htmlspecialchars_default("Unable to open guestbook file for writing."); return FALSE; } // If moderation is enabled, all posts must be approved global $MODERATION_ENABLED; $approved = $MODERATION_ENABLED !== TRUE; // Write new entry global $guestbook_fp; fputs($guestbook_fp, $nextId . "|" . value_or_blank($entry_encoded, 'name') . "|" . value_or_blank($entry_encoded, 'email') . "|" . value_or_blank($entry_encoded, 'url') . "|" . value_or_blank($entry_encoded, 'comments') . "|" . $now . "|" . $ipaddress . "|" . ($approved ? 'true' : 'false') . "\n"); // Append existing entries to file fputs($guestbook_fp, $oldContents); unset($oldContents); // Free memory guestbook_close(); // Update entry count set_guestbook_entries_count(); // Send notification global $ADMIN_EMAIL_ADDRESS; if (isset($ADMIN_EMAIL_ADDRESS) && !empty($ADMIN_EMAIL_ADDRESS)) { if (mail($ADMIN_EMAIL_ADDRESS, ($approved ? "" : "PLEASE MODERATE: ") . "Новая запись в гостевой книге: " . value_or_blank($entry_stripped, 'name'), ($approved ? "" : "Пожалуйста, подтвердите или удалите запись:\n") . "Имя: " . value_or_blank($entry_stripped, 'name') . "\n" . "E-Mail: " . value_or_blank($entry_stripped, 'email') . "\n" . "URL-адрес: " . value_or_blank($entry_stripped, 'url') . "\n" . "Комментарии: \n" . value_or_blank($entry_stripped, 'comments'), "MIME-Version: 1.0\r\nContent-type: text/plain; charset=UTF-8\r\nFrom: " . $ADMIN_EMAIL_ADDRESS . "\r\n") !== TRUE) { $dbs_error = htmlspecialchars_default("Unable to send notification."); return FALSE; } } return TRUE; } return FALSE; }
function the_site_title() { global $SITE_TITLE; echo htmlspecialchars_default($SITE_TITLE); }
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>"; } ?> <form method="post" action="login.php"> <fieldset> <legend>Панель администрирования</legend> <p> <label for="username">Логин:</label> <input type="text" name="username" id="username" class="inputText" value="admin" readonly /> <br /> <label for="password">Пароль:</label> <input type="password" name="password" id="password" class="inputText" /> </p> <input type="submit" value="Login" class="submit" />