Browse Source

Updated addjob

main
Jeroen De Meerleer 2 years ago
parent
commit
a6397cb090
  1. 15
      addjob.php
  2. 14
      templates/addjob.html.twig

15
addjob.php

@ -64,9 +64,17 @@ elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$delay = $_POST['delay'];
$expected = $_POST['expected'];
$eternal = (isset($_POST['eternal']) && $_POST['eternal'] == true) ? true : false;
$nextrunObj = DateTime::createFromFormat("d/m/Y H:i:s", $_POST['nextrun']);
$nextrun = $nextrunObj->getTimestamp();
if (!$eternal) {
$lastrunObj = DateTime::createFromFormat("d/m/Y H:i:s", $_POST['lastrun']);
$lastrun = $nextrunObj->getTimestamp();
} else {
$lastrun = -1;
}
if(!is_numeric($delay)) {
header("location:addjob.php?error=invaliddelay");
exit;
@ -75,7 +83,10 @@ elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
header("location:addjob.php?error=invalidnextrun");
exit;
}
if(!is_numeric($lastrun)) {
header("location:addjob.php?error=invalidlastrun");
exit;
}
$stmt = $db->prepare("INSERT INTO jobs(user, name, url, host, delay, nextrun, expected) VALUES(?, ?, ?, ?, ?, ?, ?)");
$stmt->execute(array($_SESSION["userID"], $name, $url, $host, $delay, $nextrun, $expected));

14
templates/addjob.html.twig

@ -56,7 +56,19 @@
</span>
<input type="text" class="form-control" name="nextrun">
</div>
</div>
</div>
<div class="form-group">
<label for="lastrun">Last run</label>
<div class="input-group date" id="lastrunselector">
<span class="input-group-addon">
<span><label id="eternal"><input type="checkbox" name="eternal" value="true">Eternal</label></span>
</span>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<input type="text" class="form-control" name="lastrun">
</div>
</div>
<div class="form-group">
<label for="expected">Expected exit code</label>
<input type="text" name="expected" class="form-control" id="host" placeholder="200">

Loading…
Cancel
Save