Example #1
0
        $response->message = 'Unauthorized';
        $response->json($response);
    }
    $response->json($user);
} elseif ($route->match('mymodules', null)) {
    $where = $user->role > 1 ? array('user_id' => $user->id) : null;
    $response->data = $model->modulesAll(array('user_id' => $user->id));
    $response->json($response);
} elseif ($route->match('modules', null)) {
    $response->data = $model->modulesAll(array('user_id' => $user->id));
    $response->json($response);
} elseif ($route->match('module', 1)) {
    // Prepare and sanitize post input
    $api->setInputs(array('id' => $route->getParam(0)));
    $where = $user->role > 1 ? array('m.id' => $api->getInputVal('id'), 'm.user_id' => $user->id) : array('m.id' => $api->getInputVal('id'));
    $module = $model->moduleFindJoin($where);
    if (!count($module)) {
        $response->status = 403;
        $response->message = 'Forbidden';
        $response->json($response);
    }
    $response->data = $module;
    $response->json($response);
} elseif ($route->match('moduleupload', null)) {
    require_once 'api/upload.php';
    die;
} elseif ($route->match('moduleverify', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    $api->moduleVerify();
    if ($api->getErrors()) {