Example #1
0
} elseif ($route->match('adminuserdelete', null)) {
    // Admin only
    if ($user->role !== 1) {
        $response->status = 403;
        $response->message = 'Forbidden';
        $response->json($response);
    }
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    $user = $model->userFind(array('id' => $api->getInputVal('id')));
    if (!count($user)) {
        $response->status = 404;
        $response->message = 'Not found';
        $response->json($response);
    }
    if (!$model->userDelete(array('id' => $api->getInputVal('id')))) {
        $response->status = 500;
        $response->message = 'DB error';
        $response->json($response);
    }
    $response->json($response);
} elseif ($route->match('api-modules', null)) {
    $tokens = '';
    $ids = '';
    if (count($_POST['token'])) {
        foreach ($_POST['token'] as $key => $value) {
            $tokens .= '\'' . $value . '\',';
        }
        $ids = $model->apiTokensModuleIds(rtrim($tokens, ','));
    }
    $response->data = $model->apiModulesAll(array('verified' => 1, 'active' => 1), $ids);