Code

Fixed stats handling
[gosa.git] / gosa-core / html / index.php
index 2f0eeba2d6f1a33cb49cf6d92fd1e7931fff0cbe..5c9207166009385b446d1fd04f92aed948fdc8af 100644 (file)
@@ -37,12 +37,12 @@ function displayLogin()
     error_reporting(E_ALL | E_STRICT);
 
     /* Check theme compatibility */
-    $theme= $config->get_cfg_value('theme', 'default');
+    $theme= $config->get_cfg_value("core",'theme');
     if (file_exists("$BASE_DIR/ihtml/themes/$theme/blacklist")) {
         $blocks= file("$BASE_DIR/ihtml/themes/$theme/blacklist");
         foreach ($blocks as $block) {
             if (preg_match('/'.preg_quote($block).'/', $_SERVER['HTTP_USER_AGENT'])) {
-                die(sprintf(_("Your browser (%s) is blacklisted for the current theme."), $block));
+                die(sprintf(_("Your browser (%s) is blacklisted for the current theme!"), $block));
             }
         }
     }
@@ -68,14 +68,14 @@ function displayLogin()
     $smarty->assign("message", $message);
 
     /* Displasy SSL mode warning? */
-    if ($ssl != "" && $config->get_cfg_value('warnssl') == 'true') {
-        $smarty->assign("ssl", sprintf(_("This session is not ecrypted. Click %s to enter an encrypted session."), "<a href=\"$ssl\">"._("here")."</a>"));
+    if ($ssl != "" && $config->get_cfg_value("core",'warnSSL') == 'true') {
+        $smarty->assign("ssl", sprintf(_("This session is not encrypted. Click %s to enter an encrypted session."), "<a href=\"$ssl\">".bold(_("here"))."</a>"));
     } else {
         $smarty->assign("ssl", "");
     }
 
     if(!$config->check_session_lifetime()) {
-        $smarty->assign ("lifetime", _("The session lifetime configured in your gosa.conf will be overridden by php.ini settings."));
+        $smarty->assign ("lifetime", _("The configured session lifetime will be overridden by php.ini settings!"));
     } else {
         $smarty->assign ("lifetime", "");
     }
@@ -83,7 +83,7 @@ function displayLogin()
     /* Generate server list */
     $servers= array();
     if (isset($_POST['server'])) {
-        $selected= validate($_POST['server']);
+        $selected= get_post('server');
     } else {
         $selected= $config->data['MAIN']['DEFAULT'];
     }
@@ -104,8 +104,7 @@ function displayLogin()
         $smarty->assign("php_errors", "");
     }
     $smarty->assign("msg_dialogs", msg_dialog::get_dialogs());
-    $smarty->assign("iePngWorkaround", $config->get_cfg_value("iePngWorkaround","false" ) == "true");
-    $smarty->assign("usePrototype", "false");
+
     $smarty->display (get_template_path('headers.tpl'));
     $smarty->assign("version",get_gosa_version());
     $smarty->display(get_template_path('login.tpl'));
@@ -161,23 +160,23 @@ if (!is_readable(CONFIG_DIR."/".CONFIG_FILE)) {
 
 /* Parse configuration file */
 $config= new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
-session::global_set('DEBUGLEVEL',$config->get_cfg_value('DEBUGLEVEL'));
+session::global_set('debugLevel',$config->get_cfg_value("core",'debugLevel'));
 if ($_SERVER["REQUEST_METHOD"] != "POST") {
     @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
 }
 
 /* Enable compressed output */
-if ($config->get_cfg_value("sendCompressedOutput") != "") {
+if ($config->get_cfg_value("core","sendCompressedOutput") != "") {
     ob_start("ob_gzhandler");
 }
 
 /* Set template compile directory */
-$smarty->compile_dir= $config->get_cfg_value("templateCompileDirectory", '/var/spool/gosa');
+$smarty->compile_dir= $config->get_cfg_value("core","templateCompileDirectory");
 $smarty->error_unassigned= true;
 
 /* Check for compile directory */
 if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))) {
-    msg_dialog::display(_("Smarty error"),sprintf(_("Directory '%s' specified as compile directory is not accessible!"),
+    msg_dialog::display(_("Smarty error"),sprintf(_("Compile directory %s is not accessible!"),
         $smarty->compile_dir),FATAL_ERROR_DIALOG);
     exit();
 }
@@ -199,6 +198,9 @@ bindtextdomain($domain, LOCALE_DIR);
 textdomain($domain);
 $smarty->assign ('nextfield', 'username');
 
+/* Translation of cookie-warning. Whether to display it, is determined by JavaScript */
+$smarty->assign ("cookies", _("Your browser has cookies disabled: please enable cookies and reload this page before logging in!"));
+
 if ($_SERVER["REQUEST_METHOD"] != "POST") {
     @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
 }
@@ -219,16 +221,16 @@ if (!isset($_SERVER['HTTPS']) ||
     }
 
 /* If SSL is forced, just forward to the SSL enabled site */
-if ($config->get_cfg_value("forcessl") == 'true' && $ssl != '') {
+if ($config->get_cfg_value("core","forceSSL") == 'true' && $ssl != '') {
     header ("Location: $ssl");
     exit;
 }
 
 /* Do we have htaccess authentification enabled? */
 $htaccess_authenticated= FALSE;
-if ($config->get_cfg_value("htaccessAuthentication") == "true" ) {
+if ($config->get_cfg_value("core","htaccessAuthentication") == "true" ) {
     if (!isset($_SERVER['REMOTE_USER'])) {
-        msg_dialog::display(_("Configuration error"), _("There is a problem with the authentication setup!"), FATAL_ERROR_DIALOG);
+        msg_dialog::display(_("Configuration error"), _("Broken HTTP authentication setup!"), FATAL_ERROR_DIALOG);
         exit;
     }
 
@@ -236,11 +238,11 @@ if ($config->get_cfg_value("htaccessAuthentication") == "true" ) {
     $username= $tmp['username'];
     $server= $tmp['server'];
     if ($username == "") {
-        msg_dialog::display(_("Error"), _("Cannot find a valid user for the current authentication setup!"), FATAL_ERROR_DIALOG);
+        msg_dialog::display(_("Error"), _("Cannot find a valid user for the current HTTP authentication!"), FATAL_ERROR_DIALOG);
         exit;
     }
     if ($server == "") {
-        msg_dialog::display(_("Error"), _("User information is not unique accross the configured LDAP trees!"), FATAL_ERROR_DIALOG);
+        msg_dialog::display(_("Error"), _("Cannot find a unique user for the current HTTP authentication!"), FATAL_ERROR_DIALOG);
         exit;
     }
 
@@ -259,7 +261,7 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
     }
 
     if (!$htaccess_authenticated) {
-        $server= validate($_POST["server"]);
+        $server= get_post("server");
     }
     $config->set_current($server);
 
@@ -271,39 +273,12 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
         exit();
     }
 
-    /* Check for schema file presence */
-    if ($config->get_cfg_value("schemaCheck") == "true") {
-        $recursive = ($config->get_cfg_value("ldapFollowReferrals") == "true");
-        $tls =       ($config->get_cfg_value("ldapTLS") == "true");
-
-        if(!count($ldap->get_objectclasses())) {
-            msg_dialog::display(_("LDAP error"), _("Cannot detect information about the installed LDAP schema!"), ERROR_DIALOG);
-            displayLogin();
-            exit()  ;
-        }else{
-            $cfg = array();
-            $cfg['admin']     = $config->current['ADMINDN'];
-            $cfg['password']  = $config->current['ADMINPASSWORD'];
-            $cfg['connection']= $config->current['SERVER'];
-            $cfg['tls']       = $tls;
-            $str = check_schema($cfg, $config->get_cfg_value("rfc2307bis") == "true");
-            $checkarr = array();
-            foreach($str as $tr) {
-                if(isset($tr['IS_MUST_HAVE']) && !$tr['STATUS']) {
-                    msg_dialog::display(_("LDAP error"), _("Your LDAP setup contains old schema definitions:")."<br><br><i>".$tr['MSG']."</i>", ERROR_DIALOG);
-                    displayLogin();
-                    exit();
-                }
-            }
-        }
-    }
-
     /* Check for locking area */
-    $ldap->cat($config->get_cfg_value("config"), array("dn"));
+    $ldap->cat($config->get_cfg_value("core","config"), array("dn"));
     $attrs= $ldap->fetch();
     if (!count ($attrs)) {
         $ldap->cd($config->current['BASE']);
-        $ldap->create_missing_trees($config->get_cfg_value("config"));
+        $ldap->create_missing_trees($config->get_cfg_value("core","config"));
     }
 
     /* Check for valid input */
@@ -311,7 +286,7 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
     if (!$htaccess_authenticated) {
         $username= $_POST["username"];
         if (!preg_match("/^[@A-Za-z0-9_.-]+$/", $username)) {
-            $message= _("Please specify a valid username!");
+            $message= _("Please specify a valid user name!");
             $ok= false;
         } elseif (mb_strlen($_POST["password"], 'UTF-8') == 0) {
             $message= _("Please specify your password!");
@@ -326,14 +301,14 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
         if ($htaccess_authenticated) {
             $ui= ldap_login_user_htaccess($username);
             if ($ui === NULL || !$ui) {
-                msg_dialog::display(_("Authentication error"), _("Cannot retrieve user information for htaccess authentication!"), FATAL_ERROR_DIALOG);
+                msg_dialog::display(_("Authentication error"), _("Cannot retrieve user information for HTTP authentication!"), FATAL_ERROR_DIALOG);
                 exit;
             }
         } else {
             $ui= ldap_login_user($username, $_POST["password"]);
         }
         if ($ui === NULL || !$ui) {
-            $message= _("Please check the username/password combination.");
+            $message= _("Please check the username/password combination!");
             $smarty->assign ('nextfield', 'password');
             session::global_set('config',$config);
             new log("security","login","",array(),"Authentication failed for user \"$username\"");
@@ -352,7 +327,7 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
             session::global_set('config',$config);
 
             /* Restore filter settings from cookie, if available */
-            if($config->get_cfg_value("storeFilterSettings") == "true") {
+            if($config->get_cfg_value("core","storeFilterSettings") == "true") {
 
                 if(isset($_COOKIE['GOsa_Filter_Settings']) || isset($HTTP_COOKIE_VARS['GOsa_Filter_Settings'])) {
 
@@ -377,29 +352,24 @@ if (($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['login'])) || $htacces
             }
 
             /* are we using accountexpiration */
-            if ($config->get_cfg_value("handleExpiredAccounts") == "true") {
+            if ($config->boolValueIsTrue("core","handleExpiredAccounts")) {
                 $expired= ldap_expired_account($config, $ui->dn, $ui->username);
 
-                if ($expired == 1) {
+                if ($expired == POSIX_ACCOUNT_EXPIRED) {
                     $message= _("Account locked. Please contact your system administrator!");
                     $smarty->assign ('nextfield', 'password');
                     new log("security","login","",array(),"Account for user \"$username\" has expired") ;
-                } elseif ($expired == 3) {
-                    $plist= new pluglist($config, $ui);
-                    foreach ($plist->dirlist as $key => $value) {
-                        if (preg_match("/\bpassword\b/i",$value)) {
-                            $plug=$key;
-                            new log("security","login","",array(),"User \"$username\" password forced to change") ;
-                            header ("Location: main.php?plug=$plug&amp;reset=1");
-                            exit;
-                        }
-                    }
+                    displayLogin();
+                    exit();
                 }
             }
 
             /* Not account expired or password forced change go to main page */
             new log("security","login","",array(),"User \"$username\" logged in successfully") ;
             $plist= new pluglist($config, $ui);
+
+            stats::log('global', 'global', array(),  $action = 'login', $amount = 1, 0);
+
             if(isset($plug) && isset($plist->dirlist[$plug])) {
                 header ("Location: main.php?plug=".$plug."&amp;global_check=1");
             }else{
@@ -424,13 +394,10 @@ if (!isset($message)) {
 
 $smarty->assign ("message", $message);
 
-/* Translation of cookie-warning. Whether to display it, is determined by JavaScript */
-$smarty->assign ("cookies", _("Your browser has cookies disabled. Please enable cookies and reload this page before logging in!"));
-
 /* Generate server list */
 $servers= array();
-if (isset($_POST['server'])) {
-    $selected= validate($_POST['server']);
+if (isset($_POST['server'])){
+    $selected= get_post('server');
 } else {
     $selected= $config->data['MAIN']['DEFAULT'];
 }