Example #1
0
        $response->status = 404;
        $response->message = 'Not found';
        $response->json($response);
    }
    $model->skinUpdate($api->getInputs(), array('id' => $api->getInputVal('id')));
    $response->json($response);
} elseif ($route->match('skindelete', null)) {
    // Prepare and sanitize post input
    $api->setInputs($_POST);
    $skin = $model->skinFind(array('id' => $api->getInputVal('id'), 'user_id' => $user->id));
    if (!count($skin)) {
        $response->status = 404;
        $response->message = 'Not found';
        $response->json($response);
    }
    if (!$model->skinDelete(array('id' => $api->getInputVal('id'), 'user_id' => $user->id))) {
        $response->status = 500;
        $response->message = 'Unable to delete a skin';
        $response->json($response);
    }
    $path = 'storage/skins/' . $skin->file;
    $img = 'storage/skins/' . $skin->icon;
    if (is_file($path)) {
        unlink($path);
    }
    if (is_file($img)) {
        unlink($img);
    }
    $response->json($response);
} elseif ($route->match('skinupload', 1)) {
    $api->setInputs(array('name' => $route->getParam(0)));