diff options
author | Christoph Brill <egore911@gmail.com> | 2017-02-05 19:30:49 +0100 |
---|---|---|
committer | Christoph Brill <egore911@gmail.com> | 2017-02-05 19:30:49 +0100 |
commit | 164205b4395fa93a904ce3d349fb4d5b6c45ebd1 (patch) | |
tree | e1fbe5231dff1a84d28a9db6920206fdd1d8affd | |
parent | 9a429cd557819b16d3b184d1408ade1e50fb0fde (diff) |
Move overview to its own file
-rwxr-xr-x | index.php | 53 | ||||
-rw-r--r-- | overview.php | 54 |
2 files changed, 55 insertions, 52 deletions
@@ -115,21 +115,6 @@ if (isset($date)) { echo ' <body>'.PHP_EOL; } -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; - } -} - function get_color($user) { global $users; $isUser = array_search($user, $users); @@ -139,43 +124,7 @@ function get_color($user) { } if (!isset($date)) { - 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; - } + require_once('overview.php'); } else { echo ' <h1>'.$title.'</h1> <hr/> 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; +} |