Example #1
0
    require_once 'api/upload.php';
    die;
} elseif ($route->match('moduleverify', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    $api->moduleVerify();
    if ($api->getErrors()) {
        $response->status = 500;
        $response->message = 'Unable to send verification request';
        $response->data = $api->getErrors();
        $response->json($response);
    }
    $response->json($response);
} elseif ($route->match('moduleupdate', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST, $model->getWhitelist('modules'));
    $where = $user->role > 1 ? array('id' => $api->getInputVal('id'), 'user_id' => $user->id) : array('id' => $api->getInputVal('id'));
    $module = $model->moduleFind($where);
    if (!$module) {
        $response->status = 403;
        $response->message = 'Forbidden';
        $response->json($response);
    }
    $model->moduleUpdate($api->getInputs(), array('id' => $api->getInputVal('id')));
    $response->json($response);
} elseif ($route->match('moduledelete', null)) {
    $api->setInputs($_POST);
    $where = $user->role === 1 ? array('id' => $api->getInputVal('id')) : array('id' => $api->getInputVal('id'), 'user_id' => $user->id);
    $module = $model->moduleFind($where);
    if (!$module) {
        $response->status = 404;