Marius Cramer
2013-10-14 d9bcf68e395d6156645a7974b1a992aa6e6c00aa
interface/web/login/index.php
@@ -65,7 +65,7 @@
         $maintenance_mode_error = $app->lng('error_maintenance_mode');
      }
      //* Login Form was send
      //* Login Form was sent
      if(count($_POST) > 0) {
         //** Check variables
@@ -78,7 +78,6 @@
           $passwort = $app->db->quote($_POST['passwort']);
         $loginAs  = false;
         $time = time();
         $logging = 'Failed login for user '. $username .' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
           if($username != '' && $passwort != '' && $error == '') {
            /*
@@ -142,6 +141,7 @@
                           $user['username'] = $username;
                           $user['language'] = $conf['language'];
                           $user['theme'] = $conf['theme'];
                           $user['app_theme'] = $conf['theme'];
                           $user['mailuser_id'] = $mailuser['mailuser_id'];
                           $user['default_group'] = $mailuser['sys_groupid'];
                        }
@@ -195,10 +195,39 @@
                        if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
                           include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
                                    $menu_dir = ISPC_WEB_PATH.'/' . $_SESSION['s']['user']['startmodule'] . '/lib/menu.d';
                                    if (is_dir($menu_dir)) {
                                        if ($dh = opendir($menu_dir)) {
                                            //** Go through all files in the menu dir
                                            while (($file = readdir($dh)) !== false) {
                                                if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') {
                                                    include_once($menu_dir . '/' . $file);
                                                }
                                            }
                                        }
                                    }
                           $_SESSION['s']['module'] = $module;
                        }
                                // check if the user theme is valid
                                if($_SESSION['s']['user']['theme'] != 'default') {
                                    $tmp_path = ISPC_THEMES_PATH."/".$_SESSION['s']['user']['theme'];
                                    if(!@is_dir($tmp_path) || !@file_exists($tmp_path."/ispconfig_version") || trim(file_get_contents($tmp_path."/ispconfig_version")) != ISPC_APP_VERSION) {
                                        // fall back to default theme if this one is not compatible with current ispc version
                                        $_SESSION['s']['user']['theme'] = 'default';
                                        $_SESSION['s']['theme'] = 'default';
                                        $_SESSION['show_error_msg'] = $app->lng('theme_not_compatible');
                                    }
                                }
                        $app->plugin->raiseEvent('login',$this);
                        //* Save successfull login message to var
                        $authlog = 'Successful login for user \''. $username .'\' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
                        $authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
                        fwrite($authlog_handle, $authlog ."\n");
                        fclose($authlog_handle);
                        /*
                        * We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
@@ -211,6 +240,7 @@
                      } else {
                         $error = $app->lng('error_user_blocked');
                      }
                 } else {
                    if(!$alreadyfailed['times'] )
                    {
@@ -228,10 +258,14 @@
                  $app->plugin->raiseEvent('login_failed',$this);
                  //* write to log (e.g. for fail2ban)
                  exec('echo '. $logging .' >> /tmp/login.log');
                  //* Save failed login message to var
                  $authlog = 'Failed login for user \''. $username .'\' from '. long2ip($ip) .' at '. date('Y-m-d H:i:s');
                  $authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
                  fwrite($authlog_handle, $authlog ."\n");
                  fclose($authlog_handle);
                    }
              }
            } else {
                //* Username or password empty
               if($error == '') $error = $app->lng('error_user_password_empty');