mirror of
				https://github.com/Mibew/i18n.git
				synced 2025-11-01 01:36:57 +03:00 
			
		
		
		
	Add an ability to run cron job
This commit is contained in:
		
							parent
							
								
									2f89219756
								
							
						
					
					
						commit
						db1b51ae8a
					
				
							
								
								
									
										31
									
								
								src/messenger/webim/cron.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/messenger/webim/cron.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| <?php | ||||
| /* | ||||
|  * Copyright 2005-2013 the original author or authors. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *     http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| require_once('libs/init.php'); | ||||
| 
 | ||||
| $cron_key = empty($_GET['cron_key']) ? '' : $_GET['cron_key']; | ||||
| 
 | ||||
| // Check cron security key
 | ||||
| if ($cron_key != Settings::get('cron_key')) { | ||||
| 	die(); | ||||
| } | ||||
| 
 | ||||
| // Trigger cron event
 | ||||
| $dispatcher = EventDispatcher::getInstance(); | ||||
| $dispatcher->triggerEvent('cronRun'); | ||||
| 
 | ||||
| ?>
 | ||||
| @ -52,9 +52,11 @@ Class Settings { | ||||
| 	/** | ||||
| 	 * Settings class constructor. Set default values and load setting from database. | ||||
| 	 * @global $home_locale Specifies home locale. Defined in libs/config.php | ||||
| 	 * @global $default_cron_key Default value for cron security key. Defined | ||||
| 	 * in libs/common/constants.php | ||||
| 	 */ | ||||
| 	protected function __construct() { | ||||
| 		global $home_locale; | ||||
| 		global $home_locale, $default_cron_key; | ||||
| 		// Set default values
 | ||||
| 		$this->settings = array( | ||||
| 			'dbversion' => 0, | ||||
| @ -100,6 +102,8 @@ Class Settings { | ||||
| 			'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 */ | ||||
| 
 | ||||
| 			'cron_key' => $default_cron_key | ||||
| 		); | ||||
| 
 | ||||
| 		// Load values from database
 | ||||
|  | ||||
| @ -36,6 +36,15 @@ $featuresversion = '1.6.4'; | ||||
|  */ | ||||
| $session_prefix = md5($mysqlhost.'##'.$mysqldb.'##'.$mysqlprefix) . '_'; | ||||
| 
 | ||||
| /** | ||||
|  * Default value for cron security key. | ||||
|  * Another value can be set at operator/settings.php page. | ||||
|  */ | ||||
| $default_cron_key = md5( | ||||
| 	$mysqlhost . '##' . $mysqldb . '##' . $mysqllogin. '##' . | ||||
| 	$mysqlpass . '##' . $mysqlprefix . '##' | ||||
| ); | ||||
| 
 | ||||
| /** | ||||
|  * Name for cookie to track visitor | ||||
|  */ | ||||
|  | ||||
| @ -487,6 +487,8 @@ settings.chatstyle.description=A preview all pages for each style is available < | ||||
| settings.chatstyle=Select a style for your chat windows | ||||
| settings.company.title.description=Enter your company title | ||||
| settings.company.title=Company title | ||||
| settings.cronkey=Cron security key | ||||
| settings.cronkey.description=To run cron use link <a href="{0}">{0}</a>. | ||||
| settings.email.description=Enter an email to receive system messages | ||||
| settings.email=Email | ||||
| settings.enableban.description=Using it you can block attacks from specific IPs | ||||
| @ -555,6 +557,7 @@ settings.usernamepattern.description=How to build visitor's identifying string f | ||||
| settings.usernamepattern=Visitor's identifier | ||||
| settings.visitorslimit.description=Specify the number of items to display in tracked visitors list. Default is 20. Set 0 for all visitors (not recommended). | ||||
| settings.visitorslimit=Limit for tracked visitors list | ||||
| settings.wrong.cronkey=Use only Latin letters(upper and lower case) and numbers in cron key. | ||||
| 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 | ||||
|  | ||||
| @ -486,6 +486,8 @@ settings.chatstyle.description= | ||||
| settings.chatstyle=Выберите вид вашего чат окна | ||||
| settings.company.title.description=Введите название Вашей компании | ||||
| settings.company.title=Название компании | ||||
| settings.cronkey=Ключ безопасности cron | ||||
| settings.cronkey.description=Для запуска cron используйте ссылку <a href="{0}">{0}</a>. | ||||
| settings.email.description=Введите адрес электронной почты для получения сообщений от системы | ||||
| settings.email=Адрес электронной почты | ||||
| settings.enableban.description=С ее помощью можно блокировать атаки с определенных адресов | ||||
| @ -557,6 +559,7 @@ settings.usernamepattern.description= | ||||
| settings.usernamepattern=Отображаемое имя посетителя | ||||
| settings.visitorslimit.description=Укажите количество выводимых в списке отслеживаемых посетителей сайта. По умолчанию, 20. Укажите 0 для снятия ограничения (не рекомендуется). | ||||
| settings.visitorslimit=Ограничение на число выводимых в списке отслеживаемых посетителей | ||||
| settings.wrong.cronkey=Используйте только Латинские буквы(верхнего и нижнего регистра) и цифры в ключе безопасности cron. | ||||
| settings.wrong.email=Введите правильный адрес электронной почты | ||||
| settings.wrong.onehostconnections=Поле "Максимальное количество диалогов" должно быть числом | ||||
| settings.wrong.threadlifetime=Поле "Время жизни диалога" должно быть числом | ||||
|  | ||||
| @ -31,7 +31,8 @@ $stylelist = get_style_list("../styles/dialogs"); | ||||
| 
 | ||||
| $options = array( | ||||
| 	'email', 'title', 'logo', 'hosturl', 'usernamepattern', | ||||
| 	'chatstyle', 'chattitle', 'geolink', 'geolinkparams', 'sendmessagekey'); | ||||
| 	'chatstyle', 'chattitle', 'geolink', 'geolinkparams', | ||||
| 	'sendmessagekey', 'cron_key'); | ||||
| 
 | ||||
| if (Settings::get('enabletracking')) { | ||||
| 	$options[] = 'invitationstyle'; | ||||
| @ -53,6 +54,7 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { | ||||
| 	$params['geolink'] = getparam('geolink'); | ||||
| 	$params['geolinkparams'] = getparam('geolinkparams'); | ||||
| 	$params['sendmessagekey'] = verifyparam('sendmessagekey', "/^c?enter$/"); | ||||
| 	$params['cron_key'] = getparam('cronkey'); | ||||
| 
 | ||||
| 	$params['chatstyle'] = verifyparam("chatstyle", "/^\w+$/", $params['chatstyle']); | ||||
| 	if (!in_array($params['chatstyle'], $stylelist)) { | ||||
| @ -78,6 +80,10 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (preg_match("/^[0-9A-z]*$/", $params['cron_key']) == 0) { | ||||
| 		$errors[] = getlocal("settings.wrong.cronkey"); | ||||
| 	} | ||||
| 
 | ||||
| 	if (count($errors) == 0) { | ||||
| 		foreach ($options as $opt) { | ||||
| 			Settings::set($opt,$params[$opt]); | ||||
| @ -101,6 +107,15 @@ $page['formsendmessagekey'] = $params['sendmessagekey']; | ||||
| $page['availableChatStyles'] = $stylelist; | ||||
| $page['stored'] = isset($_GET['stored']); | ||||
| $page['enabletracking'] = Settings::get('enabletracking'); | ||||
| $page['formcronkey'] = $params['cron_key']; | ||||
| 
 | ||||
| $page['cron_path'] = (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') | ||||
| 	? 'http://' | ||||
| 	: 'https://'; | ||||
| $page['cron_path'] .= $_SERVER['SERVER_NAME'] . $webimroot . '/cron.php'; | ||||
| $page['cron_path'] .= empty($params['cron_key']) | ||||
| 	? '' | ||||
| 	: '?cron_key='.$params['cron_key']; | ||||
| 
 | ||||
| if (Settings::get('enabletracking')) { | ||||
| 	$page['forminvitationstyle'] = $params['invitationstyle']; | ||||
|  | ||||
| @ -113,6 +113,15 @@ require_once('inc_errors.php'); | ||||
| 			<br clear="all"/> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="field"> | ||||
| 			<div class="flabel"><?php echo getlocal('settings.cronkey') ?></div>
 | ||||
| 			<div class="fvalue"> | ||||
| 				<input type="text" name="cronkey" size="40" value="<?php echo form_value('cronkey') ?>" class="formauth"/> | ||||
| 			</div> | ||||
| 			<div class="fdescr"> — <?php echo getlocal2('settings.cronkey.description', array($page['cron_path'])) ?></div>
 | ||||
| 			<br clear="all"/> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="field"> | ||||
| 			<div class="flabel"><?php echo getlocal('settings.chatstyle') ?></div>
 | ||||
| 			<div class="fvalue"> | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user