%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.226.164.53
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/rest/lib/event/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/rest/lib/event/provideroffline.php
<?php
namespace Bitrix\Rest\Event;

use Bitrix\Main\Loader;
use Bitrix\Pull;
use Bitrix\Rest\EventOfflineTable;
use Bitrix\Main\EventManager;
use Bitrix\Rest\Tools\Diagnostics\LoggerManager;

class ProviderOffline implements ProviderOfflineInterface
{
	/**
	 * @var ProviderOffline
	 */
	protected static $instance = null;

	public static function instance()
	{
		if(static::$instance === null)
		{
			static::$instance = new static();
		}

		return static::$instance;
	}

	public function send(array $eventList)
	{
		$serverAuthData = $this->getServerAuthData();

		$offlineEventsCount = array();
		$offlineEventsApp = array();

		foreach($eventList as $item)
		{
			$application = $item['APPLICATION'];
			$handler = $item['HANDLER'];

			if(
				$serverAuthData['client_id'] !== $application['CLIENT_ID']
				|| $serverAuthData['auth_connector'] !== $handler['CONNECTOR_ID']
			)
			{
				if(!isset($offlineEventsCount[$application['CLIENT_ID']]))
				{
					$offlineEventsCount[$application['CLIENT_ID']] = array();
				}

				if(!isset($offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']]))
				{
					$offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']] = 0;
				}

				EventOfflineTable::callEvent(array(
					'APP_ID' => $application['ID'],
					'EVENT_NAME' => $handler['EVENT_NAME'],
					'EVENT_DATA' => $item['DATA'],
					'EVENT_ADDITIONAL' => $item['AUTH'],
					'CONNECTOR_ID' => $handler['CONNECTOR_ID'],
				));

				$offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']]++;
				$offlineEventsApp[$application['ID']] = true;
			}
			else
			{
				$logger = LoggerManager::getInstance()->getLogger();
				if ($logger)
				{
					$logger->debug(
						"\n{delimiter}\n"
						. "{date} - {host}\n{delimiter}\n"
						. "Event skipped because initializer is current application. \n"
						. "auth: {serverAuthData}"
						. "app: {application}\n",
						[
							'serverAuthData' => $serverAuthData,
							'application' => $application,
						]
					);
				}
			}
		}

		if(count($offlineEventsCount) > 0)
		{
			$this->notifyApplications($offlineEventsCount);
		}

		if(count($offlineEventsApp) > 0)
		{
			$this->sendOfflineEvent(array_keys($offlineEventsApp));
		}
	}

	protected function getServerAuthData()
	{
		$server = \CRestServer::instance();
		$serverAuthData = array('auth_connector' => '', 'client_id' => '');
		if($server !== null)
		{
			$serverAuthData = $server->getAuthData();
			if(!isset($serverAuthData['auth_connector']))
			{
				$serverAuthData['auth_connector'] = '';
			}

			$serverAuthData['client_id'] = $server->getClientId();
		}

		return $serverAuthData;
	}



	protected function sendOfflineEvent(array $appList)
	{
		foreach (EventManager::getInstance()->findEventHandlers(
			"rest",
			"onAfterOfflineEventCall"
		) as $event)
		{
			ExecuteModuleEventEx($event, [['APP_LIST' => $appList]]);
		}
	}

	protected function notifyApplications(array $counters)
	{
		foreach($counters as $clientId => $connectorCounters)
		{
			if(is_array($connectorCounters) && count($connectorCounters) > 0)
			{
				$this->notifyApplication($clientId, $connectorCounters);
			}
		}
	}

	protected function notifyApplication($clientId, array $connectorCounters)
	{
		if(Loader::includeModule('pull'))
		{
			$eventParam = array();

			foreach($connectorCounters as $connectorId => $count)
			{
				$eventParam[] = array(
					'connector_id' => $connectorId,
					'count' => $count
				);
			}

			Pull\Event::add(Pull\Event::SHARED_CHANNEL, array(
				'module_id' => 'rest',
				'command' => 'event_offline',
				'params' => $eventParam,
			), $clientId);
		}
	}

}


Youez - 2016 - github.com/yon3zu
LinuXploit