Alcea
|
41d0596d66
|
Add files via upload
Replace status redirect handler ro resirect to instsnce ststus AND serve json for 2 seconds
if (preg_match('/^\/' . $username . '\/status\/([a-z0-9\-]+)$/', $uri, $m)) {
$postId = $m[1];
$post = null; $date = ''; $hash = '';
foreach ($data as $entry)
foreach ($entry as $d => $c)
if ("$d-" . substr(md5($c['value']),0,8) === $postId) {
$post = $c; $date = $d; $hash = substr(md5($c['value']),0,8); break 2;
}
if (!$post) {
http_response_code(404);
echo "Not found";
exit;
}
$noteId = "$baseUrl/$username/status/{$date}-$hash";
// Determine if client accepts JSON
$accept = $_SERVER['HTTP_ACCEPT'] ?? '';
if (str_contains($accept, 'application/activity+json') || str_contains($accept, 'application/ld+json')) {
header('Content-Type: application/activity+json');
echo json_encode([
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $noteId,
'type' => 'Note',
'published' => date(DATE_ATOM, strtotime($date)),
'attributedTo' => "$baseUrl/$username",
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'content' => $post['value'],
'contentMap' => ['und' => $post['value']],
], JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
exit;
}
// Otherwise, return an HTML redirect after 1 second
header('Content-Type: text/html');
$redirectUrl = "https://alceawis.com#" . $noteId;
echo <<<HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting…</title>
<m eta ht. tp-equiv="refresh" content="1; url=$re. directUrl">
</head>
<body>
<p>Redirecting to <a href="$redirectUrl">$redirectUrl</a>…</p>
</body>
</html>
HTML;
exit;
}
|
2025-07-19 09:30:59 +02:00 |
|