X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fstatusnet.php;h=648369ec4482ebf9f1f347aa382d12b13c9d2eee;hb=3904ab9983942c30ae7209c8c6a3426359a51770;hp=ef3adebf94fdf4bbc9223bc6a2d9435bf79e6411;hpb=c6f09306b1c72296db8b55500a5d6a2ea8cd5dd2;p=quix0rs-gnu-social.git diff --git a/lib/statusnet.php b/lib/statusnet.php index ef3adebf94..648369ec44 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -31,6 +31,8 @@ class StatusNet { protected static $have_config; protected static $is_api; + protected static $is_ajax; + protected static $plugins = array(); /** * Configure and instantiate a plugin into the current configuration. @@ -74,9 +76,22 @@ class StatusNet $inst->$aname = $avalue; } } + + // Record activated plugins for later display/config dump + self::$plugins[] = array($name, $attrs); + return true; } + /** + * Get a list of activated plugins in this process. + * @return array of (string $name, array $args) pairs + */ + public static function getActivePlugins() + { + return self::$plugins; + } + /** * Initialize, or re-initialize, StatusNet global configuration * and plugins. @@ -127,7 +142,7 @@ class StatusNet return true; } - $sn = Status_network::staticGet($nickname); + $sn = Status_network::staticGet('nickname', $nickname); if (empty($sn)) { return false; throw new Exception("No such site nickname '$nickname'"); @@ -155,7 +170,6 @@ class StatusNet return $sites; } - /** * Fire initialization events for all instantiated plugins. */ @@ -163,6 +177,11 @@ class StatusNet { // Load default plugins foreach (common_config('plugins', 'default') as $name => $params) { + $key = 'disable-' . $name; + if (common_config('plugins', $key)) { + continue; + } + if (is_null($params)) { addPlugin($name); } else if (is_array($params)) { @@ -206,12 +225,22 @@ class StatusNet { return self::$is_api; } - + public function setApi($mode) { self::$is_api = $mode; } + public function isAjax() + { + return self::$is_ajax; + } + + public function setAjax($mode) + { + self::$is_ajax = $mode; + } + /** * Build default configuration array * @return array @@ -227,11 +256,12 @@ class StatusNet * Establish default configuration based on given or default server and path * Sets global $_server, $_path, and $config */ - protected static function initDefaults($server, $path) + public static function initDefaults($server, $path) { global $_server, $_path, $config; Event::clearHandlers(); + self::$plugins = array(); // try to figure out where we are. $server and $path // can be set by including module, else we guess based @@ -321,8 +351,11 @@ class StatusNet foreach ($config_files as $_config_file) { if (@file_exists($_config_file)) { - include($_config_file); - self::$have_config = true; + // Ignore 0-byte config files + if (filesize($_config_file) > 0) { + include($_config_file); + self::$have_config = true; + } } } @@ -339,20 +372,46 @@ class StatusNet } // Backwards compatibility - if (array_key_exists('memcached', $config)) { if ($config['memcached']['enabled']) { - if(class_exists('Memcached')) { - addPlugin('Memcached', array('servers' => $config['memcached']['server'])); - } else { - addPlugin('Memcache', array('servers' => $config['memcached']['server'])); - } + addPlugin('Memcache', array('servers' => $config['memcached']['server'])); } if (!empty($config['memcached']['base'])) { $config['cache']['base'] = $config['memcached']['base']; } } + if (array_key_exists('xmpp', $config)) { + if ($config['xmpp']['enabled']) { + addPlugin('xmpp', array( + 'server' => $config['xmpp']['server'], + 'port' => $config['xmpp']['port'], + 'user' => $config['xmpp']['user'], + 'resource' => $config['xmpp']['resource'], + 'encryption' => $config['xmpp']['encryption'], + 'password' => $config['xmpp']['password'], + 'host' => $config['xmpp']['host'], + 'debug' => $config['xmpp']['debug'], + 'public' => $config['xmpp']['public'] + )); + } + } + } + + /** + * Are we running from the web with HTTPS? + * + * @return boolean true if we're running with HTTPS; else false + */ + + static function isHTTPS() + { + // There are some exceptions to this; add them here! + if(empty($_SERVER['HTTPS'])) { + return false; + } else { + return $_SERVER['HTTPS'] !== 'off'; + } } }