X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=index.php;h=dae1ae75145e127a906b64a488f5248ebae05ae8;hb=8cc19b90eeb7920b2cfe79959038c5e25f40930a;hp=717b17361d2f7f60c343cf9c9f3ad3e33b11632c;hpb=27e23f2dd3e071712dc9d4765beaa33b57150fe0;p=quix0rs-gnu-social.git diff --git a/index.php b/index.php index 717b17361d..dae1ae7514 100644 --- a/index.php +++ b/index.php @@ -25,20 +25,58 @@ require_once INSTALLDIR . '/lib/common.php'; $user = null; $action = null; -function getPath($req) { - if (common_config('site', 'fancy')) { +function getPath($req) +{ + if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER)) + && array_key_exists('p', $req)) { return $req['p']; - } else if ($_SERVER['PATH_INFO']) { + } else if (array_key_exists('PATH_INFO', $_SERVER)) { return $_SERVER['PATH_INFO']; } else { - return $req['p']; + return null; } } -function main() { +function handleError($error) +{ + if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { + return; + } + + $logmsg = "PEAR error: " . $error->getMessage(); + if(common_config('site', 'logdebug')) { + $logmsg .= " : ". $error->getDebugInfo(); + } + common_log(LOG_ERR, $logmsg); + $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.'), + common_config('site', 'name'), + common_config('site', 'email')); + + $dac = new DBErrorAction($msg, 500); + $dac->showPage(); + exit(-1); +} +function main() +{ global $user, $action; + if (!_have_config()) { + $msg = sprintf(_("No configuration file found. Try running ". + "the installation program first.")); + $sac = new ServerErrorAction($msg); + $sac->showPage(); + return; + } + + // For database errors + + PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError'); + // XXX: we need a little more structure in this script // get and cache current user @@ -90,8 +128,8 @@ function main() { // XXX: find somewhere for this little block to live - if ($config['db']['mirror'] && $action_obj->isReadOnly()) { - if (is_array($config['db']['mirror'])) { + if (common_config('db', 'mirror') && $action_obj->isReadOnly()) { + if (is_array(common_config('db', 'mirror'))) { // "load balancing", ha ha $k = array_rand($config['db']['mirror']);