upload: common function to parse user text input
[minimedit.git] / issue / index.php
index f950861f98c4181e459e9cb1cbe925b1637baf7c..82fa39e024287b442086c82dd824e8010a24d8b5 100644 (file)
@@ -3,7 +3,7 @@ global $User, $Db;
 require_once 'database.inc.php';
 @list ($id, $title) = explode('/', ltrim($Args, '/'));
 
-if ($id) {
+if ($id and ctype_digit($id)) {
        $Article->title = "Issue #$id";
 
        $Issue = $Db->query(
@@ -16,7 +16,7 @@ if ($id) {
        $author = $Issue->author ? new User('profile/'.$Issue->author, FALSE) : NULL;
        printf('<p><em>%s</em>%s <small class=date>%s</small></p>'."\n",
                'Geplaatst',
-               $author ? " door <strong>{$author->name}</strong>" : '',
+               $author ? " door <strong>{$author->html}</strong>" : '',
                showdate(preg_split('/\D/', $Issue->created))
        );
        if ($Issue->assign) {
@@ -37,12 +37,11 @@ if ($id) {
 }
 
 if ($_POST) {
-               $html = nl2br(htmlspecialchars($_POST['body']));
-               $html = empty($html) ? NULL : "<p>$html</p>";
+               require_once 'upload.inc.php';
                $query = $Db->set('issues', [
                        'page'    => $Page,
                        'subject' => $_POST['subject'],
-                       'body'    => $html,
+                       'body'    => messagehtml($_POST['body']),
                        'author'  => $User->login,
                ]);
                if (!$query->rowCount()) {
@@ -60,17 +59,22 @@ if (isset($_GET['open'])) {
 $sql .= ' ORDER BY closed IS NOT NULL, updated DESC';
 $query = $Db->query($sql, [$Page]);
 
+if ($id == 'feed') {
+       require 'issue/feed.inc.php';
+}
+
 ob_start();
 print '<ul>';
 while ($row = $query->fetch()) {
-       printf('<li><a href="%s">%s <small class="date">%s</small>%s</a>',
+       printf('<li%s><a href="%s">%s <small class="date">%s</small>%s</a>',
+               $row->closed ? ' class="disabled"' : '',
                "/$Page/{$row->id}/{$row->link}",
-               sprintf($row->closed ? '<strike>%s</strike>' : '%s',
+               sprintf($row->closed ? '<s>%s</s>' : '%s',
                        htmlspecialchars($row->subject)),
                showdate(array_slice(preg_split('/\D/', $row->updated), 0, 3)),
                implode(' ', [
                        $row->replycount ? sprintf('<span class=right>+%d</span>', $row->replycount) : '',
-                       isset($row->assign) ? ' <em class="right">'.$row->assign.'</em>' : '',
+                       isset($row->assign) ? '<em class="right">'.$row->assign.'</em>' : '',
                ])
        );
        print "</li>\n";