%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.218.70.79
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/main/lib/web/webpacker/output/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/web/webpacker/output/file.php
<?php

namespace Bitrix\Main\Web\WebPacker\Output;

use Bitrix\Main\Config\Option;
use Bitrix\Main\Error;
use Bitrix\Main\SystemException;
use Bitrix\Main\Web\WebPacker;
use Bitrix\Main\Web\MimeType;

/**
 * Class File
 *
 * @package Bitrix\Main\Web\WebPacker\Output
 */
class File extends Base
{
	protected $id;
	protected $moduleId;
	protected $uploadDir;
	protected $dir;
	protected $name;
	protected $type;
	protected $content;

	/**
	 * Remove by ID.
	 *
	 * @param int $id ID.
	 * @return void
	 */
	public static function removeById($id)
	{
		\CFile::Delete($id);
	}

	/**
	 * Output.
	 *
	 * @param WebPacker\Builder $builder Module.
	 * @return Result
	 */
	public function output(WebPacker\Builder $builder)
	{
		if (!$this->moduleId)
		{
			throw new SystemException('Module ID is empty.');
		}
		if (!$this->name)
		{
			throw new SystemException('File name is empty.');
		}

		$content = $builder->stringify();
		$id = $this->saveFile($content);

		$result = (new Result())->setId($id)->setContent($content);
		if (!$id)
		{
			$result->addError(new Error('Empty file ID.'));
		}

		return $result;
	}

	/**
	 * Set content.
	 *
	 * @param string $content Content.
	 * @return $this
	 */
	public function setContent($content)
	{
		$this->content = $content;
		return $this;
	}

	/**
	 * Set file ID.
	 *
	 * @param int $id File ID.
	 * @return $this
	 */
	public function setId($id)
	{
		$this->id = $id;
		return $this;
	}

	/**
	 * Get file ID.
	 *
	 * @return int|null
	 */
	public function getId()
	{
		return $this->id;
	}

	/**
	 * Set module ID.
	 *
	 * @param string $moduleId Bitrix module ID.
	 * @return $this
	 */
	public function setModuleId($moduleId)
	{
		$this->moduleId = $moduleId;
		return $this;
	}

	/**
	 * Set upload directory.
	 *
	 * @param string $uploadDir Upload directory.
	 * @return $this
	 */
	public function setUploadDir($uploadDir)
	{
		$this->uploadDir = $uploadDir;
		return $this;
	}

	/**
	 * Set directory.
	 *
	 * @param string $dir Directory.
	 * @return $this
	 */
	public function setDir($dir)
	{
		$this->dir = $dir;
		return $this;
	}

	/**
	 * Set name.
	 *
	 * @param string $name Name.
	 * @return $this
	 */
	public function setName($name)
	{
		$this->name = $name;
		return $this;
	}

	/**
	 * Set type.
	 *
	 * @param string $type Content type.
	 * @return $this
	 */
	public function setType($type)
	{
		$this->type = $type;
		return $this;
	}

	/**
	 * Remove.
	 *
	 * @return void
	 */
	public function remove()
	{
		if (!$this->id)
		{
			return;
		}

		static::removeById($this->id);
	}

	/**
	 * Get uri.
	 *
	 * @return string
	 */
	public function getUri()
	{
		$uri = '';
		if (!$this->id)
		{
			return $uri;
		}

		$file = \CFile::getByID($this->id)->fetch();
		if (!$file)
		{
			return $uri;
		}

		$uri = $file['~src'];
		if ($uri)
		{
			return $uri;
		}

		$uploadDir = $this->uploadDir ?: Option::get("main", "upload_dir", "upload");
		return WebPacker\Builder::getDefaultSiteUri() .
			'/' . $uploadDir .
			'/' . $file['SUBDIR'] .
			'/' . $file['FILE_NAME'];
	}

	protected function saveFile($content)
	{
		$this->remove();

		$type = $this->type;
		if (!$type && $this->name)
		{
			$type = static::getMimeTypeByFileName($this->name);
		}

		$fileArray = [
			'MODULE_ID' => $this->moduleId,
			'name' => $this->name,
			'content' => $content
		];

		if ($type)
		{
			$fileArray['type'] = $type;
		}

		$this->id = \CFile::SaveFile(
			$fileArray,
			$this->moduleId,
			false,
			false,
			$this->dir ?: ''
		);

		return $this->id;
	}

	protected static function getMimeTypeByFileName($fileName)
	{
		$extension = mb_strtolower(getFileExtension($fileName));
		$list = MimeType::getMimeTypeList();
		if (isset($list[$extension]))
		{
			return $list[$extension];
		}

		return 'text/plain';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit