public function execute(ShellParsedCommand $args) { $this->required('name,cmd', $args); $opt = $args->mapargs; $cfg = Config::load('services'); /* * Add service in config file */ array_push($cfg->services, array_merge(['type' => 'Service', 'url' => null], $opt->getMap())); $cfg->save(true); return new ShellResult(0, "Service added : " . $opt->name); }
<?php require 'config.php'; /** * Affiche une page d'un module */ $module = $_GET['m']; $page = $_GET['p']; /** * Check if module installed */ if (!is_dir(MOD_DIR . '/' . $module)) { exit('Module inexistant : ' . $module); } use rpi\core\Config; /** * Load config */ $config = Config::load($module); $settings = json_decode(@file_get_contents(MOD_DIR . '/' . $module . '/settings.json'));
************************************************************************************/ $extdir = opendir(MOD_DIR); $list = array(); $modules = array(); $extpaths = ""; while ($dir = readdir($extdir)) { if ($dir == '.' || $dir == '..') { continue; } $modules[] = $dir; $list[] = MOD_DIR . '/' . $dir . '/class'; } if (!empty($list)) { $extpaths = implode(PATH_SEPARATOR, $list) . PATH_SEPARATOR; } /************************************************************************************ * Configure autoload ************************************************************************************/ set_include_path($extpaths . __DIR__ . '/lib/' . PATH_SEPARATOR . get_include_path()); spl_autoload_extensions('.class.php,.lib.php'); spl_autoload_register(); /************************************************************************************ * Init module ************************************************************************************/ use rpi\core\Config; foreach ($modules as $mod) { if (is_file(MOD_DIR . '/' . $mod . '/init.php')) { $config = Config::load($mod); require MOD_DIR . '/' . $mod . '/init.php'; } }