* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version SVN: $Id: 04_configure.php 27106 2015-02-10 13:18:27Z kgrisel $ * @link http://www.mediboard.org */ require_once "includes/checkauth.php"; require_once $mbpath . "includes/compat.php"; require_once $mbpath . "classes/CMbConfig.class.php"; require_once $mbpath . "classes/CMbArray.class.php"; if (isset($_POST["username"])) { unset($_POST["username"]); } if (isset($_POST["password"])) { unset($_POST["password"]); } $mutex_drivers = array("CMbRedisMutex" => array("title" => "Redis", "params" => "Serveurs Redis, séparés par des virgules"), "CMbAPCMutex" => array("title" => "APC", "params" => null), "CMbFileMutex" => array("title" => "Fichier", "params" => null)); $mbConfig = new CMbConfig(); $mbConfig->update($_POST); $mbConfig->load(); $dPconfig = $mbConfig->values; showHeader(); ?> <script> toggleMemoryParams = function(value) { each($$('.shared-memory-params'), hideElement); each($$('.params-'+value), showElement); }; toggleSessionMutex = function(value) { each($$('.session-mutex'), hideElement); each($$('.session-mutex-'+value), showElement);
static function loadValuesFromDB() { global $dPconfig; $ds = CSQLDataSource::get("std"); $request = "SELECT * FROM config_db WHERE config_db.key " . CSQLDataSource::prepareNotIn(self::$forbidden_values); $configs = $ds->loadList($request); foreach ($configs as $_value) { CMbConfig::loadConf(explode(" ", $_value['key']), $_value['value'], $dPconfig); } // Réinclusion du config_overload if (is_file(__DIR__ . "/config_overload.php")) { include __DIR__ . "/config_overload.php"; } }
/** * Change a configuration value * * @param string $path Configuration path * @param null $value New value * * @return mixed|null Old value */ static function setConf($path = "", $value = null) { if (!CAppUI::$user->isAdmin()) { return null; } $config = new CMbConfig(); $old_value = $config->get($path); $config->set($path, $value); $config->update($config->values, true); return $old_value; }
CAppUI::redirect("m={$m}&tab={$tab}"); } global $can; $user = CUser::get(); // only user_type of Administrator (1) can access this page $can->edit |= $user->user_type != 1; $can->needsEdit(); $module_name = CValue::post("module"); $strings = CValue::post("s"); $language = CValue::post("language"); if (!$module_name || !$strings || !is_array($strings)) { CAppUI::setMsg("Certaines informations sont manquantes au traitement de la traduction.", UI_MSG_ERROR); redirect(); return; } $translateModule = new CMbConfig(); $translateModule->sourcePath = null; // Ecriture du fichier $translateModule->options = array("name" => "locales"); if ($module_name != "common") { $translateModule->targetPath = "modules/{$module_name}/locales/{$language}.php"; } else { $translateModule->targetPath = "locales/{$language}/common.php"; } $translateModule->sourcePath = $translateModule->targetPath; if (!is_file($translateModule->targetPath)) { CMbPath::forceDir(dirname($translateModule->targetPath)); file_put_contents($translateModule->targetPath, '<?php $locales["module-' . $module_name . '-court"] = "' . $module_name . '";'); } $translateModule->load(); foreach ($strings as $key => $valChaine) {
$localesDirs = array(); if ($module != "common") { $files = glob("modules/{$module}/locales/*"); foreach ($files as $file) { $name = basename($file, ".php"); $localesDirs[$name] = $file; } } else { $files = glob("locales/*/common.php"); foreach ($files as $file) { $name = basename(dirname($file)); $localesDirs[$name] = $file; } } // Récupération du fichier demandé pour toutes les langues $translateModule = new CMbConfig(); $translateModule->sourcePath = null; $contenu_file = array(); foreach ($localesDirs as $locale => $path) { $translateModule->options = array("name" => "locales"); //$translateModule->sourcePath = $path; $translateModule->targetPath = $path; $translateModule->load(); $contenu_file[$locale] = $translateModule->values; } // Réattribution des clés et organisation global $trans; $trans = array(); foreach ($localesDirs as $locale => $path) { foreach ($contenu_file[$locale] as $k => $v) { $trans[is_int($k) ? $v : $k][$locale] = $v;
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkAdmin(); global $dPconfig; $configs = $dPconfig; foreach ($configs as $_key => $_config) { if (in_array($_key, CMbConfig::$forbidden_values) || in_array($_key, array("db", "php"))) { unset($configs[$_key]); } } $inserts = array(); $ds = CSQLDataSource::get("std"); $list = array(); CMbConfig::buildConf($list, $configs, null); $count_configs = count($list); $count = 0; foreach ($list as $key => $value) { $query = "INSERT INTO `config_db`\n VALUES (%1, %2)\n ON DUPLICATE KEY UPDATE value = %3"; $query = $ds->prepare($query, $key, $value, $value); if ($ds->exec($query) === false) { CAppUI::stepAjax("Configure-failed-modify", UI_MSG_ERROR); } else { $count++; } } if ($count_configs == $count) { CAppUI::stepAjax("Toutes les configurations ont été transférées"); } else { CAppUI::stepAjax("{$count} / {$count_configs} configurations transférées", UI_MSG_WARNING);
// If baseBackup is running if (!empty($dPconfig["base_backup_lockfile_path"])) { $backup_lockfile = realpath($dPconfig["base_backup_lockfile_path"]); if (file_exists($backup_lockfile)) { // File exists, we have to check lifetime $lock_mtime = filemtime($backup_lockfile); // Lock file is not dead if (microtime(true) - $lock_mtime <= 1800) { CApp::goOffline("db-backup"); } unlink($backup_lockfile); } } // Include config in DB if (CAppUI::conf("config_db")) { CMbConfig::loadValuesFromDB(); } // Shutdown function register_shutdown_function(array("CApp", "checkPeace")); if (!@CSQLDataSource::get("std")) { CApp::goOffline("db-access"); } CMbPerformance::mark("init"); require __DIR__ . "/includes/session.php"; CMbPerformance::mark("session"); // Start chrono (after session_start as it may be locked by another request) CApp::$chrono = new Chronometer(); CApp::$chrono->main = true; CApp::$chrono->start(); $do_login = false; // Load default preferences if not logged in