public static function logout() { $query = "UPDATE User SET " . loginSession . " = null " . "WHERE " . loginSession . " = '" . session_id() . "'"; session_regenerate_id(true); session_destroy(); setCookie(userNo, "null"); setCookie("PHPSESSID", null); UserControl::$type = null; return DB::query($query); }
<?php /* Trip Report Generator, part of MedLog. This file displays all the entries belonging to a date, waits for input on which entries to include to the report and then generates it. */ require_once "./include/entries.php"; require_once "./include/usercontrol.php"; require_once "./include/static.php"; require_once "./include/tripify.php"; $u = new UserControl(); $dry = new DRYHelper(); if (!$u->CheckLogin()) { // Not logged in. header("Location: index.php"); die; } // Get the username and generate its entries controller $sess_user = $_SESSION[$u->GetLoginSessionVar()]; $e = new EntriesController($sess_user); // Are we done yet? $done = $_POST["done"]; if ($done == "no") { // No, so let's display all the entries belonging to this date. $date = $_POST["date"]; $dry->build_header("Generate Trip Report"); ?> <h1>Generate Trip Report</h1> <div id="content"> <p class="warning">Please select the entries you want to include in this trip report</p> <?php $res = $e->FindEntries(null, $date);
if (isset($_POST["weekDay"])) { $typeID = UserControl::getUserNo(); $typeID = getInfo($typeID)["ID"]; $thisWeek = date("w"); $currentDate = date("Y-m-d"); $target_day = $_POST["weekDay"]; $weekDayArray = array("Sun" => "sunday", "Mon" => "monday", "Tue" => "tuesday", "Wed" => "wednesday", "Thur" => "thursday", "Fri" => "friday", "Sat" => "saturday"); foreach ($weekDayArray as $key => $value) { if (isset($target_day[$key])) { $currentDate = date("Y-m-d"); for ($i = 0; $i < $_POST["repeatTime"]; $i++) { $nextDate = date("Y-m-d", strtotime('next ' . $value, strtotime($currentDate))); markJobDate($typeID, $nextDate, $_POST["district"]); $currentDate = $nextDate; } } } } else { echo "<script> alert('Please select the week day!'); </script>"; } } else { if (isset($_POST["date"], $_POST["district"])) { $typeID = UserControl::getUserNo(); $typeID = getInfo($typeID)["ID"]; markJobDate($typeID, $_POST["date"], $_POST["district"]); } } echo "<script> window.location.replace(\"../profile.php?userNo=" . UserControl::getUserNo() . "\"); </script>"; ?>
/* * MedLog's Internal API (mAPI). * This is not a RESTful API, but a rather simplistic API. * This API is managed by MJM, and their major version numbers (1.x.x) should be equal. * @method: POST * @endpoint: $_POST["op"] * @return: JSON encoded response. * * This is the API "router", and user authentification must be performed here before * creating the mAPI obejct. */ require_once "../include/api.php"; require_once "../include/usercontrol.php"; /* User auth */ $u = new UserControl(); // Notice that if the op code is "reg", we bypass authentification if (!$u->CheckLogin() && $_POST["op"] != "reg") { // Send a JSON response header("HTTP/1.1 403 Forbidden"); echo json_encode(array("msg" => "Not logged in!", "status" => 403)); die; } /* Now we're sure we're logged in, let's start a mAPI instance */ $sus = $_POST["op"] == "reg" ? "something" : $_SESSION[$u->GetLoginSessionVar()]; $mia = new mAPI("POST", $_POST, $sus); // Route to the right mAPI endpoint $op = $_POST["op"]; if ($op == "add") { $mia->addEntry(); } else {
include_once "Brain/User.php"; include "header1.php"; ?> <link href="css/register.css" rel="stylesheet" type="text/css" /> <script src='js/register.js'> </script> <?php include "Brain/District.php"; include "Brain/UserControl.php"; include "header2.php"; include_once "Brain/ShoppingCart.php"; $cart = new SCart(); if (isset($_GET["error"])) { echo "<script> alert('Sorry, we only delivery two day after order.')</script>"; } if (UserControl::checkState() && UserControl::getType() == 'c') { $cust = getCustomer(getInfo(UserControl::getUserNo())[ID]); if (isset($_POST[distNo], $_POST[custAddr], $_POST["sdate"])) { $date = strtotime($_POST["sdate"]); $minday = strtotime(date("Y-m-d", strtotime("+ 2 days"))); if ($date < $minday) { header("Location: checkout.php?error=true"); } else { if ($cart->checkout($_POST["sdate"], "100", $_POST[custAddr], $cust[custNo], $_POST[distNo])) { header("Location: shoppingcart.php?sucess=true"); } else { echo "<script> alert('Sorry!');</script>"; } } } $district = getAllDistricts(); $box = "<select name='distNo'>";
<th>Price:</th> <td>$' . $p[prodPrice] . '</td> </tr> <tr> <th>Supplier:</th> <td>' . $s[suppName] . '</td> </tr> '; if (UserControl::getType() == 'a') { echo '<tr> <th>Stock:</th> <td>' . $p[stockQty] . '</td> </tr>'; } echo ' </table> '; if (!$outOfStock && (UserControl::getType() == NULL || UserControl::getType() == 'c')) { echo ' <button class="btnAddToChart" rm="'; if ($cart->isExist($p[prodNo])) { echo 'true'; } else { echo 'false'; } echo '" onclick="btnAddCartClicked(this)">'; if ($cart->isExist($p[prodNo])) { echo 'REMOVE FROM CART'; } else { echo 'ADD <input class="qty" type="text" value="1" onclick="event.stopPropagation();"/> TO CART'; } echo '</button>'; }
<?php require_once "./include/usercontrol.php"; $u = new UserControl(); // Check if we actually want to log out if (!empty($_GET["logout"]) && $_GET["logout"] == "true") { $u->LogOut(); header("Location: index.php"); die; } if (empty($_POST['username'])) { $u->HandleError("UserName is empty!"); return false; } if (empty($_POST['password'])) { $u->HandleError("Password is empty!"); return false; } $username = trim($_POST['username']); $password = trim($_POST['password']); if (!$u->CheckLoginInDB($username, $password)) { return false; } session_start(); $_SESSION[$u->GetLoginSessionVar()] = $username; header("Location: index.php"); die;
<?php // TO BE INCLUDED FROM A MODULE // include_once "../../Source/ServerInformation.php"; $serverInfo = new ServerInformation("../../../"); include_once $serverInfo->SourceDirectory . "SessionManager.php"; include_once $serverInfo->SourceDirectory . "UserControl.php"; include $serverInfo->UsersFile; $userControl = new UserControl($users, $admins); $sessionManager = new SessionManager(); $userControl->setUser($sessionManager->user, $sessionManager->pass);
<?php error_reporting(0); include_once "../Brain/field_const.php"; include_once "../Brain/functions.php"; include_once "../Brain/ShoppingCart.php"; include_once "../Brain/Product.php"; include_once "../Brain/UserControl.php"; if (!UserControl::checkState()) { echo "Error: You must login first!"; return; } regGet('act', 'prodNo', 'qty'); if (!isset($act) || !isset($prodNo)) { echo "Error: No action specified"; return; } $cart = new SCart(); $prod = getProduct($prodNo); //$cart->clear(); if ($act == 'add') { if (!isset($qty)) { $qty = 1; } $cart->addProduct($prodNo, $prod[prodPrice], $qty); //if not success //... } else { $cart->removeItem($prodNo); } $cartProds = $cart->getProducts();
<?php /* Main page of MedLog. Displays the brief site details, login form and last entries of the user */ require_once "./include/usercontrol.php"; require_once "./include/entries.php"; require_once "./include/static.php"; $u = new UserControl(); $dry = new DRYHelper(); // Check login before sending headers $checklogin = $u->CheckLogin(); $dry->build_header(); if (!empty($_GET["message"])) { ?> <div id="message"><?php echo $_GET["message"]; ?> </div> <?php } ?> <h1>MedLog</h1> <div id="site-info"> <p>MedLog provides an easy-to-use medication/drug log for our users. Log every drug you take! MedLog also analyses your logged data to create powerful statistics regarding your drug use.</p> </div> <div id="content"> <?php /* Check if the user has already logged in */ if (!$checklogin) { /* Log-in form */
</div> </div> </div> <?php } ?> <div class="navTab col-10 col-m-20"> <div><span class="fa fa-2x fa-search userIcon navIcon" onclick="showSearchBar()"></span></div> </div> <div class="navTab col-10 col-m-20"> <?php include_once "UserControl.php"; echo '<div><span class="fa fa-2x fa-user userIcon navIcon" onclick="'; if (UserControl::checkState()) { echo "window.location = 'profile.php?userNo=" . UserControl::getUserNo() . "'\""; } else { echo 'showLoginPanel()'; } echo "\"></span></div>"; ?> </div> </div> <div class="searchBar"> <form action="products.php" method="get" style="margin:0;"> <div class="searchInfo_C" style="width:700px"> <label>Name:</label>
<?php include_once "Brain/field_const.php"; include "header1.php"; ?> <link href="css/profile.css" rel="stylesheet" type="text/css" /> <script src='js/profile.js'> </script> <?php include "header2.php"; if (!isset($_GET[userNo])) { return; } $isOwner = false; include_once "Brain/UserControl.php"; if (UserControl::checkState()) { $userNo = UserControl::getUserNo(); if ($userNo == $_GET[userNo]) { $isOwner = !$isOwner; } } $owner = getUser($_GET[userNo]); if (!isset($owner)) { echo "Sorry, No such user!"; return; } $ownerInfo = getInfo($_GET[userNo]); $type = getUserType($_GET[userNo]); $typeID = $ownerInfo["ID"]; ?> <div id="profileHeader">
<?php include_once "UserControl.php"; if (isset($_POST[loginName], $_POST[loginPswd])) { echo $_POST[loginName]; echo $_POST[loginPswd]; if (UserControl::login($_POST[loginName], $_POST[loginPswd])) { echo header("Location: ../profile.php?userNo=" . UserControl::getUserNo()); } else { echo "Failure to login"; } echo "<a href='checkState.php' > HI </a>"; }