]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/statusnet.php
get the subject first if you go to the feed
[quix0rs-gnu-social.git] / lib / statusnet.php
index 9c7ede5a5d4fe50164ab533d03862c1fe98c3041..85b46bbb3fed09904a31878c5f91caa01f5fd495 100644 (file)
@@ -30,6 +30,8 @@ global $config, $_server, $_path;
 class StatusNet
 {
     protected static $have_config;
+    protected static $is_api;
+    protected static $plugins = array();
 
     /**
      * Configure and instantiate a plugin into the current configuration.
@@ -63,7 +65,7 @@ class StatusNet
                 }
             }
             if (!class_exists($pluginclass)) {
-                throw new ServerException(500, "Plugin $name not found.");
+                throw new ServerException("Plugin $name not found.", 500);
             }
         }
 
@@ -73,9 +75,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.
@@ -126,7 +141,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'");
@@ -154,7 +169,6 @@ class StatusNet
         return $sites;
     }
 
-
     /**
      * Fire initialization events for all instantiated plugins.
      */
@@ -201,6 +215,16 @@ class StatusNet
         return self::$have_config;
     }
 
+    public function isApi()
+    {
+        return self::$is_api;
+    }
+
+    public function setApi($mode)
+    {
+        self::$is_api = $mode;
+    }
+
     /**
      * Build default configuration array
      * @return array
@@ -221,6 +245,7 @@ class StatusNet
         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
@@ -310,8 +335,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,14 +367,30 @@ class StatusNet
             }
         }
     }
+
+    /**
+     * 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';
+        }
+    }
 }
 
 class NoConfigException extends Exception
 {
-    public $config_files;
+    public $configFiles;
 
-    function __construct($msg, $config_files) {
+    function __construct($msg, $configFiles) {
         parent::__construct($msg);
-        $this->config_files = $config_files;
+        $this->configFiles = $configFiles;
     }
 }