diff options
Diffstat (limited to 'overview.php')
-rw-r--r-- | overview.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/overview.php b/overview.php new file mode 100644 index 0000000..e1a95c1 --- /dev/null +++ b/overview.php @@ -0,0 +1,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; +} |