@@ -104,68 +104,67 @@ function process_login_request(app $app, &$error, $conf, $module)
104104 }
105105
106106 // Maintenance mode - allow logins only when maintenance mode is off or if the user is admin
107- if (!$ app ->is_under_maintenance () || $ user ['typ ' ] == 'admin ' ) {
108-
109- // User login right, so attempts can be deleted
110- $ sql = "DELETE FROM `attempts_login` WHERE `ip`=? " ;
111- $ app ->db ->query ($ sql , $ ip );
112- $ user = $ app ->db ->toLower ($ user );
113-
114- if ($ loginAs ) $ oldSession = $ _SESSION ['s ' ];
115-
116- // Session regenerate causes login problems on some systems, see Issue #3827
117- // Set session_regenerate_id to no in security settings, it you encounter
118- // this problem.
119- $ app ->uses ('getconf ' );
120- $ security_config = $ app ->getconf ->get_security_config ('permissions ' );
121- if (isset ($ security_config ['session_regenerate_id ' ]) && $ security_config ['session_regenerate_id ' ] == 'yes ' ) {
122- if (!$ loginAs ) session_regenerate_id (true );
123- }
124- $ _SESSION = array ();
125- if ($ loginAs ) $ _SESSION ['s_old ' ] = $ oldSession ; // keep the way back!
126- $ _SESSION ['s ' ]['user ' ] = $ user ;
127- $ _SESSION ['s ' ]['user ' ]['theme ' ] = isset ($ user ['app_theme ' ]) ? $ user ['app_theme ' ] : 'default ' ;
128- $ _SESSION ['s ' ]['language ' ] = $ app ->functions ->check_language ($ user ['language ' ]);
129- $ _SESSION ["s " ]['theme ' ] = $ _SESSION ['s ' ]['user ' ]['theme ' ];
130- if ($ loginAs ) $ _SESSION ['s ' ]['plugin_cache ' ] = $ _SESSION ['s_old ' ]['plugin_cache ' ];
131-
132- if (is_file (ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/module.conf.php ' )) {
133- include_once $ app ->functions ->check_include_path (ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/module.conf.php ' );
134- $ menu_dir = ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/menu.d ' ;
135- include_menu_dir_files ($ menu_dir );
136- $ _SESSION ['s ' ]['module ' ] = $ module ;
137- }
138- // check if the user theme is valid
139- if ($ _SESSION ['s ' ]['user ' ]['theme ' ] != 'default ' ) {
140- $ tmp_path = ISPC_THEMES_PATH ."/ " .$ _SESSION ['s ' ]['user ' ]['theme ' ];
141- if (!@is_dir ($ tmp_path ) || !@file_exists ($ tmp_path ."/ispconfig_version " ) || trim (file_get_contents ($ tmp_path ."/ispconfig_version " )) != ISPC_APP_VERSION ) {
142- // fall back to default theme if this one is not compatible with current ispc version
143- $ _SESSION ['s ' ]['user ' ]['theme ' ] = 'default ' ;
144- $ _SESSION ['s ' ]['theme ' ] = 'default ' ;
145- $ _SESSION ['show_error_msg ' ] = $ app ->lng ('theme_not_compatible ' );
146- }
107+ if ($ app ->is_under_maintenance () && $ user ['typ ' ] != 'admin ' ) return ;
108+
109+ // User login right, so attempts can be deleted
110+ $ sql = "DELETE FROM `attempts_login` WHERE `ip`=? " ;
111+ $ app ->db ->query ($ sql , $ ip );
112+ $ user = $ app ->db ->toLower ($ user );
113+
114+ if ($ loginAs ) $ oldSession = $ _SESSION ['s ' ];
115+
116+ // Session regenerate causes login problems on some systems, see Issue #3827
117+ // Set session_regenerate_id to no in security settings, it you encounter
118+ // this problem.
119+ $ app ->uses ('getconf ' );
120+ $ security_config = $ app ->getconf ->get_security_config ('permissions ' );
121+ if (isset ($ security_config ['session_regenerate_id ' ]) && $ security_config ['session_regenerate_id ' ] == 'yes ' ) {
122+ if (!$ loginAs ) session_regenerate_id (true );
123+ }
124+ $ _SESSION = array ();
125+ if ($ loginAs ) $ _SESSION ['s_old ' ] = $ oldSession ; // keep the way back!
126+ $ _SESSION ['s ' ]['user ' ] = $ user ;
127+ $ _SESSION ['s ' ]['user ' ]['theme ' ] = isset ($ user ['app_theme ' ]) ? $ user ['app_theme ' ] : 'default ' ;
128+ $ _SESSION ['s ' ]['language ' ] = $ app ->functions ->check_language ($ user ['language ' ]);
129+ $ _SESSION ["s " ]['theme ' ] = $ _SESSION ['s ' ]['user ' ]['theme ' ];
130+ if ($ loginAs ) $ _SESSION ['s ' ]['plugin_cache ' ] = $ _SESSION ['s_old ' ]['plugin_cache ' ];
131+
132+ if (is_file (ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/module.conf.php ' )) {
133+ include_once $ app ->functions ->check_include_path (ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/module.conf.php ' );
134+ $ menu_dir = ISPC_WEB_PATH .'/ ' .$ _SESSION ['s ' ]['user ' ]['startmodule ' ].'/lib/menu.d ' ;
135+ include_menu_dir_files ($ menu_dir );
136+ $ _SESSION ['s ' ]['module ' ] = $ module ;
137+ }
138+ // check if the user theme is valid
139+ if ($ _SESSION ['s ' ]['user ' ]['theme ' ] != 'default ' ) {
140+ $ tmp_path = ISPC_THEMES_PATH ."/ " .$ _SESSION ['s ' ]['user ' ]['theme ' ];
141+ if (!@is_dir ($ tmp_path ) || !@file_exists ($ tmp_path ."/ispconfig_version " ) || trim (file_get_contents ($ tmp_path ."/ispconfig_version " )) != ISPC_APP_VERSION ) {
142+ // fall back to default theme if this one is not compatible with current ispc version
143+ $ _SESSION ['s ' ]['user ' ]['theme ' ] = 'default ' ;
144+ $ _SESSION ['s ' ]['theme ' ] = 'default ' ;
145+ $ _SESSION ['show_error_msg ' ] = $ app ->lng ('theme_not_compatible ' );
147146 }
147+ }
148148
149- $ app ->plugin ->raiseEvent ('login ' , $ username );
149+ $ app ->plugin ->raiseEvent ('login ' , $ username );
150150
151- //* Save successful login message to var
152- $ authlog = 'Successful login for user \'' .$ username .'\' from ' .$ _SERVER ['REMOTE_ADDR ' ].' at ' .date ('Y-m-d H:i:s ' ).' with session ID ' .session_id ();
153- $ authlog_handle = fopen ($ conf ['ispconfig_log_dir ' ].'/auth.log ' , 'a ' );
154- fwrite ($ authlog_handle , $ authlog ."\n" );
155- fclose ($ authlog_handle );
151+ //* Save successful login message to var
152+ $ authlog = 'Successful login for user \'' .$ username .'\' from ' .$ _SERVER ['REMOTE_ADDR ' ].' at ' .date ('Y-m-d H:i:s ' ).' with session ID ' .session_id ();
153+ $ authlog_handle = fopen ($ conf ['ispconfig_log_dir ' ].'/auth.log ' , 'a ' );
154+ fwrite ($ authlog_handle , $ authlog ."\n" );
155+ fclose ($ authlog_handle );
156156
157- /*
158- * We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
159- * new theme, if the logged-in user has another
160- */
157+ /*
158+ * We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
159+ * new theme, if the logged-in user has another
160+ */
161161
162- if ($ loginAs ) {
163- echo 'LOGIN_REDIRECT: ' .$ _SESSION ['s ' ]['module ' ]['startpage ' ];
164- exit ;
165- } else {
166- header ('Location: ../index.php ' );
167- die ();
168- }
162+ if ($ loginAs ) {
163+ echo 'LOGIN_REDIRECT: ' .$ _SESSION ['s ' ]['module ' ]['startpage ' ];
164+ exit ;
165+ } else {
166+ header ('Location: ../index.php ' );
167+ die ();
169168 }
170169 } else {
171170 if (!$ alreadyfailed ['times ' ]) {
0 commit comments