return;
}
+ function restricted()
+ {
+ $this->handler;
+ return $this->restricted;
+ }
+
function safetitle()
{
return trim($this->meta['og:title'] ?? strip_tags($this->title));
exit;
}
-$rootdir = 'foto' . $Args;
+$rootdir = 'foto' . $Page->path;
$target = "$rootdir/index.jpg";
if (is_link($target) or file_exists($target)) {
if (!unlink($target)) {
http_response_code(500);
- print "Kon bestaande cover niet weghalen voor $Args\n";
+ print "Kon bestaande cover niet weghalen voor {$Page->path}\n";
exit;
}
}
$img .= ltrim($_GET['img'], '/');
if (!symlink($img, $target)) {
http_response_code(500);
- print "Fout bij instellen van cover voor $Args\n";
+ print "Fout bij instellen van cover voor {$Page->path}\n";
exit;
}
}
<?php
if (!$_POST)
abort("niets te doen", '405 post error');
-if (!$Args)
+if (!$Page->path)
abort("pagina niet opgegeven", '409 input error');
-$pagename = ltrim($Args, '/').'.html';
+$pagename = ltrim($Page->path, '/').'.html';
if (!$User->admin("edit $pagename"))
abort("geen beheersrechten", '401 unauthorised');
<?php
-if (!$User->admin("edit $Page$Args"))
+if (!$User->admin("edit {$Page->link}"))
abort("geen beheersrechten", '401 unauthorised');
if ($_FILES) {
try {
require_once('upload.inc.php');
$datadir = implode('/', ['data', date('Y')]);
- if ($Args) $datadir .= $Args;
+ if ($Page->path) $datadir .= $Page->path;
$target = userupload(@$_FILES['upload'], $datadir);
if ($target) {
$response['fileName'] = $_FILES['upload']['name'];
if (!$_POST)
abort("niets te doen", '405 post error');
-$filename = trim($Args, '/') ?: 'index';
+$filename = trim($Page->path, '/') ?: 'index';
if (preg_match('{^\.}', $filename))
abort("ongeldige bestandsnaam: $filename", '403 input error');
if (is_dir($filename) && !file_exists("$filename.html"))
<?php
if ($User->admin('foto')) {
printf("\t\t\t{id:'%s', label:'%s', url:'%s'},\n",
- 'cover', 'Cover instellen', "/edit/foto/cover$Args?img={{image_url}}"
+ 'cover', 'Cover instellen', "/edit/foto/cover{$Page->path}?img={{image_url}}"
);
}
?>
<?php
-$rootdir = $Page . $Args;
+$rootdir = $Page->link;
if ($User->admin('foto')) {
- if (!empty($PageAccess)) {
+ if ($Page->restricted) {
$access = '<span class="icon icon-locked">🔒</span> Bewoners';
- if ($PageAccess != $rootdir) {
+ if ($Page->restricted != $rootdir) {
$access .= sprintf(' vanaf <a href="%s">%s</a>',
- "/$PageAccess", pathinfo($PageAccess, PATHINFO_FILENAME)
+ "/{$Page->restricted}", pathinfo($Page->restricted, PATHINFO_FILENAME)
);
}
}
$nav = explode('/', $rootdir);
$nav[0] = "Foto's"; # override of root 'foto'
$title = array_pop($nav);
-$Article->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title;
+$Page->title = ($nav ? implode(' ', $nav) . ': ' : '') . $title;
$link = '';
print "<h2>";
foreach ($nav as $i => $linktitle) {
- $link .= '/' . ($i ? $linktitle : $Page);
+ $link .= '/' . ($i ? $linktitle : $Page->handler);
printf('<a href="%s">%s</a> →'."\n", $link, $linktitle);
}
print $title;
print "</h2>\n\n";
-if (isset($Article->raw)) {
- print $Article->raw; # page intro
+if (isset($Page->raw)) {
+ print $Page->raw; # page intro
}
function showthumb($path)
foreach ($imgs as $img) {
if ($img == "$rootdir/index.jpg") {
# cover image of current album
- $Article->image = "/$img";
+ $Page->image = "/$img";
continue;
}
if (!is_link($img)) continue;
<html lang="nl">
<head>
<meta charset="utf-8" />
-<?php if ($Article->title) { ?>
- <title property="og:name"><?= htmlspecialchars($Article->safetitle) ?></title>
+<?php if ($Page->title) { ?>
+ <title property="og:name"><?= htmlspecialchars($Page->safetitle) ?></title>
<?php } ?>
-<?php if ($Article->teaser) { ?>
- <meta name="description" property="og:description" content="<?= preg_replace('/\s+/', ' ', strip_tags($Article->teaser)) ?>" />
+<?php if ($Page->teaser) { ?>
+ <meta name="description" property="og:description" content="<?= preg_replace('/\s+/', ' ', strip_tags($Page->teaser)) ?>" />
<?php } ?>
<meta name="viewport" content="width=device-width" />
<!--[if lt IE 9]><script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script><![endif]-->
-<?php if ($Article->image) { ?>
- <meta property="og:image" content="https://<?= $_SERVER['HTTP_HOST'] . '/' . htmlspecialchars($Article->thumb('640x')) ?>" />
+<?php if ($Page->image) { ?>
+ <meta property="og:image" content="https://<?= $_SERVER['HTTP_HOST'] . '/' . htmlspecialchars($Page->thumb('640x')) ?>" />
<?php } ?>
- <meta property="og:type" content="<?= $Article->meta['og:type'] ?? 'website' ?>" />
- <meta property="og:url" content="https://<?= $_SERVER['HTTP_HOST'] . '/' . htmlspecialchars($Article->link) ?>" />
+ <meta property="og:type" content="<?= $Page->meta['og:type'] ?? 'website' ?>" />
+ <meta property="og:url" content="https://<?= $_SERVER['HTTP_HOST'] . '/' . htmlspecialchars($Page->link) ?>" />
</head>
<body>
while ($row = $query->fetch()) {
?>
<entry>
- <id><?= "$siteref/$Page/{$row->id}/{$row->link}" ?></id>
- <link href="<?= "$siteref/$Page/{$row->id}/{$row->link}" ?>" />
+ <id><?= "$siteref/{$Page->handler}/{$row->id}/{$row->link}" ?></id>
+ <link href="<?= "$siteref/{$Page->handler}/{$row->id}/{$row->link}" ?>" />
<title><?= $row->subject ?></title>
<published><?= $row->created ?></published>
<updated><?= $row->updated ?></updated>
<?php
global $User, $Db;
require_once 'database.inc.php';
-@list ($id, $title) = explode('/', ltrim($Args, '/'));
+@list ($id, $title) = explode('/', ltrim($Page->path, '/'));
if ($id and ctype_digit($id)) {
- $Article->title = "Issue #$id";
- $Args = "/$id"; # minimal reference
+ $Page->title = "Issue #$id";
+ $Page->path = "/$id"; # minimal reference
$Issue = $Db->query(
- 'SELECT * FROM issues WHERE page = ? AND id = ?', [$Page, $id]
+ 'SELECT * FROM issues WHERE page = ? AND id = ?', [$Page->handler, $id]
)->fetch();
if (!$Issue) throw new Exception('Issuenummer niet gevonden');
$replies = placeholder_include('reply'); # handle updates
- $Article->title .= ': '.htmlspecialchars($Issue->subject);
- $Article->teaser = $Issue->body;
- $Article->body = $replies; # find image
+ $Page->title .= ': '.htmlspecialchars($Issue->subject);
+ $Page->teaser = $Issue->body;
+ $Page->body = $replies; # find image
- print "<h2>{$Article->title}</h2>\n";
+ print "<h2>{$Page->title}</h2>\n";
print '<aside class="metadata"><dl>'."\n";
print '<dt>Geplaatst</dt>';
printf('<dd>%s</dd>'."\n", showdate(preg_split('/\D/', $Issue->created)));
if ($_POST) {
require_once 'upload.inc.php';
$query = $Db->set('issues', [
- 'page' => $Page,
+ 'page' => $Page->handler,
'subject' => $_POST['subject'],
'body' => messagehtml($_POST['body']),
'author' => $User->login,
$sql .= ' AND closed IS NULL';
}
$sql .= ' ORDER BY closed IS NOT NULL, updated DESC';
-$query = $Db->query($sql, [$Page]);
+$query = $Db->query($sql, [$Page->handler]);
if ($id == 'feed') {
require 'issue/feed.inc.php';
while ($row = $query->fetch()) {
printf('<li%s><div><a href="%s">',
$row->closed ? ' class="disabled"' : '',
- "/$Page/{$row->id}/{$row->link}"
+ "/{$Page->handler}/{$row->id}/{$row->link}"
);
printf($row->closed ? '<s>%s</s>' : '%s', htmlspecialchars($row->subject));
{
<?php
-if ($Args and $User->admin('user')) {
- $user = new User(strtolower("profile$Args"), FALSE);
+if ($Page->path and $User->admin('user')) {
+ $user = new User(strtolower("profile{$Page->path}"), FALSE);
print placeholder_include('login/admin');
- $Article->title = "Profiel <em>{$user->login}</em>";
- print "<h2>{$Article->title}</h2>\n";
+ $Page->title = "Profiel <em>{$user->login}</em>";
+ print "<h2>{$Page->title}</h2>\n";
print placeholder_include('login/edit');
return;
}
}
if (!$User or !$User->login) {
- $Article->title = 'Inloggen';
+ $Page->title = 'Inloggen';
if (isset($_REQUEST['goto'])) {
if (empty($message)) http_response_code(403);
$target = ltrim($_REQUEST['goto'], '/');
$target = new ArchiveArticle("$target.html");
- if ($Page = $target->handler and $target->handler == 'melding') {
- $caller = $Article;
- $Article = $target;
- $Args = $target->path;
+ if ($target and $target->handler == 'melding') {
+ $caller = $Page;
+ $Page = $target;
ob_start();
include "./{$target->handler}/index.php";
ob_end_clean();
- $Article = $caller;
+ $Page = $caller;
}
if ($target->title) {
- $Article->title .= ' voor ' . $target->title;
+ $Page->title .= ' voor ' . $target->title;
}
if ($target->image) {
- $Article->image = $target->image;
+ $Page->image = $target->image;
}
}
ob_start();
require_once 'login/form.inc.php';
- $Article->raw = ob_get_clean();
+ $Page->raw = ob_get_clean();
$Place['warn'] = $message;
return TRUE;
}
exit;
}
-if (isset($Article->raw)) {
- print $Article->raw;
+if (isset($Page->raw)) {
+ print $Page->raw;
}
-if (empty($Args) and $User->admin) {
+if (empty($Page->path) and $User->admin) {
include_once 'login/admin.html';
}
printf('<p class=warn>%s</p>', $e->getMessage());
return;
}
- $Article->title = $user->login . ': ' . $Article->title;
+ $Page->title = $user->login . ': ' . $Page->title;
}
else {
$user = $User;
<?php
$mailbox = 'mail/inbox';
-@list ($msgid) = explode('/', ltrim($Args, '/'));
+@list ($msgid) = explode('/', ltrim($Page->path, '/'));
function parsemailhead($headerdata)
{
list ($headerdata, $rawbody) = explode("\n\n", file_get_contents($filename), 2);
$head = parsemailhead($headerdata);
- $Article->title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i');
+ $Page->title = 'Mailbericht ' . $head['date']->format('Y-m-d H:i');
printf("<h2>%s</h2>\n", htmlspecialchars($head['Subject'] ?? 'Mailbericht zonder onderwerp'));
print '<dl class="terse">';
list ($headerdata) = explode("\n\n", file_get_contents($filename));
$head = parsemailhead($headerdata);
- printf('<li><a href="%s">', "/$Page/".basename($filename));
+ printf('<li><a href="%s">', "/{$Page->handler}/".basename($filename));
print $head['Subject'];
printf(' <small class="date">%s</small>',
<icon>/favicon.png</icon>
<author><name>Lijtweg</name></author>
<?php
-$root = preg_replace('{/feed$}', '', $Page) . "/2???";
+$root = preg_replace('{/feed$}', '', $Page->handler) . "/2???";
$pages = array_reverse(glob("$root/*.html"));
foreach ($pages as $i => $page) {
<?php
-$replyform = $Page == 'melding' && $User->login;
-@list ($year, $page) = explode('/', trim($Args, '/'));
+$replyform = $Page->handler == 'melding' && $User->login;
+@list ($year, $page) = explode('/', trim($Page->path, '/'));
-if ($User->admin("edit $Page")) {
+if ($User->admin("edit {$Page->handler}")) {
print '<script src="/nieuws/edit.js"></script>'."\n";
}
if ($page and !is_numeric($page)) {
- $Article->meta['og:type'] = 'article';
- $edit = $User->admin("edit $Page$Args") ? htmlspecialchars(@$_GET['edit']) : NULL;
+ $Page->meta['og:type'] = 'article';
+ $edit = $User->admin("edit {$Page->link}") ? htmlspecialchars(@$_GET['edit']) : NULL;
if ($edit) {
- $Article->title = $edit;
+ $Page->title = $edit;
}
- if ($Article->dateparts) {
- $Place[1] = ' <small class="date">'.$Article->date.'</small>';
+ if ($Page->dateparts) {
+ $Place[1] = ' <small class="date">'.$Page->date.'</small>';
}
else {
$Place[1] = '';
}
- print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Article->raw);
- if ($User->admin("edit $Page$Args")) {
+ print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', $Page->raw);
+ if ($User->admin("edit {$Page->link}")) {
$taglist = [];
- foreach (glob("$Page/.tags/*") as $tagpath) {
+ foreach (glob("{$Page->handler}/.tags/*") as $tagpath) {
$tagname = pathinfo($tagpath, PATHINFO_BASENAME);
$tagvalue = file_exists("$tagpath/$year-$page.html");
$tagtarget = is_writable($tagpath);
}
if ($year) {
- $match = $Page;
+ $match = $Page->handler;
$title = "Nieuws";
if (is_numeric($year) and $year > 999) {
$match .= "/$year";
$match .= "/19??";
$title .= " vóór 2000";
}
- elseif (file_exists("$Page/.tags/$year")) {
+ elseif (file_exists("{$Page->handler}/.tags/$year")) {
$match .= "/.tags/$year";
$title .= " met $year";
}
'<span class="icon icon-user">👤</span>',
'/login', $User->login
);
- if ($User->admin("edit $Page$Args")) {
- $editpage = $Page.$Args;
+ if ($User->admin("edit {$Page->link}")) {
+ $editpage = $Page->link;
if (is_dir($editpage)) {
if (file_exists("$editpage/index.html")) {
$editpage .= '/index.html';
@include 'footer.inc.html';
print "</footer>\n";
- global $User, $Page, $Args;
- if ($User and $User->admin("edit $Page$Args")) {
+ global $User, $Page;
+ if ($User and $User->admin("edit {$Page->link}")) {
$ckesrc = '/lib/ckeditor'; # local install
if (!file_exists(DOCROOT . $ckesrc)) {
$ckesrc = '//cdn.ckeditor.com/4.15.1/full-all'; # remote fallback
}
ob_start();
- $Page = $GLOBALS['Page'] . $GLOBALS['Args'];
- $Args = '';
+ $Page = clone $GLOBALS['Page'];
+ $Page->handler = $Page->handler . $Page->path; // .= with explicit getter
+ $Page->path = '';
$Place = $GLOBALS['Place'];
foreach ($params as $param) {
if ($set = strpos($param, '=')) {
$Place[ substr($param, 0, $set) ] = substr($param, $set + 1);
}
elseif (!empty($param)) {
- $Args .= '/'.$param;
+ $Page->path .= '/'.$param;
}
}
+ $Page->link .= $Page->path;
try {
include "widget/$name.php";
return ob_get_clean();
function fail($error)
{
- global $User, $Page, $Args;
+ global $User, $Page;
http_response_code(500);
- if (!isset($Article)) {
+ if (!isset($Page)) {
require_once('article.inc.php');
- $Article = new ArchiveArticle(NULL);
- $Article->title = 'Fout';
+ $Page = new ArchiveArticle(NULL);
+ $Page->title = 'Fout';
}
include_once 'page.inc.php';
ob_start();
# setup requested page
-$Args = '';
-$Page = preg_replace('/\?.*/', '', @$_SERVER['PATH_INFO'] ?: $_SERVER['REQUEST_URI']);
-$Page = urldecode(trim($Page, '/')) ?: 'index';
+$request = preg_replace('/\?.*/', '', @$_SERVER['PATH_INFO'] ?: $_SERVER['REQUEST_URI']);
+$request = urldecode(trim($request, '/')) ?: 'index';
-$staticpage = "$Page.html";
+$staticpage = "$request.html";
if (file_exists($staticpage)) {
if (is_link($staticpage)) {
$target = preg_replace('/\.html$/', '', readlink($staticpage));
exit;
}
}
-elseif (file_exists("$Page/index.html")) {
- $staticpage = "$Page/index.html";
+elseif (file_exists("$request/index.html")) {
+ $staticpage = "$request/index.html";
}
require_once('article.inc.php');
-$Article = new ArchiveArticle($staticpage);
+$Page = new ArchiveArticle($staticpage);
-$Page = $Article->handler;
-$Args = $Article->path;
-
-if ($PageAccess = $Article->restricted) {
+if ($Page->restricted) {
# access restriction
if (!$User->login) {
http_response_code(303);
- $target = urlencode($Article->link);
+ $target = urlencode($Page->link);
header("Location: /login?goto=$target");
exit;
}
'url' => htmlspecialchars($_SERVER['REQUEST_URI']),
];
-if (!isset($Article->raw) and $User->admin("edit {$Article->link}")) {
- # open template as initial contents
- $Article->raw(file_exists("$Page/template.inc.html") ? "$Page/template.inc.html" : 'template.inc.html');
- $Article->meta['article:published_time'] = date('Y-m-d h:i:s O');
- $Article->meta['article:author'] = '/' . $User->dir;
+if (!isset($Page->raw) and $User->admin("edit {$Page->link}")) {
+ # open bottom template as initial contents
+ $template = 'template.inc.html';
+ if ($Page->handler and file_exists("{$Page->handler}/$template")) {
+ $template = "{$Page->handler}/$template";
+ }
+ $Page->raw($template);
+ $Page->meta['article:published_time'] = date('Y-m-d h:i:s O');
+ $Page->meta['article:author'] = '/' . $User->dir;
}
-if (isset($Article->raw)) {
- if ($User->admin("edit $Page$Args")) {
+if (isset($Page->raw)) {
+ if ($User->admin("edit {$Page->link}")) {
# restore meta tags in static contents for editing
- foreach (array_reverse($Article->meta) as $metaprop => $val) {
- $Article->raw = sprintf(
+ foreach (array_reverse($Page->meta) as $metaprop => $val) {
+ $Page->raw = sprintf(
'<meta property="%s" content="%s">'."\n",
$metaprop, $val
- ) . $Article->raw;
+ ) . $Page->raw;
}
}
- $Article->raw = '<div class="static">'."\n\n".$Article->raw."</div>\n\n";
+ $Page->raw = '<div class="static">'."\n\n".$Page->raw."</div>\n\n";
}
# output dynamic and/or static html
-if (!$Page or require("./$Page/index.php")) {
+if (!$Page->handler or require("./{$Page->handler}/index.php")) {
# static contents
- if (isset($Article->raw)) {
- print $Article->raw;
+ if (isset($Page->raw)) {
+ print $Page->raw;
}
else {
# no resulting output
<?php
-list ($size, $imgpath) = explode('/', ltrim($Args, '/'), 2);
+list ($size, $imgpath) = explode('/', ltrim($Page->path, '/'), 2);
$imgpath = preg_replace('{^(?=[0-9]+/)}', 'data/', $imgpath, 1);
if (!file_exists($imgpath)) {
<?php
-if (empty($Args)) {
+if (empty($Page->path)) {
return;
}
-@list ($target, $interval) = explode('+', ltrim($Args, '/'));
+@list ($target, $interval) = explode('+', ltrim($Page->path, '/'));
$target = new DateTime($target);
$now = new DateTime('NOW');
$next = $target->diff($now); # age
global $User;
$cal = [];
-foreach (glob("$Page$Args/2*") as $url) {
+foreach (glob("{$Page->link}/2*") as $url) {
$link = preg_replace('/\.html$/', '', $url);
$name = pathinfo($link, PATHINFO_BASENAME);
@list ($date, $suffix) = explode('.', $name, 2);
else {
print '<span>';
print $title;
- if ($versions and $User->admin("edit $Page$Args")) {
+ if ($versions and $User->admin("edit {$Page->link}")) {
printf(' (%s)', implode(', ', array_map(
function ($format, $url) {
return sprintf('<a href="/%s">%s</a>', $url, $format);
<?php
- $article = new ArchiveArticle($Args);
+ $article = new ArchiveArticle($Page->path);
printf('<a href="%s">%s</a>', $article->link, $article->name);
if ($article->image) {
printf("\n\t".'<img class="right" src="/%s" />', $article->thumb('100x100'));
print "</ul>\n\n";
pclose($log);
- $navbase = $Page == 'login/commits' ? '?' : '/login/commits?';
+ $navbase = $Page->handler == 'login/commits' ? '?' : '/login/commits?';
$nav = [];
$nav[] = sprintf('Pagina %d', ceil($offset / $pagesize) + 1);
if ($lines >= $pagesize) {
<?php
$basepath = 'profile';
-if ($Args) $basepath .= '/.tags' . $Args;
+if ($Page->path) $basepath .= '/.tags' . $Page->path;
$users = glob("$basepath/*/");
if (!$users) return;
}
}
-$articles = (ltrim($Args, '/') ?: 'nieuws');
+$articles = (ltrim($Page->path, '/') ?: 'nieuws');
if (strpos($articles, '/') === FALSE) {
if (@$Place['view'] === 'toc') {
print "<div>\n";
<?php
-include ".$Args.html";
+include ".{$Page->path}.html";
}
}
$query = $Db->set('comments', [
- 'page' => $Page,
+ 'page' => $Page->handler,
'message' => $html,
'author' => $User->login,
]);
}
$cols = '*, (SELECT json_agg(journal.*) FROM journal WHERE comment_id = comments.id) AS journal';
-$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page]);
+$query = $Db->query("SELECT $cols FROM comments WHERE page = ? ORDER BY created", [$Page->handler]);
print '<ul class="replies">';
if ($User->login) {
print '<li>';
print '<form method="post" action="" enctype="multipart/form-data">';
- if (isset($Issue) and $User->admin("edit $Page")) {
+ if (isset($Issue) and $User->admin("edit {$Page->handler}")) {
print '<p>';
printf(
'<label for="%s">%s:</label> '
<?php
$limit = @$Place['limit'] ?: 10;
$path = ' '.escapeshellarg('*.html');
-$query = @$_REQUEST['q'] ?: $Args ?: $Page;
+$query = @$_REQUEST['q'] ?: $Page->path ?: $Page->handler;
if (!trim($query, '/')) return;
<?php
# list article details
-$search = new PageSearch(ltrim($Args, '/') ?: '.');
+$search = new PageSearch(ltrim($Page->path, '/') ?: '.');
print '<ul class="replies">'."\n";
-foreach ($search->files() as $Args => $sorted) {
+foreach ($search->files() as $ref => $sorted) {
+ $Page->path = $ref;
print '<li>';
include 'linkref.php';
print "</li>\n";