aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind2015-11-08 17:17:16 +0100
committerMaZderMind2015-11-08 17:17:16 +0100
commitaec65f8a241d3810d5e7a029f861bc6090b65cb9 (patch)
tree467409791060ef43b13d025384df3c1c733c41e3
parent0d91cc5f111fac882f1bb375c2bf426195c9cae2 (diff)
better exception-handling in mandator-code
Diffstat (limited to '')
-rw-r--r--index.php104
-rw-r--r--model/Conferences.php4
2 files changed, 59 insertions, 49 deletions
diff --git a/index.php b/index.php
index a26f391..b7fe5da 100644
--- a/index.php
+++ b/index.php
@@ -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');
diff --git a/model/Conferences.php b/model/Conferences.php
index 10a3172..885c2c8 100644
--- a/model/Conferences.php
+++ b/model/Conferences.php
@@ -69,7 +69,7 @@ class Conferences extends ModelBase
}
public static function load($mandator) {
- $GLOBALS['MANDATOR'] = $mandator;
- require(forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php');
+ include(forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php');
+ return isset($GLOBALS['CONFIG']);
}
}