function getcomEvents() { // извлекаем события сегодняшнего дня и будущие, которые пользователь разрешил показывать гостям, формируем список и ссылки на них $query = "SELECT event_name, event_startdate, event_city, event_address, event_id FROM events WHERE event_startdate >= CURDATE( ) and event_show_guest = 'yes' limit 10"; $result = $this->mMysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $event_id = $row['event_id']; $event_names = $row['event_name']; $url = "event.php?event_id=" . $event_id; $title = $event_names; ?> <div class="comment"> <div class="comment-avatar"></div> <div class="comment-name">Название мероприятия <?php do_html_url($url, $title); ?> </div> <div class="comment-text"> <?php $this->event_city = $row['event_city']; $this->event_address = $row['event_address']; echo ' ' . $row['event_city'] . ' ' . $row['event_address'] . '<br/>'; ?> <div class="comment-date"> <?php $this->event_startdate = $row['event_startdate']; echo ' ' . $row['event_startdate'] . '<br/>'; ?> </div></div> </div> <?php } $result->close(); }
function check_valid_user() { if (isset($_SESSION['valid_user'])) { echo "Logged in as " . $_SESSION['valid_user'] . ".<br />"; } else { do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login.php', 'Login'); do_html_footer(); exit; } }
function check_valid_user() { if (isset($_SESSION['valid_user'])) { echo 'Logged in as ' . $_SESSION['valid_user'] . '.'; echo '<br />'; } else { // they are not logged in do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login', 'Login'); exit; } }
function register($name, $passwd) { $db = db_connect(); $query = "select * from members where name='" . $name . "'"; $result = $db->query($query); if ($result->num_rows > 0) { echo "the name already exits."; do_html_url('blog/register', 'Back to register'); exit; } $query = "insert into members(name, passwd) values('" . $name . "','" . $passwd . "')"; $result = $db->query($query); return $result; }
function check_valid_user() { // see if somebody is logged in and notify them if not if (isset($_SESSION['valid_user'])) { echo "Logged in as " . $_SESSION['valid_user'] . ".<br />"; } else { // they are not logged in do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login.php', 'Login'); do_html_footer(); exit; } }
function getFriends($user_id) { // друзья пользователя $query = "SELECT concat (user_name, ' ', family_name) AS fr, user_id from users" . " WHERE user_id IN " . "(SELECT friend_number FROM friends" . " WHERE user_number =\"{$user_id}\")"; $result = $this->mMysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $user_id = $row['user_id']; $spisok = $row['fr']; $url = "user.php?user_id=" . $user_id; $title = $spisok; do_html_url($url, $title); } $result->close(); }
function check_valid_user() { global $HTTP_SESSION_VARS; if (isset($HTTP_SESSION_VARS['valid_user'])) { echo 'Logged in as ' . $HTTP_SESSION_VARS['valid_user'] . '.'; echo '<br />'; } else { // they are not logged in do_html_heading('Problem:'); echo 'You are not logged in.<br />'; do_html_url('login.php', 'Login'); do_html_footer(); exit; } }
function check_valid_user() { global $valid_user; if (session_is_registered("valid_user")) { echo "Logged in como {$valid_user}."; echo "<br>"; } else { // they are not logged in do_html_heading("Problema:"); echo "No estás logged in.<br>"; do_html_url("login.php", "Login"); do_html_footer(); exit; } }
function getUsers() { // получаем список пользователей и их номер $query = "SELECT concat (user_name, ' ', family_name) AS fr, user_id from users"; // execute the query $result = $this->mMysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $user_id = $row['user_id']; $spisok = $row['fr']; $url = "user.php?user_id=" . $user_id; $title = $spisok; // функция из библиотеки функций, формирует страницы пользователей и ссылки на них do_html_url($url, $title); } $result->close(); }
function check_valid_user() { //checks that current user has a registered session. This is aimed at users who have not just logged in, //but are mid-session. So does not connect to db again //see if somebody is logged in and notify them if not if (isset($_SESSION["valid_user"])) { echo ""; echo "Logged in as " . $_SESSION["valid_user"] . ".<br /n>"; } else { //they are not logged in do_html_header("Problem: "); echo "You are not logged in. <br />"; do_html_url("login.php", "Login"); do_html_footer(); exit; } }
function getEvents() { // what SQL query you want executed? $query = "SELECT event_name, event_startdate, event_city, event_address, event_id FROM events WHERE event_startdate >= CURDATE( )"; // execute the query $result = $this->mMysqli->query($query); while ($row = $result->fetch_array(MYSQLI_ASSOC)) { $event_id = $row['event_id']; $event_names = $row['event_name']; $url = "event.php?event_id=" . $event_id; $title = $event_names; do_html_url($url, $title); $this->event_startdate = $row['event_startdate']; $this->event_city = $row['event_city']; $this->event_address = $row['event_address']; echo ' ' . $row['event_startdate'] . '<br/>'; echo ' ' . $row['event_city'] . ' ' . $row['event_address'] . '<br/>'; $a = $row['event_startdate']; $b = $row['event_city']; echo $a . $b; } $result->close(); }
<?php include 'functions.php'; session_start(); do_html_header('Register'); if ($_POST['name'] && $_POST['passwd']) { $name = $_POST['name']; $passwd = $_POST['passwd']; $result = register($name, $passwd); if ($result) { echo "register successfully."; $_SESSION['author'] = $name; header('Location:http://127.0.0.1/blog'); } else { echo "Can't register now, please try again later."; do_html_url('blog/register.php', 'Back to register'); } } ?> <form action="register.php" method="post"> Username:<input type="text" name="name" /><br> Password:<input type="password" name="passwd" /><br> <input type="submit" value="submit" /> </form> <?php do_html_footer();
<?php include 'functions.php'; session_start(); check_valid_user(); do_html_header('Blog', array('ajax_functions.js')); $_SESSION['author_id'] = get_authorid($_SESSION['author']); $result = get_entries($_SESSION['author_id']); display_entries($result); do_html_url('blog/write_post.php', 'Write post'); do_html_url('blog/logout.php', 'logout'); do_html_footer();
$password = $_POST['password']; // echo "请输入用户名或密码"; // do_html_url('login.php','请重新登录'); $db = db_connect(); $query = "select * from user where username = '******' and passwd = '" . $password . "'"; $result = $db->query($query); //var_dump($result); $result_num = $result->num_rows; if ($result_num > 0) { //成功执行SELECT, SHOW, DESCRIBE或 EXPLAIN查询会返回一个mysqli_result 对象,其他查询则返回TRUE //SELECT查询后即使是没有找到结果,也会返回对象,所以if判断结果集的行数,才能判断有没有找到 $rows = $result->fetch_assoc(); $_SESSION['valid_user'] = $username; echo "Welcome " . $rows['username'] . ""; } else { do_html_url('login.php', '用户名或密码错误,请重新登录'); exit; } } // if (!$result) { // echo "找不到此用户."; // exit(); // } check_valid_user(); if (!($url_array = get_user_urls($_SESSION['valid_user']))) { echo "您还没有添加书签,请<a href='addbm.php'>添加书签</a>"; } else { display_user_urls($url_array); } display_user_menu(); do_html_footer();
<?php require_once 'functions.php'; session_start(); $username = $_POST['username']; $password = $_POST['password']; do_html_header('登录'); if (!isset($_SESSION['valid_user'])) { if (!filled_out($_POST)) { do_html_url('login.php', '请填写用户名和密码。'); exit; } if (is_user($username, $password)) { $_SESSION['valid_user'] = $username; do_html_url('index.php', '登录成功,去购物'); } else { do_html_url('login.php', '用户名或密码错误'); exit; } } do_html_footer();
<?php //session_start(); do_html_header('Changing password'); check_admin_user(); if (!filled_out($_POST)) { echo 'You have not filled out the form completely. Please try again.'; do_html_url(baseurl() . 'cart/admin', 'Back to administration menu'); exit; } else { $new_passwd = $_POST['new_passwd']; $new_passwd2 = $_POST['new_passwd2']; $old_passwd = $_POST['old_passwd']; if ($new_passwd != $new_passwd2) { echo 'Passwords entered were not the same. Not changed.'; } else { if (strlen($new_passwd) > 16 || strlen($new_passwd) < 6) { echo 'New password must be between 6 and 16 characters. Try again.'; } else { // attempt update if (change_password($_SESSION['admin_user'], $old_passwd, $new_passwd)) { echo 'Password changed.'; } else { echo 'Password could not be changed.'; } } } } do_html_url(baseurl() . 'cart/admin', 'Back to administration menu');
$keyword = $_POST['newkeyword']; $structure = $_POST['newstructure']; $aggrelvl = $_POST['newaggrelvl']; $interacttype = $_POST['newinteracttype']; $resourcetype = $_POST['newresourcetype']; $interactlvl = $_POST['newinteractlvl']; $enduserrole = $_POST['newenduserrole']; $learningtime = $_POST['newlearningtime']; $cost = $_POST['newcost']; $copyright = $_POST['newcopyright']; $version = $_POST['newversion']; $status = $_POST['newstatus']; if (update_metadata($objid, $title, $author, $discipline, $language, $keyword, $structure, $aggrelvl, $interacttype, $resourcetype, $interactlvl, $enduserrole, $learningtime, $cost, $copyright, $version, $status)) { echo '<div class="container theme-showcase">'; echo '<div class="page-header">'; echo '<p>Object was updated.</p>'; echo '</div>'; echo '</div>'; } else { echo '<div class="container theme-showcase">'; echo '<div class="page-header">'; echo '<p>Object could not be updated.</p>'; echo '</div>'; echo '</div>'; } echo '<div class="container theme-showcase">'; echo '<div class="page-header">'; do_html_url("member.php", "Go back to member page"); echo '</div>'; echo '</div>'; do_html_footer();
function display_edit_objects($object_array) { if (!is_array($object_array)) { echo "<p>No objects currently available under this discipline</p>"; return; } echo "<ul>"; foreach ($object_array as $row) { $url = "show_edit_object.php?objid=" . $row['objid']; $title = $row['title']; echo "<li>"; do_html_url($url, $title); echo "</li>"; } echo "</ul>"; echo "<hr />"; }
function display_books($book_array) { if (!is_array($book_array)) { echo "<i>There are currently no available books.</i><br />"; return; } echo "<ul>"; foreach ($book_array as $row) { $url = "show_book.php?isbn=" . $row['isbn']; $title = $row['title']; $author = $row['author']; echo "<li>"; do_html_url($url, $title); echo " author: " . $author; echo "</li>"; } echo "</ul>"; echo "<hr />"; }
<?php error_reporting(E_ALL ^ E_NOTICE); // include function files for this application require_once 'bookmark_fns.php'; //session_start(); $old_user = $_SESSION['valid_user']; // store to test if they *were* logged in unset($_SESSION['valid_user']); $result_dest = session_destroy(); // start output html do_html_header('Logging Out'); if (!empty($old_user)) { if ($result_dest) { // if they were logged in and are now logged out echo 'Logged out.<br />'; do_html_url('login', 'Login'); } else { // they were logged in and could not be logged out echo 'Could not log you out.<br />'; } } else { // if they weren't logged in but came to this page somehow echo 'You were not logged in, and so have not been logged out.<br />'; do_html_url('login', 'Login'); }
require_once "book_f.php"; if (!isset($_SESSION['item'])) { $session['items'] = '0'; } if (!isset($_SESSION['total_price'])) { $_session['total_price'] = '0.000'; } // catid mã laoi sách if (!isset($_SESSION['catid'])) { $_SESSION['catid'] = 0.0; } echo "<p>Please choose a category</p>"; db_connect(); $sql = "select * from categories"; $kq = mysql_query($sql); if (mysql_num_rows($kq) == 0) { return false; } echo "<ul>"; while ($row = mysql_fetch_array($kq)) { // Tạo đường linh cho các category $url = "index.php?dk=show_cat&catid={$row['catid']}"; $catname = $row[catname]; echo "<li>"; do_html_url($url, $catname); echo "</li>"; echo "<br>"; } echo "</ul>"; // Đường gạch dưới echo "<hr>";
<meta charset="utf-8"> <?php session_start(); require_once "book_f.php"; ?> <?php if (check_admin_user()) { if (isset($_POST['updatecat'])) { if (update_category($_POST['catid'], $_POST['catname'])) { echo "Loại sách đã được cập nhật ok<br>"; } else { echo "Có lỗi. Loại sách không được cập nhật. Error<br>"; } } else { echo "Bạn không click updatecat<br>"; } do_html_url("index.php?dk=admin", "Trở lại trang quản trị"); } else { echo "Bạn không là admin. Không xem trang này được"; } ?>
require_once 'book_sc_fns.php'; session_start(); do_html_header('Changing password'); check_admin_user(); if (!filled_out($HTTP_POST_VARS)) { echo 'You have not filled out the form completely. Please try again.'; do_html_url('admin.php', 'Back to administration menu'); do_html_footer(); exit; } else { $new_passwd = $HTTP_POST_VARS['new_passwd']; $new_passwd2 = $HTTP_POST_VARS['new_passwd2']; $old_passwd = $HTTP_POST_VARS['old_passwd']; if ($new_passwd != $new_passwd2) { echo 'Passwords entered were not the same. Not changed.'; } else { if (strlen($new_passwd) > 16 || strlen($new_passwd) < 6) { echo 'New password must be between 6 and 16 characters. Try again.'; } else { // attempt update if (change_password($HTTP_SESSION_VARS['admin_user'], $old_passwd, $new_passwd)) { echo 'Password changed.'; } else { echo 'Password could not be changed.'; } } } } do_html_url('admin.php', 'Back to administration menu'); do_html_footer();
require_once 'functions.php'; $username = $_POST['username']; $password1 = $_POST['password1']; $password2 = $_POST['password2']; $email = $_POST['email']; session_start(); try { if (!filled_out($_POST)) { throw new Exception("You have not filled the form out correctly- please go back and try again"); } if (!vaild_email($email)) { throw new Exception("That is not a valid email address. Please go back and try again"); } if ($password1 != $password2) { throw new Exception("The passwords you enterd do not match - please go back and try again"); } if (strlen($password1) < 6 || strlen($password1) > 16) { throw new Exception("Your password must be between 6 and 16 characters. Please go back and try again"); } register($username, $email, $password1); $_SESSION['valid_user'] = $username; do_html_header('注册成功'); echo "Your REgistration was successful. Go to the members page to start setting up your bookmars!"; do_html_url('member.php', 'Go to members page'); do_html_footer(); } catch (Exception $e) { do_html_header('Problem:'); echo $e->getMessage(); do_html_footer(); exit; }
<?php // include function files for this application require_once 'book_sc_fns.php'; session_start(); do_html_header("Add a book"); if (check_admin_user()) { display_book_form(); do_html_url("admin.php", "Back to administration menu"); } else { echo "<p>You are not authorized to enter the administration area.</p>"; } do_html_footer();
function display_books($book_array) { //display all books in the array passed in if (!is_array($book_array)) { echo '<br />No books currently available in this category<br />'; } else { //create table echo '<table width = \\"100%\\" border = 0>'; //create a table row for each book foreach ($book_array as $row) { $url = 'show_book.php?isbn=' . $row['isbn']; echo '<tr><td>'; if (@file_exists('images/' . $row['isbn'] . '.jpg')) { $title = '<img src=\'images/' . $row['isbn'] . '.jpg\' border=0>'; do_html_url($url, $title); } else { echo ' '; } echo '</td><td>'; $title = $row['title'] . ' by ' . $row['author']; do_html_url($url, $title); echo '</td></tr>'; } echo '</table>'; } echo '<hr />'; }
//require_once('function/security.php'); require_once 'database/connection.php'; require_once 'includes/output.html.php'; require_once 'function/data_holder.php'; //create short variable names $email = $_POST['email']; $password = $_POST['password']; if (!empty($_POST['email']) && !empty($_POST['password'])) { // they have just tried logging in try { login($email, $password); // if they are in the database register the user id session_start(); $_SESSION['valid_user'] = $email; $cookie_name = 'login'; setcookie($cookie_name, $email, time() + 3600, "/"); if (!last_page()) { header("Location:index.php"); } } catch (Exception $e) { // unsuccessful login add_header('Problem:'); echo "<div class='wrapper' style=' position:relative; left:-200px; width:30%; height:20em; '>"; echo '<h3 style="margin-top:20%; width:180%;">You could not be logged in. You must be logged in to view this page.</h3><br/>'; echo "<b>Try Again!</b><br/><hr/>"; do_html_url('login.php', 'Login'); echo "</div>"; add_footer(); exit; } }
throw new Exception('Please fill out all required forms.'); } //Make sure the email address is valid if (!valid_email($email)) { throw new Exception('Please use a valid email address'); } //Make sure the passwords are the same if ($password != $password2) { throw new Exception('Passwords not the same, please retry.'); } //Check password length if (strlen($password) < 6 || strlen($password2) > 16) { throw new Exception('Please enter a password between 6 and 16 characters.'); } // Try to register (this function can throw an exception) register($email, $real_name, $password); // "Register session variable" $_SESSION['valid_user'] = $email; // Use email instead of username (like in the book) because it's // easier for users to remember an email address across diff sites //Provide link to members page do_html_header('Registration successful'); echo 'Your registration was successful!'; do_html_url('member.php', 'Get Started!'); do_html_footer(); } catch (Exception $e) { do_html_header('Oops!'); echo $e->getMessage(); do_html_footer(); exit; }
session_start(); //create short variable names $username = isset($_POST["username"]) ? $_POST["username"] : ""; $password = isset($_POST["password"]) ? $_POST["password"] : ""; //first check whether the user has come from the front page by filling out the form if ($username && $password) { //they have just tried to log in try { login($username, $password); //if they are in the database (as in they are a member), register their username to the session ID variable called valid_user $_SESSION["valid_user"] = $username; } catch (Exception $e) { //unsuccessful login do_html_header("Problem: "); echo "We could not log you in. You must be logged in to view this page."; do_html_url("login.php", "Login"); do_html_footer(); exit; } } //start the display do_html_header("Home"); check_valid_user(); //get the bookmarks this user has saved if ($url_array = get_user_urls($_SESSION["valid_user"])) { //gilho instead of session valid user display_user_urls($url_array); } //give menu options display_user_menu(); do_html_footer();
if (mysql_num_rows($kq) > 0) { echo "<table width=100% border=0>"; // Lấy từng dòng mỗi cuốn sách dùng vòng while "Lên thuộc lệnh này dùng nhiều" while ($row = mysql_fetch_array($kq)) { $url = "index.php?dk=show_book&isbn={$row['isbn']}"; echo "<tr>"; echo "<td>"; // "isbn" Kiềm tra 'id' sách if (@file_exists("images/{$row['isbn']}.jpg")) { $title = "<img src='images/{$row['isbn']}.jpg' width=100 height=120 border=0>"; do_html_url($url, $title); } else { echo " "; } echo "</td>"; echo "<td>"; $title = $row[title] . "by" . $row[author]; do_html_url($url, $title); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "<hr>"; } if (isset($_SESSION['admin_user'])) { display_button("index.php?dk=loaisach", "continue", "Continue Shopping"); display_button("index.php?dk=admin", "admin-menu", "Admin Menu"); display_button("index.php?dk=edit_category_form&catid={$catid}", "edit-category", "Edit Category"); } else { display_button("index.php?dk=loaisach", "continue-shopping", "Continue Shopping"); }