Bulk substitution across all PHP files in src/, build.php, worker.php, and web/frontend/. Updates composer.json's package name and PSR-4 autoload root accordingly. Casing matches the existing IndifferentKetchup\Codex package's namespace convention (capital K). Strictly a namespace rename. Aternos\Codex\* imports remain in place; those get re-pointed in a follow-up commit when the codex Composer dependency itself is swapped. Filename renames (docker/mclogs.ini, web/public/css/mclogs.css), README walk-through, env-var prefix changes, and visible-text branding land in subsequent commits.
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace IndifferentKetchup\Iblogs\Api\Action;
|
|
|
|
use IndifferentKetchup\Iblogs\Api\Response\ApiError;
|
|
use IndifferentKetchup\Iblogs\Api\Response\ApiResponse;
|
|
use IndifferentKetchup\Iblogs\Id;
|
|
use IndifferentKetchup\Iblogs\Log;
|
|
use IndifferentKetchup\Iblogs\Util\URL;
|
|
|
|
class DeleteLogAction extends ApiAction
|
|
{
|
|
protected function getRequestToken(): ?string
|
|
{
|
|
$authorizationHeader = $_SERVER['HTTP_AUTHORIZATION'] ?? null;
|
|
if (!$authorizationHeader) {
|
|
return null;
|
|
}
|
|
$parts = explode(" ", $authorizationHeader);
|
|
return $parts[1] ?? null;
|
|
}
|
|
|
|
/**
|
|
* @return ApiResponse
|
|
*/
|
|
protected function runApi(): ApiResponse
|
|
{
|
|
$requestToken = $this->getRequestToken();
|
|
|
|
if (!$requestToken) {
|
|
return new ApiError(400, "Missing token.");
|
|
}
|
|
|
|
$id = new Id(URL::getLastPathPart());
|
|
$log = Log::find($id);
|
|
|
|
if (!$log) {
|
|
return new ApiError(404, "Log not found.");
|
|
}
|
|
|
|
$token = $log->getToken();
|
|
if (!$token || !$token->matches($requestToken)) {
|
|
return new ApiError(403, "Invalid token.");
|
|
}
|
|
|
|
$deleted = $log->delete();
|
|
if (!$deleted) {
|
|
return new ApiError(500, "Failed to delete log.");
|
|
}
|
|
|
|
$this->handleDeletedLog($log);
|
|
|
|
return new ApiResponse();
|
|
}
|
|
|
|
protected function handleDeletedLog(Log $log): void
|
|
{
|
|
|
|
}
|
|
}
|