From 9cc1110717b205d606cb4e36fa87be65287f7f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Fri, 29 Nov 2013 03:10:12 +0100 Subject: [PATCH] Add function to generate strong URL --- htdocs/index.php | 10 ++- onyx/include/team/exercice.php | 10 +-- .../smarty/plugins/function.link.php | 61 +++++++++++++++++++ onyx/tpl/bootstrap/admin/layout.tpl | 12 ++-- onyx/tpl/bootstrap/clock.tpl | 2 + onyx/tpl/bootstrap/public/layout.tpl | 2 +- onyx/tpl/bootstrap/teams/layout.tpl | 6 +- onyx/tpl/bootstrap/teams/list.tpl | 2 +- onyx/tpl/bootstrap/teams/theme.tpl | 5 +- 9 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 onyx/modules/templates/smarty/plugins/function.link.php diff --git a/htdocs/index.php b/htdocs/index.php index 2af19b7b..eb5b4089 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -6,6 +6,7 @@ define("SALT_USER", "connected"); define("SALT_ADMIN", "admin"); //On active le débogage si l'on est sur le domaine de debug + if ($_SERVER["SERVER_NAME"] == "localhost" || $_SERVER["SERVER_NAME"] == "fic" || $_SERVER["SERVER_NAME"] == "fic.nemunai.re" || $_SERVER["SERVER_NAME"] == "atlantis.chen.li") define("DEBUG", true); @@ -15,7 +16,14 @@ require_once("common.php"); $template->assign("SALT_USER",SALT_USER); $template->assign("SALT_ADMIN",SALT_ADMIN); -$n = preg_match_all("#[^/]+#", strtolower(gpc("p")), $out); +// Convert hidden URL to raw one +$urls = Cache::read("urls"); +$p = strtolower(gpc("p")); + +if (!empty($urls["/".$p])) + $p = $urls["/".$p]; + +$n = preg_match_all("#[^/]+#", $p, $out); $p = $out[0]; // Admin part diff --git a/onyx/include/team/exercice.php b/onyx/include/team/exercice.php index 200f26da..fa1bf93f 100644 --- a/onyx/include/team/exercice.php +++ b/onyx/include/team/exercice.php @@ -13,7 +13,7 @@ if (isset($VAR['submission_dir'])) if ($n >= 6 && $p[5] == "werr") { $template->assign("ERRcolor", "danger"); - if (DEBUG) + if (defined("DEBUG") && DEBUG) $template->assign("ERRmessage", "DEBUG ERROR: le répertoire submission n'est pas accessible en écriture."); else $template->assign("ERRmessage", "Une erreur s'est produite durant la soumission. Veuillez réessayer dans quelques instants."); @@ -23,15 +23,15 @@ if (isset($VAR['submission_dir'])) $template->assign("ERRcolor", "success"); $template->assign("ERRmessage", "Votre réponse a bien été prise en compte et sera évaluée dans quelques instants..."); } - + if (!empty($_POST["solution"])) { if (is_writable("$submission_dir/")) { $file = $submission_dir.'/'.$p[1].'-'.$p[2].'-'.$p[3]; - + file_put_contents($file, $_POST['solution'], LOCK_EX); - + header("Location: /".implode("/", $p)); exit; } @@ -45,7 +45,7 @@ if (isset($VAR['submission_dir'])) } else { - if (DEBUG) + if (defined("DEBUG") && DEBUG) erreur("Merci d'ajouter la variable submission_dir dans root.xml"); else erreur("Une erreur s'est produite. Veuillez réessayer dans quelques instants."); diff --git a/onyx/modules/templates/smarty/plugins/function.link.php b/onyx/modules/templates/smarty/plugins/function.link.php new file mode 100644 index 00000000..d00ddca9 --- /dev/null +++ b/onyx/modules/templates/smarty/plugins/function.link.php @@ -0,0 +1,61 @@ +' . $label . ''; + else + return $href; +} diff --git a/onyx/tpl/bootstrap/admin/layout.tpl b/onyx/tpl/bootstrap/admin/layout.tpl index ea0fe9a9..bc3b77c9 100644 --- a/onyx/tpl/bootstrap/admin/layout.tpl +++ b/onyx/tpl/bootstrap/admin/layout.tpl @@ -25,19 +25,19 @@ - FIC + {link class="navbar-brand" href_prefix="/{$SALT_ADMIN}/" href="" label="FIC"}