mirror of
				https://github.com/Mibew/tray.git
				synced 2025-10-03 00:03:34 +03:00 
			
		
		
		
	Replaced settings functions with Settings class
This commit is contained in:
		
							parent
							
								
									3929f26791
								
							
						
					
					
						commit
						be696ee3da
					
				| @ -37,8 +37,7 @@ if(!$lang || !locale_exists($lang)) { | ||||
| 
 | ||||
| $groupid = verifyparam( "group", "/^\d{1,8}$/", ""); | ||||
| if($groupid) { | ||||
| 	loadsettings(); | ||||
| 	if($settings['enablegroups'] == '1') { | ||||
| 	if(Settings::get('enablegroups') == '1') { | ||||
| 		$group = group_by_id($groupid); | ||||
| 		if(!$group) { | ||||
| 			$groupid = ""; | ||||
|  | ||||
| @ -23,8 +23,7 @@ require_once('libs/expand.php'); | ||||
| require_once('libs/captcha.php'); | ||||
| require_once('libs/invitation.php'); | ||||
| 
 | ||||
| loadsettings(); | ||||
| if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { | ||||
| if(Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") { | ||||
| 	if(!is_secure_request()) { | ||||
| 		$requested = $_SERVER['PHP_SELF']; | ||||
| 		if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) { | ||||
| @ -47,7 +46,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { | ||||
| 		$groupid = ""; | ||||
| 		$groupname = ""; | ||||
| 		$group = NULL; | ||||
| 		if($settings['enablegroups'] == '1') { | ||||
| 		if(Settings::get('enablegroups') == '1') { | ||||
| 			$groupid = verifyparam( "group", "/^\d{1,8}$/", ""); | ||||
| 			if($groupid) { | ||||
| 				$group = group_by_id($groupid); | ||||
| @ -67,7 +66,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { | ||||
| 			$email = getparam("email"); | ||||
| 			$referrer = urldecode(getparam("referrer")); | ||||
| 
 | ||||
| 			if($settings['usercanchangename'] == "1" && isset($_POST['name'])) { | ||||
| 			if(Settings::get('usercanchangename') == "1" && isset($_POST['name'])) { | ||||
| 				$newname = getparam("name"); | ||||
| 				if($newname != $visitor['name']) { | ||||
| 					$data = strtr(base64_encode(myiconv($webim_encoding,"utf-8",$newname)), '+/=', '-_,'); | ||||
| @ -95,8 +94,8 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { | ||||
| 		} | ||||
| 
 | ||||
| 		$invitation_state = invitation_state($_SESSION['visitorid']); | ||||
| 		$visitor_is_invited = $settings['enabletracking'] && $invitation_state['invited'] && !$invitation_state['threadid']; | ||||
| 		if($settings['enablepresurvey'] == '1' && !(isset($_POST['survey']) && $_POST['survey'] == 'on') && !$visitor_is_invited) { | ||||
| 		$visitor_is_invited = Settings::get('enabletracking') && $invitation_state['invited'] && !$invitation_state['threadid']; | ||||
| 		if(Settings::get('enablepresurvey') == '1' && !(isset($_POST['survey']) && $_POST['survey'] == 'on') && !$visitor_is_invited) { | ||||
| 			$page = array(); | ||||
| 			setup_logo($group); | ||||
| 			setup_survey($visitor['name'], $email, $groupid, $info, $referrer); | ||||
|  | ||||
| @ -295,7 +295,7 @@ function add_canned_messages($link){ | ||||
| 
 | ||||
| function check_status() | ||||
| { | ||||
| 	global $page, $webimroot, $settings, $dbversion; | ||||
| 	global $page, $webimroot, $dbversion; | ||||
| 
 | ||||
| 	$page['done'][] = getlocal2("install.0.php", array(phpversion())); | ||||
| 
 | ||||
| @ -343,9 +343,8 @@ function check_status() | ||||
| 
 | ||||
| 	mysql_close($link); | ||||
| 
 | ||||
| 	loadsettings(); | ||||
| 	$settings['dbversion'] = $dbversion; | ||||
| 	update_settings(); | ||||
| 	Settings::set('dbversion', $dbversion); | ||||
| 	Settings::update(); | ||||
| } | ||||
| 
 | ||||
| check_status(); | ||||
|  | ||||
| @ -46,8 +46,7 @@ function store_message($name, $email, $info, $message,$groupid,$referrer) { | ||||
| $groupid = ""; | ||||
| $groupname = ""; | ||||
| $group = NULL; | ||||
| loadsettings(); | ||||
| if($settings['enablegroups'] == '1') { | ||||
| if(Settings::get('enablegroups') == '1') { | ||||
| 	$groupid = verifyparam( "group", "/^\d{1,8}$/", ""); | ||||
| 	if($groupid) { | ||||
| 		$group = group_by_id($groupid); | ||||
| @ -77,7 +76,7 @@ if( !$email ) { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| if($settings["enablecaptcha"] == "1" && can_show_captcha()) { | ||||
| if(Settings::get("enablecaptcha") == "1" && can_show_captcha()) { | ||||
| 	$captcha = getparam('captcha'); | ||||
| 	$original = isset($_SESSION["mibew_captcha"]) ? $_SESSION["mibew_captcha"] : ""; | ||||
| 	if(empty($original) || empty($captcha) || $captcha != $original) { | ||||
| @ -93,7 +92,7 @@ if( count($errors) > 0 ) { | ||||
| 	exit; | ||||
| } | ||||
| 
 | ||||
| $message_locale = $settings['left_messages_locale']; | ||||
| $message_locale = Settings::get('left_messages_locale'); | ||||
| if(!locale_exists($message_locale)) { | ||||
| 	$message_locale = $home_locale; | ||||
| } | ||||
| @ -115,7 +114,7 @@ if (isset($group) && !empty($group['vcemail'])) { | ||||
| } | ||||
| 
 | ||||
| if (empty($inbox_mail)) { | ||||
| 	$inbox_mail = $settings['email']; | ||||
| 	$inbox_mail = Settings::get('email'); | ||||
| } | ||||
| 
 | ||||
| if($inbox_mail) { | ||||
|  | ||||
| @ -175,7 +175,7 @@ function get_messages($threadid, $meth, $isuser, &$lastid) | ||||
| 
 | ||||
| function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agentid = null) | ||||
| { | ||||
| 	global $webim_encoding, $webimroot, $connection_timeout, $settings; | ||||
| 	global $webim_encoding, $webimroot, $connection_timeout; | ||||
| 	$threadid = $thread['threadid']; | ||||
| 	$istyping = abs($thread['current'] - $thread[$isuser ? "lpagent" : "lpuser"]) < $connection_timeout | ||||
| 				&& $thread[$isuser ? "agentTyping" : "userTyping"] == "1" ? "1" : "0"; | ||||
| @ -190,7 +190,6 @@ function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agen | ||||
| 		} | ||||
| 		print("</thread>"); | ||||
| 	} else if ($format == "html") { | ||||
| 		loadsettings(); | ||||
| 		$output = get_messages($threadid, "html", $isuser, $lastid); | ||||
| 
 | ||||
| 		start_html_output(); | ||||
| @ -200,7 +199,7 @@ function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agen | ||||
| 				"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . | ||||
| 				"<html>\n<head>\n" . | ||||
| 				"<link href=\"$webimroot/styles/default/chat.css\" rel=\"stylesheet\" type=\"text/css\">\n" . | ||||
| 				"<meta http-equiv=\"Refresh\" content=\"" . $settings['updatefrequency_oldchat'] . "; URL=$url&sn=11\">\n" . | ||||
| 				"<meta http-equiv=\"Refresh\" content=\"" . Settings::get('updatefrequency_oldchat') . "; URL=$url&sn=11\">\n" . | ||||
| 				"<meta http-equiv=\"Pragma\" content=\"no-cache\">\n" . | ||||
| 				"<title>chat</title>\n" . | ||||
| 				"</head>\n" . | ||||
| @ -219,11 +218,13 @@ function print_thread_messages($thread, $token, $lastid, $isuser, $format, $agen | ||||
| 
 | ||||
| function get_user_name($username, $addr, $id) | ||||
| { | ||||
| 	global $settings; | ||||
| 	loadsettings(); | ||||
| 	return str_replace("{addr}", $addr, | ||||
| 					   str_replace("{id}", $id, | ||||
| 								   str_replace("{name}", $username, $settings['usernamepattern']))); | ||||
| 	return str_replace( | ||||
| 		"{addr}", $addr, | ||||
| 		str_replace( | ||||
| 			"{id}", $id, | ||||
| 			str_replace("{name}", $username, Settings::get('usernamepattern')) | ||||
| 		) | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
| function is_ajax_browser($browserid, $ver, $useragent) | ||||
| @ -306,27 +307,26 @@ function needsFramesrc() | ||||
| 
 | ||||
| function setup_logo($group = NULL) | ||||
| { | ||||
| 	global $page, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $page; | ||||
| 	$toplevelgroup = (!$group)?array():get_top_level_group($group); | ||||
| 	$page['ct.company.name'] = topage(empty($toplevelgroup['vctitle'])?$settings['title']:$toplevelgroup['vctitle']); | ||||
| 	$page['ct.company.chatLogoURL'] = topage(empty($toplevelgroup['vclogo'])?$settings['logo']:$toplevelgroup['vclogo']); | ||||
| 	$page['webimHost'] = topage(empty($toplevelgroup['vchosturl'])?$settings['hosturl']:$toplevelgroup['vchosturl']); | ||||
| 	$page['ct.company.name'] = topage(empty($toplevelgroup['vctitle'])?Settings::get('title'):$toplevelgroup['vctitle']); | ||||
| 	$page['ct.company.chatLogoURL'] = topage(empty($toplevelgroup['vclogo'])?Settings::get('logo'):$toplevelgroup['vclogo']); | ||||
| 	$page['webimHost'] = topage(empty($toplevelgroup['vchosturl'])?Settings::get('hosturl'):$toplevelgroup['vchosturl']); | ||||
| } | ||||
| 
 | ||||
| function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info, $referrer, $canshowcaptcha) | ||||
| { | ||||
| 	global $settings, $page; | ||||
| 	global $page; | ||||
| 	$page['formname'] = topage($name); | ||||
| 	$page['formemail'] = topage($email); | ||||
| 	$page['formmessage'] = $message ? topage($message) : ""; | ||||
| 	$page['showcaptcha'] = $settings["enablecaptcha"] == "1" && $canshowcaptcha ? "1" : ""; | ||||
| 	$page['showcaptcha'] = Settings::get("enablecaptcha") == "1" && $canshowcaptcha ? "1" : ""; | ||||
| 	$page['formgroupid'] = $groupid; | ||||
| 	$page['formgroupname'] = $groupname; | ||||
| 	$page['forminfo'] = topage($info); | ||||
| 	$page['referrer'] = urlencode(topage($referrer)); | ||||
| 
 | ||||
| 	if ($settings['enablegroups'] == '1') { | ||||
| 	if (Settings::get('enablegroups') == '1') { | ||||
| 		$groups = setup_groups_select($groupid, false); | ||||
| 		if ($groups) { | ||||
| 			$page['groups'] = $groups['select']; | ||||
| @ -339,7 +339,7 @@ function setup_leavemessage($name, $email, $message, $groupid, $groupname, $info | ||||
| 
 | ||||
| function setup_survey($name, $email, $groupid, $info, $referrer) | ||||
| { | ||||
| 	global $settings, $page; | ||||
| 	global $page; | ||||
| 
 | ||||
| 	$page['formname'] = topage($name); | ||||
| 	$page['formemail'] = topage($email); | ||||
| @ -347,7 +347,7 @@ function setup_survey($name, $email, $groupid, $info, $referrer) | ||||
| 	$page['forminfo'] = topage($info); | ||||
| 	$page['referrer'] = urlencode(topage($referrer)); | ||||
| 
 | ||||
| 	if ($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") { | ||||
| 	if (Settings::get('enablegroups') == '1' && Settings::get('surveyaskgroup') == '1') { | ||||
| 		$groups = setup_groups_select($groupid, true); | ||||
| 		if ($groups) { | ||||
| 			$page['groups'] = $groups['select']; | ||||
| @ -356,15 +356,13 @@ function setup_survey($name, $email, $groupid, $info, $referrer) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	$page['showemail'] = $settings["surveyaskmail"] == "1" ? "1" : ""; | ||||
| 	$page['showmessage'] = $settings["surveyaskmessage"] == "1" ? "1" : ""; | ||||
| 	$page['showname'] = $settings['usercanchangename'] == "1" ? "1" : ""; | ||||
| 	$page['showemail'] = Settings::get("surveyaskmail") == "1" ? "1" : ""; | ||||
| 	$page['showmessage'] = Settings::get("surveyaskmessage") == "1" ? "1" : ""; | ||||
| 	$page['showname'] = Settings::get('usercanchangename') == "1" ? "1" : ""; | ||||
| } | ||||
| 
 | ||||
| function setup_groups_select($groupid, $markoffline) | ||||
| { | ||||
| 	global $settings; | ||||
| 
 | ||||
| 	$showgroups = ($groupid == '')?true:group_has_children($groupid); | ||||
| 	if (!$showgroups) { | ||||
| 		return false; | ||||
| @ -384,7 +382,7 @@ function setup_groups_select($groupid, $markoffline) | ||||
| 		if ($k['inumofagents'] == 0 || ($groupid && $k['parent'] != $groupid && $k['groupid'] != $groupid )) { | ||||
| 			continue; | ||||
| 		} | ||||
| 		if ($k['ilastseen'] !== NULL && $k['ilastseen'] < $settings['online_timeout']) { | ||||
| 		if ($k['ilastseen'] !== NULL && $k['ilastseen'] < Settings::get('online_timeout')) { | ||||
| 			if (!$selectedgroupid) { | ||||
| 				$selectedgroupid = $k['groupid']; // select first online group
 | ||||
| 			} | ||||
| @ -408,8 +406,7 @@ function setup_groups_select($groupid, $markoffline) | ||||
| 
 | ||||
| function setup_chatview_for_user($thread, $level) | ||||
| { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $page, $webimroot; | ||||
| 	$page = array(); | ||||
| 	if (! empty($thread['groupid'])) { | ||||
| 		$group = group_by_id($thread['groupid']); | ||||
| @ -427,12 +424,12 @@ function setup_chatview_for_user($thread, $level) | ||||
| 	$page['ct.chatThreadId'] = $thread['threadid']; | ||||
| 	$page['ct.token'] = $thread['ltoken']; | ||||
| 	$page['ct.user.name'] = htmlspecialchars(topage($thread['userName'])); | ||||
| 	$page['canChangeName'] = $settings['usercanchangename'] == "1"; | ||||
| 	$page['chat.title'] = topage(empty($group['vcchattitle'])?$settings['chattitle']:$group['vcchattitle']); | ||||
| 	$page['canChangeName'] = Settings::get('usercanchangename') == "1"; | ||||
| 	$page['chat.title'] = topage(empty($group['vcchattitle'])?Settings::get('chattitle'):$group['vcchattitle']); | ||||
| 	$page['chat.close.confirmation'] = getlocal('chat.close.confirmation'); | ||||
| 
 | ||||
| 	setup_logo($group); | ||||
| 	if ($settings['sendmessagekey'] == 'enter') { | ||||
| 	if (Settings::get('sendmessagekey') == 'enter') { | ||||
| 		$page['send_shortcut'] = "Enter"; | ||||
| 		$page['ignorectrl'] = 1; | ||||
| 	} else { | ||||
| @ -443,20 +440,19 @@ function setup_chatview_for_user($thread, $level) | ||||
| 	$params = "thread=" . $thread['threadid'] . "&token=" . $thread['ltoken']; | ||||
| 	$page['mailLink'] = "$webimroot/client.php?" . $params . "&level=$level&act=mailthread"; | ||||
| 
 | ||||
| 	if ($settings['enablessl'] == "1" && !is_secure_request()) { | ||||
| 	if (Settings::get('enablessl') == "1" && !is_secure_request()) { | ||||
| 		$page['sslLink'] = get_app_location(true, true) . "/client.php?" . $params . "&level=$level"; | ||||
| 	} | ||||
| 
 | ||||
| 	$page['isOpera95'] = is_agent_opera95(); | ||||
| 	$page['neediframesrc'] = needsFramesrc(); | ||||
| 
 | ||||
| 	$page['frequency'] = $settings['updatefrequency_chat']; | ||||
| 	$page['frequency'] = Settings::get('updatefrequency_chat'); | ||||
| } | ||||
| 
 | ||||
| function setup_chatview_for_operator($thread, $operator) | ||||
| { | ||||
| 	global $page, $webimroot, $company_logo_link, $webim_encoding, $company_name, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $page, $webimroot, $company_logo_link, $webim_encoding, $company_name; | ||||
| 	$page = array(); | ||||
| 	if (! is_null($thread['groupid'])) { | ||||
| 		$group = group_by_id($thread['groupid']); | ||||
| @ -470,11 +466,11 @@ function setup_chatview_for_operator($thread, $operator) | ||||
| 	$page['ct.chatThreadId'] = $thread['threadid']; | ||||
| 	$page['ct.token'] = $thread['ltoken']; | ||||
| 	$page['ct.user.name'] = htmlspecialchars(topage(get_user_name($thread['userName'], $thread['remote'], $thread['userid']))); | ||||
| 	$page['chat.title'] = topage(empty($group['vcchattitle'])?$settings['chattitle']:$group['vcchattitle']); | ||||
| 	$page['chat.title'] = topage(empty($group['vcchattitle'])?Settings::get('chattitle'):$group['vcchattitle']); | ||||
| 	$page['chat.close.confirmation'] = getlocal('chat.close.confirmation'); | ||||
| 
 | ||||
| 	setup_logo($group); | ||||
| 	if ($settings['sendmessagekey'] == 'enter') { | ||||
| 	if (Settings::get('sendmessagekey') == 'enter') { | ||||
| 		$page['send_shortcut'] = "Enter"; | ||||
| 		$page['ignorectrl'] = 1; | ||||
| 	} else { | ||||
| @ -482,14 +478,14 @@ function setup_chatview_for_operator($thread, $operator) | ||||
| 		$page['ignorectrl'] = 0; | ||||
| 	} | ||||
| 
 | ||||
| 	if ($settings['enablessl'] == "1" && !is_secure_request()) { | ||||
| 	if (Settings::get('enablessl') == "1" && !is_secure_request()) { | ||||
| 		$page['sslLink'] = get_app_location(true, true) . "/operator/agent.php?thread=" . $thread['threadid'] . "&token=" . $thread['ltoken']; | ||||
| 	} | ||||
| 	$page['isOpera95'] = is_agent_opera95(); | ||||
| 	$page['neediframesrc'] = needsFramesrc(); | ||||
| 	$page['historyParams'] = array("userid" => "" . $thread['userid']); | ||||
| 	$page['historyParamsLink'] = add_params($webimroot . "/operator/userhistory.php", $page['historyParams']); | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 	    $visitor = track_get_visitor_by_threadid($thread['threadid']); | ||||
| 	    $page['trackedParams'] = array("visitor" => "" . $visitor['visitorid']); | ||||
| 	    $page['trackedParamsLink'] = add_params($webimroot . "/operator/tracked.php", $page['trackedParams']); | ||||
| @ -512,7 +508,7 @@ function setup_chatview_for_operator($thread, $operator) | ||||
| 	$page['redirectLink'] = "$webimroot/operator/agent.php?" . $params . "&act=redirect"; | ||||
| 
 | ||||
| 	$page['namePostfix'] = ""; | ||||
| 	$page['frequency'] = $settings['updatefrequency_chat']; | ||||
| 	$page['frequency'] = Settings::get('updatefrequency_chat'); | ||||
| } | ||||
| 
 | ||||
| function update_thread_access($threadid, $params) | ||||
| @ -619,8 +615,8 @@ function close_thread($thread, $isuser) | ||||
| 
 | ||||
| function close_old_threads() | ||||
| { | ||||
| 	global $state_closed, $state_left, $state_chatting, $settings; | ||||
| 	if ($settings['thread_lifetime'] == 0) { | ||||
| 	global $state_closed, $state_left, $state_chatting; | ||||
| 	if (Settings::get('thread_lifetime') == 0) { | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| @ -641,7 +637,7 @@ function close_old_threads() | ||||
| 			':next_revision' => next_revision(), | ||||
| 			':state_closed' => $state_closed, | ||||
| 			':state_left' => $state_left, | ||||
| 			':thread_lifetime' => $settings['thread_lifetime'] | ||||
| 			':thread_lifetime' => Settings::get('thread_lifetime') | ||||
| 		) | ||||
| 	); | ||||
| } | ||||
| @ -721,14 +717,14 @@ function do_take_thread($threadid, $operatorId, $operatorName, $chatstart = fals | ||||
| 
 | ||||
| function reopen_thread($threadid) | ||||
| { | ||||
| 	global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events, $settings; | ||||
| 	global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events; | ||||
| 
 | ||||
| 	$thread = thread_by_id($threadid); | ||||
| 
 | ||||
| 	if (!$thread) | ||||
| 		return FALSE; | ||||
| 
 | ||||
| 	if ($settings['thread_lifetime'] != 0 && abs($thread['lpuser'] - time()) > $settings['thread_lifetime'] && abs($thread['lpagent'] - time()) > $settings['thread_lifetime']) { | ||||
| 	if (Settings::get('thread_lifetime') != 0 && abs($thread['lpuser'] - time()) > Settings::get('thread_lifetime') && abs($thread['lpagent'] - time()) > Settings::get('thread_lifetime')) { | ||||
| 		return FALSE; | ||||
| 	} | ||||
| 
 | ||||
| @ -806,8 +802,8 @@ function check_for_reassign($thread, $operator) | ||||
| 
 | ||||
| function check_connections_from_remote($remote) | ||||
| { | ||||
| 	global $settings, $state_closed, $state_left; | ||||
| 	if ($settings['max_connections_from_one_host'] == 0) { | ||||
| 	global $state_closed, $state_left; | ||||
| 	if (Settings::get('max_connections_from_one_host') == 0) { | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
| @ -820,7 +816,7 @@ function check_connections_from_remote($remote) | ||||
| 	); | ||||
| 
 | ||||
| 	if ($result && isset($result['opened'])) { | ||||
| 		return $result['opened'] < $settings['max_connections_from_one_host']; | ||||
| 		return $result['opened'] < Settings::get('max_connections_from_one_host'); | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
| @ -64,6 +64,7 @@ Class Settings { | ||||
| 			'logo' => '', | ||||
| 			'usernamepattern' => '{name}', | ||||
| 			'chatstyle' => 'default', | ||||
| 			'invitationstyle' => 'default', | ||||
| 			'chattitle' => 'Live Support', | ||||
| 			'geolink' => 'http://api.hostip.info/get_html.php?ip={ip}', | ||||
| 			'geolinkparams' => 'width=440,height=100,toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1', | ||||
|  | ||||
| @ -20,6 +20,7 @@ session_start(); | ||||
| require_once(dirname(__FILE__) . '/converter.php'); | ||||
| require_once(dirname(__FILE__) . '/config.php'); | ||||
| require_once(dirname(__FILE__) . '/classes/database.php'); | ||||
| require_once(dirname(__FILE__) . '/classes/settings.php'); | ||||
| 
 | ||||
| $version = '1.6.5'; | ||||
| $jsver = "165"; | ||||
| @ -563,85 +564,13 @@ function date_to_text($unixtime) | ||||
| $dbversion = '1.6.3'; | ||||
| $featuresversion = '1.6.4'; | ||||
| 
 | ||||
| $settings = array( | ||||
| 	'dbversion' => 0, | ||||
| 	'featuresversion' => 0, | ||||
| 	'title' => 'Your Company', | ||||
| 	'hosturl' => 'http://mibew.org', | ||||
| 	'logo' => '', | ||||
| 	'usernamepattern' => '{name}', | ||||
| 	'chatstyle' => 'default', | ||||
| 	'chattitle' => 'Live Support', | ||||
| 	'geolink' => 'http://api.hostip.info/get_html.php?ip={ip}', | ||||
| 	'geolinkparams' => 'width=440,height=100,toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1', | ||||
| 	'max_uploaded_file_size' => 100000, | ||||
| 	'max_connections_from_one_host' => 10, | ||||
| 	'thread_lifetime' => 600, | ||||
| 
 | ||||
| 	'email' => '', /* inbox for left messages */ | ||||
| 	'left_messages_locale' => $home_locale, | ||||
| 	'sendmessagekey' => 'center', | ||||
| 
 | ||||
| 	'enableban' => '0', | ||||
| 	'enablessl' => '0', | ||||
| 	'forcessl' => '0', | ||||
| 	'usercanchangename' => '1', | ||||
| 	'enablegroups' => '0', | ||||
| 	'enablegroupsisolation' => '0', | ||||
| 	'enablestatistics' => '1', | ||||
| 	'enabletracking' => '0', | ||||
| 	'enablepresurvey' => '1', | ||||
| 	'surveyaskmail' => '0', | ||||
| 	'surveyaskgroup' => '1', | ||||
| 	'surveyaskmessage' => '0', | ||||
| 	'enablepopupnotification' => '0', | ||||
| 	'showonlineoperators' => '0', | ||||
| 	'enablecaptcha' => '0', | ||||
| 
 | ||||
| 	'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */ | ||||
| 	'updatefrequency_operator' => 2, | ||||
| 	'updatefrequency_chat' => 2, | ||||
| 	'updatefrequency_oldchat' => 7, | ||||
| 
 | ||||
| 	'updatefrequency_tracking' => 10, | ||||
| 	'visitors_limit' => 20, /* Number of visitors to look over */ | ||||
| 	'invitation_lifetime' => 60, /* Lifetime for invitation to chat */ | ||||
| 	'tracking_lifetime' => 600, /* Time to store tracked old visitors' data */ | ||||
| 
 | ||||
| ); | ||||
| $settingsloaded = false; | ||||
| $settings_in_db = array(); | ||||
| 
 | ||||
| function loadsettings() | ||||
| { | ||||
| 	global $settingsloaded, $settings_in_db, $settings; | ||||
| 	if ($settingsloaded) { | ||||
| 		return; | ||||
| 	} | ||||
| 	$settingsloaded = true; | ||||
| 
 | ||||
| 	$db = Database::getInstance(); | ||||
| 	$rows = $db->query( | ||||
| 		"select vckey,vcvalue from {chatconfig}", | ||||
| 		NULL, | ||||
| 		array('return_rows' => Database::RETURN_ALL_ROWS) | ||||
| 	); | ||||
| 	foreach ($rows as $row) { | ||||
| 		$name = $row['vckey']; | ||||
| 		$settings[$name] = $row['vcvalue']; | ||||
| 		$settings_in_db[$name] = true; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| function getchatstyle() | ||||
| { | ||||
| 	global $settings; | ||||
| 	$chatstyle = verifyparam("style", "/^\w+$/", ""); | ||||
| 	if ($chatstyle) { | ||||
| 		return $chatstyle; | ||||
| 	} | ||||
| 	loadsettings(); | ||||
| 	return $settings['chatstyle']; | ||||
| 	return Settings::get('chatstyle'); | ||||
| } | ||||
| 
 | ||||
| function jspath() | ||||
|  | ||||
| @ -27,8 +27,7 @@ function demo_print_message($msg, $format) | ||||
| 
 | ||||
| function demo_process_thread($act, $outformat, $lastid, $isuser, $canpost, $istyping, $postmessage) | ||||
| { | ||||
| 	global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent, $webimroot, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $kind_for_agent, $kind_info, $kind_events, $kind_user, $kind_agent, $webimroot; | ||||
| 	if ($act == "refresh" || $act == "post") { | ||||
| 		$lastid++; | ||||
| 		if ($outformat == "xml") { | ||||
| @ -42,7 +41,7 @@ function demo_process_thread($act, $outformat, $lastid, $isuser, $canpost, $isty | ||||
| 					"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" . | ||||
| 					"<html>\n<head>\n" . | ||||
| 					"<link href=\"$webimroot/styles/default/chat.css\" rel=\"stylesheet\" type=\"text/css\">\n" . | ||||
| 					"<meta http-equiv=\"Refresh\" content=\"" . $settings['updatefrequency_oldchat'] . "; URL=$url&sn=11\">\n" . | ||||
| 					"<meta http-equiv=\"Refresh\" content=\"" . Settings::get('updatefrequency_oldchat') . "; URL=$url&sn=11\">\n" . | ||||
| 					"<meta http-equiv=\"Pragma\" content=\"no-cache\">\n" . | ||||
| 					"<title>chat</title>\n" . | ||||
| 					"</head>\n" . | ||||
|  | ||||
| @ -17,7 +17,6 @@ | ||||
| 
 | ||||
| function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity) | ||||
| { | ||||
| 	global $settings; | ||||
| 	$link = get_app_location($showhost, $forcesecure) . "/client.php"; | ||||
| 	if ($locale) | ||||
| 		$link = append_query($link, "locale=$locale"); | ||||
| @ -30,14 +29,14 @@ function generate_button($title, $locale, $style, $invitationstyle, $group, $inn | ||||
| 	$jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)"); | ||||
| 	$temp = get_popup($link, "$jslink", | ||||
| 					  $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"); | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 	    $temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp); | ||||
| 	    $temp .= '<div id="mibewinvitation"></div><script type="text/javascript">var mibewInviteStyle = \'@import url('; | ||||
| 	    $temp .= get_app_location($showhost, $forcesecure); | ||||
| 	    $temp .= '/styles/invitations/'; | ||||
| 	    $temp .= ($invitationstyle?$invitationstyle:(array_key_exists('invitationstyle', $settings)?$settings['invitationstyle']:'default')); | ||||
| 	    $temp .= ($invitationstyle?$invitationstyle:(Settings::get('invitationstyle'))); | ||||
| 	    $temp .= '/invite.css);\'; var mibewRequestTimeout = '; | ||||
| 	    $temp .= $settings['updatefrequency_tracking']; | ||||
| 	    $temp .= Settings::get('updatefrequency_tracking'); | ||||
| 	    $temp .= '*1000; var mibewRequestUrl = \''; | ||||
| 	    $temp .= get_app_location($showhost, $forcesecure); | ||||
| 	    $temp .= '/request.php?entry=\' + escape(document.referrer) + \'&lang=ru\'</script><script type="text/javascript" src="'; | ||||
|  | ||||
| @ -37,7 +37,7 @@ function get_group_name($group) | ||||
| 
 | ||||
| function setup_group_settings_tabs($gid, $active) | ||||
| { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	global $page, $webimroot; | ||||
| 	if ($gid) { | ||||
| 		$page['tabs'] = array( | ||||
| 			getlocal("page_group.tab.main") => $active != 0 ? "$webimroot/operator/group.php?gid=$gid" : "", | ||||
| @ -50,9 +50,8 @@ function setup_group_settings_tabs($gid, $active) | ||||
| 
 | ||||
| function get_operator_groupslist($operatorid) | ||||
| { | ||||
| 	global $settings; | ||||
| 	$db = Database::getInstance(); | ||||
| 	if ($settings['enablegroups'] == '1') { | ||||
| 	if (Settings::get('enablegroups') == '1') { | ||||
| 		$groupids = array(0); | ||||
| 		$allgroups = $db->query( | ||||
| 			"select groupid from {chatgroupoperator} where operatorid = ? order by groupid", | ||||
|  | ||||
| @ -162,20 +162,17 @@ function get_operators_from_adjacent_groups($operator) | ||||
| 
 | ||||
| function operator_is_online($operator) | ||||
| { | ||||
| 	global $settings; | ||||
| 	return $operator['time'] < $settings['online_timeout']; | ||||
| 	return $operator['time'] < Settings::get('online_timeout'); | ||||
| } | ||||
| 
 | ||||
| function operator_is_available($operator) | ||||
| { | ||||
| 	global $settings; | ||||
| 	return $operator['istatus'] == 0 && $operator['time'] < $settings['online_timeout'] ? "1" : ""; | ||||
| 	return $operator['istatus'] == 0 && $operator['time'] < Settings::get('online_timeout') ? "1" : ""; | ||||
| } | ||||
| 
 | ||||
| function operator_is_away($operator) | ||||
| { | ||||
| 	global $settings; | ||||
| 	return $operator['istatus'] != 0 && $operator['time'] < $settings['online_timeout'] ? "1" : ""; | ||||
| 	return $operator['istatus'] != 0 && $operator['time'] < Settings::get('online_timeout') ? "1" : ""; | ||||
| } | ||||
| 
 | ||||
| function operator_is_disabled($operator) | ||||
| @ -255,8 +252,6 @@ function notify_operator_alive($operatorid, $istatus) | ||||
| 
 | ||||
| function has_online_operators($groupid = "") | ||||
| { | ||||
| 	global $settings; | ||||
| 	loadsettings(); | ||||
| 	$db = Database::getInstance(); | ||||
| 
 | ||||
| 	$query = "select count(*) as total, min(unix_timestamp(CURRENT_TIMESTAMP)-unix_timestamp(dtmlastvisited)) as time from {chatoperator}"; | ||||
| @ -265,7 +260,7 @@ function has_online_operators($groupid = "") | ||||
| 			"({chatgroup}.groupid = :groupid or {chatgroup}.parent = :groupid) and {chatoperator}.operatorid = " . | ||||
| 			"{chatgroupoperator}.operatorid and istatus = 0"; | ||||
| 	} else { | ||||
| 		if ($settings['enablegroups'] == 1) { | ||||
| 		if (Settings::get('enablegroups') == 1) { | ||||
| 			$query .= ", {chatgroupoperator} where {chatoperator}.operatorid = " . | ||||
| 				"{chatgroupoperator}.operatorid and istatus = 0"; | ||||
| 		} else { | ||||
| @ -278,14 +273,11 @@ function has_online_operators($groupid = "") | ||||
| 		array(':groupid'=>$groupid), | ||||
| 		array('return_rows' => Database::RETURN_ONE_ROW) | ||||
| 	); | ||||
| 	return $row['time'] < $settings['online_timeout'] && $row['total'] > 0; | ||||
| 	return $row['time'] < Settings::get('online_timeout') && $row['total'] > 0; | ||||
| } | ||||
| 
 | ||||
| function is_operator_online($operatorid) | ||||
| { | ||||
| 	global $settings; | ||||
| 	loadsettings(); | ||||
| 	 | ||||
| 	$db = Database::getInstance(); | ||||
| 	$row = $db->query( | ||||
| 		"select count(*) as total, " . | ||||
| @ -295,7 +287,7 @@ function is_operator_online($operatorid) | ||||
| 		array('return_rows' => Database::RETURN_ONE_ROW) | ||||
| 	); | ||||
| 	 | ||||
| 	return $row['time'] < $settings['online_timeout'] && $row['total'] == 1; | ||||
| 	return $row['time'] < Settings::get('online_timeout') && $row['total'] == 1; | ||||
| } | ||||
| 
 | ||||
| function get_operator_name($operator) | ||||
| @ -384,8 +376,7 @@ function logout_operator() | ||||
| 
 | ||||
| function setup_redirect_links($threadid, $operator, $token) | ||||
| { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $page, $webimroot; | ||||
| 
 | ||||
| 	$operator_in_isolation = in_isolation($operator); | ||||
| 
 | ||||
| @ -395,7 +386,7 @@ function setup_redirect_links($threadid, $operator, $token) | ||||
| 
 | ||||
| 	$groupscount = 0; | ||||
| 	$groups = array(); | ||||
| 	if ($settings['enablegroups'] == "1") { | ||||
| 	if (Settings::get('enablegroups') == "1") { | ||||
| 		$groupslist = $operator_in_isolation?get_groups_for_operator($operator, true):get_groups(true); | ||||
| 		foreach ($groupslist as $group) { | ||||
| 			if ($group['inumofagents'] == 0) { | ||||
| @ -417,7 +408,7 @@ function setup_redirect_links($threadid, $operator, $token) | ||||
| 	$params = array('thread' => $threadid, 'token' => $token); | ||||
| 	foreach ($operators as $agent) { | ||||
| 		$params['nextAgent'] = $agent['operatorid']; | ||||
| 		$status = $agent['time'] < $settings['online_timeout'] | ||||
| 		$status = $agent['time'] < Settings::get('online_timeout') | ||||
| 				? ($agent['istatus'] == 0 | ||||
| 						? getlocal("char.redirect.operator.online_suff") | ||||
| 						: getlocal("char.redirect.operator.away_suff") | ||||
| @ -431,13 +422,13 @@ function setup_redirect_links($threadid, $operator, $token) | ||||
| 	$page['redirectToAgent'] = $agent_list; | ||||
| 
 | ||||
| 	$group_list = ""; | ||||
| 	if ($settings['enablegroups'] == "1") { | ||||
| 	if (Settings::get('enablegroups') == "1") { | ||||
| 		$params = array('thread' => $threadid, 'token' => $token); | ||||
| 		foreach ($groups as $group) { | ||||
| 			$params['nextGroup'] = $group['groupid']; | ||||
| 			$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] | ||||
| 			$status = $group['ilastseen'] !== NULL && $group['ilastseen'] < Settings::get('online_timeout') | ||||
| 					? getlocal("char.redirect.operator.online_suff") | ||||
| 					: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] | ||||
| 					: ($group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < Settings::get('online_timeout') | ||||
| 							? getlocal("char.redirect.operator.away_suff") | ||||
| 							: ""); | ||||
| 			$group_list .= "<li><a href=\"" . add_params($webimroot . "/operator/redirect.php", $params) . | ||||
| @ -473,19 +464,17 @@ function is_capable($perm, $operator) | ||||
| 
 | ||||
| function in_isolation($operator) | ||||
| { | ||||
| 	global $settings, $can_administrate; | ||||
| 	loadsettings(); | ||||
| 	return (!is_capable($can_administrate, $operator) && $settings['enablegroups'] && $settings['enablegroupsisolation']); | ||||
| 	global $can_administrate; | ||||
| 	return (!is_capable($can_administrate, $operator) && Settings::get('enablegroups') && Settings::get('enablegroupsisolation')); | ||||
| } | ||||
| 
 | ||||
| function prepare_menu($operator, $hasright = true) | ||||
| { | ||||
| 	global $page, $settings, $can_administrate; | ||||
| 	global $page, $can_administrate; | ||||
| 	$page['operator'] = topage(get_operator_name($operator)); | ||||
| 	if ($hasright) { | ||||
| 		loadsettings(); | ||||
| 		$page['showban'] = $settings['enableban'] == "1"; | ||||
| 		$page['showstat'] = $settings['enablestatistics'] == "1"; | ||||
| 		$page['showban'] = Settings::get('enableban') == "1"; | ||||
| 		$page['showstat'] = Settings::get('enablestatistics') == "1"; | ||||
| 		$page['showadmin'] = is_capable($can_administrate, $operator); | ||||
| 		$page['currentopid'] = $operator['operatorid']; | ||||
| 	} | ||||
|  | ||||
| @ -17,8 +17,7 @@ | ||||
| 
 | ||||
| function setup_operator_settings_tabs($opId, $active) | ||||
| { | ||||
| 	global $page, $webimroot, $settings; | ||||
| 	loadsettings(); | ||||
| 	global $page, $webimroot; | ||||
| 
 | ||||
| 	if ($opId) { | ||||
| 		$page['tabs'] = array( | ||||
|  | ||||
| @ -15,28 +15,16 @@ | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| function update_settings() | ||||
| { | ||||
| 	global $settings, $settings_in_db; | ||||
| 	$db = Database::getInstance(); | ||||
| 	foreach ($settings as $key => $value) { | ||||
| 		if (!isset($settings_in_db[$key])) { | ||||
| 			$db->query("insert into {chatconfig} (vckey) values (?)", array($key)); | ||||
| 		} | ||||
| 		$db->query("update {chatconfig} set vcvalue=? where vckey=?", array($value, $key)); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| function setup_settings_tabs($active) | ||||
| { | ||||
| 	global $settings, $page, $webimroot; | ||||
| 	global $page, $webimroot; | ||||
| 	$page['tabs'] = array( | ||||
| 		getlocal("page_settings.tab.main") => $active != 0 ? "$webimroot/operator/settings.php" : "", | ||||
| 		getlocal("page_settings.tab.features") => $active != 1 ? "$webimroot/operator/features.php" : "", | ||||
| 		getlocal("page_settings.tab.performance") => $active != 2 ? "$webimroot/operator/performance.php" : "", | ||||
| 		getlocal("page_settings.tab.themes") => $active != 3 ? "$webimroot/operator/themes.php" : "", | ||||
| 	); | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 		$page['tabs'][getlocal("page_settings.tab.invitationthemes")] = ($active != 4 ? "$webimroot/operator/invitationthemes.php" : ""); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -29,12 +29,12 @@ function get_statistics_query($type) | ||||
| 
 | ||||
| function setup_statistics_tabs($active) | ||||
| { | ||||
| 	global $settings, $page, $webimroot; | ||||
| 	global $page, $webimroot; | ||||
| 	$page['tabs'] = array( | ||||
| 		getlocal("report.bydate.title") => $active != 0 ? "$webimroot/operator/statistics.php".get_statistics_query('bydate') : "", | ||||
| 		getlocal("report.byoperator.title") => $active != 1 ? "$webimroot/operator/statistics.php".get_statistics_query('byagent') : "" | ||||
| 	); | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 		$page['tabs'][getlocal("report.bypage.title")] = ($active != 2 ? "$webimroot/operator/statistics.php".get_statistics_query('bypage') : ""); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -47,10 +47,16 @@ function get_useragent_version($userAgent) | ||||
| 
 | ||||
| function get_user_addr($addr) | ||||
| { | ||||
| 	global $settings; | ||||
| 	if ($settings['geolink'] && preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches)) { | ||||
| 	if (Settings::get('geolink') && preg_match("/(\\d+\\.\\d+\\.\\d+\\.\\d+)/", $addr, $matches)) { | ||||
| 		$userip = $matches[1]; | ||||
| 		return get_popup(str_replace("{ip}", $userip, $settings['geolink']), '', htmlspecialchars($addr), "GeoLocation", "ip$userip", $settings['geolinkparams']); | ||||
| 		return get_popup( | ||||
| 			str_replace("{ip}", $userip, Settings::get('geolink')), | ||||
| 			'', | ||||
| 			htmlspecialchars($addr), | ||||
| 			"GeoLocation", | ||||
| 			"ip$userip", | ||||
| 			Settings::get('geolinkparams') | ||||
| 		); | ||||
| 	} | ||||
| 	return htmlspecialchars($addr); | ||||
| } | ||||
|  | ||||
| @ -58,10 +58,8 @@ foreach( $output as $msg ) { | ||||
| 	$history .= $msg; | ||||
| } | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $subject = getstring("mail.user.history.subject"); | ||||
| $body = getstring2("mail.user.history.body", array($thread['userName'],$history,$settings['title'],$settings['hosturl']) ); | ||||
| $body = getstring2("mail.user.history.body", array($thread['userName'],$history,Settings::get('title'),Settings::get('hosturl')) ); | ||||
| 
 | ||||
| webim_mail($email, $webim_mailbox, $subject, $body); | ||||
| 
 | ||||
|  | ||||
| @ -25,8 +25,7 @@ require_once('../libs/expand.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| if ($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { | ||||
| if (Settings::get('enablessl') == "1" && Settings::get('forcessl') == "1") { | ||||
| 	if (!is_secure_request()) { | ||||
| 		$requested = $_SERVER['PHP_SELF']; | ||||
| 		if ($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) { | ||||
|  | ||||
| @ -48,10 +48,9 @@ if (!$op) { | ||||
| 
 | ||||
| 		$ext = strtolower(substr($orig_filename, 1 + strrpos($orig_filename, "."))); | ||||
| 		$new_file_name = "$opId.$ext"; | ||||
| 		loadsettings(); | ||||
| 
 | ||||
| 		$file_size = $_FILES['avatarFile']['size']; | ||||
| 		if ($file_size == 0 || $file_size > $settings['max_uploaded_file_size']) { | ||||
| 		if ($file_size == 0 || $file_size > Settings::get('max_uploaded_file_size')) { | ||||
| 			$errors[] = failed_uploading_file($orig_filename, "errors.file.size.exceeded"); | ||||
| 		} elseif (!in_array($ext, $valid_types)) { | ||||
| 			$errors[] = failed_uploading_file($orig_filename, "errors.invalid.file.type"); | ||||
|  | ||||
| @ -26,8 +26,6 @@ $operator = check_login(); | ||||
| force_password($operator); | ||||
| csrfchecktoken(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $errors = array(); | ||||
| $page = array(); | ||||
| 
 | ||||
|  | ||||
| @ -22,7 +22,6 @@ require_once('../libs/pagination.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| csrfchecktoken(); | ||||
| loadsettings(); | ||||
| 
 | ||||
| $stringid = verifyparam("key", "/^\d{0,9}$/", ""); | ||||
| 
 | ||||
|  | ||||
| @ -34,22 +34,21 @@ $options = array( | ||||
| 	'enablepopupnotification', 'showonlineoperators', | ||||
| 	'enablecaptcha'); | ||||
| 
 | ||||
| loadsettings(); | ||||
| if ($settings['featuresversion'] != $featuresversion) { | ||||
| 	$settings['featuresversion'] = $featuresversion; | ||||
| 	update_settings(); | ||||
| if (Settings::get('featuresversion') != $featuresversion) { | ||||
| 	Settings::set('featuresversion',$featuresversion); | ||||
| 	Settings::update(); | ||||
| } | ||||
| $params = array(); | ||||
| foreach ($options as $opt) { | ||||
| 	$params[$opt] = $settings[$opt]; | ||||
| 	$params[$opt] = Settings::get($opt); | ||||
| } | ||||
| 
 | ||||
| if (isset($_POST['sent'])) { | ||||
| 	if (is_capable($can_administrate, $operator)) { | ||||
| 		foreach ($options as $opt) { | ||||
| 			$settings[$opt] = verifyparam($opt, "/^on$/", "") == "on" ? "1" : "0"; | ||||
| 			Settings::set($opt,(verifyparam($opt, "/^on$/", "") == "on" ? "1" : "0")); | ||||
| 		} | ||||
| 		update_settings(); | ||||
| 		Settings::update(); | ||||
| 		header("Location: $webimroot/operator/features.php?stored"); | ||||
| 		exit; | ||||
| 	} else { | ||||
|  | ||||
| @ -24,8 +24,6 @@ require_once('../libs/styles.php'); | ||||
| $operator = check_login(); | ||||
| force_password($operator); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $imageLocales = get_image_locales_map("../locales"); | ||||
| $image = verifyparam(isset($_GET['image']) ? "image" : "i", "/^\w+$/", "webim"); | ||||
| if (!isset($imageLocales[$image])) { | ||||
| @ -84,7 +82,7 @@ $page['formhostname'] = $showhost; | ||||
| $page['formsecure'] = $forcesecure; | ||||
| $page['formmodsecurity'] = $modsecurity; | ||||
| 
 | ||||
| $page['enabletracking'] = $settings['enabletracking']; | ||||
| $page['enabletracking'] = Settings::get('enabletracking'); | ||||
| 
 | ||||
| prepare_menu($operator); | ||||
| start_html_output(); | ||||
|  | ||||
| @ -44,14 +44,12 @@ if (isset($_GET['act']) && $_GET['act'] == 'del') { | ||||
| 
 | ||||
| function is_online($group) | ||||
| { | ||||
| 	global $settings; | ||||
| 	return $group['ilastseen'] !== NULL && $group['ilastseen'] < $settings['online_timeout'] ? "1" : ""; | ||||
| 	return $group['ilastseen'] !== NULL && $group['ilastseen'] < Settings::get('online_timeout') ? "1" : ""; | ||||
| } | ||||
| 
 | ||||
| function is_away($group) | ||||
| { | ||||
| 	global $settings; | ||||
| 	return $group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < $settings['online_timeout'] ? "1" : ""; | ||||
| 	return $group['ilastseenaway'] !== NULL && $group['ilastseenaway'] < Settings::get('online_timeout') ? "1" : ""; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -24,8 +24,6 @@ require_once('../libs/pagination.php'); | ||||
| $operator = check_login(); | ||||
| force_password($operator); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| setlocale(LC_TIME, getstring("time.locale")); | ||||
| 
 | ||||
| $page = array(); | ||||
|  | ||||
| @ -21,17 +21,16 @@ require_once('../libs/operator.php'); | ||||
| $operator = check_login(); | ||||
| force_password($operator); | ||||
| 
 | ||||
| loadsettings(); | ||||
| $isonline = is_operator_online($operator['operatorid']); | ||||
| 
 | ||||
| $page = array( | ||||
| 	'version' => $version, | ||||
| 	'localeLinks' => get_locale_links("$webimroot/operator/index.php"), | ||||
| 	'needUpdate' => $settings['dbversion'] != $dbversion, | ||||
| 	'needUpdate' => Settings::get('dbversion') != $dbversion, | ||||
| 	'needChangePassword' => $operator['vcpassword'] == md5(''), | ||||
| 	'profilePage' => "$webimroot/operator/operator.php?op=".$operator['operatorid'], | ||||
| 	'updateWizard' => "$webimroot/install/", | ||||
| 	'newFeatures' => $settings['featuresversion'] != $featuresversion, | ||||
| 	'newFeatures' => Settings::get('featuresversion') != $featuresversion, | ||||
| 	'featuresPage' => "$webimroot/operator/features.php", | ||||
| 	'isOnline' => $isonline | ||||
| ); | ||||
|  | ||||
| @ -21,8 +21,6 @@ require_once('../libs/operator.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $visitorid = verifyparam("visitor", "/^\d{1,8}$/"); | ||||
| 
 | ||||
| $errors = array(); | ||||
|  | ||||
| @ -21,8 +21,6 @@ require_once('../libs/operator.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $visitorid = verifyparam("visitor", "/^\d{1,8}$/"); | ||||
| 
 | ||||
| if (!invitation_invite($visitorid, $operator['operatorid'])) { | ||||
| @ -31,7 +29,7 @@ if (!invitation_invite($visitorid, $operator['operatorid'])) { | ||||
| 
 | ||||
| $page = array(); | ||||
| $page['visitor'] = $visitorid; | ||||
| $page['frequency'] = $settings['updatefrequency_operator']; | ||||
| $page['frequency'] = Settings::get('updatefrequency_operator'); | ||||
| 
 | ||||
| start_html_output(); | ||||
| require('../view/invite.php'); | ||||
|  | ||||
| @ -31,10 +31,9 @@ $options = array( | ||||
| 	'updatefrequency_tracking', 'visitors_limit', 'invitation_lifetime', | ||||
| 	'tracking_lifetime', 'thread_lifetime' ); | ||||
| 
 | ||||
| loadsettings(); | ||||
| $params = array(); | ||||
| foreach ($options as $opt) { | ||||
| 	$params[$opt] = $settings[$opt]; | ||||
| 	$params[$opt] = Settings::get($opt); | ||||
| } | ||||
| 
 | ||||
| if (isset($_POST['onlinetimeout'])) { | ||||
| @ -68,7 +67,7 @@ if (isset($_POST['onlinetimeout'])) { | ||||
| 		$errors[] = getlocal("settings.wrong.threadlifetime"); | ||||
| 	} | ||||
| 
 | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 
 | ||||
| 	    $params['updatefrequency_tracking'] = getparam('frequencytracking'); | ||||
| 	    if (!is_numeric($params['updatefrequency_tracking'])) { | ||||
| @ -94,9 +93,9 @@ if (isset($_POST['onlinetimeout'])) { | ||||
| 
 | ||||
| 	if (count($errors) == 0) { | ||||
| 		foreach ($options as $opt) { | ||||
| 			$settings[$opt] = $params[$opt]; | ||||
| 			Settings::set($opt,$params[$opt]); | ||||
| 		} | ||||
| 		update_settings(); | ||||
| 		Settings::update(); | ||||
| 		header("Location: $webimroot/operator/performance.php?stored"); | ||||
| 		exit; | ||||
| 	} | ||||
| @ -110,7 +109,7 @@ $page['formthreadlifetime'] = $params['thread_lifetime']; | ||||
| $page['formonehostconnections'] = $params['max_connections_from_one_host']; | ||||
| $page['formthreadlifetime'] = $params['thread_lifetime']; | ||||
| 
 | ||||
| if ($settings['enabletracking']) { | ||||
| if (Settings::get('enabletracking')) { | ||||
| 
 | ||||
| 	$page['formfrequencytracking'] = $params['updatefrequency_tracking']; | ||||
| 	$page['formvisitorslimit'] = $params['visitors_limit']; | ||||
| @ -119,7 +118,7 @@ if ($settings['enabletracking']) { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| $page['enabletracking'] = $settings['enabletracking']; | ||||
| $page['enabletracking'] = Settings::get('enabletracking'); | ||||
| 
 | ||||
| $page['stored'] = isset($_GET['stored']); | ||||
| 
 | ||||
|  | ||||
| @ -33,16 +33,14 @@ $options = array( | ||||
| 	'email', 'title', 'logo', 'hosturl', 'usernamepattern', | ||||
| 	'chatstyle', 'chattitle', 'geolink', 'geolinkparams', 'sendmessagekey'); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| if ($settings['enabletracking']) { | ||||
| if (Settings::get('enabletracking')) { | ||||
| 	$options[] = 'invitationstyle'; | ||||
| 	$invitationstylelist = get_style_list("../styles/invitations"); | ||||
| } | ||||
| 
 | ||||
| $params = array(); | ||||
| foreach ($options as $opt) { | ||||
| 	$params[$opt] = $settings[$opt]; | ||||
| 	$params[$opt] = Settings::get($opt); | ||||
| } | ||||
| 
 | ||||
| if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { | ||||
| @ -61,7 +59,7 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { | ||||
| 		$params['chatstyle'] = $stylelist[0]; | ||||
| 	} | ||||
| 
 | ||||
| 	if ($settings['enabletracking']) { | ||||
| 	if (Settings::get('enabletracking')) { | ||||
| 		$params['invitationstyle'] = verifyparam("invitationstyle", "/^\w+$/", $params['invitationstyle']); | ||||
| 		if (!in_array($params['invitationstyle'], $invitationstylelist)) { | ||||
| 			$params['invitationstyle'] = $invitationstylelist[0]; | ||||
| @ -82,9 +80,9 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { | ||||
| 
 | ||||
| 	if (count($errors) == 0) { | ||||
| 		foreach ($options as $opt) { | ||||
| 			$settings[$opt] = $params[$opt]; | ||||
| 			Settings::set($opt,$params[$opt]); | ||||
| 		} | ||||
| 		update_settings(); | ||||
| 		Settings::update(); | ||||
| 		header("Location: $webimroot/operator/settings.php?stored"); | ||||
| 		exit; | ||||
| 	} | ||||
| @ -102,9 +100,9 @@ $page['formchattitle'] = topage($params['chattitle']); | ||||
| $page['formsendmessagekey'] = $params['sendmessagekey']; | ||||
| $page['availableChatStyles'] = $stylelist; | ||||
| $page['stored'] = isset($_GET['stored']); | ||||
| $page['enabletracking'] = $settings['enabletracking']; | ||||
| $page['enabletracking'] = Settings::get('enabletracking'); | ||||
| 
 | ||||
| if ($settings['enabletracking']) { | ||||
| if (Settings::get('enabletracking')) { | ||||
| 	$page['forminvitationstyle'] = $params['invitationstyle']; | ||||
| 	$page['availableInvitationStyles'] = $invitationstylelist; | ||||
| } | ||||
|  | ||||
| @ -48,7 +48,6 @@ if ($show == 'chat' || $show == 'mail' || $show == 'leavemessage' || $show == 'l | ||||
| 	exit; | ||||
| } | ||||
| if ($show == 'survey') { | ||||
| 	loadsettings(); | ||||
| 	setup_survey("Visitor", "", "", "", "http://google.com"); | ||||
| 	setup_logo(); | ||||
| 	expand("../styles/dialogs", "$preview", "$show.tpl"); | ||||
|  | ||||
| @ -24,7 +24,6 @@ $operator = check_login(); | ||||
| 
 | ||||
| $page = array(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| setlocale(LC_TIME, getstring("time.locale")); | ||||
| 
 | ||||
| function thread_info($id) | ||||
|  | ||||
| @ -22,10 +22,9 @@ require_once('../libs/track.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| 
 | ||||
| loadsettings(); | ||||
| setlocale(LC_TIME, getstring("time.locale")); | ||||
| 
 | ||||
| if ($settings['enabletracking'] == "0") { | ||||
| if (Settings::get('enabletracking') == "0") { | ||||
|     die("Tracking disabled!"); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -49,8 +49,7 @@ $threadstate_key = array( | ||||
| function thread_to_xml($thread) | ||||
| { | ||||
| 	global $state_chatting, $threadstate_to_string, $threadstate_key, | ||||
| 		$webim_encoding, $operator, $settings, | ||||
| 		$can_viewthreads, $can_takeover; | ||||
| 		$webim_encoding, $operator, $can_viewthreads, $can_takeover; | ||||
| 	$state = $threadstate_to_string[$thread['istate']]; | ||||
| 	$result = "<thread id=\"" . $thread['threadid'] . "\" stateid=\"$state\"";
 | ||||
| 	if ($state == "closed") | ||||
| @ -72,11 +71,11 @@ function thread_to_xml($thread) | ||||
| 		&& is_capable($can_viewthreads, $operator)) { | ||||
| 		$result .= " canview=\"true\""; | ||||
| 	} | ||||
| 	if ($settings['enableban'] == "1") { | ||||
| 	if (Settings::get('enableban') == "1") { | ||||
| 		$result .= " canban=\"true\""; | ||||
| 	} | ||||
| 
 | ||||
| 	$banForThread = $settings['enableban'] == "1" ? ban_for_addr($thread['remote']) : false; | ||||
| 	$banForThread = Settings::get('enableban') == "1" ? ban_for_addr($thread['remote']) : false; | ||||
| 	if ($banForThread) { | ||||
| 		$result .= " ban=\"blocked\" banid=\"" . $banForThread['banid'] . "\""; | ||||
| 	} | ||||
| @ -116,7 +115,7 @@ function thread_to_xml($thread) | ||||
| 
 | ||||
| function print_pending_threads($groupids, $since) | ||||
| { | ||||
| 	global $webim_encoding, $settings, $state_closed, $state_left; | ||||
| 	global $webim_encoding, $state_closed, $state_left; | ||||
| 	$db = Database::getInstance(); | ||||
| 
 | ||||
| 	$revision = $since; | ||||
| @ -127,7 +126,7 @@ function print_pending_threads($groupids, $since) | ||||
| 		($since <= 0 | ||||
| 			? "AND istate <> :state_closed AND istate <> :state_left " | ||||
| 			: "") . | ||||
| 		($settings['enablegroups'] == '1' | ||||
| 		(Settings::get('enablegroups') == '1' | ||||
| 			? "AND (groupid is NULL" . ($groupids | ||||
| 				? " OR groupid IN ($groupids) OR groupid IN (SELECT parent FROM {chatgroup} WHERE groupid IN ($groupids)) " | ||||
| 				: "") . | ||||
| @ -161,7 +160,7 @@ function print_pending_threads($groupids, $since) | ||||
| 
 | ||||
| function print_operators($operator) | ||||
| { | ||||
| 	global $webim_encoding, $settings; | ||||
| 	global $webim_encoding; | ||||
| 	echo "<operators>"; | ||||
| 
 | ||||
| 	$list_options = in_isolation($operator)?array('isolated_operator_id' => $operator['operatorid']):array(); | ||||
| @ -220,7 +219,7 @@ function visitor_to_xml($visitor) | ||||
| 
 | ||||
| function print_visitors() | ||||
| { | ||||
| 	global $webim_encoding, $settings, $state_closed, $state_left; | ||||
| 	global $webim_encoding, $state_closed, $state_left; | ||||
| 
 | ||||
| 	$db = Database::getInstance(); | ||||
| 
 | ||||
| @ -231,14 +230,14 @@ function print_visitors() | ||||
| 		"AND (threadid IS NULL OR " . | ||||
| 		"(SELECT count(*) FROM {chatthread} WHERE threadid = {chatsitevisitor}.threadid " . | ||||
| 		"AND istate <> {$state_closed} AND istate <> {$state_left}) = 0)", | ||||
| 		array($settings['tracking_lifetime']) | ||||
| 		array(Settings::get('tracking_lifetime')) | ||||
| 	); | ||||
| 
 | ||||
| // Remove old invitations
 | ||||
| 	$db->query( | ||||
| 		"UPDATE {chatsitevisitor} SET invited = 0, invitationtime = NULL, invitedby = NULL". | ||||
| 		" WHERE threadid IS NULL AND (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(invitationtime)) > ?", | ||||
| 		array($settings['invitation_lifetime']) | ||||
| 		array(Settings::get('invitation_lifetime')) | ||||
| 	); | ||||
| 
 | ||||
| // Remove associations of visitors with closed threads
 | ||||
| @ -252,7 +251,7 @@ function print_visitors() | ||||
| 	$db->query( | ||||
| 		"DELETE FROM {visitedpage} WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(visittime)) > ? " . | ||||
| 		" AND visitorid NOT IN (SELECT visitorid FROM {chatsitevisitor})", | ||||
| 		array($settings['tracking_lifetime']) | ||||
| 		array(Settings::get('tracking_lifetime')) | ||||
| 	); | ||||
| 
 | ||||
| 	$query = "SELECT visitorid, userid, username, unix_timestamp(firsttime), unix_timestamp(lasttime), " . | ||||
| @ -260,7 +259,7 @@ function print_visitors() | ||||
| 			 "FROM {chatsitevisitor} " . | ||||
| 			 "WHERE threadid IS NULL " . | ||||
| 			 "ORDER BY invited, lasttime DESC, invitations"; | ||||
| 	$query .= ($settings['visitors_limit'] == '0') ? "" : " LIMIT " . $settings['visitors_limit']; | ||||
| 	$query .= (Settings::get('visitors_limit') == '0') ? "" : " LIMIT " . Settings::get('visitors_limit'); | ||||
| 	 | ||||
| 	$rows = $db->query($query, NULL, array('return_rows' => Database::RETURN_ALL_ROWS)); | ||||
| 	 | ||||
| @ -282,7 +281,6 @@ $status = verifyparam("status", "/^\d{1,2}$/", 0); | ||||
| $showonline = verifyparam("showonline", "/^1$/", 0); | ||||
| $showvisitors = verifyparam("showvisitors", "/^1$/", 0); | ||||
| 
 | ||||
| loadsettings(); | ||||
| if (!isset($_SESSION["${mysqlprefix}operatorgroups"])) { | ||||
| 	$_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid']); | ||||
| } | ||||
|  | ||||
| @ -22,7 +22,6 @@ require_once('../libs/userinfo.php'); | ||||
| require_once('../libs/pagination.php'); | ||||
| 
 | ||||
| $operator = check_login(); | ||||
| loadsettings(); | ||||
| 
 | ||||
| $page = array(); | ||||
| 
 | ||||
|  | ||||
| @ -26,16 +26,15 @@ $status = isset($_GET['away']) ? 1 : 0; | ||||
| 
 | ||||
| notify_operator_alive($operator['operatorid'], $status); | ||||
| 
 | ||||
| loadsettings(); | ||||
| $_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid']); | ||||
| 
 | ||||
| $page = array(); | ||||
| $page['havemenu'] = isset($_GET['nomenu']) ? "0" : "1"; | ||||
| $page['showpopup'] = $settings['enablepopupnotification'] == '1' ? "1" : "0"; | ||||
| $page['frequency'] = $settings['updatefrequency_operator']; | ||||
| $page['showpopup'] = Settings::get('enablepopupnotification') == '1' ? "1" : "0"; | ||||
| $page['frequency'] = Settings::get('updatefrequency_operator'); | ||||
| $page['istatus'] = $status; | ||||
| $page['showonline'] = $settings['showonlineoperators'] == '1' ? "1" : "0"; | ||||
| $page['showvisitors'] = $settings['enabletracking'] == '1' ? "1" : "0"; | ||||
| $page['showonline'] = Settings::get('showonlineoperators') == '1' ? "1" : "0"; | ||||
| $page['showvisitors'] = Settings::get('enabletracking') == '1' ? "1" : "0"; | ||||
| 
 | ||||
| prepare_menu($operator); | ||||
| start_html_output(); | ||||
|  | ||||
| @ -21,11 +21,9 @@ require_once('libs/operator.php'); | ||||
| require_once('libs/track.php'); | ||||
| require_once('libs/request.php'); | ||||
| 
 | ||||
| loadsettings(); | ||||
| 
 | ||||
| $invited = FALSE; | ||||
| $operator = array(); | ||||
| if ($settings['enabletracking'] == '1') { | ||||
| if (Settings::get('enabletracking') == '1') { | ||||
| 
 | ||||
|     $entry = isset($_GET['entry']) ? $_GET['entry'] : ""; | ||||
|     $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""; | ||||
|  | ||||
| @ -82,8 +82,7 @@ if( $act == "refresh" ) { | ||||
| 
 | ||||
| } else if( $act == "rename" ) { | ||||
| 
 | ||||
| 	loadsettings(); | ||||
| 	if( $settings['usercanchangename'] != "1" ) { | ||||
| 	if( Settings::get('usercanchangename') != "1" ) { | ||||
| 		show_error("server: forbidden to change name"); | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user