Example #1
0
function init($host_, $database_, $prefix_, $user_, $password_)
{
    $p = new Preferences_admin();
    $sql_conf = array();
    $sql_conf['host'] = $host_;
    $sql_conf['database'] = $database_;
    $sql_conf['user'] = $user_;
    $sql_conf['password'] = $password_;
    $sql_conf['prefix'] = $prefix_;
    $p->set('general', 'sql', $sql_conf);
    $ret = $p->isValid();
    if ($ret !== true) {
        echo 'error isValid : ' . $ret . "\n";
        return false;
    }
    $p->backup();
    return true;
}
Example #2
0
     $setup = true;
     unset($_POST['setup']);
     $elements_form = formToArray($_POST);
     try {
         $prefs = new Preferences_admin();
         $prefs->deleteConfFile();
         $prefs = new Preferences_admin();
     } catch (Exception $e) {
     }
     $prefs->initialize();
     $prefs->set('general', 'sql', $elements_form['general']['sql']);
 } else {
     $elements_form = formToArray($_POST);
     $prefs = new Preferences_admin($elements_form);
 }
 $ret = $prefs->isValid();
 if ($ret === true) {
     $ret = $prefs->backup();
     if ($ret > 0) {
         $buf = $prefs->get('general', 'admin_language');
         $language = locale2unix($buf);
         setlocale(LC_ALL, $language . '.UTF-8');
         // configuration saved
         popup_info(_('Configuration successfully saved'));
         redirect('index.php');
     } else {
         header_static(_('Configuration'));
         echo 'problem : configuration not saved<br>';
         // TODO (class msg...) + gettext
         footer_static();
     }
Example #3
0
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
require_once dirname(__FILE__) . '/../includes/core-minimal.inc.php';
if (!defined('STDIN')) {
    echo "This script cannot be used in CGI mode.\n";
    exit(1);
}
// Check if session manager is in maintenance
try {
    $prefs = new Preferences_admin();
} catch (Exception $e) {
    echo "Internal error while loading settings, unable to continue.\n";
    exit(2);
}
if ($prefs->isValid() !== true) {
    // First install
    exit(0);
}
$system_in_maintenance = $prefs->get('general', 'system_in_maintenance');
if ($system_in_maintenance != '1') {
    echo "The Session Manager is in production mode. It's not possible to perform an upgrade until it's on maintenance mode.\n";
    exit(3);
}
// Check if there still have sessions
$nb_sessions = Abstract_Session::countByStatus();
if ($nb_sessions != 0) {
    echo "There are running sessions on the OVD farm. It's not possible to perform an upgrade until there are running sessions\n";
    exit(4);
}
exit(0);
Example #4
0
 public function settings_set($settings_)
 {
     $this->check_authorized('manageConfiguration');
     // saving preferences
     $prefs = new Preferences_admin();
     $diff = array();
     $keys = $prefs->getKeys();
     foreach ($keys as $key_name) {
         if (!array_key_exists($key_name, $settings_)) {
             continue;
         }
         $diff_sub = $this->import_elements_content_from_dict($prefs->elements[$key_name], $settings_[$key_name]);
         foreach ($diff_sub as $k => $v) {
             $diff[$key_name . '.' . $k] = $v;
         }
     }
     $ret = $prefs->isValid();
     if ($ret !== true) {
         return false;
     }
     $ret = $prefs->backup();
     if ($ret <= 0) {
         return false;
     }
     $ret = $this->hooks_system_integration_changes($prefs, $diff);
     // configuration saved
     if (count($diff) > 0) {
         $this->log_action('settings_set', $diff);
     }
     return true;
 }