Esempio n. 1
0
function checkCookie()
{
    if (isset($_COOKIE["token"]) && isset($_COOKIE["expiry"]) && isset($_COOKIE["username"])) {
        $username = $_COOKIE['username'];
        $info = getLoginInfo($username);
        $time = time();
        if ($info['token'] == $_COOKIE['token'] && $time <= $_COOKIE['expiry']) {
            $allowed = true;
            return $allowed;
        }
    } else {
        $allowed = false;
        return $allowed;
    }
}
Esempio n. 2
0
function checkCookie()
{
    $allowed = false;
    if (isset($_COOKIE["token"]) && isset($_COOKIE["expiry"]) && isset($_COOKIE["username"])) {
        $username = $_COOKIE['username'];
        $loginInfo = getLoginInfo($username);
        $time = time();
        if ($loginInfo['token'] == $_COOKIE['token'] && $time <= $_COOKIE['expiry'] && $time <= $loginInfo['expiry']) {
            $allowed = true;
        }
    }
    if (isset($_COOKIE['expiry']) && time() > $_COOKIE['expiry'] && time() > $loginInfo['expiry']) {
        setcookie("expiry", "", time() - 3600);
        setcookie("token", "", time() - 3600);
        setcookie("username", "", time() - 3600);
    }
    return $allowed;
}
Esempio n. 3
0
<?php

require_once 'setup.php';
$app = new \Slim\Slim();
/* GET USER LOGIN INFO */
$app->get('/user/:email/:password', function ($email, $password) {
    $user = getLoginInfo($email, $password);
    if ($user != null) {
        echo json_encode($user);
    }
});
/* GET USER INFO FOR ONE EVENT */
$app->get('/user/:email/events/:eventId', function ($email, $eventId) {
    $user = getUserEventInfo($email, $eventId);
    if ($user != null) {
        echo json_encode($user);
    }
});
/* GET ALL EVENTS */
$app->get('/events/all', function () {
    echo json_encode(getAllEvents());
});
/* USERS */
$app->post('/user', function () {
    $body = http_get_request_body();
    if ($body != null) {
        $typeCheck = json_decode($body);
        switch ($typeCheck->type) {
            /* CREATE A USER */
            case USER:
                $inUser = $typeCheck->obj;