login: metadata preview of linked subdirectory pages
[minimedit.git] / login / index.php
index e1f0cae048e58a2753b6a61dbb20ea46b025a0cc..f94984bbe0eec29dfb85620963cb0d4532dadc36 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+if ($Page->api) return;
 $message = NULL;
 
 if (isset($_POST['mail'])) {
@@ -38,25 +39,19 @@ elseif (isset($_GET['logout'])) {
 if (!$User or !$User->login) {
        $Page->title = 'Inloggen';
        if (isset($_REQUEST['goto'])) {
-               if (empty($message)) http_response_code(403);
-               $target = ltrim($_REQUEST['goto'], '/');
-               $target = new ArchiveArticle("$target.html");
-
-               if ($target and $target->handler == 'melding') {
-                       $caller = $Page;
-                       $Page = $target;
-                       ob_start();
-                       include "./{$target->handler}/index.php";
-                       ob_end_clean();
-                       $Page = $caller;
+               if (empty($message)
+               and !preg_match('(^WhatsApp/)', $_SERVER['HTTP_USER_AGENT'])) {
+                       http_response_code(403);
                }
+               $target = ltrim($_REQUEST['goto'], '/');
+               $target = new ArchiveArticle(file_exists("$target/index.html") ? "$target/index.html" : "$target.html");
+               $target->index; # run forbidden handler to determine metadata
 
                if ($target->title) {
                        $Page->title .= ' voor ' . $target->title;
                }
-               if ($target->image) {
-                       $Page->image = $target->image;
-               }
+               $Page->image = $target->image;
+               $Page->teaser = $target->teaser;
        }
        ob_start();
        require_once 'login/form.inc.php';
@@ -67,9 +62,7 @@ if (!$User or !$User->login) {
 
 if (isset($_REQUEST['goto'])) {
        $target = ltrim($_REQUEST['goto'], '/');
-       header("Location: /$target");
-       http_response_code(302);
-       exit;
+       abort("/$target", '303 Return');
 }
 
 if (isset($Page->raw)) {