Added frontend

This commit is contained in:
Jeroen De Meerleer 2017-04-14 15:58:09 +02:00
parent e9463c43f8
commit 3f2e898c26
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
17 changed files with 878 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
cache/*
!cache/.gitkeep
nbproject/private/
vendor/
config.inc.php

85
addjob.php Normal file
View File

@ -0,0 +1,85 @@
<?php
/*
* The MIT License
*
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once "include/initialize.inc.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true));
$error = "";
if ($_GET["error"]) {
switch ($_GET["error"]) {
case "emptyfields":
$error = "Some fields were empty"; break;
case "invalidurl":
$error = "The URL is invalid"; break;
case "invaliddelay":
$error = "The delay is invalid"; break;
}
}
$message = "";
if ($_GET["message"]) {
switch ($_GET["message"]) {
case "added":
$message = "The cronjob has been added"; break;
}
}
echo $twig->render('addjob.html.twig', array("message" => $message, "error" => $error));
}
elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST['name']) || empty($_POST['url'] || empty($_POST['delay']))) {
header("location:addjob.php?error=emptyfields");
exit;
}
$url = $_POST['url'];
$name = $_POST['name'];
$delay = $_POST['delay'];
if(filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
header("location:addjob.php?error=invalidurl");
exit;
}
if(!is_numeric($delay)) {
header("location:addjob.php?error=invaliddelay");
exit;
}
$stmt = $db->prepare("INSERT INTO jobs(user, name, url, delay, nextrun) VALUES(?, ?, ?, ?, ?)");
$stmt->execute(array($_SESSION["userID"], $name, $url, $delay, time()+$delay));
header("location:addjob.php?message=added");
exit;
}
require_once 'include/finalize.inc.php';

0
cache/.gitkeep vendored Normal file
View File

14
composer.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "jeroened/jeroen-e-d-web-dev-webcron",
"description": "Description of project JeroenED-WebDev-Webcron.",
"authors": [
{
"name": "Jeroen De Meerleer",
"email": "me@jeroened.be"
}
],
"require": {
"guzzlehttp/guzzle": "6.2.3",
"twig/twig": "v2.3.0"
}
}

369
composer.lock generated Normal file
View File

@ -0,0 +1,369 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "94673161c41195b4e13ab88bfb8b548e",
"content-hash": "59067e6b5fba936b8b1dbb117e2c3a0a",
"packages": [
{
"name": "guzzlehttp/guzzle",
"version": "6.2.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006",
"shasum": ""
},
"require": {
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0",
"psr/log": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.2-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2017-02-28 22:50:30"
},
{
"name": "guzzlehttp/promises",
"version": "v1.3.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2016-12-20 10:07:11"
},
{
"name": "guzzlehttp/psr7",
"version": "1.4.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"request",
"response",
"stream",
"uri",
"url"
],
"time": "2017-03-20 17:10:46"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06 14:39:51"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "e79d363049d1c2128f133a2667e4f4190904f7f4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4",
"reference": "e79d363049d1c2128f133a2667e4f4190904f7f4",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2016-11-14 01:06:16"
},
{
"name": "twig/twig",
"version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "9718186a5df85a4f7917e78d3ffcabc204c75d25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/9718186a5df85a4f7917e78d3ffcabc204c75d25",
"reference": "9718186a5df85a4f7917e78d3ffcabc204c75d25",
"shasum": ""
},
"require": {
"php": "^7.0",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"psr/container": "^1.0",
"symfony/debug": "~2.7",
"symfony/phpunit-bridge": "~3.3@dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-0": {
"Twig_": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher@active-4.com",
"role": "Project Founder"
},
{
"name": "Twig Team",
"homepage": "http://twig.sensiolabs.org/contributors",
"role": "Contributors"
}
],
"description": "Twig, the flexible, fast, and secure template language for PHP",
"homepage": "http://twig.sensiolabs.org",
"keywords": [
"templating"
],
"time": "2017-03-22 15:41:51"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

5
css/site.css Normal file
View File

@ -0,0 +1,5 @@
body{
margin-left:auto;
margin-right:auto;
width:90%;
}

73
index.php Normal file
View File

@ -0,0 +1,73 @@
<?php
/*
* The MIT License
*
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once "include/initialize.inc.php";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true));
$error = "";
if ($_GET["error"]) {
switch ($_GET["error"]) {
case "emptyfields":
$error = "Some fields were empty"; break;
case "invalidcredentials":
$error = "The credentials were invalid"; break;
}
}
echo $twig->render('index.html.twig', array("message" => $message, "error" => $error));
}
elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST['name']) || empty($_POST['passwd'])) {
header("location:index.php?error=emptyfields");
exit;
}
$passwd = $_POST['passwd'];
$name = $_POST['name'];
$userQry = $db->prepare("SELECT * FROM users WHERE name = ?");
$userQry->execute(array($name));
$user = $userQry->fetchAll(PDO::FETCH_ASSOC);
if ( password_verify($passwd, $user[0]['password']) ) {
$_SESSION['userID'] = $user[0]['userID'];
header("location:overview.php");
exit;
} else {
header("location:index.php?error=invalidcredentials");
exit;
}
}
require_once 'include/finalize.inc.php';

30
js/site.js Normal file
View File

@ -0,0 +1,30 @@
/*
* The MIT License
*
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
$(document).ready(function() {
$("body").on("change", "#patternDropdown", function() {
if(this.value != "custom") { $("input#delay").val($("option:selected", this).data("val")); }
});
});

View File

@ -0,0 +1,9 @@
browser.reload.on.save=true
include.path=${php.global.include.path}
php.version=PHP_70
project.license=mit
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.

9
nbproject/project.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>JeroenED-WebDev-Webcron</name>
</data>
</configuration>
</project>

71
overview.php Normal file
View File

@ -0,0 +1,71 @@
<?php
/*
* The MIT License
*
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once "include/initialize.inc.php";
$allJobs = $db->prepare("SELECT * FROM jobs WHERE user = ?");
$allJobs->execute(array($_SESSION["userID"]));
$allJobsResult = $allJobs->fetchAll(PDO::FETCH_ASSOC);
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true));
//var_dump($alljobsResult);
//exit;
$allJobsRendered = array();$count = 0;
foreach($allJobsResult as $key=>$value) {
$allJobsRendered[$count]["jobID"] = $value["jobID"];
$allJobsRendered[$count]["name"] = $value["name"];
$allJobsRendered[$count]["nextrun"] = date("d/m/Y H:i:s", $value["nextrun"]);
$allJobsRendered[$count]["delay"] = secondsToInterval($value["delay"]);
$count++;
}
$twig_vars = array('jobs' => $allJobsRendered);
//echo $twig->render('overview.html.twig', array('the' => 'variables', 'go' => 'here'));
echo $twig->render('overview.html.twig', $twig_vars);
require_once 'include/finalize.inc.php';
function secondsToInterval($time) {
$days = floor($time / (60 * 60 * 24));
$time -= $days * (60 * 60 * 24);
$hours = floor($time / (60 * 60));
$time -= $hours * (60 * 60);
$minutes = floor($time / 60);
$time -= $minutes * 60;
$seconds = floor($time);
$time -= $seconds;
return "{$days}d {$hours}h {$minutes}m {$seconds}s";
}

56
runs.php Normal file
View File

@ -0,0 +1,56 @@
<?php
/*
* The MIT License
*
* Copyright 2017 Jeroen De Meerleer <me@jeroened.be>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once "include/initialize.inc.php";
$runsForJob = $db->prepare("SELECT runs.*, jobs.name FROM runs, jobs WHERE runs.job = jobs.jobID AND runs.job = ?");
$runsForJob->execute(array($_GET['jobID']));
$runsForJobResult = $runsForJob->fetchAll(PDO::FETCH_ASSOC);
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader, array('cache' => 'cache', "debug" => true));
//var_dump($alljobsResult);
//exit;
$jobName = $runsForJobResult[0]['jobname'];
$runsForJobRendered = array();$count = 0;
foreach($runsForJobResult as $key=>$value) {
$runsForJobRendered[$count]["runID"] = $value["runID"];
$runsForJobRendered[$count]["statuscode"] = $value["statuscode"];
$runsForJobRendered[$count]["result"] = $value["result"];
$runsForJobRendered[$count]["timestamp"] = date("d/m/Y H:i:s", $value["timestamp"]);
$count++;
}
$twig_vars = array('runs' => $runsForJobRendered, "title" => $jobName);
//echo $twig->render('overview.html.twig', array('the' => 'variables', 'go' => 'here'));
echo $twig->render('runs.html.twig', $twig_vars);
require_once 'include/finalize.inc.php';

View File

@ -0,0 +1,48 @@
{% extends "base.html.twig" %}
{% block content %}
<form class="form-horizontal" method="post" action="/addjob.php">
{% if not error == "" %}
<div class="alert alert-danger fade in">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Error!</strong> {{ error }}
</div>
{% endif %}
{% if not message == "" %}
<div class="alert alert-success fade in">
<a href="#" class="close" data-dismiss="alert">&times;</a>
{{ message }}
</div>
{% endif %}
<div class="form-group col-sm-12">
<label for="name">Name</label>
<input type="text" name="name" class="form-control" id="name" placeholder="blah">
</div>
<div class="form-group col-sm-12">
<label for="url">url</label>
<input type="url" name="url" class="form-control" id="url" placeholder="https://">
</div>
<div class="form-group">
<div class="col-sm-2">
<label for="name">Delay (in seconds)</label>
<select class="form-control" id="patternDropdown">
<option data-val="60"><a href="#">Every minute</a></option>
<option data-val="3600"><a href="#">Every hour</a></option>
<option data-val="86400"><a href="#">Every day</a></option>
<option data-val="604800"><a href="#">Every week</a></option>
<option data-val="2419200"><a href="#">Every 4 weeks</a></option>
<option data-val="custom"><a href="#">Custom</a></option>
</select>
</div>
<div class="col-sm-10">
<label for="name">&nbsp;</label>
<input type="number" class="form-control" id="delay" name="delay">
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
{% endblock %}

36
templates/base.html.twig Normal file
View File

@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="/css/site.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="/js/site.js" type="text/javascript"></script>
</head>
<body>
<div class="page-header">
<h1>Webcron management</h1>
</div>
<div class="col-xs-12 col-sm-2">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-body">
<ul class="nav nav-stacked">
<li><a href="overview.php">Overview</a></li>
<li><a href="addjob.php">Add a new cronjob</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-10">
{% block content %}{% endblock %}
</div>
</body>
</html>

38
templates/index.html.twig Normal file
View File

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="/css/site.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="/js/site.js" type="text/javascript"></script>
</head>
<body>
<div class="col-md-4 col-md-offset-4 col-xs-12">
<h1>Webcron management</h1>
<form class="form-horizontal" method="post" action="/index.php">
{% if not error == "" %}
<div class="alert alert-danger fade in">
<a href="#" class="close" data-dismiss="alert">&times;</a>
<strong>Error!</strong> {{ error }}
</div>
{% endif %}
<div class="form-group col-sm-12">
<label for="name">Username</label>
<input type="text" name="name" class="form-control" id="name" placeholder="username">
</div>
<div class="form-group col-sm-12">
<label for="passwd">Password</label>
<input type="password" name="passwd" class="form-control" id="url" placeholder="password">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,10 @@
{% extends "base.html.twig" %}
{% block content %}
<h2>Overview of your cronjobs</h2>
<table class="table">
<tr><th>ID</th><th>Name</th><th>Delay</th><th>Next run</th><th></th></tr>
{% for job in jobs %}
<tr><td>{{ job.jobID }}</td><td>{{ job.name }}</td><td>{{ job.delay }}</td><td>{{ job.nextrun }}</td><td><a href="runs.php?jobID={{ job.jobID }}">View runs</a></tr>
{% endfor %}
</table>
{% endblock %}

20
templates/runs.html.twig Normal file
View File

@ -0,0 +1,20 @@
{% extends "base.html.twig" %}
{% block content %}
<h2>Overview of runs of {{ title }}</h2>
<div id="accordion" class="panel-group">
{% for run in runs %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse{{ loop.index }}">({{ run.statuscode }}) {{ run.timestamp }}</a>
</h4>
</div>
<div id="collapse{{ loop.index }}" class="panel-collapse collapse">
<div class="panel-body">
<code>{{ run.result }}</code>
</div>
</div>
</div>
{% endfor %}
</table>
{% endblock %}