X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=index.php;h=3534739bface4334914d14a07dbb700363d3f974;hb=a35392da2f96f30a065ec1cd1de3d553ce31776a;hp=0aceeda55a8174d2e6425ba656e554ab96fb3655;hpb=ae696728f5edf8972c68c17ce9ea21f07d44cbed;p=quix0rs-gnu-social.git diff --git a/index.php b/index.php index 0aceeda55a..3534739bfa 100644 --- a/index.php +++ b/index.php @@ -37,6 +37,9 @@ * @license GNU Affero General Public License http://www.gnu.org/licenses/ */ +$_startTime = microtime(true); +$_perfCounters = array(); + define('INSTALLDIR', dirname(__FILE__)); define('STATUSNET', true); define('LACONICA', true); // compatibility @@ -103,20 +106,20 @@ function handleError($error) $_cur = null; $msg = sprintf( - _( - 'The database for %s isn\'t responding correctly, '. - 'so the site won\'t work properly. '. - 'The site admins probably know about the problem, '. - 'but you can contact them at %s to make sure. '. - 'Otherwise, wait a few minutes and try again.' + // TRANS: Database error message. + _('The database for %1$s is not responding correctly, '. + 'so the site will not work properly. '. + 'The site admins probably know about the problem, '. + 'but you can contact them at %2$s to make sure. '. + 'Otherwise, wait a few minutes and try again.' ), common_config('site', 'name'), common_config('site', 'email') ); } else { - $msg = _( - 'An important error occured, probably related to email setup. '. - 'Check logfiles for more info..' + // TRANS: Error message. + $msg = _('An important error occured, probably related to email setup. '. + 'Check logfiles for more info.' ); } @@ -124,6 +127,7 @@ function handleError($error) $dac->showPage(); } catch (Exception $e) { + // TRANS: Error message. echo _('An error occurred.'); } exit(-1); @@ -171,15 +175,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) @@ -204,7 +217,7 @@ function checkMirror($action_obj, $args) function isLoginAction($action) { - static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp', 'opensearch', 'rsd'); + static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp', 'opensearch', 'rsd', 'hostmeta'); $login = null; @@ -219,18 +232,18 @@ function main() { // fake HTTP redirects using lighttpd's 404 redirects if (strpos($_SERVER['SERVER_SOFTWARE'], 'lighttpd') !== false) { - $_lighty_url = $base_url.$_SERVER['REQUEST_URI']; + $_lighty_url = $_SERVER['REQUEST_URI']; $_lighty_url = @parse_url($_lighty_url); if ($_lighty_url['path'] != '/index.php' && $_lighty_url['path'] != '/') { $_lighty_path = preg_replace('/^'.preg_quote(common_config('site', 'path')).'\//', '', substr($_lighty_url['path'], 1)); $_SERVER['QUERY_STRING'] = 'p='.$_lighty_path; - if ($_lighty_url['query']) { + if (isset($_lighty_url['query']) && $_lighty_url['query'] != '') { $_SERVER['QUERY_STRING'] .= '&'.$_lighty_url['query']; - } - parse_str($_lighty_url['query'], $_lighty_query); - foreach ($_lighty_query as $key => $val) { - $_GET[$key] = $_REQUEST[$key] = $val; + parse_str($_lighty_url['query'], $_lighty_query); + foreach ($_lighty_query as $key => $val) { + $_GET[$key] = $_REQUEST[$key] = $val; + } } $_GET['p'] = $_REQUEST['p'] = $_lighty_path; } @@ -247,9 +260,9 @@ function main() if (!_have_config()) { $msg = sprintf( - _( - "No configuration file found. Try running ". - "the installation program first." + // TRANS: Error message displayed when there is no StatusNet configuration file. + _("No configuration file found. Try running ". + "the installation program first." ) ); $sac = new ServerErrorAction($msg); @@ -278,11 +291,20 @@ function main() $args = $r->map($path); if (!$args) { + // TRANS: Error message displayed when trying to access a non-existing page. $cac = new ClientErrorAction(_('Unknown page'), 404); $cac->showPage(); return; } + $site_ssl = common_config('site', 'ssl'); + + // If the request is HTTP and it should be HTTPS... + if ($site_ssl != 'never' && !StatusNet::isHTTPS() && common_is_sensitive($args['action'])) { + common_redirect(common_local_url($args['action'], $args)); + return; + } + $args = array_merge($args, $_REQUEST); Event::handle('ArgsInitialize', array(&$args)); @@ -324,6 +346,7 @@ function main() $action_class = ucfirst($action).'Action'; if (!class_exists($action_class)) { + // TRANS: Error message displayed when trying to perform an undefined action. $cac = new ClientErrorAction(_('Unknown action'), 404); $cac->showPage(); } else {