4da5a8bc9c22895cc66ddf0906fb6228875d82bd
[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                 print placeholder_include('nieuws/replies');
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"%s>Feed</a></div>'."\n",
44         "/$Page/feed",
45         ' rel="alternate" title="Atom feed van nieuwsberichten" type="application/atom+xml"'
46 );
47 print $html;
48
49 print '<div id="news">'."\n\n";
50
51 foreach (array_reverse(glob("$Page/2???")) as $page) {
52         $year = basename($page, '.html');
53         printf('<h3><a href="/%s">%s</a></h3>'."\n", $page, $year);
54         printtoc($page);
55 }
56
57 if ($pages = glob("$Page/19??/*.html")) {
58         printf('<h3><a href="/%s">%s</a></h3>'."\n", "$Page/19", 'Eerder');
59         printtoc($pages);
60 }
61
62 print "</div>\n\n";
63
64 if ($replyform) {
65         print "<h3>Melding rapporteren</h3>\n";
66         $_REQUEST['subject'] = 'melding';
67         require 'contact.php';
68 ?>
69 <form method="post">
70 <p>
71         <textarea name="body" cols=60 rows=4></textarea>
72         <input type="submit" value="Versturen" />
73 </p>
74 </form>
75 <?php
76 }
77
78 if (!empty($User['admin'])) {
79         print '<script src="/nieuws/edit.js"></script>'."\n";
80 }