From 56038e48acda50a175915709b0e37397d5a22f1a Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 10:29:27 +0200 Subject: [PATCH 01/11] Added type hidden --- include/functions.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/functions.php b/include/functions.php index f1c220b..4a6819f 100644 --- a/include/functions.php +++ b/include/functions.php @@ -48,7 +48,8 @@ function load_config_categorized() { $configCategorized[$value['category']][$count]['label'] = $value['label']; $configCategorized[$value['category']][$count]['description'] = $value['description']; $configCategorized[$value['category']][$count]['type'] = parse_config_type($value['type']); - $count++; + + if ($configCategorized[$value['category']][$count]['type']['type'] != 'hidden') $count++; } // into a easy twig array @@ -74,18 +75,20 @@ function get_configvalue($conf) { } function parse_config_type($type) { - $splittype = explode('(', substr($type, 0, -1)); + $splittype = explode('(', explode(')', $type)[0]); $r_var['type'] = $splittype[0]; - $splitargs = explode(',', $splittype[1]); + if (isset($splittype[1])) { + $splitargs = explode(',', $splittype[1]); - switch($r_var['type']) - { - case 'number': - $r_var['args'][] = $splitargs[0] != '-1' ? 'min="' . $splitargs[0] . '"' : ''; - $r_var['args'][] = $splitargs[1] != '-1' ? 'max="' . $splitargs[1] . '"' : ''; - break; - } + switch($r_var['type']) + { + case 'number': + $r_var['args'][] = isset($splitargs[0]) ? 'min="' . $splitargs[0] . '"' : ''; + $r_var['args'][] = isset($splitargs[1]) ? 'max="' . $splitargs[1] . '"' : ''; + break; + } + } return $r_var; } From cd8f31f03a653f632993e19fdfe88a105ccb79c4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 12:23:22 +0200 Subject: [PATCH 02/11] Writing lastrun to config-table --- include/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/functions.php b/include/functions.php index 4a6819f..084c998 100644 --- a/include/functions.php +++ b/include/functions.php @@ -99,4 +99,7 @@ function clean_database() { $stmt = $db->prepare("DELETE FROM runs WHERE timestamp < ?"); $stmt->execute(array($oldestrun)); + + $stmt = $db->prepare("UPDATE config SET value = ? WHERE conf = ?"); + $stmt->execute(array('dbclean.lastrun', $time())); } \ No newline at end of file From 7807653e1ece081283f118a0a911a2c0c353fa21 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 12:25:10 +0200 Subject: [PATCH 03/11] Fixed tabs --- config.php | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/config.php b/config.php index 2af910b..0980c66 100644 --- a/config.php +++ b/config.php @@ -28,15 +28,15 @@ require_once "include/initialize.inc.php"; if ($_SERVER["REQUEST_METHOD"] == "GET") { - $message = ""; - if (isset($_GET["message"])) { - switch ($_GET["message"]) { - case "edited": - $message = "The config has been edited"; break; - } - } - - $error = ""; + $message = ""; + if (isset($_GET["message"])) { + switch ($_GET["message"]) { + case "edited": + $message = "The config has been edited"; break; + } + } + + $error = ""; if (isset($_GET["error"])) { switch ($_GET["error"]) { case "emptyfields": @@ -45,28 +45,28 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { } - $loader = new Twig_Loader_Filesystem('templates'); - $twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true)); + $loader = new Twig_Loader_Filesystem('templates'); + $twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true)); - $configs = load_config_categorized(); + $configs = load_config_categorized(); - $twig_vars = array('config' => $configs, "error" => $error, "message" => $message); + $twig_vars = array('config' => $configs, "error" => $error, "message" => $message); - echo $twig->render('config.html.twig', $twig_vars); + echo $twig->render('config.html.twig', $twig_vars); } elseif ($_SERVER["REQUEST_METHOD"] == "POST") { - foreach($_POST as $key => $value) { - if (empty($value)) { - header("location:config.php?error=emptyfields"); exit; - } + foreach($_POST as $key => $value) { + if (empty($value)) { + header("location:config.php?error=emptyfields"); exit; + } - $keydb = str_replace('_', '.', $key); - $stmt = $db->prepare("UPDATE config SET value = ? WHERE conf = ?"); - $stmt->execute(array($value, $keydb)); - } + $keydb = str_replace('_', '.', $key); + $stmt = $db->prepare("UPDATE config SET value = ? WHERE conf = ?"); + $stmt->execute(array($value, $keydb)); + } - header("location:config.php?message=edited"); + header("location:config.php?message=edited"); exit; } From 92afa1bba9254e14b5621908c7a504a3b4bf7bba Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 12:43:29 +0200 Subject: [PATCH 04/11] Updated database --- database.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/database.sql b/database.sql index 30782fe..9363272 100644 --- a/database.sql +++ b/database.sql @@ -36,7 +36,9 @@ CREATE TABLE IF NOT EXISTS `config` ( -- INSERT INTO `config` (`conf`, `category`, `type`, `label`, `description`, `value`) VALUES -('dbclean.expireruns', 'Database Cleanup', 'number(0,-1)', 'Retention value', 'How many days does the database keep the runs', '30'), +('dbclean.delay', 'Database Cleanup', 'number(0)', 'Cleanup Delay', 'How many days until the database cleanup is triggered', '7'), +('dbclean.expireruns', 'Database Cleanup', 'number(0)', 'Retention value', 'How many days does the database keep the runs', '30'), +('dbclean.lastrun', 'Database Cleanup', 'hidden', 'Last run', 'Last run of database cleanup', UNIX_TIMESTAMP()), ('jobs.reboottime', 'Jobs', 'number(0,30)', 'Reboot delay', 'The amount of delay in minutes between scheduling a reboot and the actual reboot', '5'); -- -------------------------------------------------------- From 88b6a46cc143eefe4c81d0e674472856c474548f Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 12:56:02 +0200 Subject: [PATCH 05/11] Triggering dbclean after run --- webcron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webcron.php b/webcron.php index 20a8109..9a12cf6 100644 --- a/webcron.php +++ b/webcron.php @@ -105,7 +105,7 @@ foreach ($results as $result) { $nosave = false; } -clean_database(); +if (get_configvalue('dbclean.lastrun') + (60 * 60 * 24 * get_configvalue('dbclean.delay')) < time()) clean_database(); unlink('/tmp/webcron.lock'); From 776b79f4cd36336a2dee2c564d91dc9996497043 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 12:57:23 +0200 Subject: [PATCH 06/11] Make functions, not variables --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index 084c998..dc107c9 100644 --- a/include/functions.php +++ b/include/functions.php @@ -101,5 +101,5 @@ function clean_database() { $stmt->execute(array($oldestrun)); $stmt = $db->prepare("UPDATE config SET value = ? WHERE conf = ?"); - $stmt->execute(array('dbclean.lastrun', $time())); + $stmt->execute(array('dbclean.lastrun', time())); } \ No newline at end of file From 2704abc940efd78a116f49f038f00c4ce8dbcf6e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 13:09:28 +0200 Subject: [PATCH 07/11] Requires a separate function, I know --- include/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/functions.php b/include/functions.php index dc107c9..6fb9d07 100644 --- a/include/functions.php +++ b/include/functions.php @@ -101,5 +101,5 @@ function clean_database() { $stmt->execute(array($oldestrun)); $stmt = $db->prepare("UPDATE config SET value = ? WHERE conf = ?"); - $stmt->execute(array('dbclean.lastrun', time())); + $stmt->execute(array(time(), 'dbclean.lastrun')); } \ No newline at end of file From b28ce39cae291a836b454585fdf5cac86b913e7a Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 15:08:10 +0200 Subject: [PATCH 08/11] Added seconds to php-output --- editjob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editjob.php b/editjob.php index 3953e8e..b60fcf3 100644 --- a/editjob.php +++ b/editjob.php @@ -41,7 +41,7 @@ if ($_SERVER["REQUEST_METHOD"] == "GET") { $host = $jobnameResult[0]['host']; $delay = $jobnameResult[0]['delay']; $expected = $jobnameResult[0]['expected']; - $nextrun = date("m/d/Y h:i A", $jobnameResult[0]['nextrun']); + $nextrun = date("m/d/Y H:i:s", $jobnameResult[0]['nextrun']); $loader = new Twig_Loader_Filesystem('templates'); From 55419daf05752255238f91a7e705c88cce5fc584 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 15:08:43 +0200 Subject: [PATCH 09/11] Added format to date-time-picker --- js/site.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/site.js b/js/site.js index 9810527..775d0fa 100644 --- a/js/site.js +++ b/js/site.js @@ -27,7 +27,7 @@ $(document).ready(function() { $("body").on("click", "#patternDropdown li", function() { if(this.value != "custom") { $("input#delay").val($(this).data("val")); } }); - $('#nextrunselector').datetimepicker(); + $('#nextrunselector').datetimepicker( { format: 'MM/DD/YYYY hh:mm:ss' } ); $("body").on("click", ".runcron", function() { $("#ajax_loader").show(); From 61fce418353d6d0030ce4c35e16667b4a4d43edf Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 15:08:56 +0200 Subject: [PATCH 10/11] Updated dependencies --- templates/base.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/base.html.twig b/templates/base.html.twig index 7df5f69..6b0e4b6 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -10,9 +10,9 @@ - + - + From 6f2e4c5ea9cc412ba86a89cd44ea400011ea59b2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 14 Sep 2018 15:12:54 +0200 Subject: [PATCH 11/11] HH:hh --- js/site.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/site.js b/js/site.js index 775d0fa..d555429 100644 --- a/js/site.js +++ b/js/site.js @@ -27,7 +27,7 @@ $(document).ready(function() { $("body").on("click", "#patternDropdown li", function() { if(this.value != "custom") { $("input#delay").val($(this).data("val")); } }); - $('#nextrunselector').datetimepicker( { format: 'MM/DD/YYYY hh:mm:ss' } ); + $('#nextrunselector').datetimepicker( { format: 'MM/DD/YYYY HH:mm:ss' } ); $("body").on("click", ".runcron", function() { $("#ajax_loader").show();