X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=index.php;h=1566399fa2f351e8381796397d0f697b5b4e617f;hb=09b80a6e90aa6313704577d7bd6f0df7c803ba9b;hp=3265f0c0e9e4b647803e246cb9b2c2e29fee960f;hpb=c4b9dc7a0ff2e41712715ac21bace067e8c02715;p=quix0rs-gnu-social.git diff --git a/index.php b/index.php index 3265f0c0e9..1566399fa2 100644 --- a/index.php +++ b/index.php @@ -49,21 +49,29 @@ $action = null; function getPath($req) { + $p = null; + if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) && array_key_exists('p', $req) ) { - return $req['p']; + $p = $req['p']; } else if (array_key_exists('PATH_INFO', $_SERVER)) { $path = $_SERVER['PATH_INFO']; $script = $_SERVER['SCRIPT_NAME']; if (substr($path, 0, mb_strlen($script)) == $script) { - return substr($path, mb_strlen($script)); + $p = substr($path, mb_strlen($script) + 1); } else { - return $path; + $p = $path; } } else { - return null; + $p = null; } + + // Trim all initial '/' + + $p = ltrim($p, '/'); + + return $p; } /** @@ -116,16 +124,14 @@ function handleError($error) common_config('site', 'name'), common_config('site', 'email') ); + + $dac = new DBErrorAction($msg, 500); + $dac->showPage(); } else { - // TRANS: Error message. - $msg = _('An important error occured, probably related to email setup. '. - 'Check logfiles for more info.' - ); + $sac = new ServerErrorAction($error->getMessage(), 500, $error); + $sac->showPage(); } - $dac = new DBErrorAction($msg, 500); - $dac->showPage(); - } catch (Exception $e) { // TRANS: Error message. echo _('An error occurred.'); @@ -175,15 +181,24 @@ function setupRW() static $alwaysRW = array('session', 'remember_me'); - // We ensure that these tables always are used - // on the master DB + $rwdb = $config['db']['database']; + + if (Event::handle('StartReadWriteTables', array(&$alwaysRW, &$rwdb))) { + + // We ensure that these tables always are used + // on the master DB - $config['db']['database_rw'] = $config['db']['database']; - $config['db']['ini_rw'] = INSTALLDIR.'/classes/statusnet.ini'; + $config['db']['database_rw'] = $rwdb; + $config['db']['ini_rw'] = INSTALLDIR.'/classes/statusnet.ini'; - foreach ($alwaysRW as $table) { - $config['db']['table_'.$table] = 'rw'; + foreach ($alwaysRW as $table) { + $config['db']['table_'.$table] = 'rw'; + } + + Event::handle('EndReadWriteTables', array($alwaysRW, $rwdb)); } + + return; } function checkMirror($action_obj, $args)