| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/safemyident.de/web/api/lib/ |
Upload File : |
<?php
/**
* Einheitliche JSON-Antworten.
*
* @package SafeMyIdent\Api
*/
declare(strict_types=1);
/**
* Erfolgs-Antwort.
*
* @param mixed $data Nutzdaten.
* @param bool $cached Aus Cache bedient?
*/
function smi_json_ok($data, bool $cached = false): void
{
echo json_encode(
['ok' => true, 'data' => $data, 'cached' => $cached, 'ts' => time()],
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
);
exit;
}
/**
* Fehler-Antwort.
*
* @param string $message Nachricht (nutzerfreundlich, keine internen Details).
* @param int $code HTTP-Status.
*/
function smi_json_error(string $message, int $code = 400): void
{
// Bewusst HTTP 200: nginx (fastcgi_intercept_errors) würde 4xx/5xx sonst
// durch eine HTML-Fehlerseite ersetzen. Der Fehler steckt im JSON-Body.
http_response_code(200);
echo json_encode(
['ok' => false, 'error' => $message, 'code' => $code, 'ts' => time()],
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
);
exit;
}