Ejemplo n.º 1
0
function get_dir_structure($path, $recursive = TRUE, $ext = NULL)
{
    $return = NULL;
    if (!is_dir($path)) {
        trigger_error('$path is not a directory!', E_USER_WARNING);
        return FALSE;
    }
    if ($handle = opendir($path)) {
        while (FALSE !== ($item = readdir($handle))) {
            if ($item != '.' && $item != '..') {
                if (is_dir($path . $item)) {
                    if ($recursive) {
                        $return[$item] = get_dir_structure($path . $item . '/', $recursive, $ext);
                    } else {
                        $return[$item] = array();
                    }
                } else {
                    if ($ext != null && strrpos($item, $ext) !== FALSE) {
                        $return[] = $item;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $return;
}
Ejemplo n.º 2
0
 public function loadPlugins()
 {
     global $PRISM;
     $loadedPluginCount = 0;
     if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) {
         console('Loading plugins');
     }
     $pluginPath = ROOTPATH . '/plugins';
     if (($pluginFiles = get_dir_structure($pluginPath, false, '.php')) === null) {
         if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) {
             console('No plugins found in the directory.');
         }
         # As we can't find any plugin files, we invalidate the the ini settings.
         $this->pluginvars = null;
     }
     # If there are no plugins, then don't loop through the list.
     if ($this->pluginvars == null) {
         return true;
     }
     # Find what plugin files have ini entrys
     foreach ($this->pluginvars as $pluginSection => $pluginHosts) {
         $pluginFileHasPluginSection = false;
         foreach ($pluginFiles as $pluginFile) {
             if ("{$pluginSection}.php" == $pluginFile) {
                 $pluginFileHasPluginSection = true;
             }
         }
         # Remove any pluginini value who does not have a file associated with it.
         if ($pluginFileHasPluginSection === false) {
             unset($this->pluginvars[$pluginSection]);
             continue;
         }
         # Load the plugin file.
         if ($PRISM->config->cvars['debugMode'] & PRISM_DEBUG_CORE) {
             console("Loading plugin: {$pluginSection}");
         }
         include_once "{$pluginPath}/{$pluginSection}.php";
         $this->plugins[$pluginSection] = new $pluginSection($this);
         ++$loadedPluginCount;
     }
     return $loadedPluginCount;
 }
Ejemplo n.º 3
0
 public function cmdPluginLoad($cmd, $ucid)
 {
     global $PRISM;
     $MTC = IS_MTC()->UCID($ucid);
     if (($argc = count($argv = str_getcsv($cmd, ' '))) < 4) {
         $MTC->Text('Useage: `prism plugins load <plugin>`')->Send();
         $MTC->Text('Loads plugin(s) at runtime.')->Send();
         $PluginsAll = get_dir_structure(PHPInSimMod::ROOTPATH . '/plugins/');
         $PluginsLoaded = array_keys($PRISM->plugins->getPlugins());
         $PluginsNotloaded = array_diff($PluginsAll, $PluginsLoaded);
         var_dump($PluginsAvailable, $PluginsLoaded, $PluginsNotloaded);
         /*			foreach ($PluginsNotloaded as $Plugin)
         			{
         				if (validatePHPFile(PHPInSimMod::ROOTPATH . '/plugins/' . $Plugins . '.php'))
         					#Plugin Is Sane, Color Should be GREEN.
         				else
         					#Plugin Not Sname, Color Should be RED.
         			} */
     }
     #Load Plugins
     return PLUGIN_HANDLED;
 }