Beispiel #1
0
    require_once $GLOBALS['dirCore'] . '/pages/compileIndex.php';
});
$f3->route('GET /compile/@id', function ($f3) {
    require_once $GLOBALS['dirCore'] . '/pages/compileMain.php';
});
// API
// Generate public/private key pairs
$f3->route('GET ' . $apiBaseUrl . '/generate', function ($f3) {
    echo CWM_API::generate();
});
// Authorize user
$f3->route('POST ' . $apiBaseUrl . '/authorize/@data/@key/@hash', function ($f3) {
    $data = $f3->get('PARAMS.data');
    $publicApiKey = $f3->get('PARAMS.key');
    $hash = $f3->get('PARAMS.hash');
    echo CWM_API::authorize($data, $publicApiKey, $hash);
});
// Deauthorize user
$f3->route('POST ' . $apiBaseUrl . '/deauthorize/@tokenValue', function ($f3) {
    $tokenValue = $f3->get('PARAMS.tokenValue');
    echo CWM_API::deAuthorize($tokenValue);
});
// Get user
$f3->route('GET ' . $apiBaseUrl . '/user/@tokenValue', function ($f3) {
    require_once $GLOBALS['dirRoot'] . '/api/User.class.php';
    $tokenValue = $f3->get('PARAMS.tokenValue');
    $user = CWM_User::getFromToken($tokenValue);
    if (!is_null($user)) {
        echo $user->getAsJson();
    } else {
        echo -1;