AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.145.74.228
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/modules/main/lib/web/webpacker/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/modules/main/lib/web/webpacker//loader.php
<?php

namespace Bitrix\Main\Web\WebPacker;

/**
 * Class Loader
 *
 * @package Bitrix\Main\Web\WebPacker
 */
class Loader
{
	/** @var Output\File */
	protected $file;

	protected $cacheTtl = 60;

	protected $skipMoving = false;

	protected $tagAttributes = [];

	/**
	 * Loader constructor.
	 *
	 * @param Output\File $file File output instance.
	 */
	public function __construct(Output\File $file)
	{
		$this->file = $file;
	}

	/**
	 * Set cache ttl.
	 *
	 * @param int $cacheTtl Ttl in seconds.
	 * @return $this
	 */
	public function setCacheTtl($cacheTtl)
	{
		$this->cacheTtl = (int) $cacheTtl;
		return $this;
	}

	/**
	 * Set skip moving.
	 *
	 * @param bool $skip Skip moving.
	 * @return $this
	 */
	public function setSkipMoving($skip)
	{
		$this->skipMoving = (bool) $skip;
		return $this;
	}

	/**
	 * Set tag attributes.
	 *
	 * @param array $tagAttributes Tag attributes.
	 * @return $this
	 */
	public function setTagAttributes(array $tagAttributes = [])
	{
		$this->tagAttributes = $tagAttributes;
		return $this;
	}

	/**
	 * Return loader file url.
	 *
	 * @return string
	 */
	public function getFileUrl()
	{
		return $this->file->getUri();
	}

	/**
	 * Return loader string.
	 *
	 * @return string
	 */
	public function getString()
	{
		$content = $this->getStringJs();
		$attributes = $this->tagAttributes;
		if ($this->skipMoving)
		{
			$attributes['data-skip-moving'] = 'true';
		}
		$attrs = '';
		foreach ($attributes as $key => $value)
		{
			$attrs .= " " . htmlspecialcharsbx($key) . '="'
				. htmlspecialcharsbx($value) . '"';
		}
		return <<<EOD
<script{$attrs}>
$content
</script>
EOD;

	}

	/**
	 * Return loader js string.
	 *
	 * @return string
	 */
	public function getStringJs()
	{
		$path = $this->file->getUri();
		if (!$path)
		{
			return '';
		}

		$ttl = ($this->cacheTtl ?: 1) * 1000;

		return
<<<EOD
	(function(w,d,u){
		var s=d.createElement('script');s.async=true;s.src=u+'?'+(Date.now()/$ttl|0);
		var h=d.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);
	})(window,document,'$path');
EOD;

	}
}

Anon7 - 2022
AnonSec Team