summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Brill <egore911@gmail.com>2017-02-05 19:30:49 +0100
committerChristoph Brill <egore911@gmail.com>2017-02-05 19:30:49 +0100
commit164205b4395fa93a904ce3d349fb4d5b6c45ebd1 (patch)
treee1fbe5231dff1a84d28a9db6920206fdd1d8affd
parent9a429cd557819b16d3b184d1408ade1e50fb0fde (diff)
Move overview to its own file
-rwxr-xr-xindex.php53
-rw-r--r--overview.php54
2 files changed, 55 insertions, 52 deletions
diff --git a/index.php b/index.php
index ac06c17..1aad556 100755
--- a/index.php
+++ b/index.php
@@ -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;
+}