Exemplo n.º 1
0
function RunService($path)
{
    // Run the specified path, returning a json response.
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    if (file_exists($path)) {
        require_once $path;
    } else {
        OutputResponse(array(), 1000, 'Service not implemented.');
    }
}
Exemplo n.º 2
0
 * @file   rest/session.php
 * @author Katharine Gillis
 * @date   6/25/2013
 * @brief  Runs the session REST webservice.
 */
require_once 'utils.php';
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    // Start up the session, and if it is no longer valid, kick out an invalid session error and exit.
    session_start();
    if (!$_SESSION['loggedIn'] || time() - $_SESSION['lastActivity'] > 30 * 60) {
        session_unset();
        session_destroy();
        OutputResponse(array(), 1110, "Invalid session");
        exit;
    }
    // Update the session activity time, and then run the GET part of the service.
    $_SESSION['lastActivity'] = time();
    RunService('session/get.php');
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Start up the session, and if it is no longer valid, kick out an invalid session error and exit.
    session_start();
    if (!$_SESSION['loggedIn'] || time() - $_SESSION['lastActivity'] > 30 * 60) {
        session_unset();
        session_destroy();
        OutputResponse(array(), 1110, "Invalid session");
        exit;
    }
    // Update the session activity time, and then run the GET part of the service.
    $_SESSION['lastActivity'] = time();
    RunService('session/post.php');
}