public function init($options) { parent::init($options); $this->useQueue = $this->pluginConf["USE_QUEUE"]; try { $this->msgExchanger = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_MS_INSTANCE"], "AJXP_MessageExchanger"); } catch (Exception $e) { } }
/** * @return AbstractConfDriver */ public function getConfImpl() { if (!isset(self::$confImpl) || isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) && self::$confImpl->getId() != $this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) { if (isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"])) { self::$confImpl = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("conf", self::$confImpl->getName()); } } return self::$confImpl; }
public function init($options) { parent::init($options); self::$globalOptions = $this->pluginConf; $this->pluginInstance = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_PLUGIN_INSTANCE"], "AbstractLogDriver"); if ($this->pluginInstance != false) { AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("log", $this->pluginInstance->getName(), $this->pluginInstance); } self::$loggerInstance = $this->pluginInstance; }
public function init($options) { parent::init($options); $this->userId = AuthService::getLoggedUser() !== null ? AuthService::getLoggedUser()->getId() : "shared"; try { $this->eventStore = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_FEED_INSTANCE"], "AJXP_FeedStore"); } catch (Exception $e) { } if ($this->eventStore === false) { $this->pluginConf["USER_EVENTS"] = false; } }
public function init($options) { parent::init($options); if (AJXP_SERVER_DEBUG) { $this->mailCache = $this->getPluginWorkDir(true) . "/mailbox"; } $pConf = $this->pluginConf["UNIQUE_MAILER_INSTANCE"]; if (!empty($pConf)) { $p = ConfService::instanciatePluginFromGlobalParams($pConf, "AjxpMailer"); AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType($p->getType(), $p->getName(), $p); } }
public function init($options) { parent::init($options); $this->useQueue = $this->pluginConf["USE_QUEUE"]; try { $this->msgExchanger = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_MS_INSTANCE"], "AJXP_MessageExchanger"); if (AuthService::$bufferedMessage != null && AuthService::getLoggedUser() != null) { $this->sendInstantMessage(AuthService::$bufferedMessage, ConfService::getCurrentRepositoryId(), AuthService::getLoggedUser()->getId()); AuthService::$bufferedMessage = null; } } catch (Exception $e) { } }
public function getCacheImpl() { $pluginInstance = null; if (!isset(self::$cacheInstance) || isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) && self::$cacheInstance->getId() != $this->pluginConf["UNIQUE_INSTANCE_CONFIG"]["instance_name"]) { if (isset($this->pluginConf["UNIQUE_INSTANCE_CONFIG"])) { $pluginInstance = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_INSTANCE_CONFIG"], "AbstractCacheDriver"); if ($pluginInstance != false) { AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("cache", $pluginInstance->getName(), $pluginInstance); } } self::$cacheInstance = $pluginInstance; if ($pluginInstance !== null && is_a($pluginInstance, "AbstractCacheDriver") && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)) { AJXP_MetaStreamWrapper::appendMetaWrapper("pydio.cache", "CacheStreamLayer"); } } return self::$cacheInstance; }
/** * Create or update the bootstrap json file. * @param Array $data Parsed result of the installer form * @return array 2 entries array containing the new Conf Driver (0) and Auth Driver (1) * @throws Exception */ public function createBootstrapConf($data) { // Create a custom bootstrap.json file $coreConf = array(); $coreAuth = array(); $this->_loadPluginConfig("core.conf", $coreConf); $this->_loadPluginConfig("core.auth", $coreAuth); if (!isset($coreConf["UNIQUE_INSTANCE_CONFIG"])) { $coreConf["UNIQUE_INSTANCE_CONFIG"] = array(); } if (!isset($coreAuth["MASTER_INSTANCE_CONFIG"])) { $coreAuth["MASTER_INSTANCE_CONFIG"] = array(); } $coreConf["AJXP_CLI_SECRET_KEY"] = AJXP_Utils::generateRandomString(24, true); // REWRITE BOOTSTRAP.JSON $coreConf["DIBI_PRECONFIGURATION"] = $data["db_type"]; if (isset($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) { $dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]); if (!file_exists(dirname($dbFile))) { mkdir(dirname($dbFile), 0755, true); } } $coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.sql", "group_switch_value" => "conf.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); $coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.sql", "group_switch_value" => "auth.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); // DETECT REQUIRED SQL TABLES AND INSTALL THEM $registry = AJXP_PluginsService::getInstance()->getDetectedPlugins(); $driverData = array("SQL_DRIVER" => $data["db_type"]); foreach ($registry as $type => $plugins) { foreach ($plugins as $plugObject) { if ($plugObject instanceof SqlTableProvider) { $plugObject->installSQLTables($driverData); } } } $oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json"; if (is_file($oldBoot)) { copy($oldBoot, $oldBoot . ".bak"); unlink($oldBoot); } $newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth); AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true); // Write new bootstrap and reload conf plugin! $coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; $coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; $newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); $newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver"); $sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql"); foreach ($sqlPlugs as $core => $value) { list($pluginId, $param) = explode("/", $core); $options = array(); $newConfigPlugin->_loadPluginConfig($pluginId, $options); $options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")); $newConfigPlugin->_savePluginConfig($pluginId, $options); } return array($newConfigPlugin, $newAuthPlugin); }
/** * Transmit to the ajxp_conf load_plugin_manifest action * @param $action * @param $httpVars * @param $fileVars */ public function applyInstallerForm($action, $httpVars, $fileVars) { $data = array(); AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, ""); // Create a custom bootstrap.json file $coreConf = array(); $coreAuth = array(); $this->_loadPluginConfig("core.conf", $coreConf); $this->_loadPluginConfig("core.auth", $coreAuth); if (!isset($coreConf["UNIQUE_INSTANCE_CONFIG"])) { $coreConf["UNIQUE_INSTANCE_CONFIG"] = array(); } if (!isset($coreAuth["MASTER_INSTANCE_CONFIG"])) { $coreAuth["MASTER_INSTANCE_CONFIG"] = array(); } $coreConf["AJXP_CLI_SECRET_KEY"] = AJXP_Utils::generateRandomString(24, true); $storageType = $data["STORAGE_TYPE"]["type"]; if ($storageType == "db") { // REWRITE BOOTSTRAP.JSON $coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"]; if (isset($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) { $dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]); if (!file_exists(dirname($dbFile))) { mkdir(dirname($dbFile), 0755, true); } } $coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.sql", "group_switch_value" => "conf.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); $coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.sql", "group_switch_value" => "auth.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); // INSTALL ALL SQL TABLES $sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "meta.syncable"); foreach ($sqlPlugs as $plugId) { $plug = AJXP_PluginsService::findPluginById($plugId); $plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"])); } } else { $coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.serial", "group_switch_value" => "conf.serial")); $coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.serial", "group_switch_value" => "auth.serial")); } $oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json"; if (is_file($oldBoot)) { copy($oldBoot, $oldBoot . ".bak"); unlink($oldBoot); } $newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth); AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true); // Write new bootstrap and reload conf plugin! if ($storageType == "db") { $coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; $coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; } $newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); $newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver"); if ($data["ENCODING"] != (defined('AJXP_LOCALE') ? AJXP_LOCALE : SystemTextEncoding::getEncoding())) { file_put_contents($this->getPluginWorkDir() . "/encoding.php", "<?php \$ROOT_ENCODING='" . $data["ENCODING"] . "';"); } $tpl = file_get_contents($this->getBaseDir() . "/htaccess.tpl"); if (!empty($data["SERVER_URI"]) && $data["SERVER_URI"] != "/") { $htContent = str_replace('${APPLICATION_ROOT}', $data["SERVER_URI"], $tpl); } else { $htContent = str_replace('${APPLICATION_ROOT}/', "/", $tpl); $htContent = str_replace('${APPLICATION_ROOT}', "/", $htContent); } if (is_writeable(AJXP_INSTALL_PATH . "/.htaccess")) { file_put_contents(AJXP_INSTALL_PATH . "/.htaccess", $htContent); } else { $htAccessToUpdate = AJXP_INSTALL_PATH . "/.htaccess"; } if ($storageType == "db") { $sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql"); $data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"]; } // Prepare plugins configs $direct = array("APPLICATION_TITLE" => "core.ajaxplorer/APPLICATION_TITLE", "APPLICATION_LANGUAGE" => "core.ajaxplorer/DEFAULT_LANGUAGE", "ENABLE_NOTIF" => "core.notifications/USER_EVENTS", "APPLICATION_WELCOME" => "gui.ajax/CUSTOM_WELCOME_MESSAGE"); $mailerEnabled = $data["MAILER_ENABLE"]["status"]; if ($mailerEnabled == "yes") { // Enable core.mailer $data["MAILER_SYSTEM"] = $data["MAILER_ENABLE"]["MAILER_SYSTEM"]; $data["MAILER_ADMIN"] = $data["MAILER_ENABLE"]["MAILER_ADMIN"]; $direct = array_merge($direct, array("MAILER_SYSTEM" => "mailer.phpmailer-lite/MAILER", "MAILER_ADMIN" => "core.mailer/FROM")); } foreach ($direct as $key => $value) { list($pluginId, $param) = explode("/", $value); $options = array(); $newConfigPlugin->_loadPluginConfig($pluginId, $options); $options[$param] = $data[$key]; $newConfigPlugin->_savePluginConfig($pluginId, $options); } if (isset($sqlPlugs)) { foreach ($sqlPlugs as $core => $value) { list($pluginId, $param) = explode("/", $core); $options = array(); $newConfigPlugin->_loadPluginConfig($pluginId, $options); $options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")); $newConfigPlugin->_savePluginConfig($pluginId, $options); } } ConfService::setTmpStorageImplementations($newConfigPlugin, $newAuthPlugin); require_once $newConfigPlugin->getUserClassFileName(); $adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS); $adminName = $data["ADMIN_USER_NAME"]; $adminPass = $data["ADMIN_USER_PASS"]; $adminPass2 = $data["ADMIN_USER_PASS2"]; AuthService::createUser($adminLogin, $adminPass, true); $uObj = $newConfigPlugin->createUserObject($adminLogin); if (isset($data["MAILER_ADMIN"])) { $uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]); } $uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName); $uObj->personalRole->setAcl('ajxp_conf', 'rw'); AuthService::updateRole($uObj->personalRole); $loginP = "USER_LOGIN"; $i = 0; while (isset($data[$loginP]) && !empty($data[$loginP])) { $pass = $data[str_replace("_LOGIN", "_PASS", $loginP)]; $pass2 = $data[str_replace("_LOGIN", "_PASS2", $loginP)]; $name = $data[str_replace("_LOGIN", "_NAME", $loginP)]; $mail = $data[str_replace("_LOGIN", "_MAIL", $loginP)]; $saniLogin = AJXP_Utils::sanitize($data[$loginP], AJXP_SANITIZE_EMAILCHARS); AuthService::createUser($saniLogin, $pass); $uObj = $newConfigPlugin->createUserObject($saniLogin); $uObj->personalRole->setParameterValue("core.conf", "email", $mail); $uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $name); AuthService::updateRole($uObj->personalRole); $i++; $loginP = "USER_LOGIN_" . $i; } AJXP_PluginsService::clearPluginsCache(); AJXP_Utils::setApplicationFirstRunPassed(); if (isset($htAccessToUpdate)) { HTMLWriter::charsetHeader("application/json"); echo json_encode(array('file' => $htAccessToUpdate, 'content' => $htContent)); } else { session_destroy(); HTMLWriter::charsetHeader("text/plain"); echo 'OK'; } }
public function getAuthImpl() { if (!isset(self::$authStorageImpl)) { if (!isset($this->pluginConf["MASTER_INSTANCE_CONFIG"])) { throw new Exception("Please set up at least one MASTER_INSTANCE_CONFIG in core.auth options"); } $masterName = is_array($this->pluginConf["MASTER_INSTANCE_CONFIG"]) ? $this->pluginConf["MASTER_INSTANCE_CONFIG"]["instance_name"] : $this->pluginConf["MASTER_INSTANCE_CONFIG"]; $masterName = str_replace("auth.", "", $masterName); if (!empty($this->pluginConf["SLAVE_INSTANCE_CONFIG"]) && !empty($this->pluginConf["MULTI_MODE"])) { $slaveName = is_array($this->pluginConf["SLAVE_INSTANCE_CONFIG"]) ? $this->pluginConf["SLAVE_INSTANCE_CONFIG"]["instance_name"] : $this->pluginConf["SLAVE_INSTANCE_CONFIG"]; $slaveName = str_replace("auth.", "", $slaveName); // Manually set up a multi config $userBase = $this->pluginConf["MULTI_USER_BASE_DRIVER"]; if ($userBase == "master") { $baseName = $masterName; } else { if ($userBase == "slave") { $baseName = $slaveName; } else { $baseName = ""; } } $mLabel = ""; $sLabel = ""; $separator = ""; $cacheMasters = true; if (isset($this->pluginConf["MULTI_MODE"]) && !isset($this->pluginConf["MULTI_MODE"]["instance_name"])) { $this->pluginConf["MULTI_MODE"]["instance_name"] = $this->pluginConf["MULTI_MODE"]["group_switch_value"]; } if ($this->pluginConf["MULTI_MODE"]["instance_name"] == "USER_CHOICE") { $mLabel = $this->pluginConf["MULTI_MODE"]["MULTI_MASTER_LABEL"]; $sLabel = $this->pluginConf["MULTI_MODE"]["MULTI_SLAVE_LABEL"]; $separator = $this->pluginConf["MULTI_MODE"]["MULTI_USER_ID_SEPARATOR"]; } else { $cacheMasters = $this->pluginConf["MULTI_MODE"]["CACHE_MASTER_USERS_TO_SLAVE"]; } $newOptions = array("instance_name" => "auth.multi", "MODE" => $this->pluginConf["MULTI_MODE"]["instance_name"], "MASTER_DRIVER" => $masterName, "USER_BASE_DRIVER" => $baseName, "USER_ID_SEPARATOR" => $separator, "CACHE_MASTER_USERS_TO_SLAVE" => $cacheMasters, "TRANSMIT_CLEAR_PASS" => $this->pluginConf["TRANSMIT_CLEAR_PASS"], "DRIVERS" => array($masterName => array("NAME" => $masterName, "LABEL" => $mLabel, "OPTIONS" => $this->pluginConf["MASTER_INSTANCE_CONFIG"]), $slaveName => array("NAME" => $slaveName, "LABEL" => $sLabel, "OPTIONS" => $this->pluginConf["SLAVE_INSTANCE_CONFIG"]))); // MERGE BASIC AUTH OPTIONS FROM MASTER $masterMainAuthOptions = array(); $keys = array("TRANSMIT_CLEAR_PASS", "AUTOCREATE_AJXPUSER", "LOGIN_REDIRECT", "AJXP_ADMIN_LOGIN"); if (is_array($this->pluginConf["MASTER_INSTANCE_CONFIG"])) { foreach ($keys as $key) { if (isset($this->pluginConf["MASTER_INSTANCE_CONFIG"][$key])) { $masterMainAuthOptions[$key] = $this->pluginConf["MASTER_INSTANCE_CONFIG"][$key]; } } } $newOptions = array_merge($newOptions, $masterMainAuthOptions); self::$authStorageImpl = ConfService::instanciatePluginFromGlobalParams($newOptions, "AbstractAuthDriver"); AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("auth", self::$authStorageImpl->getName(), self::$authStorageImpl); } else { self::$authStorageImpl = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver"); AJXP_PluginsService::getInstance()->setPluginUniqueActiveForType("auth", self::$authStorageImpl->getName()); } } return self::$authStorageImpl; }
/** * Transmit to the ajxp_conf load_plugin_manifest action * @param $action * @param $httpVars * @param $fileVars */ public function applyInstallerForm($action, $httpVars, $fileVars) { $data = array(); AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, ""); // Create a custom bootstrap.json file $coreConf = array(); $coreAuth = array(); $this->_loadPluginConfig("core.conf", $coreConf); $this->_loadPluginConfig("core.auth", $coreAuth); if (!isset($coreConf["UNIQUE_INSTANCE_CONFIG"])) { $coreConf["UNIQUE_INSTANCE_CONFIG"] = array(); } if (!isset($coreAuth["MASTER_INSTANCE_CONFIG"])) { $coreAuth["MASTER_INSTANCE_CONFIG"] = array(); } $storageType = $data["STORAGE_TYPE"]["type"]; $coreConfLIVECONFIG = array(); if ($storageType == "db") { // REWRITE BOOTSTRAP.JSON $coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"]; if (isset($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) { $dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]); if (!file_exists(dirname($dbFile))) { mkdir(dirname($dbFile), 0755, true); } } $coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.sql", "group_switch_value" => "conf.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); $coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.sql", "group_switch_value" => "auth.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"))); // INSTALL ALL SQL TABLES $sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "mq.sql"); foreach ($sqlPlugs as $plugId) { $plug = AJXP_PluginsService::findPluginById($plugId); $plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"])); } } else { $coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.serial", "group_switch_value" => "conf.serial")); $coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.serial", "group_switch_value" => "auth.serial")); } $oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json"; if (is_file($oldBoot)) { copy($oldBoot, $oldBoot . ".bak"); unlink($oldBoot); } $newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth); AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true); // Write new bootstrap and reload conf plugin! if ($storageType == "db") { $coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; $coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"]; } $newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver"); $newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver"); if ($storageType == "db") { $sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql"); $data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"]; } // Prepare plugins configs $direct = array("APPLICATION_TITLE" => "core.ajaxplorer/APPLICATION_TITLE", "APPLICATION_LANGUAGE" => "core.ajaxplorer/DEFAULT_LANGUAGE", "ENABLE_NOTIF" => "core.notifications/USER_EVENTS", "APPLICATION_WELCOME" => "gui.ajax/CUSTOM_WELCOME_MESSAGE"); $mailerEnabled = $data["MAILER_ENABLE"]["status"]; if ($mailerEnabled == "yes") { // Enable core.mailer $data["MAILER_SYSTEM"] = $data["MAILER_ENABLE"]["MAILER_SYSTEM"]; $data["MAILER_ADMIN"] = $data["MAILER_ENABLE"]["MAILER_ADMIN"]; $direct = array_merge($direct, array("MAILER_SYSTEM" => "mailer.phpmailer-lite/MAILER", "MAILER_ADMIN" => "core.mailer/FROM")); } foreach ($direct as $key => $value) { list($pluginId, $param) = explode("/", $value); $options = array(); $newConfigPlugin->_loadPluginConfig($pluginId, $options); $options[$param] = $data[$key]; $newConfigPlugin->_savePluginConfig($pluginId, $options); } if (isset($sqlPlugs)) { foreach ($sqlPlugs as $core => $value) { list($pluginId, $param) = explode("/", $core); $options = array(); $newConfigPlugin->_loadPluginConfig($pluginId, $options); $options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")); $newConfigPlugin->_savePluginConfig($pluginId, $options); } } ConfService::setTmpStorageImplementations($newConfigPlugin, $newAuthPlugin); require_once $newConfigPlugin->getUserClassFileName(); $adminLogin = AJXP_Utils::sanitize($data["ADMIN_USER_LOGIN"], AJXP_SANITIZE_EMAILCHARS); $adminName = $data["ADMIN_USER_NAME"]; $adminPass = $data["ADMIN_USER_PASS"]; $adminPass2 = $data["ADMIN_USER_PASS2"]; AuthService::createUser($adminLogin, $adminPass, true); $uObj = $newConfigPlugin->createUserObject($adminLogin); if (isset($data["MAILER_ADMIN"])) { $uObj->personalRole->setParameterValue("core.conf", "email", $data["MAILER_ADMIN"]); } $uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $adminName); AuthService::updateRole($uObj->personalRole); $loginP = "USER_LOGIN"; $i = 0; while (isset($data[$loginP]) && !empty($data[$loginP])) { $pass = $data[str_replace("_LOGIN", "_PASS", $loginP)]; $pass2 = $data[str_replace("_LOGIN", "_PASS2", $loginP)]; $name = $data[str_replace("_LOGIN", "_NAME", $loginP)]; $mail = $data[str_replace("_LOGIN", "_MAIL", $loginP)]; $saniLogin = AJXP_Utils::sanitize($data[$loginP], AJXP_SANITIZE_EMAILCHARS); AuthService::createUser($saniLogin, $pass); $uObj = $newConfigPlugin->createUserObject($saniLogin); $uObj->personalRole->setParameterValue("core.conf", "email", $mail); $uObj->personalRole->setParameterValue("core.conf", "USER_DISPLAY_NAME", $name); AuthService::updateRole($uObj->personalRole); $i++; $loginP = "USER_LOGIN_" . $i; } @unlink(AJXP_PLUGINS_CACHE_FILE); @unlink(AJXP_PLUGINS_REQUIRES_FILE); @unlink(AJXP_PLUGINS_MESSAGES_FILE); AJXP_Utils::setApplicationFirstRunPassed(); session_destroy(); echo 'OK'; }