X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommon.php;h=7342c177a66091bacfef35a22ab960f4b9f6ebf7;hb=bd6571c2e17939b21e01afd3772acb5cebbbadfe;hp=e29456ed4e9d2345fbcb3ac76916d4fa0e28edbb;hpb=4e639b8769f42e700b9ad3abe5564ddb0178501c;p=quix0rs-gnu-social.git diff --git a/lib/common.php b/lib/common.php index e29456ed4e..7342c177a6 100644 --- a/lib/common.php +++ b/lib/common.php @@ -19,7 +19,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -define('STATUSNET_VERSION', '0.9.0dev'); +//exit with 200 response, if this is checking fancy from the installer +if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; } + +define('STATUSNET_VERSION', '0.9.0rc2'); define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility define('STATUSNET_CODENAME', 'Stand'); @@ -38,22 +41,24 @@ define('FOREIGN_NOTICE_SEND_REPLY', 4); define('FOREIGN_FRIEND_SEND', 1); define('FOREIGN_FRIEND_RECV', 2); -define_syslog_variables(); - # append our extlib dir as the last-resort place to find libs set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib/'); +# To protect against upstream libraries which haven't updated +# for PHP 5.3 where dl() function may not be present... +if (!function_exists('dl')) { + function dl($library) { + return false; + } +} + # global configuration object require_once('PEAR.php'); require_once('DB/DataObject.php'); require_once('DB/DataObject/Cast.php'); # for dates -if (!function_exists('gettext')) { - require_once("php-gettext/gettext.inc"); -} - require_once(INSTALLDIR.'/lib/language.php'); // This gets included before the config file, so that admin code and plugins @@ -74,6 +79,9 @@ function _sn_to_path($sn) return $p; } +// Save our sanity when code gets loaded through subroutines such as PHPUnit tests +global $default, $config, $_server, $_path; + // try to figure out where we are. $server and $path // can be set by including module, else we guess based // on HTTP info. @@ -169,6 +177,7 @@ if (isset($conffile)) { $_config_files[] = INSTALLDIR.'/config.php'; } +global $_have_a_config; $_have_a_config = false; foreach ($_config_files as $_config_file) { @@ -185,7 +194,14 @@ function _have_config() } // XXX: Throw a conniption if database not installed - +// XXX: Find a way to use htmlwriter for this instead of handcoded markup +if (!_have_config()) { + echo '

'. _('No configuration file found. ') .'

'; + echo '

'. _('I looked for configuration files in the following places: ') .'
'. implode($_config_files, '
'); + echo '

'. _('You may wish to run the installer to fix this.') .'

'; + echo ''. _('Go to the installer.') .''; + exit; +} // Fixup for statusnet.ini $_db_name = substr($config['db']['database'], strrpos($config['db']['database'], '/') + 1); @@ -194,6 +210,18 @@ if ($_db_name != 'statusnet' && !array_key_exists('ini_'.$_db_name, $config['db' $config['db']['ini_'.$_db_name] = INSTALLDIR.'/classes/statusnet.ini'; } +// Backwards compatibility + +if (array_key_exists('memcached', $config)) { + if ($config['memcached']['enabled']) { + addPlugin('Memcache', array('servers' => $config['memcached']['server'])); + } + + if (!empty($config['memcached']['base'])) { + $config['cache']['base'] = $config['memcached']['base']; + } +} + function __autoload($cls) { if (file_exists(INSTALLDIR.'/classes/' . $cls . '.php')) { @@ -210,6 +238,27 @@ function __autoload($cls) } } +// Load default plugins + +foreach ($config['plugins']['default'] as $name => $params) { + if (is_null($params)) { + addPlugin($name); + } else if (is_array($params)) { + if (count($params) == 0) { + addPlugin($name); + } else { + $keys = array_keys($params); + if (is_string($keys[0])) { + addPlugin($name, $params); + } else { + foreach ($params as $paramset) { + addPlugin($name, $paramset); + } + } + } + } +} + // XXX: how many of these could be auto-loaded on use? // XXX: note that these files should not use config options // at compile time since DB config options are not yet loaded. @@ -219,10 +268,8 @@ require_once 'markdown.php'; require_once INSTALLDIR.'/lib/util.php'; require_once INSTALLDIR.'/lib/action.php'; -require_once INSTALLDIR.'/lib/theme.php'; require_once INSTALLDIR.'/lib/mail.php'; require_once INSTALLDIR.'/lib/subs.php'; -require_once INSTALLDIR.'/lib/Shorturl_api.php'; require_once INSTALLDIR.'/lib/clientexception.php'; require_once INSTALLDIR.'/lib/serverexception.php';