Import fortune foo from www.infodrom.org
[infodrom.org/lists.infodrom.org] / src / index.wml
1 #include <infodrom.style>
2 #include <quote.style>
3
4 <page title="Infodrom Oldenburg - Mail-Archive">
5
6 <p><colorbox bgcolor=<box-blue>>
7 <font size=+1 color=ffffff><b>Mail Archive<?
8   if (strlen ($_GET["list"]) > 0 && is_dir ($_GET["list"])) {
9     echo " - " . $_GET["list"];
10   }
11 ?></b></font>
12 </colorbox>
13
14 <ul>
15 <?
16   /*
17     ACHTUNG: - Kein Support für ausgeschriebenen Namen der Liste
18              - Kein Support für Liste ohne Unterverzeichnisse 1999, 2000 etc.
19   */
20
21   function get_months ($dirname)
22   {
23     $dir = dir ($dirname);
24     $months = array ();
25
26     while ($dentry = $dir->read()) {
27       if ($dentry != "." && $dentry != ".." && is_dir ("$dirname/$dentry") && ereg ("^[01][0-9]$", $dentry)) {
28         $months[] = $dentry;
29       }
30     }
31     $dir->close();
32     sort ($months);
33     return $months;
34   }
35
36   if (strlen ($_GET["list"]) > 0 && is_dir ($_GET["list"])) {
37     $dirs = array ($_GET["list"]);
38   } else {
39     $dir = dir (".");
40     $dirs = array ();
41     while ($dentry = $dir->read()) {
42       if ($dentry != "." && $dentry != ".." && is_dir ($dentry)
43         && $dentry != "gifs" && $dentry != "stats") {
44         $dirs[] = $dentry;
45       }
46     }
47     $dir->close();
48     sort ($dirs);
49   }
50
51   $max = count ($dirs);
52   for ($i=0; $i < $max; $i++) {
53
54     $file = $dirs[$i] . "/" . "index.inc";
55     if (is_file ($file)) {
56       $f = fopen ($file, "r");
57       if ($f) {
58         while (!feof ($f)) {
59           $line = fgets ($f, 255);
60           print ($line);
61         }
62         fclose ($f);
63       }
64     } else {
65       # Do it yourself
66
67
68     printf ("<li> <strong>%s</strong><br>", $dirs[$i]);
69
70     $dir = dir ($dirs[$i]);
71     $years = array ();
72     while ($dentry = $dir->read()) {
73       if ($dentry != "." && $dentry != ".." && is_dir ("$dirs[$i]/$dentry")) {
74         $years[] = $dentry;
75       }
76     }
77     $dir->close();
78     sort ($years);
79
80     $ymax = count ($years);
81     for ($y=0; $y < $ymax; $y++) {
82       $months = get_months ("$dirs[$i]/$years[$y]");
83       if (count ($months) > 0) {
84         printf ("%s%s (", $y>0?", ":"", $years[$y]);
85         for ($m=0; $m < count ($months); $m++) {
86           printf ("%s<a href=\"%s/%s/%s/\">%s</a>",
87             $m>0?", ":"", $dirs[$i], $years[$y], $months[$m], $months[$m]);
88         }
89         echo   (")");
90       } else {
91         printf ("%s<a href=\"%s/%s/\">%s</a>",
92           $y>0?", ":"", $dirs[$i], $years[$y], $years[$y]);
93       }
94     }
95   }  # else
96   }
97
98   if (strlen ($_GET["list"]) > 0 && is_dir ($_GET["list"])) {
99     printf ("<li> <strong><a href=\"<root_prefix>stats/details.php?list=%s\">Statistics</a></strong><br>",
100         $_GET["list"]);
101   } else {
102     echo ("<li> <strong><a href=\"<root_prefix>stats/index.php\">Statistics</a></strong><br>");
103   }
104 ?>
105
106 <li> <strong><a href="<root_prefix>search.html">Search</a></strong><br>
107 </ul>
108
109 <div class="fortune">
110 <div class="fortune-body">
111 <h3 class="fortune-title">Quote of the Day</h3>
112 <div class="fortune-content" id="fortune">
113 <?
114   function format_cookie ($cookie, $bg)
115   {
116     $fsource = "<div class=\"fortune-attribution\"><span style=\"display: none;\">-- </span>%s</div>";
117     $attribution = 0;
118     $result = '<div class="fortune_'.$bg.'">';
119     $firstchar = substr ($cookie[0], 0, 1);
120     if ( ($firstchar == "<")
121       || ($firstchar == ">")
122       || ($firstchar == "*")
123       || ($firstchar == " ")
124       || ($firstchar == "[") ) {
125       $pre = 1;
126       $result .= "<pre class=\"smallfont\">\n";
127     } else {
128       $result .= "<p>\n";
129     }
130
131     for ($i=0; $i < count ($cookie); $i++) {
132       $line = $cookie[$i];
133       $line = ereg_replace ("<", "&lt;", $line);
134       $line = ereg_replace (">", "&gt;", $line);
135
136       if (ereg ("^              ?-- ", $line)) {
137         $line = ereg_replace ("^                ?-- ", "", rtrim($line));
138         if ($pre) {
139           $pre = 0;
140           $result .= "</pre>\n";
141         } else {
142           $result .= "</p>\n";
143         }
144         $result .= sprintf ($fsource, $line);
145         $attribution = 1;
146       } else {
147         if (!$pre && substr($line, 0, 1) == ' ')
148           $result .= "<br>";
149         $result .= $line;
150       }
151     }
152     if (!$attribution) {
153       if ($pre) {
154         $pre = 0;
155         $result .= "</pre>\n";
156       } else {
157         $result .= "</p>\n";
158       }
159     }
160     $result .= "</div>\n";
161     return $result;
162   }
163
164   if (is_file ("../www.infodrom.org/fortune-general-en.html")) {
165     $fortune = fopen ("../www.infodrom.org/fortune-general-en.html", "r");
166   }
167   if ($fortune) {
168     $cookie = array ();
169     while (!feof ($fortune)) {
170       $line = fgets ($fortune, 255);
171       $cookie[] = $line;
172     }
173     fclose ($fortune);
174     echo format_cookie ($cookie, 0);
175   } else {
176     echo "<p>No fortune today.</p>";
177   }
178 ?>
179 </div>
180 </div>
181 </div>
182
183 </page>
184
185 # Local variables:
186 # mode: indented-text
187 # mode: auto-fill
188 # end: