From e1ceb050e19c7574bca146a8da7047ee4ff456b5 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Sun, 10 Jul 2016 05:02:35 -0400
Subject: [PATCH] Merge branch 'stable-3.1'

---
 interface/web/login/index.php |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/interface/web/login/index.php b/interface/web/login/index.php
index 5339f04..2ecf4ac 100644
--- a/interface/web/login/index.php
+++ b/interface/web/login/index.php
@@ -60,7 +60,7 @@
 
 	//** Check variables
 	if(!preg_match("/^[\w\.\-\_\@]{1,128}$/", $_POST['username'])) $error = $app->lng('user_regex_error');
-	if(!preg_match("/^.{1,64}$/i", $_POST['password'])) $error = $app->lng('pw_error_length');
+	if(!preg_match("/^.{1,256}$/i", $_POST['password'])) $error = $app->lng('pw_error_length');
 
 	//** importing variables
 	$ip    = ip2long($_SERVER['REMOTE_ADDR']);
@@ -209,16 +209,18 @@
 						$user = $app->db->toLower($user);
 						
 						if ($loginAs) $oldSession = $_SESSION['s'];
-						if (!$loginAs) session_regenerate_id(true);
+						// Session regenerate causes login problems on some systems, have to find a better way. see Issue #3827
+						//if (!$loginAs) session_regenerate_id(true);
 						$_SESSION = array();
 						if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
 						$_SESSION['s']['user'] = $user;
 						$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
 						$_SESSION['s']['language'] = $user['language'];
 						$_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
+						if ($loginAs) $_SESSION['s']['plugin_cache'] = $_SESSION['s_old']['plugin_cache'];
 						
-						if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
-							include_once $_SESSION['s']['user']['startmodule'].'/lib/module.conf.php';
+						if(is_file(ISPC_WEB_PATH . '/' . $_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
+							include_once ISPC_WEB_PATH . '/' . $_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)) {
@@ -260,7 +262,7 @@
 							echo 'LOGIN_REDIRECT:'.$_SESSION['s']['module']['startpage'];
 							exit;
 						} else {
-							header('Location: /index.php?phpsessid='.session_id());
+							header('Location: ../index.php');
 							die();
 						}
 					}
@@ -341,7 +343,9 @@
 $app->tpl->setVar('base64_logo_txt', $base64_logo_txt);
 
 // Title
-$app->tpl->setVar('company_name', $sys_config['company_name']. ' :: ');
+if (!empty($sys_config['company_name'])) {
+	$app->tpl->setVar('company_name', $sys_config['company_name']. ' :: ');
+}
 
 // Custom Login
 if ($sys_config['custom_login_text'] != '') {

--
Gitblit v1.9.1