X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatal.php;h=4560f6ef5d3ea433bc0a7a81fd53075ab4b62d13;hb=40b79bfc4a940747b434d9611601007d7026b473;hp=c23fb5337a51be5d020d6e0efc0e7d4ab68250cc;hpb=41e571e3c1546e3288eb386bdd1f2863bcbb95be;p=platal.git diff --git a/classes/platal.php b/classes/platal.php index c23fb53..4560f6e 100644 --- a/classes/platal.php +++ b/classes/platal.php @@ -65,13 +65,14 @@ abstract class PlHook if ($this->hasType(DO_AUTH)) { if (!$session->start($this->auth)) { $platal->force_login($page); + return PL_FORBIDDEN; } } else { return PL_FORBIDDEN; } } if (!$this->checkPerms()) { - if (!Platal::notAllowed()) { + if (Platal::notAllowed()) { return PL_FORBIDDEN; } } @@ -218,7 +219,6 @@ class PlHookTree } } - abstract class Platal { private $mods; @@ -228,7 +228,7 @@ abstract class Platal public $ns; public $path; - public $argv; + public $argv = array(); static private $_page = null; @@ -266,7 +266,7 @@ abstract class Platal $this->mods[$module] = $m = PLModule::factory($module); $hooks = $m->handlers(); foreach ($hooks as $path=>$hook) { - $this->hooks->addChild(split('/', $path), $hook); + $this->hooks->addChild(explode('/', $path), $hook); } } @@ -301,7 +301,7 @@ abstract class Platal protected function find_hook() { - $p = split('/', $this->path); + $p = explode('/', $this->path); list($hook, $matched, $remain, $aliased) = $this->hooks->findChild($p); if (empty($hook)) { return null; @@ -317,7 +317,7 @@ abstract class Platal public function near_hook() { - $p = split('/', $this->path); + $p = explode('/', $this->path); list($hook, $matched, $remain, $aliased) = $this->hooks->findNearestChild($p); if (empty($hook)) { return null; @@ -359,18 +359,29 @@ abstract class Platal $this->path = 'index'; } - $page->assign('platal', $this); - switch ($this->call_hook($page)) { - case PL_FORBIDDEN: - $this->mods['core']->handler_403($page); - break; + try { + $page->assign('platal', $this); + switch ($this->call_hook($page)) { + case PL_FORBIDDEN: + $this->mods['core']->handler_403($page); + break; - case PL_NOT_FOUND: - $this->mods['core']->handler_404($page); - break; + case PL_NOT_FOUND: + $this->mods['core']->handler_404($page); + break; - case PL_WIKI: - return PL_WIKI; + case PL_WIKI: + return PL_WIKI; + } + } catch (Exception $e) { + header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); + PlErrorReport::report($e); + if (self::globals()->debug) { + $page->kill(pl_entities($e->getMessage()) + . '
' . pl_entities("" . $e) . '
'); + } else { + $page->kill(pl_entities($e->getMessage())); + } } $page->assign('platal', $this); @@ -423,16 +434,15 @@ abstract class Platal } } - public static function assert($cond, $error, $userfriendly) + public static function assert($cond, $error, $userfriendly = null) { - global $globals; if ($cond === false) { - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); - $file = fopen($globals->spoolroot . '/spool/tmp/assert_erros', 'a'); - fwrite($file, '
' . pl_entities($error) . '
\n'); - fclose($file); - - Platal::page()->kill($userfriendly); + if ($userfriendly == null) { + $userfriendly = "Une erreur interne s'est produite. + Merci de réessayer la manipulation qui a déclenché l'erreur ; + si cela ne fonctionne toujours pas, merci de nous signaler le problème rencontré."; + } + throw new PlException($userfriendly, $error); } } @@ -440,7 +450,8 @@ abstract class Platal { if (defined('PL_LOGGER_CLASS')) { $class = PL_LOGGER_CLASS; - return new $class($uid, $suid); + $logger = new $class($uid, $suid); + return $logger; } else { return PlLogger::dummy($uid, $suid); }