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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/location/lib/source/sourceselector.php
<?php

namespace Bitrix\Location\Source;

use Bitrix\Location\Entity\Source\Factory;
use Bitrix\Location\Entity\Source\OrmConverter;
use Bitrix\Location\Repository\SourceRepository;
use Bitrix\Location\Source\Google;
use Bitrix\Location\Source\Osm;
use Bitrix\Main\Config\Option;
use Bitrix\Main\Error;
use Bitrix\Main\Result;

class SourceSelector
{
	protected $sourceRepository;

	public function __construct(SourceRepository $sourceRepository = null)
	{
		$this->sourceRepository = $sourceRepository ?: new SourceRepository(new OrmConverter());
	}

	protected function isConstantDefinesOtherSource(string $sourceCode): bool
	{
		$result = false;

		if (defined('LOCATION_DEFAULT_SOURCE_CODE') && $sourceCode !== LOCATION_DEFAULT_SOURCE_CODE)
		{
			$result = true;
		}

		return $result;
	}

	public function setSource(string $sourceCode, IConfigFactory $configFactory): Result
	{
		$result = new Result();

		if($this->isConstantDefinesOtherSource($sourceCode))
		{
			$result->addError(
				new Error('Defined constant "LOCATION_DEFAULT_SOURCE_CODE" with other source')
			);

			return $result;
		}

		$source = $this->sourceRepository->findByCode($sourceCode);

		if (!$source)
		{
			$source = Factory::makeSource($sourceCode);
			$source->setName($sourceCode);
		}

		$source->setConfig(
			$configFactory->createConfig()
		);

		$res = $this->sourceRepository->save($source);

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

		Option::set('location', 'location_default_source_code', $sourceCode);

		return $result;
	}

	public static function setGoogleSource(string $frontendKey, string $backendKey): Result
	{
		$sourceSelector = new self();
		$configFactory = new Google\ConfigFactory($frontendKey, $backendKey);
		return $sourceSelector->setSource(Factory::GOOGLE_SOURCE_CODE, $configFactory);
	}

	public static function setOsmSource(string $serviceUrl, string $token): Result
	{
		$sourceSelector = new self();
		$configFactory = new Osm\ConfigFactory($serviceUrl, $token);
		return $sourceSelector->setSource(Factory::OSM_SOURCE_CODE, $configFactory);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit