mirror of
				https://github.com/Mibew/i18n.git
				synced 2025-11-04 02:35:07 +03:00 
			
		
		
		
	Create prefix for session vars
This commit is contained in:
		
							parent
							
								
									74ebf724cc
								
							
						
					
					
						commit
						0cdd55cdf8
					
				@ -153,7 +153,7 @@ class UsersProcessor extends ClientSideProcessor {
 | 
			
		||||
	/**
 | 
			
		||||
	 * Return updated threads list. API function
 | 
			
		||||
	 *
 | 
			
		||||
	 * @global string $mysqlprefix Database tables prefix
 | 
			
		||||
	 * @global string $session_prefix Session vars prefix
 | 
			
		||||
	 * @global int $can_viewthreads View threads permission code
 | 
			
		||||
	 * @global int $can_takeover Take threads over permission code
 | 
			
		||||
	 * @param array $args Associative array of arguments. It must contains
 | 
			
		||||
@ -164,17 +164,17 @@ class UsersProcessor extends ClientSideProcessor {
 | 
			
		||||
	 *  - 'threads': array of threads changes
 | 
			
		||||
	 */
 | 
			
		||||
	protected function apiUpdateThreads($args) {
 | 
			
		||||
		global $mysqlprefix, $can_viewthreads, $can_takeover;
 | 
			
		||||
		global $session_prefix, $can_viewthreads, $can_takeover;
 | 
			
		||||
 | 
			
		||||
		$operator = self::checkOperator($args['agentId']);
 | 
			
		||||
 | 
			
		||||
		$since = $args['revision'];
 | 
			
		||||
		// Get operator groups
 | 
			
		||||
		if (!isset($_SESSION["${mysqlprefix}operatorgroups"])) {
 | 
			
		||||
			$_SESSION["${mysqlprefix}operatorgroups"]
 | 
			
		||||
		if (!isset($_SESSION[$session_prefix."operatorgroups"])) {
 | 
			
		||||
			$_SESSION[$session_prefix."operatorgroups"]
 | 
			
		||||
				= get_operator_groupslist($operator['operatorid']);
 | 
			
		||||
		}
 | 
			
		||||
		$groupids = $_SESSION["${mysqlprefix}operatorgroups"];
 | 
			
		||||
		$groupids = $_SESSION[$session_prefix."operatorgroups"];
 | 
			
		||||
 | 
			
		||||
		$db = Database::getInstance();
 | 
			
		||||
		$query = "select t.*, " .
 | 
			
		||||
 | 
			
		||||
@ -30,5 +30,10 @@ $dbversion = '1.6.3';
 | 
			
		||||
 */
 | 
			
		||||
$featuresversion = '1.6.4';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Prefix for session variables.
 | 
			
		||||
 * Provide an ability to instal several mibew instances on one server.
 | 
			
		||||
 */
 | 
			
		||||
$session_prefix = md5($mysqlhost.'##'.$mysqldb.'##'.$mysqlprefix) . '_';
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@ -21,6 +21,9 @@ session_start();
 | 
			
		||||
// Include configuration file
 | 
			
		||||
require_once(dirname(__FILE__) . '/config.php');
 | 
			
		||||
 | 
			
		||||
// Include system constants file
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/constants.php');
 | 
			
		||||
 | 
			
		||||
// Include system classes
 | 
			
		||||
require_once(dirname(__FILE__) . '/classes/database.php');
 | 
			
		||||
require_once(dirname(__FILE__) . '/classes/settings.php');
 | 
			
		||||
@ -30,7 +33,6 @@ require_once(dirname(__FILE__) . '/classes/plugin.php');
 | 
			
		||||
 | 
			
		||||
// Include common libs
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/configurations.php');
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/constants.php');
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/csrf.php');
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/datetime.php');
 | 
			
		||||
require_once(dirname(__FILE__) . '/common/forms.php');
 | 
			
		||||
 | 
			
		||||
@ -268,7 +268,7 @@ function create_operator($login, $email, $password, $localename, $commonname, $a
 | 
			
		||||
 */
 | 
			
		||||
function notify_operator_alive($operatorid, $istatus)
 | 
			
		||||
{
 | 
			
		||||
	global $mysqlprefix;
 | 
			
		||||
	global $session_prefix;
 | 
			
		||||
	$db = Database::getInstance();
 | 
			
		||||
	$db->query(
 | 
			
		||||
		"update {chatoperator} set istatus = :istatus, dtmlastvisited = :now " .
 | 
			
		||||
@ -279,9 +279,9 @@ function notify_operator_alive($operatorid, $istatus)
 | 
			
		||||
			':operatorid' => $operatorid
 | 
			
		||||
		)
 | 
			
		||||
	);
 | 
			
		||||
	if (isset($_SESSION["${mysqlprefix}operator"])) {
 | 
			
		||||
		if ($_SESSION["${mysqlprefix}operator"]['operatorid'] == $operatorid) {
 | 
			
		||||
			$_SESSION["${mysqlprefix}operator"]['istatus'] = $istatus;
 | 
			
		||||
	if (isset($_SESSION[$session_prefix."operator"])) {
 | 
			
		||||
		if ($_SESSION[$session_prefix."operator"]['operatorid'] == $operatorid) {
 | 
			
		||||
			$_SESSION[$session_prefix."operator"]['istatus'] = $istatus;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -369,13 +369,13 @@ function append_query($link, $pv)
 | 
			
		||||
 | 
			
		||||
function check_login($redirect = true)
 | 
			
		||||
{
 | 
			
		||||
	global $webimroot, $mysqlprefix;
 | 
			
		||||
	if (!isset($_SESSION["${mysqlprefix}operator"])) {
 | 
			
		||||
	global $webimroot, $session_prefix;
 | 
			
		||||
	if (!isset($_SESSION[$session_prefix."operator"])) {
 | 
			
		||||
		if (isset($_COOKIE['webim_lite'])) {
 | 
			
		||||
			list($login, $pwd) = preg_split("/,/", $_COOKIE['webim_lite'], 2);
 | 
			
		||||
			$op = operator_by_login($login);
 | 
			
		||||
			if ($op && isset($pwd) && isset($op['vcpassword']) && md5($op['vcpassword']) == $pwd && !operator_is_disabled($op)) {
 | 
			
		||||
				$_SESSION["${mysqlprefix}operator"] = $op;
 | 
			
		||||
				$_SESSION[$session_prefix."operator"] = $op;
 | 
			
		||||
				return $op;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -391,7 +391,7 @@ function check_login($redirect = true)
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return $_SESSION["${mysqlprefix}operator"];
 | 
			
		||||
	return $_SESSION[$session_prefix."operator"];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Force the admin to set a password after the installation
 | 
			
		||||
@ -407,14 +407,14 @@ function force_password($operator)
 | 
			
		||||
 | 
			
		||||
function get_logged_in()
 | 
			
		||||
{
 | 
			
		||||
	global $mysqlprefix;
 | 
			
		||||
	return isset($_SESSION["${mysqlprefix}operator"]) ? $_SESSION["${mysqlprefix}operator"] : FALSE;
 | 
			
		||||
	global $session_prefix;
 | 
			
		||||
	return isset($_SESSION[$session_prefix."operator"]) ? $_SESSION[$session_prefix."operator"] : FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function login_operator($operator, $remember)
 | 
			
		||||
{
 | 
			
		||||
	global $webimroot, $mysqlprefix;
 | 
			
		||||
	$_SESSION["${mysqlprefix}operator"] = $operator;
 | 
			
		||||
	global $webimroot, $session_prefix;
 | 
			
		||||
	$_SESSION[$session_prefix."operator"] = $operator;
 | 
			
		||||
	if ($remember) {
 | 
			
		||||
		$value = $operator['vclogin'] . "," . md5($operator['vcpassword']);
 | 
			
		||||
		setcookie('webim_lite', $value, time() + 60 * 60 * 24 * 1000, "$webimroot/");
 | 
			
		||||
@ -426,8 +426,8 @@ function login_operator($operator, $remember)
 | 
			
		||||
 | 
			
		||||
function logout_operator()
 | 
			
		||||
{
 | 
			
		||||
	global $webimroot, $mysqlprefix;
 | 
			
		||||
	unset($_SESSION["${mysqlprefix}operator"]);
 | 
			
		||||
	global $webimroot, $session_prefix;
 | 
			
		||||
	unset($_SESSION[$session_prefix."operator"]);
 | 
			
		||||
	unset($_SESSION['backpath']);
 | 
			
		||||
	if (isset($_COOKIE['webim_lite'])) {
 | 
			
		||||
		setcookie('webim_lite', '', time() - 3600, "$webimroot/");
 | 
			
		||||
 | 
			
		||||
@ -73,8 +73,8 @@ if (!$op) {
 | 
			
		||||
	if (count($errors) == 0) {
 | 
			
		||||
		update_operator_avatar($op['operatorid'], $avatar);
 | 
			
		||||
 | 
			
		||||
		if ($opId && $avatar && $_SESSION["${mysqlprefix}operator"] && $operator['operatorid'] == $opId) {
 | 
			
		||||
			$_SESSION["${mysqlprefix}operator"]['vcavatar'] = $avatar;
 | 
			
		||||
		if ($opId && $avatar && $_SESSION[$session_prefix."operator"] && $operator['operatorid'] == $opId) {
 | 
			
		||||
			$_SESSION[$session_prefix."operator"]['vcavatar'] = $avatar;
 | 
			
		||||
		}
 | 
			
		||||
		header("Location: $webimroot/operator/avatar.php?op=$opId");
 | 
			
		||||
		exit;
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ if ((isset($_POST['login']) || !is_capable($can_administrate, $operator)) && iss
 | 
			
		||||
			// update the session password
 | 
			
		||||
			if (!empty($password) && $opId == $operator['operatorid']) {
 | 
			
		||||
				$toDashboard = $operator['vcpassword'] == md5('') && $password != '';
 | 
			
		||||
				$_SESSION["${mysqlprefix}operator"]['vcpassword'] = md5($password);
 | 
			
		||||
				$_SESSION[$session_prefix."operator"]['vcpassword'] = md5($password);
 | 
			
		||||
				if($toDashboard) {
 | 
			
		||||
					header("Location: $webimroot/operator/index.php");
 | 
			
		||||
					exit;
 | 
			
		||||
 | 
			
		||||
@ -59,8 +59,8 @@ if (!$op) {
 | 
			
		||||
	if (count($errors) == 0) {
 | 
			
		||||
		update_operator_permissions($op['operatorid'], $new_permissions);
 | 
			
		||||
 | 
			
		||||
		if ($opId && $_SESSION["${mysqlprefix}operator"] && $operator['operatorid'] == $opId) {
 | 
			
		||||
			$_SESSION["${mysqlprefix}operator"]['iperm'] = $new_permissions;
 | 
			
		||||
		if ($opId && $_SESSION[$session_prefix."operator"] && $operator['operatorid'] == $opId) {
 | 
			
		||||
			$_SESSION[$session_prefix."operator"]['iperm'] = $new_permissions;
 | 
			
		||||
		}
 | 
			
		||||
		header("Location: $webimroot/operator/permissions.php?op=$opId&stored");
 | 
			
		||||
		exit;
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@ $status = isset($_GET['away']) ? 1 : 0;
 | 
			
		||||
 | 
			
		||||
notify_operator_alive($operator['operatorid'], $status);
 | 
			
		||||
 | 
			
		||||
$_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid']);
 | 
			
		||||
$_SESSION[$session_prefix."operatorgroups"] = get_operator_groupslist($operator['operatorid']);
 | 
			
		||||
 | 
			
		||||
$page = array();
 | 
			
		||||
$page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1";
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user