diff --git a/htdocs/index.php b/htdocs/index.php index 393f0d21..2af19b7b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -136,36 +136,46 @@ else if ($n && $p[0] == SALT_USER) { $tmp = explode("-", $p[2]); $id = intval($tmp[0]); - $THEME = new Theme($id); - unset($tmp, $id); - $template->assign("cur_theme", $THEME); - if ($n == 4 || ($n >= 5 && $p[4] == "submission")) - $id_exo = $p[3]; - else if ($n == 3) - { - foreach($THEME->get_exercices_ordered() as $exo) - { - if (! $exo->has_solved($TEAM)) - break; - } - $id_exo = $exo->id; - } + if ($id == 0) + $page = "404"; + else + { + try + { + $THEME = new Theme($id); + unset($tmp, $id); + $template->assign("cur_theme", $THEME); - try - { - $EXERCICE = new Exercice($id_exo, $THEME); - $template->assign("cur_exercice", $EXERCICE); - $page = require("team/exercice.php"); - } - catch(ExerciceNotFoundException $e) - { - $page = "404"; - } - catch(InvalidThemeException $e) - { - $page = "404"; - } + if ($n == 4 || ($n >= 5 && $p[4] == "submission")) + $id_exo = $p[3]; + else if ($n == 3) + { + foreach($THEME->get_exercices_ordered() as $exo) + { + if (! $exo->has_solved($TEAM)) + break; + } + $id_exo = $exo->id; + } + + $EXERCICE = new Exercice($id_exo, $THEME); + $template->assign("cur_exercice", $EXERCICE); + $page = require("team/exercice.php"); + } + catch(ExerciceNotFoundException $e) + { + $page = "404"; + } + catch(InvalidThemeException $e) + { + $page = "404"; + } + catch(ThemeNotFoundException $e) + { + $page = "404"; + } + } } } } diff --git a/onyx/include/common/Theme.class.php b/onyx/include/common/Theme.class.php index 1c470bc1..15f81d41 100644 --- a/onyx/include/common/Theme.class.php +++ b/onyx/include/common/Theme.class.php @@ -20,6 +20,11 @@ class Theme $this->id = $res['id']; $this->name = $res['name']; } + else + { + $db->deconnexion(); + throw new ThemeNotFoundException(); + } $db->deconnexion(); } } @@ -137,3 +142,8 @@ class Theme return $array; } } + +class ThemeNotFoundException extends Exception +{ +} +