mirror of
				https://github.com/Mibew/design.git
				synced 2025-10-31 18:41:05 +03:00 
			
		
		
		
	Added closing threads by timeout
This commit is contained in:
		
							parent
							
								
									36a2d977a0
								
							
						
					
					
						commit
						323a7f2fcd
					
				| @ -552,6 +552,21 @@ function close_thread($thread, $isuser) | ||||
| 	mysql_close($link); | ||||
| } | ||||
| 
 | ||||
| function close_old_threads($link) | ||||
| { | ||||
| 	global $state_closed, $state_left, $state_chatting, $mysqlprefix, $settings; | ||||
| 	if ($settings['thread_lifetime'] == 0) { | ||||
| 		return; | ||||
| 	} | ||||
| 	$next_revision = next_revision($link); | ||||
| 	$query = "update ${mysqlprefix}chatthread set lrevision =  $next_revision, dtmmodified = CURRENT_TIMESTAMP, istate = $state_closed " . | ||||
| 			"where istate <> $state_closed and istate <> $state_left and  " . | ||||
| 			"(ABS(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(lastpinguser)) > " . $settings['thread_lifetime'] . " and " . | ||||
| 			"ABS(UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(lastpingagent)) > " . $settings['thread_lifetime'] . ")"; | ||||
| 
 | ||||
| 	perform_query($query, $link); | ||||
| } | ||||
| 
 | ||||
| function thread_by_id_($id, $link) | ||||
| { | ||||
| 	global $mysqlprefix; | ||||
| @ -611,13 +626,18 @@ function do_take_thread($threadid, $operatorId, $operatorName) | ||||
| 
 | ||||
| function reopen_thread($threadid) | ||||
| { | ||||
| 	global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events; | ||||
| 	global $state_queue, $state_loading, $state_waiting, $state_chatting, $state_closed, $state_left, $kind_events, $settings; | ||||
| 	$link = connect(); | ||||
| 
 | ||||
| 	$thread = thread_by_id_($threadid, $link); | ||||
| 
 | ||||
| 	if (!$thread) | ||||
| 		return FALSE; | ||||
| 
 | ||||
| 	if ($settings['thread_lifetime'] != 0 && abs($thread['lpuser'] - time()) > $settings['thread_lifetime'] && abs($thread['lpagent'] - time()) > $settings['thread_lifetime']) { | ||||
| 		return FALSE; | ||||
| 	} | ||||
| 
 | ||||
| 	if ($thread['istate'] == $state_closed || $thread['istate'] == $state_left) | ||||
| 		return FALSE; | ||||
| 
 | ||||
| @ -737,4 +757,4 @@ function get_remote_host() | ||||
| 	return isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr; | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
| ?>
 | ||||
|  | ||||
| @ -615,6 +615,7 @@ $settings = array( | ||||
| 	'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, | ||||
|  | ||||
| @ -468,12 +468,15 @@ settings.survey.askmail=Ask for visitor's email | ||||
| settings.survey.askmessage.description=Show/hide initial question field in the survey | ||||
| settings.survey.askmessage=Show initial question field | ||||
| settings.title=Messenger settings | ||||
| settings.threadlifetime.description=Specify the lifetime of the thread after closing the dialog box in seconds. Default is 600 seconds. Set 0 for unlimited thread lifetime. | ||||
| settings.threadlifetime=Thread lifetime | ||||
| settings.usercanchangename.description=Turn off to hide edit box from chat window | ||||
| settings.usercanchangename=Allows users to change their names | ||||
| settings.usernamepattern.description=How to build visitor's identifying string from {name}, {id} or {addr}. Default: {name} | ||||
| settings.usernamepattern=Visitor's identifier | ||||
| settings.wrong.email=Enter a valid email address | ||||
| settings.wrong.onehostconnections="Max number of threads" field should be a number | ||||
| settings.wrong.threadlifetime="Thread lifetime" field should be a number | ||||
| site.title=mibew.org | ||||
| site.url=http://mibew.org | ||||
| statistics.dates=Select dates | ||||
|  | ||||
| @ -458,12 +458,15 @@ settings.survey.askmail= | ||||
| settings.survey.askmessage.description=Показать/спрятать поле ввода первого вопроса | ||||
| settings.survey.askmessage=Предлагать сразу же задать вопрос | ||||
| settings.title=Настройки мессенджера | ||||
| settings.threadlifetime.description=Укажите время жизни диалога после закрытия диалогового окна в секундах. По умолчанию, 600 секунд. Укажите 0 для снятия ограничения. | ||||
| settings.threadlifetime=Время жизни диалога | ||||
| settings.usercanchangename.description=Возможность убрать поле смены имени из чат окна | ||||
| settings.usercanchangename=Разрешать посетителям менять имена | ||||
| settings.usernamepattern.description=Укажите как отобразить имя посетителя операторам. Можно использовать {name}, {id} и {addr}. По умолчанию: {name} | ||||
| settings.usernamepattern=Отображаемое имя посетителя | ||||
| settings.wrong.email=Введите правильный адрес электронной почты | ||||
| settings.wrong.onehostconnections=Поле "Максимальное количество диалогов" должно быть числом | ||||
| settings.wrong.threadlifetime=Поле "Время жизни диалога" должно быть числом | ||||
| site.title=mibew.org | ||||
| site.url=http://mibew.org | ||||
| statistics.dates=Выберите даты | ||||
|  | ||||
| @ -30,7 +30,7 @@ $errors = array(); | ||||
| 
 | ||||
| $options = array( | ||||
| 	'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat', | ||||
| 	'updatefrequency_oldchat', 'max_connections_from_one_host'); | ||||
| 	'updatefrequency_oldchat', 'max_connections_from_one_host', 'thread_lifetime'); | ||||
| 
 | ||||
| loadsettings(); | ||||
| $params = array(); | ||||
| @ -64,6 +64,11 @@ if (isset($_POST['onlinetimeout'])) { | ||||
| 		$errors[] = getlocal("settings.wrong.onehostconnections"); | ||||
| 	} | ||||
| 
 | ||||
| 	$params['thread_lifetime'] = getparam('threadlifetime'); | ||||
| 	if (!is_numeric($params['thread_lifetime'])) { | ||||
| 		$errors[] = getlocal("settings.wrong.threadlifetime"); | ||||
| 	} | ||||
| 
 | ||||
| 	if (count($errors) == 0) { | ||||
| 		foreach ($options as $opt) { | ||||
| 			$settings[$opt] = $params[$opt]; | ||||
| @ -78,6 +83,7 @@ $page['formonlinetimeout'] = $params['online_timeout']; | ||||
| $page['formfrequencyoperator'] = $params['updatefrequency_operator']; | ||||
| $page['formfrequencychat'] = $params['updatefrequency_chat']; | ||||
| $page['formfrequencyoldchat'] = $params['updatefrequency_oldchat']; | ||||
| $page['formthreadlifetime'] = $params['thread_lifetime']; | ||||
| $page['formonehostconnections'] = $params['max_connections_from_one_host']; | ||||
| $page['stored'] = isset($_GET['stored']); | ||||
| 
 | ||||
|  | ||||
| @ -177,6 +177,7 @@ loadsettings_($link); | ||||
| if (!isset($_SESSION["${mysqlprefix}operatorgroups"])) { | ||||
| 	$_SESSION["${mysqlprefix}operatorgroups"] = get_operator_groupslist($operator['operatorid'], $link); | ||||
| } | ||||
| close_old_threads($link); | ||||
| mysql_close($link); | ||||
| $groupids = $_SESSION["${mysqlprefix}operatorgroups"]; | ||||
| 
 | ||||
|  | ||||
| @ -90,6 +90,15 @@ require_once('inc_errors.php'); | ||||
| 			<br clear="all"/> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="field"> | ||||
| 			<div class="flabel"><?php echo getlocal('settings.threadlifetime') ?></div>
 | ||||
| 			<div class="fvalue"> | ||||
| 				<input type="text" name="threadlifetime" size="40" value="<?php echo form_value('threadlifetime') ?>" class="formauth"/> | ||||
| 			</div> | ||||
| 			<div class="fdescr"> — <?php echo getlocal('settings.threadlifetime.description') ?></div>
 | ||||
| 			<br clear="all"/> | ||||
| 		</div> | ||||
| 		 | ||||
| 		<div class="fbutton"> | ||||
| 			<input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/> | ||||
| 		</div> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user