Пример #1
0
 * 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 {
    if ($op == "rem") {
        $mia->remEntry();
Пример #2
0
<?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);
Пример #3
0
<?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 */