Code

Updated filter
[gosa.git] / gosa-core / html / password.php
index 1aecdc429627157be30554415fc6ecb8b1a40631..459512228ef18b6574e2257483c79b57d07ca091 100644 (file)
@@ -48,34 +48,30 @@ if(is_array(session::get_all()) && count(session::get_all())){
 }
 
 /* Reset errors */
-session::set('js',true);
+session::global_set('js',true);
 session::set('errors',"");
 session::set('errorsAlreadyPosted',array());
 session::set('LastError',"");
 
 /* Check if CONFIG_FILE is accessible */
 if (!is_readable(CONFIG_DIR."/".CONFIG_FILE)){
-  msg_dialog::display("", sprintf(_("GOsa configuration %s/%s is not readable. Aborted."),CONFIG_DIR,CONFIG_FILE), FATAL_ERROR_DIALOG);
+  msg_dialog::display(_("Fatal error"), sprintf(_("GOsa configuration %s/%s is not readable. Aborted."),CONFIG_DIR,CONFIG_FILE), FATAL_ERROR_DIALOG);
   exit;
 }
 
 /* Parse configuration file */
 $config= new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
-session::set('DEBUGLEVEL',$config->data['MAIN']['DEBUGLEVEL']);
+session::global_set('DEBUGLEVEL', $config->get_cfg_value("debuglevel"));
 if ($_SERVER["REQUEST_METHOD"] != "POST"){
   @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
 }
 
 /* Set template compile directory */
-if (isset ($config->data['MAIN']['COMPILE'])){
-  $smarty->compile_dir= $config->data['MAIN']['COMPILE'];
-} else {
-  $smarty->compile_dir= '/var/spool/gosa';
-}
+$smarty->compile_dir= $config->get_cfg_value("templateCompileDirectory", '/var/spool/gosa');
 
 /* Check for compile directory */
 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
-  msg_dialog::display(_("Accessibility"), sprintf(_("Directory '%s' specified as compile directory is not accessible!"),
+  msg_dialog::display(_("Configuration error"), sprintf(_("Directory '%s' specified as compile directory is not accessible!"),
         $smarty->compile_dir), FATAL_ERROR_DIALOG);
   exit;
 }
@@ -84,10 +80,10 @@ if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
 clean_smarty_compile_dir($smarty->compile_dir);
 
 /* Language setup */
-if ($config->data['MAIN']['LANG'] == ""){
+if ($config->get_cfg_value("language") == ""){
   $lang= get_browser_language();
 } else {
-  $lang= $config->data['MAIN']['LANG'];
+  $lang= $config->get_cfg_value("language");
 }
 $lang.=".UTF-8";
 putenv("LANGUAGE=");
@@ -126,7 +122,7 @@ if (isset($_GET['directory']) && isset($servers[$_GET['directory']])){
 
 /* Set config to selected one */
 $config->set_current($directory);
-session::set('config',$config);
+session::global_set('config',$config);
 
 if ($_SERVER["REQUEST_METHOD"] != "POST"){
   @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
@@ -148,13 +144,13 @@ if (!isset($_SERVER['HTTPS']) ||
 }
 
 /* If SSL is forced, just forward to the SSL enabled site */
-if ($config->data['MAIN']['FORCESSL'] == 'true' && $ssl != ''){
+if ($config->get_cfg_value("forcessl") == 'true' && $ssl != ''){
   header ("Location: $ssl");
   exit;
 }
 
 /* Check for selected password method */
-$method= $config->current['HASH'];
+$method= $config->get_cfg_value("hash", "crypt/md5");
 if (isset($_GET['method'])){
        $method= validate($_GET['method']);
        $tmp = new passwordMethod($config);
@@ -184,8 +180,8 @@ $smarty->assign("changed", false);
 if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){
 
   /* Destroy old sessions, they cause a successfull login to relog again ...*/
-  if(session::is_set('_LAST_PAGE_REQUEST')){
-    session::set('_LAST_PAGE_REQUEST',time());
+  if(session::global_is_set('_LAST_PAGE_REQUEST')){
+    session::global_set('_LAST_PAGE_REQUEST',time());
   }
 
   $message= array();
@@ -202,14 +198,14 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){
   }
 
   /* Password policy fulfilled? */
-  if (isset($config->data['MAIN']['PWDIFFER'])){
-         $l= $config->data['MAIN']['PWDIFFER'];
+  if ($config->get_cfg_value("passwordMinDiffer") != ""){
+         $l= $config->get_cfg_value("passwordMinDiffer");
          if (substr($_POST['current_password'], 0, $l) == substr($_POST['new_password'], 0, $l)){
                  $message[]= _("The password used as new and current are too similar.");
          }
   }
-  if (isset($config->data['MAIN']['PWMINLEN'])){
-         if (strlen($_POST['new_password']) < $config->data['MAIN']['PWMINLEN']){
+  if ($config->get_cfg_value("passwordMinLength") != ""){
+         if (strlen($_POST['new_password']) < $config->get_cfg_value("passwordMinLength")){
                  $message[]= _("The password used as new is to short.");
          }
   }
@@ -242,8 +238,8 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){
 
          /* Passed quality check, just try to change the password now */
          $output= "";
-         if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
-                 exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".
+         if ($config->get_cfg_value("passwordHook") != ""){
+                 exec($config->get_cfg_value("passwordHook")." ".$ui->username." ".
                                  $_POST['current_password']." ".$_POST['new_password'], $resarr);
                  if(count($resarr) > 0) {
                          $output= join('\n', $resarr);
@@ -280,14 +276,14 @@ $smarty->assign ('uid', $uid);
 $smarty->assign ('password_img', get_template_path('images/password.png'));
 
 /* Displasy SSL mode warning? */
-if ($ssl != "" && $config->data['MAIN']['WARNSSL'] == 'true'){
+if ($ssl != "" && $config->get_cfg_value("warnssl") == 'true'){
   $smarty->assign ("ssl", "<b>"._("Warning").":</b> "._("Session will not be encrypted.")." <a style=\"color:red;\" href=\"".htmlentities($ssl)."\"><b>"._("Enter SSL session")."</b></a>!");
 } else {
   $smarty->assign ("ssl", "");
 }
 
 /* show login screen */
-$smarty->assign("JS",session::get('js'));
+$smarty->assign("JS",session::global_get('js'));
 $smarty->assign ("PHPSESSID", session_id());
 if (session::is_set('errors')){
   $smarty->assign("errors", session::get('errors'));;
@@ -298,6 +294,7 @@ if ($error_collector != ""){
   $smarty->assign("php_errors", "");
 }
 
+$smarty->assign("msg_dialogs", msg_dialog::get_dialogs());
 displayPWchanger();
 
 ?>