nieuws: blockquote containers around replies
[minimedit.git] / nieuws / replies.php
1 <?php
2 global $User;
3
4 print '<h3>Reacties</h3>'."\n";
5 $pagelink = $Page.$Args;
6
7 if ($_POST) {
8         try {
9                 @mkdir($pagelink);
10                 $target = $pagelink.'/'.date('YmdHis').':'.$User['name'].'.html';
11                 $html = nl2br(htmlspecialchars($_POST['reply']));
12                 $html = "<p>$html</p>\n";
13                 $written = file_put_contents($target, $html);
14                 if ($written === FALSE) {
15                         throw new Exception('Fout bij opslaan');
16                 }
17                 $_POST['reply'] = NULL;
18         }
19         catch (Exception $e) {
20                 print '<p class=warn>Antwoord niet opgeslagen.</p>'."\n\n";
21         }
22 }
23
24 print '<ul class="replies">';
25
26 foreach (glob("$pagelink/*.html") as $reply) {
27         preg_match('</(\d{2,14}) : ([^:]*) [^/]* \.html$>x', $reply, $replymeta);
28         if (!$replymeta) continue;
29         $replydate = str_split($replymeta[1], 2);
30         $replydate[1] = $replydate[0] . $replydate[1];
31         print '<li>';
32         printf('<strong>%s</strong> <small class=date>%s</small>',
33                 $replymeta[2], showdate($replydate)
34         );
35         printf("<blockquote>%s</blockquote>\n", file_get_contents($reply));
36         print "</li>\n";
37 }
38
39 print '<li>';
40 print '<form method="post" action="">';
41 printf('<textarea id="%s" name="%1$s" cols=60 rows=3 placeholder="%s">%s</textarea>'."\n",
42         'reply',
43         "Bericht van {$User['name']}",
44         ''
45 );
46 print '<input type="submit" value="Plaatsen" />'."\n";
47 print "</form></li>\n";
48
49 print "</ul>\n\n";