diff options
author | MaZderMind | 2015-11-08 17:17:16 +0100 |
---|---|---|
committer | MaZderMind | 2015-11-08 17:17:16 +0100 |
commit | aec65f8a241d3810d5e7a029f861bc6090b65cb9 (patch) | |
tree | 467409791060ef43b13d025384df3c1c733c41e3 /index.php | |
parent | 0d91cc5f111fac882f1bb375c2bf426195c9cae2 (diff) |
better exception-handling in mandator-code
Diffstat (limited to '')
-rw-r--r-- | index.php | 104 |
1 files changed, 57 insertions, 47 deletions
@@ -24,71 +24,81 @@ require_once('model/Relive.php'); require_once('model/Upcoming.php'); -$route = @$_GET['route']; -$route = rtrim($route, '/'); - -// GLOBAL CSS (for conferences overview) -if($route == 'gen/main.css') -{ - handle_lesscss_request('assets/css/main.less', '../assets/css/'); - exit; -} +ob_start(); +try { + $route = @$_GET['route']; + $route = rtrim($route, '/'); -// generic template -$tpl = new PhpTemplate('template/page.phtml'); -$tpl->set(array( - 'baseurl' => forceslash(baseurl()), - 'route' => $route, - 'canonicalurl' => forceslash(baseurl()).forceslash($route), - 'assemblies' => './template/assemblies/', - 'assets' => 'assets/', + // GLOBAL CSS (for conferences overview) + if($route == 'gen/main.css') + { + handle_lesscss_request('assets/css/main.less', '../assets/css/'); + exit; + } - 'conference' => new GenericConference(), -)); + // generic template + $tpl = new PhpTemplate('template/page.phtml'); + $tpl->set(array( + 'baseurl' => forceslash(baseurl()), + 'route' => $route, + 'canonicalurl' => forceslash(baseurl()).forceslash($route), + 'assemblies' => './template/assemblies/', + 'assets' => 'assets/', -@list($mandator, $route) = explode('/', $route, 2); -if(!$mandator) -{ - // root requested + 'conference' => new GenericConference(), + )); - if(Conferences::getActiveConferencesCount() == 0) + @list($mandator, $route) = explode('/', $route, 2); + if(!$mandator) { - // no clients - // error + // root requested - require('view/allclosed.php'); - exit; - } - else if(Conferences::getActiveConferencesCount() == 1) - { - // one client - // redirect + if(Conferences::getActiveConferencesCount() == 0) + { + // no clients + // error - $clients = Conferences::getActiveConferences(); - header('Location: '.forceslash( baseurl() . $clients[0] )); - exit; + require('view/allclosed.php'); + exit; + } + else if(Conferences::getActiveConferencesCount() == 1) + { + // one client + // redirect + + $clients = Conferences::getActiveConferences(); + header('Location: '.forceslash( baseurl() . $clients[0]['link'] )); + exit; + } + else + { + // multiple clients + // show overview + + require('view/allconferences.php'); + exit; + } } - else + else if(!Conferences::exists($mandator)) { - // multiple clients - // show overview - - require('view/allconferences.php'); + // old url OR wrong client OR + // -> error + require('view/404.php'); exit; } + + Conferences::load($mandator); } -else if(!Conferences::exists($mandator)) +catch(Exception $e) { - // old url OR wrong client OR - // -> error - require('view/404.php'); - exit; + ob_clean(); + require('view/500.php'); } -Conferences::load($mandator); // PER-CONFERENCE CODE +$GLOBALS['MANDATOR'] = $mandator; $conference = new Conference(); $tpl = new PhpTemplate('template/page.phtml'); |