1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
function get_month($filename) {
return substr($filename, 10, 7);
}
function finish_month() {
global $last_month, $month_counter;
if ($last_month != '') {
while ($month_counter++ < 32) {
echo ' <br/>'.PHP_EOL;
}
$month_counter = 0;
echo ' </div>'.PHP_EOL;
}
}
echo ' <h1>'.$title.'</h1>
<hr/>
<form name="open_for" method="get" action="">
<input name="channel" type="text" value="' . $channel . '" style="display: none; visibility: hidden;"/>
<label for="date">Enter date of the log to open:</label>
<input id="date" size="10" maxlength="10" name="date" value="'.date('Y-m-d').'" onkeyup="javascript:makeValid(\'date\')" onblur="javascript:makeValidFinal(this, \'date\', \'date_chooser\', 1950, 2049, Date.patterns.ISO8601ShortPattern, false)" type="text"/><img src="images/calendar.png" alt="Choose date" onclick="showChooser(this, \'date\', \'date_chooser\', 1950, 2049, Date.patterns.ISO8601ShortPattern, false);"/><div id="date_chooser" class="dateChooser select-free" style="display: none; visibility: hidden; width: 160px;"></div>
<input value="OK" type="submit"/>
</form>
<hr/>'.PHP_EOL;
if ($handle = opendir(LOG_DIR)) {
// Get the files sorted by name
$files = array();
while (false !== ($file = readdir($handle))) {
if (substr($file, -4) == '.log' && !is_dir($file))
$files[] = $file;
}
closedir($handle);
rsort($files);
$last_month = '';
$month_counter = 0;
// Border for all month blocks, floating so it will put them right
echo ' <div style="float: right; width: 100%;">'.PHP_EOL;
foreach ($files as $file) {
$month = get_month($file);
if ($last_month != $month) {
finish_month();
$last_month = $month;
echo ' <div style="border: 1px solid gray; margin: 10px; padding: 20px; float: left;">'.$month.'<hr/>'.PHP_EOL;
}
echo ' <a href="?channel='.$channel.'&date='.get_date($file).'">'.get_date($file).'</a> <a href="'.LOG_DIR.'/'.$file.'">(raw)</a><br/>'.PHP_EOL;
$month_counter++;
}
finish_month();
echo ' </div>'.PHP_EOL;
}
|