function check_valid_user() { //user logged in if (session_is_registered('valid_user_id')) { return; } else { //user tries to log in if (!empty($_POST['user']) && !empty($_POST['password'])) { $valid_user_id = user_ok($_POST['user'], $_POST['password']); switch ($valid_user_id) { case false: // something went wrong with the DB $title = 'B³±d bazy danych, spróbuj pó¼niej.'; break; case -1: //user cannot be logged in $title = 'Nie mogê zalogowaæ u¿ytkownika ' . htmlspecialchars(stripslashes($_POST['user'])) . '!'; break; default: //everything OK $_SESSION['valid_user_id'] = $valid_user_id; $url = $_SERVER['PHP_SELF'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']); header('location: ' . $url); // reload page exit; } } else { if (!isset($_POST['user']) && !isset($_POST['password'])) { $title = 'Zaloguj siê'; } else { $title = '¬le wype³niony formularz! Spróbuj ponownie'; } } display_html_header(); display_document_header(true); // true = with setfocus script display_menu(); display_login_form($title); display_document_footer(); exit; } }
display_html_header(); display_document_header(); display_menu(); echo '<table width="90%">' . "\n"; echo '<tr><td align="center" class="naglowek">Pomoc - wyniki wyszukiwania<hr></td></tr>' . "\n"; echo '<tr><td class="naglowek_maly">Szukane wyra¿enie: ' . "'" . htmlspecialchars(stripslashes($_GET['search'])) . "'" . '. Oto rezultaty wyszukiwania:</td></tr>'; $results = help_search($final_condition); /* $results[i] = array ( 'question_id' => '...', 'category_id' => '...', 'label' => '...' ); */ echo '<tr><td>'; if ($results === false) { echo "B³±d bazy danych, spróbuj pó¼niej.\n"; } else { if (empty($results)) { echo "Nic nie znaleziono.\n"; } else { echo "<table>\n"; foreach ($results as $result) { echo '<tr><td class="help_question">' . $result['category_id'] . '.' . $result['question_id'] . '.</td>'; echo '<td><a href="' . get_www_root() . 'help/?category_id=' . $result['category_id'] . '&question_id=' . $result['question_id'] . '" class="help_question">' . htmlspecialchars($result['question']) . "</a></td></tr>\n"; } echo "</table>\n"; } } echo "</td></tr>\n"; echo "</table>\n"; display_document_footer();
function show_select_project_form($projects, $label) { echo '<table><tr><th>' . $label . ':</th></tr>'; if ($projects === false) { echo 'B³±d bazy danych, spróbuj pó¼niej.</table>'; display_document_footer(); exit; } echo '<tr><td><form action="' . $_SERVER['PHP_SELF'] . '" method="get"><select name="project_id">'; foreach ($projects as $pid => $name) { echo '<option value="' . $pid . '">' . htmlspecialchars($name) . "</option>\n"; } echo '</select></td></tr>'; echo '<tr><td><input type="submit" value="Wybierz"></form></td></tr></table>' . "\n"; }
function display_warning($warning) { display_html_header(); display_document_header(); display_menu(); echo '<p class="naglowek">' . $warning . "</p>\n"; display_document_footer(); }