Beautification
[infodrom.org/lists.infodrom.org] / src / stats / stats.inc
1 <define-tag listpath>/var/list/</define-tag>
2 <define-tag listdescr>description</define-tag>
3
4 <define-tag img_width>497</define-tag>
5 <define-tag img_height>161</define-tag>
6
7 # Sideeffect: fills $list and $description
8 #             img_format img_format_href
9 #
10 <define-tag read-lists>
11 <?
12     $img_format_href = '<p><div align="center">'
13                       .'<a href="%s">'
14                       .'<img src="%s" width=<img_width> height=<img_height> alt="%s" border=0>'
15                       .'</a>'
16                       .'</div>';
17
18     $img_format     = '<p><div align="center">'
19                       .'<img src="%s" width=<img_width> height=<img_height> alt="%s" border=0>'
20                       .'</div>';
21
22     $dir = dir (".");
23     $months = array ();
24
25     while ($dentry = $dir->read()) {
26       if ($dentry != "." && $dentry != "..") {
27         $list[] = $dentry;
28
29         if (is_file ("<listpath>/$dentry/<listdescr>")) {
30           if (($f = fopen ("<listpath>/$dentry/<listdescr>", "r"))) {
31             $description[$dentry] = fgets ($f, 255);
32             fclose ($f);
33           }
34         }
35       }
36     }
37     $dir->close();
38     sort ($list);
39 ?>
40 </define-tag>
41
42 # Make an overview about all similar files
43 #
44 <define-tag make-overview>
45 <preserve frac href>
46 <set-var %attributes>
47
48 <?
49     $i=0;for ($i=0; $i <= count ($list); $i++) {
50       if (is_file ("$list[$i]/$list[$i]-<get-var frac>.png")) {
51
52         if (strlen ($description[$list[$i]])) {
53           if (strlen ($description[$list[$i]]) < 40) {
54             printf ("<h3 class=\"bar\">%s</h3>", $description[$list[$i]]);
55           } else {
56             printf ("<h3 class=\"bar\">%s - %s</h3>", $list[$i], $description[$list[$i]]);
57           }
58         } else {
59           printf ("<h3 class=\"bar\">%s</h3>", $list[$i]);
60         }
61
62         printf ($img_format_href, "<get-var href>.php3?list=$list[$i]", "$list[$i]/$list[$i]-<get-var frac>.png", $list[$i]);
63       }
64     }
65 ?>
66
67 <p>
68 <restore frac href>
69 </define-tag>
70
71 <define-tag display-list>
72 <h1>Lists Statistics for list <? echo $list; ?></h1>
73
74 <h3 class="bar">Total Subscribers</h3>
75
76 <p><center>\
77 <?
78   printf ("<img src=\"%s/%s-distabs-month.png\" width=\"<img_width>\" height=\"<img_height>\" alt=\"[%s]\" border=\"0\">",
79     $list, $list, $list);
80 ?>
81 </center>
82
83 <h3 class="bar">Posting Frequency</h3>
84
85 <p><center>\
86 <?
87   printf ("<img src=\"%s/%s-latest-month.png\" width=\"<img_width>\" height=\"<img_height>\" alt=\"[%s]\" border=\"0\">",
88     $list, $list, $list);
89 ?>
90 </center>
91
92 </define-tag>
93
94 # Local variables:
95 # mode: indented-text
96 # mode: auto-fill
97 # end: