示例#1
0
	public static function Get($userId, $reOpen = false)
	{
		global $DB;
		$nginxStatus = CPullOptions::GetNginxStatus();
		$webSocketStatus = CPullOptions::GetWebSocketStatus();

		CTimeZone::Disable();
		$strSql = "
				SELECT CHANNEL_ID, LAST_ID, ".$DB->DateToCharFunction('DATE_CREATE')." DATE_CREATE
				FROM b_pull_channel
				WHERE USER_ID = ".intval($userId);
		CTimeZone::Enable();

		$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
		if ($arRes = $dbRes->Fetch())
		{
			if (MakeTimeStamp($arRes['DATE_CREATE'])+43200 > time())
			{
				if ($nginxStatus && $reOpen)
				{
					$arData = Array(
						'module_id' => 'pull',
						'command' => 'reopen',
						'params' => Array(),
					);
					$channelId = $arRes['CHANNEL_ID'];
					$CHTTP = new CHTTP();
					$CHTTP->http_timeout = 10;
					$CHTTP->HTTPQuery('POST', CPullOptions::GetPublishUrl($channelId), CUtil::PhpToJsObject(Array('MESSAGE' => Array($arData), 'ERROR' => '')));
				}

				return Array(
					'CHANNEL_ID' => $arRes['CHANNEL_ID'],
					'CHANNEL_DT' => MakeTimeStamp($arRes['DATE_CREATE']),
					'LAST_ID' => intval($arRes['LAST_ID']),
					'PATH' => ($nginxStatus? CPullOptions::GetListenUrl($arRes['CHANNEL_ID']): '/bitrix/components/bitrix/pull.request/ajax.php'),
					'PATH_WS' => ($nginxStatus && $webSocketStatus? CPullOptions::GetWebSocketUrl($arRes['CHANNEL_ID']): ''),
					'METHOD' => ($nginxStatus? 'LONG': 'PULL'),
				);
			}
			else
			{
				self::Delete($arRes['CHANNEL_ID']);
			}
		}

		$channelId = self::Add($userId);
		return $channelId? Array(
			'CHANNEL_ID' => $channelId,
			'CHANNEL_DT' => time(),
			'LAST_ID' => 0,
			'PATH' => ($nginxStatus? CPullOptions::GetListenUrl($channelId): '/bitrix/components/bitrix/pull.request/ajax.php'),
			'PATH_WS' => ($nginxStatus && $webSocketStatus? CPullOptions::GetWebSocketUrl($channelId): ''),
			'METHOD' => ($nginxStatus? 'LONG': 'PULL')
		): false;
	}
 /**
  * Return some information about P&P, such as publish url
  *
  * @since 14.5.4
  * @return array
  */
 protected static function getPullingInfo()
 {
     $result = array('enabled' => CModule::IncludeModule('pull') && CPullOptions::ModuleEnable());
     if ($result['enabled']) {
         $result['nginx_used'] = CPullOptions::GetQueueServerStatus();
         if ($result['nginx_used']) {
             $result['server_protocol'] = CPullOptions::GetQueueServerVersion();
             $result['publish_url'] = CPullOptions::GetPublishUrl();
             $result['pulling_url'] = CPullOptions::GetListenUrl();
             $result['pulling_url_secure'] = CPullOptions::GetListenSecureUrl();
             $result['websocket_url'] = CPullOptions::GetWebSocketUrl();
             $result['websocket_url_secure'] = CPullOptions::GetWebSocketSecureUrl();
         }
     }
     return $result;
 }
	public static function GetConfig($userId, $cache = true, $reopen = false, $mobile = false)
	{
		$pullConfig = Array();

		if (defined('BX_PULL_SKIP_LS'))
			$pullConfig['LOCAL_STORAGE'] = 'N';

		if (IsModuleInstalled('bitrix24'))
			$pullConfig['BITRIX24'] = 'Y';

		$arChannel = CPullChannel::Get($userId, $cache, $reopen);
		if (is_array($arChannel))
		{
			$nginxStatus = CPullOptions::GetQueueServerStatus();
			$webSocketStatus = false;

			$arChannels = Array($arChannel['CHANNEL_ID']);
			if ($nginxStatus)
			{
				if (defined('BX_PULL_SKIP_WEBSOCKET'))
				{
					$pullConfig['WEBSOCKET'] = 'N';
				}
				else
				{
					$webSocketStatus = CPullOptions::GetWebSocketStatus();
				}

				$arChannelShared = CPullChannel::GetShared($cache, $reopen);
				if (is_array($arChannelShared))
				{
					$arChannels[] = $arChannelShared['CHANNEL_ID'];
					$arChannel['CHANNEL_DT'] = $arChannel['CHANNEL_DT'].'/'.$arChannelShared['CHANNEL_DT'];
				}
			}
			if ($mobile || defined('BX_MOBILE') || defined('BX_PULL_MOBILE'))
			{
				$pullConfig['MOBILE'] = 'Y';
				$pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE');
			}
			else
			{
				$pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels): CPullOptions::GetListenUrl($arChannels)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE');
			}

			$pullPathWs = ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): '');

			return $pullConfig+Array(
				'CHANNEL_ID' => implode('/', $arChannels),
				'CHANNEL_DT' => $arChannel['CHANNEL_DT'],
				'LAST_ID' => $arChannel['LAST_ID'],
				'PATH' => $pullPath,
				'PATH_WS' => $pullPathWs,
				'PATH_COMMAND' => defined('BX_PULL_COMMAND_PATH')? BX_PULL_COMMAND_PATH: '',
				'METHOD' => ($nginxStatus? 'LONG': 'PULL'),
				'REVISION' => PULL_REVISION,
				'ERROR' => '',
			);
		}
		return false;
	}
示例#4
0
文件: ajax.php 项目: ASDAFF/entask.ru
			$arChannels = Array($arChannel['CHANNEL_ID']);
			if ($nginxStatus)
			{
				$arChannelShared = CPullChannel::GetShared($_POST['CACHE'] == 'Y'? true: false, $_POST['CACHE'] == 'Y'? false: true);
				if ($arChannelShared)
				{
					$arChannels[] = $arChannelShared['CHANNEL_ID'];
					if ($arChannel['CHANNEL_DT'] > $arChannelShared['CHANNEL_DT'])
						$arChannel['CHANNEL_DT'] = $arChannelShared['CHANNEL_DT'];
				}
			}
			if ($_POST['MOBILE'] == 'Y')
				$pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels, true): CPullOptions::GetListenUrl($arChannels, true)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE');
			else
				$pullPath = ($nginxStatus? (CMain::IsHTTPS()? CPullOptions::GetListenSecureUrl($arChannels): CPullOptions::GetListenUrl($arChannels)): '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE');

			echo CUtil::PhpToJsObject(Array(
				'CHANNEL_ID' => implode('/', $arChannels),
				'CHANNEL_DT' => $arChannel['CHANNEL_DT'],
				'LAST_ID' => $pullChannel['LAST_ID'],
				'PATH' => $pullPath,
				'PATH_WS' => ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): ''),
				'METHOD' => ($nginxStatus? 'LONG': 'PULL'),
				'REVISION' => PULL_REVISION,
				'ERROR' => '',
			));
		}
		else
			echo CUtil::PhpToJsObject(Array('ERROR' => 'ERROR_OPEN_CHANNEL'));
	}
示例#5
0
<?endif;?>
	<tr>
		<td width="40%"></td>
		<td width="60%"></td>
	</tr>
	<tr>
		<td width="40%"><nobr><?=GetMessage("PULL_OPTIONS_NGINX")?></nobr>:</td>
		<td width="60%"><input id="config_nginx" type="checkbox" size="40" value="Y" <?=(CPullOptions::GetNginxStatus()?' checked':'')?> name="nginx"></td>
	</tr>
	<tr>
		<td><?=GetMessage("PULL_OPTIONS_PATH_TO_PUBLISH")?>:</td>
		<td><input id="config_path_to_publish" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetPublishUrl())?>" name="path_to_publish" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_LISTENER")?>:</td>
		<td><input id="config_path_to_listener" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenUrl())?>" name="path_to_listener" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<?/*
	<tr>
		<td width="40%"><nobr><?=GetMessage("PULL_OPTIONS_WEBSOCKET")?></nobr>:</td>
		<td width="60%"><input id="config_websocket" type="checkbox" size="40" value="Y" <?=(CPullOptions::GetWebSocketStatus()?' checked':'')?> name="websocket" <?=(CPullOptions::GetNginxStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_WEBSOCKET")?>:</td>
		<td><input id="config_path_to_websocket" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetWebSocketUrl())?>" name="path_to_websocket" <?=(!CPullOptions::GetNginxStatus() || !CPullOptions::GetWebSocketStatus() ? 'disabled="true"': '')?></td>
	</tr>
	*/?>
<?if (IsModuleInstalled('mobileapp')):?>
	<tr>
		<td align="right" width="50%"><?=GetMessage("PULL_OPTIONS_PUSH")?>:</td>
		<td><input type="checkbox" size="40" value="Y" <?=(CPullOptions::GetPushStatus()?' checked':'')?> name="push"></td>
示例#6
0
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_LISTENER")?>:</td>
		<td><input id="config_path_to_listener" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenUrl())?>" name="path_to_listener" <?=(CPullOptions::GetQueueServerStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_LISTENER_SECURE")?>:</td>
		<td><input id="config_path_to_listener_secure" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenSecureUrl())?>" name="path_to_listener_secure" <?=(CPullOptions::GetQueueServerStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td width="40%"></td>
		<td width="60%">
			<?=GetMessage("PULL_OPTIONS_PATH_TO_LISTENER_DESC")?>
		</td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_MOBILE_LISTENER")?>:</td>
		<td><input id="config_path_to_mobile_listener" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenUrl("", true))?>" name="path_to_mobile_listener" <?=(CPullOptions::GetQueueServerStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td ><?=GetMessage("PULL_OPTIONS_PATH_TO_MOBILE_LISTENER_SECURE")?>:</td>
		<td><input id="config_path_to_mobile_listener_secure" type="text" size="40" value="<?=htmlspecialcharsbx(CPullOptions::GetListenSecureUrl("", true))?>" name="path_to_mobile_listener_secure" <?=(CPullOptions::GetQueueServerStatus()? '':'disabled="true"')?>></td>
	</tr>
	<tr>
		<td width="40%"></td>
		<td width="60%">
			<?=GetMessage("PULL_OPTIONS_PATH_TO_MOBILE_LISTENER_DESC")?>
		</td>
	</tr>
	<tr>
		<td width="40%"></td>
		<td width="60%"></td>
	</tr>
示例#7
0
?>
		</td>
	</tr>
	<tr class="heading">
		<td colspan="2"><b><?php 
echo GetMessage('PULL_OPTIONS_HEAD_SUB_MOB');
?>
</b></td>
	</tr>
	<tr>
		<td ><?php 
echo GetMessage("PULL_OPTIONS_PATH_TO_LISTENER");
?>
:</td>
		<td><input id="config_path_to_mobile_listener" type="text" size="40" value="<?php 
echo htmlspecialcharsbx(CPullOptions::GetListenUrl("", true));
?>
" name="path_to_mobile_listener" <?php 
echo CPullOptions::GetQueueServerStatus() ? '' : 'disabled="true"';
?>
></td>
	</tr>
	<tr>
		<td ><?php 
echo GetMessage("PULL_OPTIONS_PATH_TO_LISTENER_SECURE");
?>
:</td>
		<td><input id="config_path_to_mobile_listener_secure" type="text" size="40" value="<?php 
echo htmlspecialcharsbx(CPullOptions::GetListenSecureUrl("", true));
?>
" name="path_to_mobile_listener_secure" <?php 
示例#8
0
		<td width="40%"><nobr><?php 
echo GetMessage("PULL_OPTIONS_NGINX");
?>
</nobr>:</td>
		<td width="60%"><input id="config_nginx" type="checkbox" size="40" value="Y" <?php 
echo CPullOptions::GetNginxStatus() ? ' checked' : '';
?>
 name="nginx"></td>
	</tr>
	<tr>
		<td ><?php 
echo GetMessage("PULL_OPTIONS_PATH_TO_LISTENER");
?>
:</td>
		<td><input id="config_path_to_listener" type="text" size="40" value="<?php 
echo CPullOptions::GetListenUrl();
?>
" name="path_to_listener" <?php 
echo CPullOptions::GetNginxStatus() ? '' : 'disabled="true"';
?>
></td>
	</tr>
	<tr>
		<td><?php 
echo GetMessage("PULL_OPTIONS_PATH_TO_PUBLISH");
?>
:</td>
		<td><input id="config_path_to_publish" type="text" size="40" value="<?php 
echo CPullOptions::GetPublishUrl();
?>
" name="path_to_publish" <?php 
示例#9
0
 public static function GetUserConfig($userId)
 {
     $pullConfig = array();
     if (defined('BX_PULL_SKIP_LS')) {
         $pullConfig['LOCAL_STORAGE'] = 'N';
     }
     if (IsModuleInstalled('bitrix24')) {
         $pullConfig['BITRIX24'] = 'Y';
     }
     $pullChannel = CPullChannel::Get($userId);
     if (is_array($pullChannel)) {
         $pullWebSocketStatus = false;
         $pullNginxStatus = CPullOptions::GetQueueServerStatus();
         $pullChannels = array($pullChannel['CHANNEL_ID']);
         if ($pullNginxStatus) {
             if (defined('BX_PULL_SKIP_WEBSOCKET')) {
                 $pullWebSocketStatus = false;
                 $pullConfig['WEBSOCKET'] = 'N';
             } else {
                 $pullWebSocketStatus = CPullOptions::GetWebSocketStatus();
             }
             $pullChannelShared = CPullChannel::GetShared();
             if (is_array($pullChannelShared)) {
                 $pullChannels[] = $pullChannelShared['CHANNEL_ID'];
                 if ($pullChannel['CHANNEL_DT'] > $pullChannelShared['CHANNEL_DT']) {
                     $pullChannel['CHANNEL_DT'] = $pullChannelShared['CHANNEL_DT'];
                 }
             }
         }
         if (defined('BX_MOBILE') || defined('BX_PULL_MOBILE')) {
             $pullConfig['MOBILE'] = 'Y';
             $pullPath = $pullNginxStatus ? CMain::IsHTTPS() ? CPullOptions::GetListenSecureUrl($pullChannels, true) : CPullOptions::GetListenUrl($pullChannels, true) : '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE';
         } else {
             $pullPath = $pullNginxStatus ? CMain::IsHTTPS() ? CPullOptions::GetListenSecureUrl($pullChannels) : CPullOptions::GetListenUrl($pullChannels) : '/bitrix/components/bitrix/pull.request/ajax.php?UPDATE_STATE';
         }
         $pullConfig = $pullConfig + array('CHANNEL_ID' => implode('/', $pullChannels), 'LAST_ID' => $pullChannel['LAST_ID'], 'CHANNEL_DT' => $pullChannel['CHANNEL_DT'], 'PATH' => $pullPath, 'PATH_WS' => $pullNginxStatus && $pullWebSocketStatus ? CMain::IsHTTPS() ? CPullOptions::GetWebSocketSecureUrl($pullChannels) : CPullOptions::GetWebSocketUrl($pullChannels) : '', 'PATH_COMMAND' => defined('BX_PULL_COMMAND_PATH') ? BX_PULL_COMMAND_PATH : '', 'METHOD' => $pullNginxStatus ? 'LONG' : 'PULL');
     }
     return $pullConfig;
 }