From 164205b4395fa93a904ce3d349fb4d5b6c45ebd1 Mon Sep 17 00:00:00 2001 From: Christoph Brill Date: Sun, 5 Feb 2017 19:30:49 +0100 Subject: Move overview to its own file --- index.php | 53 +---------------------------------------------------- overview.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 52 deletions(-) create mode 100644 overview.php 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 ' '.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 '
'.PHP_EOL; - } - $month_counter = 0; - echo ' '.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 '

'.$title.'

-
-
- - - Choose date - -
-
'.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 '
'.PHP_EOL; - foreach ($files as $file) { - $month = get_month($file); - if ($last_month != $month) { - finish_month(); - $last_month = $month; - echo '
'.$month.'
'.PHP_EOL; - } - echo ' '.get_date($file).' (raw)
'.PHP_EOL; - $month_counter++; - } - finish_month(); - echo '
'.PHP_EOL; - } + require_once('overview.php'); } else { echo '

'.$title.'


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_EOL; + } + $month_counter = 0; + echo '
'.PHP_EOL; + } +} + +echo '

'.$title.'

+
+
+ + + Choose date + +
+
'.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 '
'.PHP_EOL; + foreach ($files as $file) { + $month = get_month($file); + if ($last_month != $month) { + finish_month(); + $last_month = $month; + echo '
'.$month.'
'.PHP_EOL; + } + echo ' '.get_date($file).' (raw)
'.PHP_EOL; + $month_counter++; + } + finish_month(); + echo '
'.PHP_EOL; +} -- cgit v1.2.3