From: Mischa POSLAWSKY Date: Sun, 27 Dec 2020 18:33:48 +0000 (+0100) Subject: page: api attribute indicate index requests X-Git-Tag: v5.1~14 X-Git-Url: http://git.shiar.nl/minimedit.git/commitdiff_plain/da2d6e5537e9fdcd6f424ea1cc8ab6ef8f45727e page: api attribute indicate index requests Replaces userless calls for better fault tolerance and permission support. --- diff --git a/article.inc.php b/article.inc.php index 9e92094..1dbda25 100644 --- a/article.inc.php +++ b/article.inc.php @@ -4,6 +4,7 @@ class ArchiveArticle public $raw, $title, $body; # file contents public $meta = []; # head metadata properties public $place = []; # template variables replaced in render() + public $api = FALSE; # requested programming interface function __construct($path) { @@ -71,7 +72,7 @@ class ArchiveArticle if (empty($this->handler)) { return; } - $User = NULL; + $this->api = TRUE; $Page = $this; $res = include "./{$this->handler}/index.php"; return $res; diff --git a/edit/index.php b/edit/index.php index ae2da7e..ebf3d5d 100644 --- a/edit/index.php +++ b/edit/index.php @@ -1,3 +1,3 @@ api) return; abort("aanpasdienst onbekend", '404 unknown'); diff --git a/foto/index.php b/foto/index.php index 7df1d5c..a6378ef 100644 --- a/foto/index.php +++ b/foto/index.php @@ -6,7 +6,7 @@ $nav[0] = "Foto's"; # override of root 'foto' $title = array_pop($nav); $Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title; -if (!$User) { +if ($Page->api) { $img = "$rootdir/index.jpg"; if (file_exists($img)) { # cover image of current album diff --git a/issue/index.php b/issue/index.php index e8a36d2..87b22a3 100644 --- a/issue/index.php +++ b/issue/index.php @@ -15,7 +15,7 @@ if ($id and ctype_digit($id)) { $Page->title .= ': '.htmlspecialchars($Issue->subject); $Page->teaser = $Issue->body; - if (!$User) return; + if ($Page->api) return; $Page->body = $replies; # find image print "

{$Page->title}

\n"; @@ -41,7 +41,6 @@ if ($id and ctype_digit($id)) { print "\n"; return; } -elseif (!$User) return; if ($_POST) { require_once 'upload.inc.php'; @@ -56,6 +55,7 @@ if ($_POST) { } $_POST = []; } +if ($Page->api) return; $subsql = "SELECT count(*) FROM comments WHERE page=i.page||'/'||i.id"; $cols = "*, ($subsql AND message IS NOT NULL) AS replycount"; diff --git a/login/index.php b/login/index.php index 8e36628..38b7c23 100644 --- a/login/index.php +++ b/login/index.php @@ -1,5 +1,5 @@ api) return; $message = NULL; if (isset($_POST['mail'])) { diff --git a/login/post/index.php b/login/post/index.php index 23c4451..c4dcffc 100644 --- a/login/post/index.php +++ b/login/post/index.php @@ -1,5 +1,5 @@ api) return; if (!$User->login) { $target = urlencode($_SERVER['REQUEST_URI']); diff --git a/mail/index.php b/mail/index.php index 2b6e600..ee7365a 100644 --- a/mail/index.php +++ b/mail/index.php @@ -55,7 +55,7 @@ if ($msgid) { return; } -if (!$User) { +if ($Page->api) { return; } if (!$User->admin('user')) { diff --git a/nieuws/index.php b/nieuws/index.php index 6ea68dc..1cbaf94 100644 --- a/nieuws/index.php +++ b/nieuws/index.php @@ -2,7 +2,7 @@ $replyform = $Page->handler == 'melding' && $User->login; @list ($year, $page) = explode('/', trim($Page->path, '/')); -if (!$User) { +if ($Page->api) { if ($Page->path) return; return (new PageSearch($Page->link))->files(); } diff --git a/sitemap.xml/index.php b/sitemap.xml/index.php index 82abc75..99b6fcf 100644 --- a/sitemap.xml/index.php +++ b/sitemap.xml/index.php @@ -1,5 +1,5 @@ api) return; header('Content-Type: application/atom+xml; charset=utf-8'); print ''; $siteref = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . '://' . $_SERVER['HTTP_HOST']; diff --git a/thumb/index.php b/thumb/index.php index 42e9362..9232b33 100644 --- a/thumb/index.php +++ b/thumb/index.php @@ -1,5 +1,5 @@ api) return; $imgpath = ltrim($Page->path, '/'); if (!preg_match('{^[0-9x]+/}', $imgpath)) { return;