Ejemplo n.º 1
0
        $response->status = 500;
        $response->message = 'Unable to delete the icon';
        $response->json($response);
    }
    $path = 'storage/icons/';
    if (is_file($path . $icon->file)) {
        unlink($path . $icon->file);
    }
    if (is_file($path . $icon->icon)) {
        unlink($path . $icon->icon);
    }
    Ut::cleanDirectory($path . $icon->name);
    $response->json($response);
} elseif ($route->match('iconupload', 1)) {
    $api->setInputs(array('name' => $route->getParam(0)));
    $name = Ut::toSlug(strtok($_FILES['file']['name'], '.'));
    // Check if skin name and uploaded name are equal
    if ($api->getInputVal('name') !== $name) {
        $response->status = 500;
        $response->message = 'The uploaded file must be named:  ' . $api->getInputVal('name') . '!!! Your file name is: ' . $name;
        $response->json($response);
    }
    // Check if model exists
    $icon = $model->iconFind(array('user_id' => $user->id, 'name' => $api->getInputVal('name')));
    if (!$icon) {
        $response->status = 404;
        $response->message = 'Icon not found';
        $response->json($response);
    }
    $icon_path = 'storage/icons/';
    $icon_path_temp = 'storage/icons/' . $name . '/';