cdb38925e1d50dcea8450ab8244c785b336ae929
[minimedit.git] / nieuws / index.php
1 <?php
2 include 'nieuws.inc.php';
3
4 $replyform = $Page == 'melding' && !empty($User);
5 @list ($year, $page) = explode('/', trim($Args, '/'));
6
7 if ($page and !is_numeric($page)) {
8         $edit = !empty($User['admin']) ? htmlspecialchars(@$_GET['edit']) : NULL;
9         $article = new ArchiveArticle("$Page$Args.html");
10         $Place[1] = ' <small class="date">'.$article->date.'</small>';
11         print preg_replace('{(?<=<h2>)(.*?)(?=</h2>)}', ($edit ?: '\1').' [[1]]', ob_get_clean());
12         if ($article->image) {
13                 $Place['image'] = "https://lijtweg.nl/".$article->thumb('600x');
14         }
15         if ($replyform) {
16                 include 'nieuws/replies.php';
17         }
18         return 1;
19 }
20
21 if ($year) {
22         ob_clean();
23         $title = "Nieuws";
24         if (is_numeric($year) and $year > 999) {
25                 $match = "$Page/$year/";
26                 if (is_numeric($page)) {
27                         $title .= ' '.$monthname[intval($page)];
28                         $match .= sprintf('%02d-', $page);
29                 }
30                 $title .= ' '.$year;
31         }
32         elseif ($year === '19') {
33                 $match = "$Page/19??/";
34                 $title .= " vóór 2000";
35         }
36
37         print "<h2>$title</h2>\n\n";
38         shownews(glob($match.'*.html'));
39         return 1;
40 }
41
42 $html = ob_get_clean();
43 printf('<div class="nav right"><a href="%s">Feed</a></div>'."\n", "/$Page/feed");
44 print $html;
45
46 print '<div id="news">'."\n\n";
47
48 foreach (array_reverse(glob("$Page/2???")) as $page) {
49         $year = basename($page, '.html');
50         printf('<h3><a href="/%s">%s</a></h3>'."\n", $page, $year);
51         printtoc($page);
52 }
53
54 if ($pages = glob("$Page/19??/*.html")) {
55         printf('<h3><a href="/%s">%s</a></h3>'."\n", "$Page/19", 'Eerder');
56         printtoc($pages);
57 }
58
59 print "</div>\n\n";
60
61 if ($replyform) {
62         print "<h3>Melding rapporteren</h3>\n";
63         $_REQUEST['subject'] = 'melding';
64         require 'contact.php';
65 ?>
66 <form method="post">
67 <p>
68         <textarea name="body" cols=60 rows=4></textarea>
69         <input type="submit" value="Versturen" />
70 </p>
71 </form>
72 <?php
73 }
74
75 if (!empty($User['admin'])) {
76         print '<script src="/nieuws/edit.js"></script>'."\n";
77 }