From 54ddda70cde54a99d311cdbc9d2eb14a38c0aab5 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Sat, 15 Apr 2017 11:37:54 +0200 Subject: [PATCH] Added nextrun control --- addjob.php | 8 +++++++- js/site.js | 3 ++- templates/addjob.html.twig | 9 +++++++++ templates/base.html.twig | 3 +++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/addjob.php b/addjob.php index 4c01302..a2b06c6 100644 --- a/addjob.php +++ b/addjob.php @@ -62,6 +62,8 @@ elseif ($_SERVER["REQUEST_METHOD"] == "POST") { $url = $_POST['url']; $name = $_POST['name']; $delay = $_POST['delay']; + $nextrunObj = new DateTime($_POST['nextrun']); + $nextrun = $nextrunObj->getTimestamp(); if(filter_var($url, FILTER_VALIDATE_URL) === FALSE) { header("location:addjob.php?error=invalidurl"); @@ -72,10 +74,14 @@ elseif ($_SERVER["REQUEST_METHOD"] == "POST") { header("location:addjob.php?error=invaliddelay"); exit; } + if(!is_numeric($nextrun)) { + header("location:addjob.php?error=invalidnextrun"); + exit; + } $stmt = $db->prepare("INSERT INTO jobs(user, name, url, delay, nextrun) VALUES(?, ?, ?, ?, ?)"); - $stmt->execute(array($_SESSION["userID"], $name, $url, $delay, time()+$delay)); + $stmt->execute(array($_SESSION["userID"], $name, $url, $delay, $nextrun)); header("location:addjob.php?message=added"); exit; diff --git a/js/site.js b/js/site.js index 1043b2f..31a4626 100644 --- a/js/site.js +++ b/js/site.js @@ -26,5 +26,6 @@ $(document).ready(function() { $("body").on("click", "#patternDropdown li", function() { if(this.value != "custom") { $("input#delay").val($(this).data("val")); } - }); + }); + $('#nextrunselector').datetimepicker(); }); diff --git a/templates/addjob.html.twig b/templates/addjob.html.twig index da27995..d973259 100644 --- a/templates/addjob.html.twig +++ b/templates/addjob.html.twig @@ -42,6 +42,15 @@ +
+ +
+ + + + +
+
diff --git a/templates/base.html.twig b/templates/base.html.twig index 882bad9..8ff95d4 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -5,10 +5,13 @@ + + +