9 Commits

Author SHA1 Message Date
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
Alcea 452fef3290 Add files via upload 2025-07-15 12:52:57 +02:00
Alcea 90d02f346f Add files via upload
Instance endpoint
2025-07-14 10:11:30 +02:00
Alcea 65a22d963b Add files via upload 2025-07-14 09:53:08 +02:00
Alcea da241c40a7 Add files via upload
Compatibility for nodeinfo
2025-07-14 09:35:27 +02:00
Alcea 2ef091e148 Add files via upload
Only redirect status posts to renderer if direcrly from alceawis root domain
2025-07-13 07:49:40 +02:00
Alcea fe11e33f6d Add files via upload 2025-07-13 07:42:06 +02:00
Alcea d5289fc575 Add files via upload
Fixing users redirect to actual user with htaccess
Hope this won't break things...
2025-07-12 09:58:11 +02:00
alceawisteria a973aaeedf Upload files to "/" 2025-07-08 20:15:51 +02:00