%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.219.13.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/sale/lib/exchange/integration/rest/cmd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/lib/exchange/integration/rest/cmd//base.php
<?php
namespace Bitrix\Sale\Exchange\Integration\Rest\Cmd;

use Bitrix\Main\ArgumentException;
use Bitrix\Main\Error;
use Bitrix\Main\Web\Uri;
use Bitrix\Sale\Exchange\Integration;
use Bitrix\Sale\Internals\Fields;
use Bitrix\Sale\Result;

class Base
{
	const DIRECTORY_PAGE = '/rest/';

	protected $query;
	protected $page;
	protected $directory;

	private $token;

	public function __construct()
	{
		$this->query = new Fields();

		$this->initialize(new Integration\App\IntegrationB24());
	}

	public function setField($name, $value)
	{
		$this->query->set($name, $value);
		return $this;
	}
	public function setFieldsValues($values)
	{
		if(is_array($values))
		{
			$this->query->setValues($values);
		}
		return $this;
	}
	public function getFieldsValues()
	{
		return $this->query->getValues();
	}
	public function setDirectory($directory)
	{
		$this->directory = $directory;
		return $this;
	}
	public function setPageByType($type)
	{
		$registry = Registry::getRegistry();
		$page = isset($registry[$type]) ? $registry[$type]:null;

		if(is_null($page))
		{
			throw new ArgumentException("Unsupported cmd type: {$type}");
		}

		$this->setPage($page);
		return $this;
	}
	public function setPage($page)
	{
		$this->page = $page;
		return $this;
	}
	public function build()
	{
		$uri = new Uri($this->buildDirectoryPage());
		return $uri
			->addParams($this->getFieldsValues())
			->getUri();
	}
	public function call()
	{
		$r = new Result();
		try
		{
			$response = (new Integration\Rest\Client\TokenClient($this->token))
				->call(
					$this->buildDirectoryPage(), $this->getFieldsValues());
		}
		catch (\Exception $exception)
		{
			return $r->addError(new Error("Error: ".$exception->getMessage()));
		}

		if (isset($response["error"]))
		{
			return $r->addError(new Error(
				"Server Error: ".$response["error_description"]." (".$response["error"].")"
			));
		}
		else if (!isset($response["result"]))
		{
			return $r->addError(new Error("Wrong Server Response."));
		}

		return $r->setData(['DATA'=>$response]);
	}
	public function fill()
	{
		return $this;
	}

	protected function buildDirectoryPage()
	{
		return $this->directory.$this->page;
	}

	protected function initialize(Integration\App\Base $application)
	{
		$this->token = static::getAppToken($application->getCode());
	}

	private static function getAppToken($guid)
	{
		if (!is_string($guid) || empty($guid))
		{
			return null;
		}

		$token = Integration\Entity\B24integrationTokenTable::getList([
			"select" => ["*"],
			"filter" => ["=GUID" => $guid]
		])->fetchObject();

		return $token ? $token : null;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit