%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.15.149.182
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/pull/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/pull/lib/mobilecounter.php
<?php
namespace Bitrix\Pull;

class MobileCounter
{
	const MOBILE_APP = 'Bitrix24';

	public static function getTypes()
	{
		$types = Array();

		$event = new \Bitrix\Main\Event("pull", "onGetMobileCounterTypes");
		$event->send();

		foreach ($event->getResults() as $eventResult)
		{
			if ($eventResult->getType() != \Bitrix\Main\EventResult::SUCCESS)
			{
				continue;
			}

			$result = $eventResult->getParameters();
			if (!is_array($types))
			{
				continue;
			}

			foreach ($result as $type => $config)
			{
				$config['TYPE'] = $eventResult->getModuleId().'_'.$type;
				$types[$eventResult->getModuleId().'_'.$type] = $config;
			}
		}

		return $types;
	}

	public static function get($userId = null)
	{
		if (is_null($userId) && is_object($GLOBALS['USER']))
		{
			$userId = $GLOBALS['USER']->getId();
		}

		$userId = intval($userId);
		if (!$userId)
		{
			return false;
		}

		$counter = 0;

		if (IsModuleInstalled('intranet'))
		{
			if (\Bitrix\Main\Loader::includeModule('im')) // TODO remove IM include!
			{
				$siteId = \Bitrix\Im\User::getInstance($userId)->isExtranet()? 'ex': 's1';
			}
			else
			{
				$siteId = 's1';
			}
		}
		else
		{
			$siteId = \Bitrix\Main\Context::getCurrent()->getSite();
			if (!$siteId)
			{
				$siteId = 's1';
			}
		}

		$event = new \Bitrix\Main\Event("pull", "onGetMobileCounter", array(
			'USER_ID' => $userId,
			'SITE_ID' => $siteId
		));
		$event->send();

		$typeStatus = self::getConfig($userId);

		foreach ($event->getResults() as $eventResult)
		{
			if ($eventResult->getType() != \Bitrix\Main\EventResult::SUCCESS)
			{
				continue;
			}

			$result = $eventResult->getParameters();

			$type = $eventResult->getModuleId().'_'.$result['TYPE'];
			if ($typeStatus[$type] === false)
			{
				continue;
			}

			if (intval($result['COUNTER']) > 0)
			{
				$counter += $result['COUNTER'];
			}
		}

		return $counter;
	}

	public static function getConfig($userId = null)
	{
		if (is_null($userId) && is_object($GLOBALS['USER']))
		{
			$userId = $GLOBALS['USER']->getId();
		}

		$userId = intval($userId);
		if ($userId <= 0)
		{
			return false;
		}

		$types = Array();

		foreach (self::getTypes() as $type => $config)
		{
			$types[$type] = $config['DEFAULT'];
		}

		$options = \CUserOptions::GetOption('pull', 'mobileCounterType', Array(), $userId);
		foreach ($options as $type => $default)
		{
			$types[$type] = $default;
		}

		return $types;
	}

	public static function setConfigType($type, $status, $userId = null)
	{
		return self::setConfig(Array($type => $status), $userId);
	}

	public static function setConfig($config, $userId = null)
	{
		if (!is_array($config))
		{
			return false;
		}

		if (is_null($userId) && is_object($GLOBALS['USER']))
		{
			$userId = $GLOBALS['USER']->getId();
		}
		$userId = intval($userId);
		if ($userId <= 0)
		{
			return false;
		}

		$needUpdate = false;
		$types = self::getConfig($userId);

		foreach ($config as $type => $status)
		{
			if (!isset($types[$type]))
			{
				continue;
			}
			$types[$type] = (bool)$status;
			$needUpdate = true;
		}

		if ($needUpdate)
		{
			\CUserOptions::SetOption('pull', 'mobileCounterType', $types, false, $userId);
		}

		return true;
	}

	public static function send($userId = null, $appId = self::MOBILE_APP)
	{
		if (is_null($userId) && is_object($GLOBALS['USER']))
		{
			$userId = $GLOBALS['USER']->getId();
		}

		$userId = intval($userId);
		if ($userId <= 0)
		{
			return false;
		}

		\Bitrix\Pull\Push::add($userId, Array(
			'module_id' => 'pull',
			'push' => Array('badge' => 'Y')
		));

		return true;
	}

	public static function onSonetLogCounterClear($counterType = '', $timestamp = 0)
	{
		$userId = is_object($GLOBALS['USER'])? intval($GLOBALS['USER']->getId()): 0;

		if (
			$userId <= 0
			|| $counterType != '**'
		)
		{
			return false;
		}

		self::send($userId);

		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit