diff --git a/htdocs/index.php b/htdocs/index.php index 71f8aed2..840aa92c 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -72,6 +72,15 @@ if ($n && $p[0] == SALT_ADMIN) $page = require("admin/certificate.php"); break; + case "chrono": + case "chrono/": + case "chrono/init": + case "chrono/init/": + case "chrono/start": + case "chrono/start/": + $page = require("admin/chrono.php"); + break; + case "exercices/import": case "exercices/import/": $page = require("admin/import_exercices.php"); diff --git a/htdocs/js/countdown.js b/htdocs/js/countdown.js index 3ae82d6a..fee573f2 100644 --- a/htdocs/js/countdown.js +++ b/htdocs/js/countdown.js @@ -1,6 +1,10 @@ function update_end() { - var left = (end_challenge - new Date())/1000; + var left; + if (typeof end_challenge === 'undefined') + left = 14400; + else + left = (end_challenge - new Date())/1000; if (left < 0) left = 0; diff --git a/onyx/include/admin/chrono.php b/onyx/include/admin/chrono.php new file mode 100644 index 00000000..954684c0 --- /dev/null +++ b/onyx/include/admin/chrono.php @@ -0,0 +1,22 @@ + 2) +{ + switch($p[2]) + { + case "start": + file_put_contents($VAR["misc_dir"]."/challenge_started", time()); + break; + + case "init": + unlink($VAR["misc_dir"]."/challenge_started"); + break; + } +} + +header("Location: /".SALT_ADMIN."/"); +exit(); \ No newline at end of file diff --git a/onyx/include/common.php b/onyx/include/common.php index 5d7b7b22..f21a6236 100644 --- a/onyx/include/common.php +++ b/onyx/include/common.php @@ -14,7 +14,13 @@ require_once("common/Theme.class.php"); $template = new Template(); $template->assign("ERRmessage", false); -$template->assign("END", $VAR['end_challenge']); + +if (is_file($VAR["misc_dir"]."/challenge_started")) +{ + $VAR["start_challenge"] = intval(file_get_contents($VAR["misc_dir"]."/challenge_started")); + $VAR["end_challenge"] = $VAR["start_challenge"] + 14400; + $template->assign("END", $VAR['end_challenge']); +} if (!empty($LANG)) $template->assign("LANG", $LANG); diff --git a/onyx/tpl/bootstrap/admin/home.tpl b/onyx/tpl/bootstrap/admin/home.tpl index 33a7366d..25101ae8 100644 --- a/onyx/tpl/bootstrap/admin/home.tpl +++ b/onyx/tpl/bootstrap/admin/home.tpl @@ -25,4 +25,14 @@ {/if} + +
+
+

Chrono

+
+
+ Start + Réinitialiser +
+
{/block} diff --git a/onyx/tpl/bootstrap/admin/layout.tpl b/onyx/tpl/bootstrap/admin/layout.tpl index bc3b77c9..05e0b339 100644 --- a/onyx/tpl/bootstrap/admin/layout.tpl +++ b/onyx/tpl/bootstrap/admin/layout.tpl @@ -11,7 +11,9 @@ {block name=end} {/block} diff --git a/onyx/tpl/bootstrap/public/layout.tpl b/onyx/tpl/bootstrap/public/layout.tpl index 44b1a683..6056acc6 100644 --- a/onyx/tpl/bootstrap/public/layout.tpl +++ b/onyx/tpl/bootstrap/public/layout.tpl @@ -42,17 +42,9 @@ {block name=end} {/block} diff --git a/onyx/tpl/bootstrap/teams/layout.tpl b/onyx/tpl/bootstrap/teams/layout.tpl index 481a7527..c0002f59 100644 --- a/onyx/tpl/bootstrap/teams/layout.tpl +++ b/onyx/tpl/bootstrap/teams/layout.tpl @@ -8,18 +8,10 @@ {block name=end} {/block}