Beispiel #1
0
<?php

namespace SP\App\Api\Session;

require_once __DIR__ . '/../session/Session.php';
use SP\App\Api\Session\Session;
/**
* @var mixed[] $request Array with name of variable, 'name', and 'value' (empty on get).
*/
$request = json_decode(file_get_contents('php://input'), true);
$reqMethod = $_SERVER['REQUEST_METHOD'];
$session = new Session();
$response = false;
switch ($reqMethod) {
    case 'GET':
        $response = $session->getVar($_GET['var']);
        break;
    case 'DELETE':
        $response = $session->unsetVar($_GET['var']);
        break;
    case 'POST':
    case 'PUT':
        $response = $session->setVar($_GET['var'], $request);
}
echo json_encode($response);
Beispiel #2
0
<?php

namespace SP\App\Api\User;

require_once __DIR__ . '/../session/Session.php';
use SP\App\Api\Session\Session;
$session = new Session();
$session->end();
echo '';
Beispiel #3
0
<?php

namespace SP\App\Api\User;

require_once __DIR__ . '/../session/Session.php';
require_once __DIR__ . '/../user/Authentication.php';
use SP\App\Api\Session\Session;
use SP\App\Api\User\Authentication;
/**
* @var mixed[] $request Array with 'name' and 'password' to authenticate.
*/
$request = json_decode(file_get_contents('php://input'), true);
$auth = new Authentication($request);
$response = $auth->verify();
if (!$response['success']) {
    echo json_encode($response);
} else {
    $session = new Session();
    $session->start($request['name']);
    echo json_encode($response);
}
Beispiel #4
0
 /**
  * Where clauses for activities require a user ID.
  * @return string User ID. -1 if no user logged in.
  */
 protected function getUserID()
 {
     $session = new Session();
     $result = $session->getVar('id');
     return $result['success'] ? $result['data'] : '-1';
 }