예제 #1
0
 public static function AddShared($arMessage, $channelType = 'shared')
 {
     if (!CPullOptions::GetQueueServerStatus()) {
         return false;
     }
     $arChannel = CPullChannel::GetChannelShared($channelType);
     return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage);
 }
예제 #2
0
 public static function AddByUser($userId, $arMessage)
 {
     if (intval($userId) <= 0) {
         return false;
     }
     $arChannel = CPullChannel::Get($userId);
     $arMessage['push_user'] = $userId;
     return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage);
 }
예제 #3
0
 public static function Extend($userId, $tag)
 {
     global $DB;
     if (intval($userId) <= 0 && strlen($tag) <= 0) {
         return false;
     }
     $strSql = "SELECT ID FROM b_pull_watch WHERE USER_ID = " . intval($userId) . " AND TAG = '" . $DB->ForSQL($tag) . "'";
     $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($arRes = $dbRes->Fetch()) {
         $ID = $arRes['ID'];
         $arChannel = CPullChannel::Get($userId);
         $DB->Query("UPDATE b_pull_watch SET DATE_CREATE = " . $DB->CurrentTimeFunction() . ", CHANNEL_ID = '" . $DB->ForSQL($arChannel['CHANNEL_ID']) . "' WHERE ID = " . $ID);
     }
     return false;
 }
예제 #4
0
 public static function OnEpilog()
 {
     if (!defined('BX_PULL_SKIP_INIT') && !(isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') && $GLOBALS['USER'] && intval($GLOBALS['USER']->GetID()) > 0 && CModule::IncludeModule('pull')) {
         define("BX_PULL_SKIP_INIT", true);
         if (CPullOptions::CheckNeedRun()) {
             CJSCore::Init(array('pull'));
             $pullConfig = CPullChannel::GetConfig($GLOBALS['USER']->GetID());
             global $APPLICATION;
             $APPLICATION->AddAdditionalJS('<script type="text/javascript">BX.bind(window, "load", function() { BX.PULL.start(' . (empty($pullConfig) ? '' : CUtil::PhpToJsObject($pullConfig)) . '); });</script>');
             /*
             if(!defined("BX_DESKTOP") && !defined("BX_MOBILE") && !defined("ADMIN_SECTION") && !IsModuleInstalled('b24network') && IsModuleInstalled('bitrix24') && (COption::GetOptionString('bitrix24', 'network', 'N') == 'Y'))
             {
             	CJSCore::Init(array('npull'));
             	$APPLICATION->AddAdditionalJS('<script type="text/javascript">BX.bind(window, "load", function() { BX.NPULL.start(); });</script>');
             }
             */
         }
     }
 }
예제 #5
0
         $arMessage = $CIMMessage->GetUnreadMessage(array('SPEED_CHECK' => 'N', 'LOAD_DEPARTMENT' => 'N', 'ORDER' => 'ASC', 'GROUP_BY_CHAT' => 'Y'));
         $arResult['COUNTER_MESSAGES'] = count($arMessage['message']);
         $arData = array();
         $arUnread = array();
         foreach ($arMessage['message'] as $data) {
             $arUnread[$data['senderId']]['MESSAGE'] = $data;
             $arUnread[$data['senderId']]['USER'] = $arMessage['users'][$data['senderId']];
         }
         foreach ($arUnread as $userId => $data) {
             $arData[$userId] = $data;
         }
         uasort($arData, create_function('$a, $b', 'if($a["MESSAGE"]["date"] < $b["MESSAGE"]["date"] ) return 1; elseif($a["MESSAGE"]["date"]  > $b["MESSAGE"]["date"] ) return -1; else return 0;'));
         $arResult['COUNTER_UNREAD_MESSAGES'] = $arData;
     }
     if (CModule::IncludeModule('pull')) {
         $arChannel = CPullChannel::Get($USER->GetId());
         if (is_array($arChannel)) {
             $arResult['PULL_CONFIG'] = array('CHANNEL_ID' => $arChannel['CHANNEL_ID'], 'LAST_ID' => $arChannel['LAST_ID'], 'PATH' => $arChannel['PATH'], 'PATH_WS' => $arChannel['PATH_WS'], 'METHOD' => $arChannel['METHOD'], 'ERROR' => '');
         }
     }
     // Counters
     $arResult["COUNTERS"] = CUserCounter::GetValues($USER->GetID(), $_POST['SITE_ID']);
     $arResult["ERROR"] = $errorMessage;
     echo CUtil::PhpToJsObject($arResult);
 } else {
     if ($_POST['IM_NOTIFY_LOAD'] == 'Y') {
         $CIMNotify = new CIMNotify();
         $arNotify = $CIMNotify->GetUnreadNotify(array('SPEED_CHECK' => 'N', 'USE_TIME_ZONE' => 'N'));
         if ($arNotify['result']) {
             $arSend['NOTIFY'] = $arNotify['notify'];
             $arSend['UNREAD_NOTIFY'] = $arNotify['unreadNotify'];
예제 #6
0
파일: ajax.php 프로젝트: ASDAFF/entask.ru
	die();
}
if (check_bitrix_sessid())
{
	if ($_POST['PULL_GET_CHANNEL'] == 'Y')
	{
		$arChannel = CPullChannel::Get($USER->GetId(), $_POST['CACHE'] == 'Y'? true: false, $_POST['CACHE'] == 'Y'? false: true);
		if (is_array($arChannel))
		{
			$nginxStatus = CPullOptions::GetQueueServerStatus();
			$webSocketStatus = CPullOptions::GetWebSocketStatus();

			$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'],
예제 #7
0
파일: ajax.php 프로젝트: Satariall/izurit
    if ($userId <= 0) {
        // TODO need change AUTHORIZE ERROR callbacks
        //header("HTTP/1.0 401 Not Authorized");
        //header("Content-Type: application/x-javascript");
        //header("BX-Authorize: ".bitrix_sessid());
        echo CUtil::PhpToJsObject(array('ERROR' => 'AUTHORIZE_ERROR', 'BITRIX_SESSID' => bitrix_sessid()));
        CMain::FinalActions();
        die;
    }
} else {
    $userId = PULL_USER_ID;
}
if (check_bitrix_sessid()) {
    if ($_POST['PULL_GET_CHANNEL'] == 'Y') {
        session_write_close();
        $arConfig = CPullChannel::GetConfig($userId, $_POST['CACHE'] == 'Y', $_POST['CACHE'] == 'Y' ? false : true, $_POST['MOBILE'] == 'Y');
        if (is_array($arConfig)) {
            echo CUtil::PhpToJsObject($arConfig);
        } else {
            echo CUtil::PhpToJsObject(array('ERROR' => 'ERROR_OPEN_CHANNEL'));
        }
    } elseif ($_POST['PULL_UPDATE_WATCH'] == 'Y') {
        foreach ($_POST['WATCH'] as $tag) {
            CPullWatch::Extend($userId, $tag);
        }
        echo CUtil::PhpToJsObject(array('ERROR' => ''));
    } elseif ($_POST['PULL_UPDATE_STATE'] == 'Y') {
        $arMessage = CPullStack::Get($_POST['CHANNEL_ID'], intval($_POST['CHANNEL_LAST_ID']));
        $arResult["COUNTERS"] = CUserCounter::GetAllValues($userId);
        if (!empty($arResult["COUNTERS"])) {
            $arMessage[] = array('module_id' => 'main', 'command' => 'user_counter', 'params' => $arResult["COUNTERS"]);
예제 #8
0
		$arOnline = CIMStatus::GetList();
		$arResult['ONLINE'] = !empty($arOnline)? $arOnline['users']: Array();

		if (CModule::IncludeModule('pull'))
		{
			$arChannel = CPullChannel::Get($USER->GetId());
			if (is_array($arChannel))
			{
				$nginxStatus = CPullOptions::GetNginxStatus();
				$webSocketStatus = CPullOptions::GetWebSocketStatus();

				$arChannels = Array($arChannel['CHANNEL_ID']);
				if ($nginxStatus)
				{
					$arChannelShared = CPullChannel::GetShared();
					$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');

				$arResult['PULL_CONFIG'] = Array(
					'CHANNEL_ID' => implode('/', $arChannels),
					'CHANNEL_DT' => $arChannel['CHANNEL_DT'],
					'PATH' => $pullPath,
					'PATH_WS' => ($nginxStatus && $webSocketStatus? (CMain::IsHTTPS()? CPullOptions::GetWebSocketSecureUrl($arChannels): CPullOptions::GetWebSocketUrl($arChannels)): ''),
예제 #9
0
	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;
	}
예제 #10
0
    die;
}
if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') {
    return;
}
if (!CModule::IncludeModule('pull')) {
    return;
}
if (defined('BX_PULL_SKIP_INIT')) {
    return;
}
$userId = 0;
if (defined('PULL_USER_ID')) {
    $userId = PULL_USER_ID;
} else {
    if ($GLOBALS['USER'] && intval($GLOBALS['USER']->GetID()) > 0) {
        $userId = intval($GLOBALS['USER']->GetID());
    }
}
if ($userId == 0) {
    return;
}
if (CPullOptions::CheckNeedRun()) {
    CJSCore::Init(array('pull'));
    $arResult = CPullChannel::GetConfig($userId);
    if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) {
        define("BX_PULL_SKIP_INIT", true);
        $this->IncludeComponentTemplate();
    }
}
return $arResult;
예제 #11
0
	public static function AddShared($arMessage)
	{
		if (!CPullOptions::GetNginxStatus())
			return false;

		$arChannel = CPullChannel::GetShared();
		return self::AddByChannel($arChannel['CHANNEL_ID'], $arMessage);
	}
예제 #12
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') {
    return;
}
if (intval($USER->GetID()) <= 0) {
    return;
}
if (!CModule::IncludeModule('pull')) {
    return;
}
if (defined('BX_PULL_SKIP_INIT')) {
    return;
}
if (CPullOptions::CheckNeedRun()) {
    CJSCore::Init(array('pull'));
    $arResult = CPullChannel::GetConfig($GLOBALS['USER']->GetID());
    if (!(isset($arParams['TEMPLATE_HIDE']) && $arParams['TEMPLATE_HIDE'] == 'Y')) {
        define("BX_PULL_SKIP_INIT", true);
        $this->IncludeComponentTemplate();
    }
}
return $arResult;
예제 #13
0
 public static function OnEpilog()
 {
     $userId = 0;
     if (defined('PULL_USER_ID')) {
         $userId = PULL_USER_ID;
     } else {
         if ($GLOBALS['USER'] && intval($GLOBALS['USER']->GetID()) > 0) {
             $userId = intval($GLOBALS['USER']->GetID());
         }
     }
     if (!defined('BX_PULL_SKIP_INIT') && !(isset($_REQUEST['AJAX_CALL']) && $_REQUEST['AJAX_CALL'] == 'Y') && $userId != 0 && CModule::IncludeModule('pull')) {
         define("BX_PULL_SKIP_INIT", true);
         if (CPullOptions::CheckNeedRun()) {
             CJSCore::Init(array('pull'));
             $pullConfig = CPullChannel::GetConfig($userId);
             global $APPLICATION;
             $APPLICATION->AddAdditionalJS('<script type="text/javascript">BX.bind(window, "load", function() { BX.PULL.start(' . (empty($pullConfig) ? '' : CUtil::PhpToJsObject($pullConfig)) . '); });</script>');
         }
     }
 }
예제 #14
0
파일: ajax.php 프로젝트: ASDAFF/bitrix-5
{
	echo CUtil::PhpToJsObject(Array('ERROR' => 'PULL_MODULE_IS_NOT_INSTALLED'));
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
	die();
}
if (intval($USER->GetID()) <= 0)
{
	echo CUtil::PhpToJsObject(Array('ERROR' => 'AUTHORIZE_ERROR'));
	require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
	die();
}
if (check_bitrix_sessid())
{
	if ($_POST['PULL_GET_CHANNEL'] == 'Y')
	{
		$arChannel = CPullChannel::Get($USER->GetId(), true);
		if (is_array($arChannel))
		{
			echo CUtil::PhpToJsObject(Array(
				'CHANNEL_ID' => $arChannel['CHANNEL_ID'],
				'CHANNEL_DT' => $arChannel['CHANNEL_DT'],
				'LAST_ID' => $arChannel['LAST_ID'],
				'PATH' => $arChannel['PATH'],
				'PATH_WS' => $arChannel['PATH_WS'],
				'METHOD' => $arChannel['METHOD'],
				'ERROR' => '',
			));
		}
		else
			echo CUtil::PhpToJsObject(Array('ERROR' => 'ERROR_OPEN_CHANNEL'));
	}
예제 #15
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;
 }