Пример #1
0
 * 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 {
    if ($op == "rem") {
        $mia->remEntry();
    } else {
        if ($op == "fetch") {
            $mia->fetchEntry();
        } else {
            if ($op == "edit") {
                $mia->editEntry();
            } else {
Пример #2
0
/* 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 ($res != false) {
        $dry->build_trg_table_header();
Пример #3
0
<?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;