X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=index.php;h=0a79b9731d0aaa97ce321ec47d41bef37c270460;hb=175f1e73950ab80c799944af8f69391113906394;hp=3cecb5c8b6c3825d5e2e116ba05a2574191231ba;hpb=b8c0091390a9d0377eab80d77c9605d6b0ee428e;p=quix0rs-gnu-social.git diff --git a/index.php b/index.php index 3cecb5c8b6..0a79b9731d 100644 --- a/index.php +++ b/index.php @@ -47,7 +47,10 @@ if (!$user && common_config('site', 'private') && $actionfile = INSTALLDIR."/actions/$action.php"; -if (file_exists($actionfile)) { +if (!file_exists($actionfile)) { + $cac = new ClientErrorAction(_('Unknown action'), 404); + $cac->showPage(); +} else { include_once $actionfile; @@ -55,7 +58,7 @@ if (file_exists($actionfile)) { $action_obj = new $action_class(); - if ($config['db']['mirror'] && $action_obj->is_readonly()) { + if ($config['db']['mirror'] && $action_obj->isReadOnly()) { if (is_array($config['db']['mirror'])) { // "load balancing", ha ha $k = array_rand($config['db']['mirror']); @@ -66,9 +69,24 @@ if (file_exists($actionfile)) { } $config['db']['database'] = $mirror; } - if (call_user_func(array($action_obj, 'prepare'), $_REQUEST)) { - call_user_func(array($action_obj, 'handle'), $_REQUEST); + + try { + if ($action_obj->prepare($_REQUEST)) { + $action_obj->handle($_REQUEST); + } + } catch (ClientException $cex) { + $cac = new ClientErrorAction($cex->getMessage(), $cex->getCode()); + $cac->showPage(); + } catch (ServerException $sex) { // snort snort guffaw + $sac = new ServerErrorAction($sex->getMessage(), $sex->getCode()); + $sac->showPage(); + } catch (Exception $ex) { + $sac = new ServerErrorAction($ex->getMessage()); + $sac->showPage(); } -} else { - common_user_error(_('Unknown action')); -} \ No newline at end of file +} + +// XXX: cleanup exit() calls or add an exit handler so +// this always gets called + +Event::handle('CleanupPlugin');