Example #1
0
    if (isset($_POST['update_settings'])) {
        //get current settings
        $settings = LoadAvg::$_settings->general;
        //need to check all modules status first
        //as form drops unchecked values when posted for some reason
        $modules = LoadPlugins::$_plugins;
        foreach ($plugins as $plugin => $pluginName) {
            $_POST['formsettings']['plugins'][$plugin] = !isset($_POST['formsettings']['plugins'][$plugin]) ? "false" : "true";
        }
        //grab changes / posts
        $postsettings = $_POST['formsettings'];
        //merge in with current settings
        $mergedsettings = array_replace($settings, $postsettings);
        //write out new inin file
        $settings_file = HOME_PATH . '/app/config/' . LoadAvg::$settings_ini;
        LoadUtility::write_php_ini($mergedsettings, $settings_file);
        /* 
         * need to reload settings here after posting
         * as for some reason after a post the data isnt updated internally
         */
        $loadPlugins->updateModuleSettings();
        /* force reload settings page now */
        header('Location: ' . $_SERVER['REQUEST_URI']);
    }
    ?>


<form action="" method="post" autocomplete="off">
	<input type="hidden" name="update_settings" value="1" />

Example #2
0
 public function upgradeSettings21to22($reload = true)
 {
     //echo 'update';
     //die;
     $settings_file = HOME_PATH . '/app/config/' . LoadAvg::$settings_ini;
     //get current settings
     $settings = LoadAvg::$_settings->general;
     //add new stuff here
     $settings['settings']['version'] = '2.2';
     //update core settings with new features
     if (!isset($settings['settings']['clienttimezone'])) {
         $settings['settings']['clienttimezone'] = "America/New_York";
     }
     if (!isset($settings['settings']['timezone'])) {
         $settings['settings']['timezone'] = "America/New_York";
     }
     if (!isset($settings['settings']['timezonemode'])) {
         $settings['settings']['timezonemode'] = "Browser";
     }
     if (!isset($settings['settings']['logalerts'])) {
         $settings['settings']['logalerts'] = "true";
     }
     //update core modules with new modules
     if (!isset($settings['modules']['Miner'])) {
         $settings['modules']['Miner'] = "false";
     }
     //update core plugins with new plugins
     if (!isset($settings['plugins']['Alerts'])) {
         $settings['plugins']['Alerts'] = "true";
     }
     if (!isset($settings['plugins']['Process'])) {
         $settings['plugins']['Process'] = "true";
     }
     if (!isset($settings['plugins']['Server'])) {
         $settings['plugins']['Server'] = "true";
     }
     //echo '<pre>'; var_dump ($settings); echo '</pre>';
     LoadUtility::write_php_ini($settings, $settings_file);
     //clear update cookies
     $this->checkForUpdate();
     //relaod the app now
     if ($reload) {
         header("Location: index.php");
     }
     //die;
 }
Example #3
0
        echo '</pre>';
        
        echo '<pre>Posted settings';
        print_r($postsettings);
        echo '</pre>';
        */
        $replaced_settings = LoadUtility::ini_merge($settings, $postsettings);
        //$replaced_settings = array_replace($settings, $postsettings);
        /*
        echo '<pre>';
        print_r($replaced_settings);
        echo '</pre>';
        
        die;
        */
        LoadUtility::write_php_ini($replaced_settings, $settings_file);
        ///////////////////////////////////////////////////
        //updates all the modules settings here
        //exit;
        /* 
         * need to reload settings here after posting
         * as for some reason after a post the data isnt updated internally
         */
        $settings = LoadAvg::$_settings->general;
        /* force reload settings page now */
        header('Location: ' . $_SERVER['REQUEST_URI']);
    }
    ?>

<!--
		//if things get crazy for any reason then we need to just delete all cookies 
Example #4
0
 ///////////////////////////////////////////////////
 //updates all the modules settings here
 //these are dirty dirty hacks! until we can rewrite the settings using proper api
 $_POST['Mysql_settings']['settings']['show_queries'] = !isset($_POST['Mysql_settings']['settings']['show_queries']) ? "false" : "true";
 //echo '<pre>';var_dump($_POST);echo'</pre>';
 $modules = LoadModules::$_modules;
 foreach ($modules as $module => $moduleStatus) {
     //echo $moduleName;
     if (isset($_POST[$module . '_settings'])) {
         $module_config_file = HOME_PATH . '/lib/modules/' . $module . '/' . strtolower($module) . '.ini.php';
         $module_config_ini = parse_ini_file($module_config_file, true);
         //the array replace is deleting out missing data on posts
         //when the data has not been modified
         //$replaced_settings = array_replace($module_config_ini, $_POST[$module . '_settings']);
         $replaced_settings = LoadUtility::ini_merge($module_config_ini, $_POST[$module . '_settings']);
         LoadUtility::write_php_ini($replaced_settings, $module_config_file);
         //why is this here ?
         //$fh = fopen($module_config_file, "a"); fwrite($fh, "\n"); fclose($fh);
     }
 }
 //exit;
 /* 
  * need to reload settings here after posting
  * as for some reason after a post the data isnt updated internally
  */
 //still old here mate
 //$settings = LoadAvg::$_settings->general;
 $loadModules->updateModuleSettings();
 //LoadModules::updateModuleSettings();
 //not changed either as written to file above
 $loadedModules = LoadModules::$_settings->general['modules'];