2013-11-28 21:03:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if(!defined('ONYX')) exit;
|
|
|
|
|
2015-01-14 10:20:29 +00:00
|
|
|
$template->assign("fortyp", array(
|
|
|
|
"raw" => "RAW",
|
|
|
|
"sha1" => "SHA-1",
|
|
|
|
"md5" => "MD5",
|
|
|
|
"sha224" => "SHA-224",
|
|
|
|
"sha256" => "SHA-256",
|
|
|
|
"sha384" => "SHA-384",
|
|
|
|
"sha512" => "SHA-512",
|
|
|
|
"whirlpool" => "Whirlpool"));
|
2014-01-14 15:14:31 +00:00
|
|
|
|
2013-12-01 19:29:59 +00:00
|
|
|
try
|
2013-12-01 19:03:20 +00:00
|
|
|
{
|
2013-12-01 19:29:59 +00:00
|
|
|
if (isset($p[2]))
|
|
|
|
{
|
2013-12-01 19:03:20 +00:00
|
|
|
$tmp = explode("-", $p[2]);
|
|
|
|
$id = intval($tmp[0]);
|
|
|
|
if ($id == 0)
|
|
|
|
return "404";
|
|
|
|
$theme = new Theme($id);
|
|
|
|
$template->assign("theme", $theme);
|
2013-12-01 19:29:59 +00:00
|
|
|
}
|
2013-11-28 21:03:27 +00:00
|
|
|
|
2013-12-01 19:29:59 +00:00
|
|
|
if (isset($p[3]))
|
2014-01-14 15:14:31 +00:00
|
|
|
{
|
|
|
|
$exercice = new Exercice($p[3], $theme);
|
|
|
|
|
|
|
|
if (!empty($_POST))
|
|
|
|
{
|
|
|
|
$exercice->points = intval($_POST["points"]);
|
2014-12-14 10:04:17 +00:00
|
|
|
$exercice->title = $_POST["title"];
|
2014-01-14 15:14:31 +00:00
|
|
|
$exercice->statement = $_POST["desc"];
|
|
|
|
$exercice->require = $_POST["require"];
|
|
|
|
$exercice->level = intval($_POST["level"]);
|
|
|
|
|
2014-01-14 17:49:38 +00:00
|
|
|
$exercice->flush_keys();
|
2014-01-14 15:14:31 +00:00
|
|
|
foreach ($_POST as $k => $key)
|
|
|
|
{
|
|
|
|
if (preg_match("/k([0-9]+)_value/", $k, $out) && !empty($key) && !empty($_POST["k".$out[1]."_type"]))
|
|
|
|
$exercice->add_key($_POST["k".$out[1]."_type"], $key);
|
2014-01-14 17:49:38 +00:00
|
|
|
|
|
|
|
if (preg_match("/f([0-9]+)_name/", $k, $out) && !empty($key) && !empty($_POST["f".$out[1]."_path"]) && isset($exercice->files[$out[1]]))
|
|
|
|
{
|
|
|
|
$exercice->files[$out[1]]["path_orig"] = $_POST["f".$out[1]."_path"];
|
|
|
|
$exercice->files[$out[1]]["name"] = trim($_POST["f".$out[1]."_name"]);
|
|
|
|
$exercice->files[$out[1]]["sha1"] = $_POST["f".$out[1]."_sha1"];
|
|
|
|
}
|
2014-01-14 15:14:31 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 17:49:38 +00:00
|
|
|
$exercice->update();
|
2014-11-20 20:56:17 +00:00
|
|
|
Cache::del("ordered_th".$exercice->theme->get_id());
|
2014-01-14 17:49:38 +00:00
|
|
|
header("Location: /".implode("/", $p));
|
|
|
|
exit();
|
2014-01-14 15:14:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$template->assign("ex", $exercice);
|
|
|
|
}
|
2015-01-14 10:20:29 +00:00
|
|
|
} catch (ThemeNotFoundException $e) {
|
|
|
|
return "404";
|
|
|
|
} catch(ExerciceNotFoundException $e) {
|
|
|
|
return "404";
|
|
|
|
} catch(ExerciceNotFoundException $e) {
|
|
|
|
return "404";
|
2013-12-01 19:29:59 +00:00
|
|
|
}
|
2013-11-28 21:03:27 +00:00
|
|
|
|
2014-11-05 16:18:07 +00:00
|
|
|
return "admin/exercice";
|