Fixed a problem with multiple installations on the same domain.

When a user logged in on one chat, they also got logged in to all the other chats.
This commit is contained in:
novagen 2010-10-29 11:44:17 +02:00
parent e304901bd0
commit 7cc810c683
3 changed files with 579 additions and 578 deletions

19
src/messenger/webim/libs/operator.php Normal file → Executable file
View File

@ -195,13 +195,13 @@ function append_query($link,$pv) {
} }
function check_login($redirect=true) { function check_login($redirect=true) {
global $webimroot; global $webimroot, $mysqlprefix;
if( !isset( $_SESSION['operator'] ) ) { if( !isset( $_SESSION[$mysqlprefix . 'operator'] ) ) {
if( isset($_COOKIE['webim_lite']) ) { if( isset($_COOKIE['webim_lite']) ) {
list($login,$pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2); list($login,$pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
$op = operator_by_login($login); $op = operator_by_login($login);
if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) { if( $op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd ) {
$_SESSION['operator'] = $op; $_SESSION[$mysqlprefix . 'operator'] = $op;
return $op; return $op;
} }
} }
@ -217,16 +217,17 @@ function check_login($redirect=true) {
return null; return null;
} }
} }
return $_SESSION['operator']; return $_SESSION[$mysqlprefix . 'operator'];
} }
function get_logged_in() { function get_logged_in() {
return isset( $_SESSION['operator'] ) ? $_SESSION['operator'] : FALSE; global $mysqlprefix;
return isset( $_SESSION[$mysqlprefix . 'operator'] ) ? $_SESSION[$mysqlprefix . 'operator'] : FALSE;
} }
function login_operator($operator,$remember) { function login_operator($operator,$remember) {
global $webimroot; global $webimroot, $mysqlprefix;
$_SESSION['operator'] = $operator; $_SESSION[$mysqlprefix . 'operator'] = $operator;
if( $remember ) { if( $remember ) {
$value = $operator['vclogin'].",".md5($operator['vcpassword']); $value = $operator['vclogin'].",".md5($operator['vcpassword']);
setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/"); setcookie('webim_lite', $value, time()+60*60*24*1000, "$webimroot/");
@ -237,8 +238,8 @@ function login_operator($operator,$remember) {
} }
function logout_operator() { function logout_operator() {
global $webimroot; global $webimroot, $mysqlprefix;
unset($_SESSION['operator']); unset($_SESSION[$mysqlprefix . 'operator']);
unset($_SESSION['backpath']); unset($_SESSION['backpath']);
if( isset($_COOKIE['webim_lite']) ) { if( isset($_COOKIE['webim_lite']) ) {
setcookie('webim_lite', '', time() - 3600, "$webimroot/"); setcookie('webim_lite', '', time() - 3600, "$webimroot/");

4
src/messenger/webim/operator/avatar.php Normal file → Executable file
View File

@ -77,8 +77,8 @@ if( !$op ) {
if(count($errors) == 0) { if(count($errors) == 0) {
update_operator_avatar($op['operatorid'],$avatar); update_operator_avatar($op['operatorid'],$avatar);
if ($opId && $avatar && $_SESSION['operator'] && $operator['operatorid'] == $opId) { if ($opId && $avatar && $_SESSION[$mysqlprefix . 'operator'] && $operator['operatorid'] == $opId) {
$_SESSION['operator']['vcavatar'] = $avatar; $_SESSION[$mysqlprefix . 'operator']['vcavatar'] = $avatar;
} }
header("Location: $webimroot/operator/avatar.php?op=$opId"); header("Location: $webimroot/operator/avatar.php?op=$opId");
exit; exit;

4
src/messenger/webim/operator/permissions.php Normal file → Executable file
View File

@ -62,8 +62,8 @@ if( !$op ) {
if(count($errors) == 0) { if(count($errors) == 0) {
update_operator_permissions($op['operatorid'],$new_permissions); update_operator_permissions($op['operatorid'],$new_permissions);
if ($opId && $_SESSION['operator'] && $operator['operatorid'] == $opId) { if ($opId && $_SESSION[$mysqlprefix . 'operator'] && $operator['operatorid'] == $opId) {
$_SESSION['operator']['iperm'] = $new_permissions; $_SESSION[$mysqlprefix . $mysqlprefix . 'operator']['iperm'] = $new_permissions;
} }
header("Location: $webimroot/operator/permissions.php?op=$opId&stored"); header("Location: $webimroot/operator/permissions.php?op=$opId&stored");
exit; exit;