Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Dompdf; class Options { private $rootDir; private $tempDir; private $font..
Decoded Output download
<?php
namespace Dompdf; class Options { private $rootDir; private $tempDir; private $fontDir; private $fontCache; private $chroot; private $allowedProtocols = array("file://" => array("rules" => array()), "http://" => array("rules" => array()), "https://" => array("rules" => array())); private $logOutputFile; private $defaultMediaType = "screen"; private $defaultPaperSize = "letter"; private $defaultPaperOrientation = "portrait"; private $defaultFont = "serif"; private $dpi = 96; private $fontHeightRatio = 1.1; private $isPhpEnabled = false; private $isRemoteEnabled = false; private $allowedRemoteHosts = null; private $isJavascriptEnabled = true; private $isHtml5ParserEnabled = true; private $isFontSubsettingEnabled = true; private $debugPng = false; private $debugKeepTemp = false; private $debugCss = false; private $debugLayout = false; private $debugLayoutLines = true; private $debugLayoutBlocks = true; private $debugLayoutInline = true; private $debugLayoutPaddingBox = true; private $pdfBackend = "CPDF"; private $pdflibLicense = ''; private $httpContext; public function __construct(array $attributes = null) { $rootDir = realpath(__DIR__ . "/../"); $this->setChroot(array($rootDir)); $this->setRootDir($rootDir); $this->setTempDir(sys_get_temp_dir()); $this->setFontDir($rootDir . "/lib/fonts"); $this->setFontCache($this->getFontDir()); $ver = ''; $versionFile = realpath(__DIR__ . "/../VERSION"); if (($version = file_get_contents($versionFile)) !== false) { $version = trim($version); if ($version !== "$Format:<%h>$") { $ver = "/{$version}"; } } $this->setHttpContext(array("http" => array("follow_location" => false, "user_agent" => "Dompdf{$ver} https://github.com/dompdf/dompdf"))); $this->setAllowedProtocols(array("file://", "http://", "https://")); if (null !== $attributes) { $this->set($attributes); } } public function set($attributes, $value = null) { if (!is_array($attributes)) { $attributes = array($attributes => $value); } foreach ($attributes as $key => $value) { if ($key === "tempDir" || $key === "temp_dir") { $this->setTempDir($value); } elseif ($key === "fontDir" || $key === "font_dir") { $this->setFontDir($value); } elseif ($key === "fontCache" || $key === "font_cache") { $this->setFontCache($value); } elseif ($key === "chroot") { $this->setChroot($value); } elseif ($key === "allowedProtocols" || $key === "allowed_protocols") { $this->setAllowedProtocols($value); } elseif ($key === "logOutputFile" || $key === "log_output_file") { $this->setLogOutputFile($value); } elseif ($key === "defaultMediaType" || $key === "default_media_type") { $this->setDefaultMediaType($value); } elseif ($key === "defaultPaperSize" || $key === "default_paper_size") { $this->setDefaultPaperSize($value); } elseif ($key === "defaultPaperOrientation" || $key === "default_paper_orientation") { $this->setDefaultPaperOrientation($value); } elseif ($key === "defaultFont" || $key === "default_font") { $this->setDefaultFont($value); } elseif ($key === "dpi") { $this->setDpi($value); } elseif ($key === "fontHeightRatio" || $key === "font_height_ratio") { $this->setFontHeightRatio($value); } elseif ($key === "isPhpEnabled" || $key === "is_php_enabled" || $key === "enable_php") { $this->setIsPhpEnabled($value); } elseif ($key === "isRemoteEnabled" || $key === "is_remote_enabled" || $key === "enable_remote") { $this->setIsRemoteEnabled($value); } elseif ($key === "allowedRemoteHosts" || $key === "allowed_remote_hosts") { $this->setAllowedRemoteHosts($value); } elseif ($key === "isJavascriptEnabled" || $key === "is_javascript_enabled" || $key === "enable_javascript") { $this->setIsJavascriptEnabled($value); } elseif ($key === "isHtml5ParserEnabled" || $key === "is_html5_parser_enabled" || $key === "enable_html5_parser") { $this->setIsHtml5ParserEnabled($value); } elseif ($key === "isFontSubsettingEnabled" || $key === "is_font_subsetting_enabled" || $key === "enable_font_subsetting") { $this->setIsFontSubsettingEnabled($value); } elseif ($key === "debugPng" || $key === "debug_png") { $this->setDebugPng($value); } elseif ($key === "debugKeepTemp" || $key === "debug_keep_temp") { $this->setDebugKeepTemp($value); } elseif ($key === "debugCss" || $key === "debug_css") { $this->setDebugCss($value); } elseif ($key === "debugLayout" || $key === "debug_layout") { $this->setDebugLayout($value); } elseif ($key === "debugLayoutLines" || $key === "debug_layout_lines") { $this->setDebugLayoutLines($value); } elseif ($key === "debugLayoutBlocks" || $key === "debug_layout_blocks") { $this->setDebugLayoutBlocks($value); } elseif ($key === "debugLayoutInline" || $key === "debug_layout_inline") { $this->setDebugLayoutInline($value); } elseif ($key === "debugLayoutPaddingBox" || $key === "debug_layout_padding_box") { $this->setDebugLayoutPaddingBox($value); } elseif ($key === "pdfBackend" || $key === "pdf_backend") { $this->setPdfBackend($value); } elseif ($key === "pdflibLicense" || $key === "pdflib_license") { $this->setPdflibLicense($value); } elseif ($key === "httpContext" || $key === "http_context") { $this->setHttpContext($value); } } return $this; } public function get($key) { if ($key === "tempDir" || $key === "temp_dir") { return $this->getTempDir(); } elseif ($key === "fontDir" || $key === "font_dir") { return $this->getFontDir(); } elseif ($key === "fontCache" || $key === "font_cache") { return $this->getFontCache(); } elseif ($key === "chroot") { return $this->getChroot(); } elseif ($key === "allowedProtocols" || $key === "allowed_protocols") { return $this->getAllowedProtocols(); } elseif ($key === "logOutputFile" || $key === "log_output_file") { return $this->getLogOutputFile(); } elseif ($key === "defaultMediaType" || $key === "default_media_type") { return $this->getDefaultMediaType(); } elseif ($key === "defaultPaperSize" || $key === "default_paper_size") { return $this->getDefaultPaperSize(); } elseif ($key === "defaultPaperOrientation" || $key === "default_paper_orientation") { return $this->getDefaultPaperOrientation(); } elseif ($key === "defaultFont" || $key === "default_font") { return $this->getDefaultFont(); } elseif ($key === "dpi") { return $this->getDpi(); } elseif ($key === "fontHeightRatio" || $key === "font_height_ratio") { return $this->getFontHeightRatio(); } elseif ($key === "isPhpEnabled" || $key === "is_php_enabled" || $key === "enable_php") { return $this->getIsPhpEnabled(); } elseif ($key === "isRemoteEnabled" || $key === "is_remote_enabled" || $key === "enable_remote") { return $this->getIsRemoteEnabled(); } elseif ($key === "allowedRemoteHosts" || $key === "allowed_remote_hosts") { return $this->getAllowedProtocols(); } elseif ($key === "isJavascriptEnabled" || $key === "is_javascript_enabled" || $key === "enable_javascript") { return $this->getIsJavascriptEnabled(); } elseif ($key === "isHtml5ParserEnabled" || $key === "is_html5_parser_enabled" || $key === "enable_html5_parser") { return $this->getIsHtml5ParserEnabled(); } elseif ($key === "isFontSubsettingEnabled" || $key === "is_font_subsetting_enabled" || $key === "enable_font_subsetting") { return $this->getIsFontSubsettingEnabled(); } elseif ($key === "debugPng" || $key === "debug_png") { return $this->getDebugPng(); } elseif ($key === "debugKeepTemp" || $key === "debug_keep_temp") { return $this->getDebugKeepTemp(); } elseif ($key === "debugCss" || $key === "debug_css") { return $this->getDebugCss(); } elseif ($key === "debugLayout" || $key === "debug_layout") { return $this->getDebugLayout(); } elseif ($key === "debugLayoutLines" || $key === "debug_layout_lines") { return $this->getDebugLayoutLines(); } elseif ($key === "debugLayoutBlocks" || $key === "debug_layout_blocks") { return $this->getDebugLayoutBlocks(); } elseif ($key === "debugLayoutInline" || $key === "debug_layout_inline") { return $this->getDebugLayoutInline(); } elseif ($key === "debugLayoutPaddingBox" || $key === "debug_layout_padding_box") { return $this->getDebugLayoutPaddingBox(); } elseif ($key === "pdfBackend" || $key === "pdf_backend") { return $this->getPdfBackend(); } elseif ($key === "pdflibLicense" || $key === "pdflib_license") { return $this->getPdflibLicense(); } elseif ($key === "httpContext" || $key === "http_context") { return $this->getHttpContext(); } return null; } public function setPdfBackend($pdfBackend) { $this->pdfBackend = $pdfBackend; return $this; } public function getPdfBackend() { return $this->pdfBackend; } public function setPdflibLicense($pdflibLicense) { $this->pdflibLicense = $pdflibLicense; return $this; } public function getPdflibLicense() { return $this->pdflibLicense; } public function setChroot($chroot, $delimiter = ",") { if (is_string($chroot)) { $this->chroot = explode($delimiter, $chroot); } elseif (is_array($chroot)) { $this->chroot = $chroot; } return $this; } public function getAllowedProtocols() { return $this->allowedProtocols; } public function setAllowedProtocols(array $allowedProtocols) { $protocols = array(); foreach ($allowedProtocols as $protocol => $config) { if (is_string($protocol)) { $protocols[$protocol] = array(); if (is_array($config)) { $protocols[$protocol] = $config; } } elseif (is_string($config)) { $protocols[$config] = array(); } } $this->allowedProtocols = array(); foreach ($protocols as $protocol => $config) { $this->addAllowedProtocol($protocol, ...$config["rules"] ?? array()); } return $this; } public function addAllowedProtocol(string $protocol, callable ...$rules) { $protocol = strtolower($protocol); if (empty($rules)) { $rules = array(); switch ($protocol) { case "file://": $rules[] = array($this, "validateLocalUri"); break; case "http://": case "https://": $rules[] = array($this, "validateRemoteUri"); break; case "phar://": $rules[] = array($this, "validatePharUri"); break; } } $this->allowedProtocols[$protocol] = array("rules" => $rules); return $this; } public function getChroot() { $chroot = array(); if (is_array($this->chroot)) { $chroot = $this->chroot; } return $chroot; } public function setDebugCss($debugCss) { $this->debugCss = $debugCss; return $this; } public function getDebugCss() { return $this->debugCss; } public function setDebugKeepTemp($debugKeepTemp) { $this->debugKeepTemp = $debugKeepTemp; return $this; } public function getDebugKeepTemp() { return $this->debugKeepTemp; } public function setDebugLayout($debugLayout) { $this->debugLayout = $debugLayout; return $this; } public function getDebugLayout() { return $this->debugLayout; } public function setDebugLayoutBlocks($debugLayoutBlocks) { $this->debugLayoutBlocks = $debugLayoutBlocks; return $this; } public function getDebugLayoutBlocks() { return $this->debugLayoutBlocks; } public function setDebugLayoutInline($debugLayoutInline) { $this->debugLayoutInline = $debugLayoutInline; return $this; } public function getDebugLayoutInline() { return $this->debugLayoutInline; } public function setDebugLayoutLines($debugLayoutLines) { $this->debugLayoutLines = $debugLayoutLines; return $this; } public function getDebugLayoutLines() { return $this->debugLayoutLines; } public function setDebugLayoutPaddingBox($debugLayoutPaddingBox) { $this->debugLayoutPaddingBox = $debugLayoutPaddingBox; return $this; } public function getDebugLayoutPaddingBox() { return $this->debugLayoutPaddingBox; } public function setDebugPng($debugPng) { $this->debugPng = $debugPng; return $this; } public function getDebugPng() { return $this->debugPng; } public function setDefaultFont($defaultFont) { if (!($defaultFont === null || trim($defaultFont) === '')) { $this->defaultFont = $defaultFont; } else { $this->defaultFont = "serif"; } return $this; } public function getDefaultFont() { return $this->defaultFont; } public function setDefaultMediaType($defaultMediaType) { $this->defaultMediaType = $defaultMediaType; return $this; } public function getDefaultMediaType() { return $this->defaultMediaType; } public function setDefaultPaperSize($defaultPaperSize) : self { $this->defaultPaperSize = $defaultPaperSize; return $this; } public function setDefaultPaperOrientation(string $defaultPaperOrientation) : self { $this->defaultPaperOrientation = $defaultPaperOrientation; return $this; } public function getDefaultPaperSize() { return $this->defaultPaperSize; } public function getDefaultPaperOrientation() : string { return $this->defaultPaperOrientation; } public function setDpi($dpi) { $this->dpi = $dpi; return $this; } public function getDpi() { return $this->dpi; } public function setFontCache($fontCache) { $this->fontCache = $fontCache; return $this; } public function getFontCache() { return $this->fontCache; } public function setFontDir($fontDir) { $this->fontDir = $fontDir; return $this; } public function getFontDir() { return $this->fontDir; } public function setFontHeightRatio($fontHeightRatio) { $this->fontHeightRatio = $fontHeightRatio; return $this; } public function getFontHeightRatio() { return $this->fontHeightRatio; } public function setIsFontSubsettingEnabled($isFontSubsettingEnabled) { $this->isFontSubsettingEnabled = $isFontSubsettingEnabled; return $this; } public function getIsFontSubsettingEnabled() { return $this->isFontSubsettingEnabled; } public function isFontSubsettingEnabled() { return $this->getIsFontSubsettingEnabled(); } public function setIsHtml5ParserEnabled($isHtml5ParserEnabled) { $this->isHtml5ParserEnabled = $isHtml5ParserEnabled; return $this; } public function getIsHtml5ParserEnabled() { return $this->isHtml5ParserEnabled; } public function isHtml5ParserEnabled() { return $this->getIsHtml5ParserEnabled(); } public function setIsJavascriptEnabled($isJavascriptEnabled) { $this->isJavascriptEnabled = $isJavascriptEnabled; return $this; } public function getIsJavascriptEnabled() { return $this->isJavascriptEnabled; } public function isJavascriptEnabled() { return $this->getIsJavascriptEnabled(); } public function setIsPhpEnabled($isPhpEnabled) { $this->isPhpEnabled = $isPhpEnabled; return $this; } public function getIsPhpEnabled() { return $this->isPhpEnabled; } public function isPhpEnabled() { return $this->getIsPhpEnabled(); } public function setIsRemoteEnabled($isRemoteEnabled) { $this->isRemoteEnabled = $isRemoteEnabled; return $this; } public function getIsRemoteEnabled() { return $this->isRemoteEnabled; } public function isRemoteEnabled() { return $this->getIsRemoteEnabled(); } public function setAllowedRemoteHosts($allowedRemoteHosts) { if (is_array($allowedRemoteHosts)) { foreach ($allowedRemoteHosts as &$host) { $host = mb_strtolower($host); } unset($host); } $this->allowedRemoteHosts = $allowedRemoteHosts; return $this; } public function getAllowedRemoteHosts() { return $this->allowedRemoteHosts; } public function setLogOutputFile($logOutputFile) { $this->logOutputFile = $logOutputFile; return $this; } public function getLogOutputFile() { return $this->logOutputFile; } public function setTempDir($tempDir) { $this->tempDir = $tempDir; return $this; } public function getTempDir() { return $this->tempDir; } public function setRootDir($rootDir) { $this->rootDir = $rootDir; return $this; } public function getRootDir() { return $this->rootDir; } public function setHttpContext($httpContext) { $this->httpContext = is_array($httpContext) ? stream_context_create($httpContext) : $httpContext; return $this; } public function getHttpContext() { return $this->httpContext; } public function validateLocalUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "The URI must not be empty."); } $realfile = realpath(str_replace("file://", '', $uri)); $dirs = $this->chroot; $dirs[] = $this->rootDir; $chrootValid = false; foreach ($dirs as $chrootPath) { $chrootPath = realpath($chrootPath); if ($chrootPath !== false && strpos($realfile, $chrootPath) === 0) { $chrootValid = true; break; } } if ($chrootValid !== true) { return array(false, "Permission denied. The file could not be found under the paths specified by Options::chroot."); } if (!$realfile) { return array(false, "File not found."); } return array(true, null); } public function validatePharUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "The URI must not be empty."); } $file = substr(substr($uri, 0, strpos($uri, ".phar") + 5), 7); return $this->validateLocalUri($file); } public function validateRemoteUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "The URI must not be empty."); } if (!$this->isRemoteEnabled) { return array(false, "Remote file requested, but remote file download is disabled."); } if (is_array($this->allowedRemoteHosts) && count($this->allowedRemoteHosts) > 0) { $host = parse_url($uri, PHP_URL_HOST); $host = mb_strtolower($host); if (!in_array($host, $this->allowedRemoteHosts, true)) { return array(false, "Remote host is not in allowed list: " . $host); } } return array(true, null); } } ?>
Did this file decode correctly?
Original Code
<?php
namespace Dompdf; class Options { private $rootDir; private $tempDir; private $fontDir; private $fontCache; private $chroot; private $allowedProtocols = array("\x66\x69\x6c\x65\x3a\x2f\57" => array("\x72\165\x6c\x65\x73" => array()), "\150\164\x74\x70\72\x2f\x2f" => array("\162\165\154\x65\x73" => array()), "\150\164\164\160\x73\x3a\x2f\x2f" => array("\x72\165\154\145\163" => array())); private $logOutputFile; private $defaultMediaType = "\163\x63\x72\145\x65\x6e"; private $defaultPaperSize = "\x6c\145\164\x74\145\x72"; private $defaultPaperOrientation = "\x70\x6f\x72\x74\x72\x61\x69\164"; private $defaultFont = "\x73\145\x72\151\146"; private $dpi = 96; private $fontHeightRatio = 1.1; private $isPhpEnabled = false; private $isRemoteEnabled = false; private $allowedRemoteHosts = null; private $isJavascriptEnabled = true; private $isHtml5ParserEnabled = true; private $isFontSubsettingEnabled = true; private $debugPng = false; private $debugKeepTemp = false; private $debugCss = false; private $debugLayout = false; private $debugLayoutLines = true; private $debugLayoutBlocks = true; private $debugLayoutInline = true; private $debugLayoutPaddingBox = true; private $pdfBackend = "\x43\x50\104\106"; private $pdflibLicense = ''; private $httpContext; public function __construct(array $attributes = null) { $rootDir = realpath(__DIR__ . "\x2f\x2e\56\x2f"); $this->setChroot(array($rootDir)); $this->setRootDir($rootDir); $this->setTempDir(sys_get_temp_dir()); $this->setFontDir($rootDir . "\57\x6c\151\x62\x2f\146\157\x6e\164\x73"); $this->setFontCache($this->getFontDir()); $ver = ''; $versionFile = realpath(__DIR__ . "\57\56\56\x2f\126\105\122\123\x49\x4f\116"); if (($version = file_get_contents($versionFile)) !== false) { $version = trim($version); if ($version !== "\44\106\x6f\x72\x6d\141\164\x3a\74\45\x68\76\44") { $ver = "\57{$version}"; } } $this->setHttpContext(array("\150\164\x74\x70" => array("\x66\x6f\154\x6c\157\x77\x5f\x6c\x6f\143\141\x74\x69\x6f\x6e" => false, "\x75\163\145\162\137\x61\x67\145\x6e\x74" => "\x44\x6f\155\160\144\x66{$ver}\x20\x68\164\x74\x70\163\x3a\x2f\57\147\x69\x74\150\165\142\x2e\143\x6f\155\57\144\157\x6d\x70\144\x66\x2f\144\x6f\155\160\144\x66"))); $this->setAllowedProtocols(array("\146\151\x6c\x65\72\57\x2f", "\x68\164\x74\x70\x3a\x2f\x2f", "\x68\x74\164\160\x73\x3a\x2f\x2f")); if (null !== $attributes) { $this->set($attributes); } } public function set($attributes, $value = null) { if (!is_array($attributes)) { $attributes = array($attributes => $value); } foreach ($attributes as $key => $value) { if ($key === "\x74\x65\x6d\x70\x44\x69\162" || $key === "\164\145\155\x70\x5f\144\x69\x72") { $this->setTempDir($value); } elseif ($key === "\146\x6f\156\164\104\151\x72" || $key === "\x66\x6f\156\164\137\x64\151\162") { $this->setFontDir($value); } elseif ($key === "\146\157\x6e\x74\x43\x61\143\x68\145" || $key === "\146\x6f\x6e\164\x5f\x63\141\143\150\x65") { $this->setFontCache($value); } elseif ($key === "\143\x68\x72\x6f\x6f\164") { $this->setChroot($value); } elseif ($key === "\141\x6c\x6c\157\x77\145\144\x50\x72\x6f\164\157\143\157\154\163" || $key === "\141\154\154\x6f\167\x65\144\x5f\160\162\x6f\x74\157\x63\x6f\154\163") { $this->setAllowedProtocols($value); } elseif ($key === "\x6c\157\x67\x4f\165\164\160\165\x74\106\151\154\x65" || $key === "\x6c\157\147\x5f\157\165\x74\160\165\164\137\146\151\x6c\145") { $this->setLogOutputFile($value); } elseif ($key === "\144\145\146\x61\165\154\x74\x4d\145\144\x69\x61\x54\171\x70\x65" || $key === "\x64\145\x66\141\x75\154\164\137\155\x65\144\151\x61\137\164\171\160\x65") { $this->setDefaultMediaType($value); } elseif ($key === "\144\145\146\141\x75\154\x74\120\x61\x70\145\x72\x53\151\x7a\145" || $key === "\144\145\146\x61\165\154\164\x5f\x70\141\160\x65\x72\x5f\163\x69\x7a\145") { $this->setDefaultPaperSize($value); } elseif ($key === "\144\145\x66\141\x75\x6c\x74\x50\141\160\x65\162\x4f\x72\x69\x65\156\164\x61\x74\x69\x6f\156" || $key === "\144\145\146\141\x75\154\x74\137\x70\141\160\x65\162\x5f\157\162\x69\145\x6e\164\x61\x74\x69\157\x6e") { $this->setDefaultPaperOrientation($value); } elseif ($key === "\x64\x65\x66\141\165\154\164\106\x6f\x6e\x74" || $key === "\x64\145\x66\141\x75\x6c\164\137\x66\157\x6e\x74") { $this->setDefaultFont($value); } elseif ($key === "\x64\160\x69") { $this->setDpi($value); } elseif ($key === "\x66\157\x6e\164\x48\x65\151\x67\x68\164\122\x61\164\151\157" || $key === "\146\x6f\156\x74\137\150\145\151\x67\x68\164\x5f\x72\x61\x74\151\157") { $this->setFontHeightRatio($value); } elseif ($key === "\151\x73\x50\x68\x70\105\156\141\142\x6c\145\144" || $key === "\151\x73\x5f\x70\x68\x70\137\x65\156\141\x62\x6c\x65\144" || $key === "\145\x6e\x61\142\154\x65\137\160\150\x70") { $this->setIsPhpEnabled($value); } elseif ($key === "\151\x73\122\x65\x6d\x6f\x74\145\x45\156\x61\142\x6c\x65\144" || $key === "\151\163\137\162\145\x6d\157\x74\x65\x5f\145\x6e\x61\x62\x6c\145\144" || $key === "\145\x6e\141\x62\154\145\x5f\162\x65\x6d\157\x74\x65") { $this->setIsRemoteEnabled($value); } elseif ($key === "\141\x6c\x6c\x6f\167\x65\144\x52\x65\155\157\164\x65\110\157\x73\164\163" || $key === "\141\x6c\154\157\167\145\144\x5f\162\x65\155\x6f\164\145\137\x68\x6f\x73\164\163") { $this->setAllowedRemoteHosts($value); } elseif ($key === "\151\x73\112\141\166\141\163\143\162\x69\160\x74\x45\156\141\x62\154\145\144" || $key === "\x69\163\137\152\141\166\141\163\x63\162\x69\160\x74\137\145\156\x61\x62\154\x65\144" || $key === "\x65\x6e\x61\x62\x6c\x65\x5f\152\x61\166\141\x73\143\x72\151\x70\x74") { $this->setIsJavascriptEnabled($value); } elseif ($key === "\x69\x73\x48\x74\x6d\x6c\x35\x50\141\x72\163\145\162\x45\156\x61\142\x6c\x65\144" || $key === "\151\163\x5f\150\164\x6d\x6c\65\137\x70\141\x72\x73\145\162\137\145\x6e\141\142\x6c\145\x64" || $key === "\x65\156\141\142\154\145\x5f\150\164\155\154\x35\137\160\x61\x72\x73\x65\x72") { $this->setIsHtml5ParserEnabled($value); } elseif ($key === "\x69\163\x46\x6f\x6e\x74\123\x75\x62\163\x65\164\164\x69\x6e\147\105\156\x61\x62\154\x65\144" || $key === "\x69\x73\137\146\x6f\x6e\164\137\163\x75\142\x73\x65\x74\x74\x69\x6e\147\x5f\145\156\141\142\154\x65\144" || $key === "\145\x6e\141\142\154\145\137\x66\157\x6e\x74\137\x73\x75\x62\x73\x65\x74\x74\x69\156\x67") { $this->setIsFontSubsettingEnabled($value); } elseif ($key === "\x64\x65\142\x75\147\120\156\x67" || $key === "\x64\x65\142\x75\147\137\x70\156\x67") { $this->setDebugPng($value); } elseif ($key === "\144\145\x62\165\x67\113\145\x65\x70\x54\x65\x6d\160" || $key === "\x64\x65\142\x75\x67\x5f\x6b\x65\x65\x70\x5f\164\x65\x6d\160") { $this->setDebugKeepTemp($value); } elseif ($key === "\x64\x65\x62\165\147\x43\x73\163" || $key === "\x64\x65\x62\x75\x67\137\143\x73\x73") { $this->setDebugCss($value); } elseif ($key === "\x64\145\142\x75\147\114\x61\171\x6f\165\x74" || $key === "\x64\x65\142\x75\147\137\x6c\x61\171\x6f\x75\164") { $this->setDebugLayout($value); } elseif ($key === "\144\145\142\165\x67\114\x61\x79\157\x75\x74\x4c\151\x6e\x65\163" || $key === "\x64\145\x62\165\147\x5f\x6c\x61\x79\x6f\x75\164\137\154\151\x6e\145\163") { $this->setDebugLayoutLines($value); } elseif ($key === "\x64\x65\142\x75\147\x4c\x61\x79\157\165\164\x42\x6c\157\x63\x6b\x73" || $key === "\144\x65\142\x75\147\x5f\154\141\171\x6f\165\164\137\x62\154\157\143\x6b\163") { $this->setDebugLayoutBlocks($value); } elseif ($key === "\144\x65\142\165\147\114\141\171\157\x75\x74\111\156\154\151\156\145" || $key === "\144\x65\142\165\147\137\154\141\x79\x6f\x75\x74\137\x69\156\154\151\x6e\x65") { $this->setDebugLayoutInline($value); } elseif ($key === "\x64\145\x62\165\x67\x4c\x61\171\157\x75\x74\120\x61\144\x64\x69\156\x67\x42\157\170" || $key === "\144\145\142\x75\147\137\x6c\141\x79\x6f\165\x74\137\x70\141\144\144\151\156\x67\x5f\142\x6f\170") { $this->setDebugLayoutPaddingBox($value); } elseif ($key === "\160\x64\146\x42\x61\143\x6b\145\x6e\144" || $key === "\160\144\x66\137\x62\141\143\153\145\x6e\144") { $this->setPdfBackend($value); } elseif ($key === "\x70\x64\x66\x6c\151\x62\x4c\x69\x63\x65\156\163\145" || $key === "\160\x64\146\x6c\x69\x62\x5f\154\x69\143\x65\x6e\x73\145") { $this->setPdflibLicense($value); } elseif ($key === "\150\x74\164\160\103\x6f\x6e\x74\x65\x78\x74" || $key === "\150\164\x74\160\137\x63\x6f\156\164\x65\x78\x74") { $this->setHttpContext($value); } } return $this; } public function get($key) { if ($key === "\x74\145\155\x70\x44\151\162" || $key === "\164\x65\x6d\x70\x5f\x64\151\162") { return $this->getTempDir(); } elseif ($key === "\146\x6f\156\164\104\151\162" || $key === "\x66\157\x6e\164\137\x64\x69\x72") { return $this->getFontDir(); } elseif ($key === "\146\157\156\164\x43\141\143\x68\x65" || $key === "\x66\157\156\164\x5f\143\141\143\x68\145") { return $this->getFontCache(); } elseif ($key === "\143\150\x72\157\x6f\x74") { return $this->getChroot(); } elseif ($key === "\141\154\x6c\x6f\167\x65\144\120\162\157\x74\x6f\x63\157\x6c\163" || $key === "\x61\154\x6c\x6f\167\x65\x64\x5f\x70\162\157\x74\157\143\157\x6c\163") { return $this->getAllowedProtocols(); } elseif ($key === "\154\157\147\117\165\x74\x70\165\164\106\x69\x6c\x65" || $key === "\154\157\147\x5f\157\165\164\x70\x75\164\x5f\x66\151\154\145") { return $this->getLogOutputFile(); } elseif ($key === "\144\145\x66\141\165\154\164\115\x65\x64\151\x61\x54\x79\160\145" || $key === "\x64\x65\146\141\x75\x6c\x74\x5f\x6d\x65\144\151\x61\x5f\x74\171\x70\145") { return $this->getDefaultMediaType(); } elseif ($key === "\144\145\x66\x61\165\x6c\x74\120\141\160\145\x72\x53\x69\172\145" || $key === "\144\x65\146\x61\x75\154\164\137\160\141\x70\145\162\137\x73\x69\172\x65") { return $this->getDefaultPaperSize(); } elseif ($key === "\x64\x65\x66\141\x75\x6c\x74\x50\141\x70\x65\162\x4f\x72\151\x65\x6e\x74\x61\x74\151\157\x6e" || $key === "\x64\145\x66\141\165\x6c\x74\137\160\141\160\x65\x72\x5f\x6f\162\x69\145\156\164\x61\x74\151\157\156") { return $this->getDefaultPaperOrientation(); } elseif ($key === "\144\145\x66\x61\165\154\x74\106\x6f\x6e\x74" || $key === "\144\x65\x66\x61\165\x6c\x74\137\x66\x6f\x6e\164") { return $this->getDefaultFont(); } elseif ($key === "\x64\160\x69") { return $this->getDpi(); } elseif ($key === "\x66\x6f\156\164\110\x65\151\x67\150\164\122\141\x74\x69\157" || $key === "\x66\157\156\164\x5f\x68\145\x69\x67\x68\164\x5f\162\x61\x74\x69\x6f") { return $this->getFontHeightRatio(); } elseif ($key === "\151\x73\x50\150\x70\x45\x6e\141\x62\154\x65\144" || $key === "\151\163\x5f\160\x68\160\x5f\145\156\x61\142\154\145\144" || $key === "\145\x6e\x61\x62\x6c\145\x5f\160\150\x70") { return $this->getIsPhpEnabled(); } elseif ($key === "\x69\x73\122\x65\155\x6f\164\145\105\x6e\141\x62\154\x65\144" || $key === "\151\x73\137\x72\145\x6d\157\164\145\x5f\x65\x6e\141\x62\x6c\x65\144" || $key === "\x65\x6e\141\x62\x6c\x65\x5f\x72\145\x6d\x6f\x74\x65") { return $this->getIsRemoteEnabled(); } elseif ($key === "\x61\154\x6c\157\167\145\x64\x52\x65\x6d\157\x74\x65\110\x6f\x73\164\x73" || $key === "\141\154\154\157\x77\145\144\137\162\x65\x6d\157\x74\x65\137\x68\x6f\x73\x74\163") { return $this->getAllowedProtocols(); } elseif ($key === "\x69\163\112\141\x76\x61\163\x63\x72\151\x70\x74\105\156\x61\x62\154\x65\x64" || $key === "\x69\x73\x5f\152\x61\x76\x61\163\x63\x72\x69\x70\x74\x5f\x65\156\141\x62\154\x65\x64" || $key === "\x65\x6e\141\x62\154\145\137\152\141\166\141\x73\143\x72\151\160\x74") { return $this->getIsJavascriptEnabled(); } elseif ($key === "\x69\x73\x48\164\155\154\65\120\141\162\163\145\162\105\156\141\x62\x6c\145\144" || $key === "\x69\x73\137\x68\x74\155\154\x35\137\x70\x61\x72\x73\145\162\x5f\x65\156\141\x62\x6c\145\x64" || $key === "\145\156\x61\142\x6c\x65\137\x68\x74\155\x6c\x35\137\160\x61\x72\x73\145\x72") { return $this->getIsHtml5ParserEnabled(); } elseif ($key === "\151\163\x46\x6f\x6e\x74\123\x75\142\163\x65\x74\164\x69\156\x67\105\156\x61\x62\154\145\144" || $key === "\x69\163\x5f\x66\x6f\x6e\164\137\x73\165\x62\x73\x65\x74\x74\x69\156\x67\x5f\145\x6e\x61\x62\154\x65\144" || $key === "\145\156\141\x62\154\145\x5f\146\x6f\x6e\164\137\x73\165\142\x73\x65\x74\x74\x69\156\147") { return $this->getIsFontSubsettingEnabled(); } elseif ($key === "\144\145\142\x75\x67\x50\x6e\147" || $key === "\144\x65\142\165\x67\x5f\x70\156\x67") { return $this->getDebugPng(); } elseif ($key === "\x64\145\142\165\147\113\145\x65\160\x54\x65\x6d\160" || $key === "\x64\145\x62\x75\x67\x5f\x6b\145\x65\x70\x5f\164\x65\155\x70") { return $this->getDebugKeepTemp(); } elseif ($key === "\144\x65\142\x75\147\103\163\163" || $key === "\x64\x65\142\165\x67\137\143\163\163") { return $this->getDebugCss(); } elseif ($key === "\144\145\x62\x75\x67\x4c\141\171\157\x75\164" || $key === "\x64\145\142\x75\147\x5f\154\x61\171\157\165\x74") { return $this->getDebugLayout(); } elseif ($key === "\144\145\142\165\147\114\141\171\157\x75\x74\114\151\x6e\145\x73" || $key === "\144\x65\142\x75\147\x5f\154\x61\x79\157\165\164\x5f\154\x69\156\x65\x73") { return $this->getDebugLayoutLines(); } elseif ($key === "\144\x65\142\165\147\x4c\141\x79\157\165\164\x42\x6c\x6f\x63\x6b\163" || $key === "\x64\145\142\165\147\137\154\x61\171\157\165\164\x5f\142\x6c\157\143\153\163") { return $this->getDebugLayoutBlocks(); } elseif ($key === "\144\x65\142\165\x67\114\x61\171\157\165\164\111\156\x6c\x69\x6e\x65" || $key === "\144\x65\x62\x75\147\137\x6c\141\x79\157\165\x74\x5f\151\156\154\151\x6e\x65") { return $this->getDebugLayoutInline(); } elseif ($key === "\144\145\x62\x75\147\x4c\x61\x79\157\x75\164\x50\x61\x64\144\151\x6e\x67\x42\157\170" || $key === "\144\145\142\x75\x67\137\x6c\x61\171\157\165\x74\137\x70\x61\x64\144\x69\156\147\137\x62\157\170") { return $this->getDebugLayoutPaddingBox(); } elseif ($key === "\x70\144\x66\x42\141\143\153\x65\156\x64" || $key === "\x70\144\146\x5f\142\x61\143\x6b\145\x6e\x64") { return $this->getPdfBackend(); } elseif ($key === "\160\144\x66\x6c\x69\x62\x4c\151\143\x65\x6e\163\145" || $key === "\x70\144\x66\x6c\151\x62\x5f\x6c\151\x63\x65\156\163\x65") { return $this->getPdflibLicense(); } elseif ($key === "\x68\x74\164\x70\103\x6f\x6e\x74\145\x78\x74" || $key === "\x68\x74\x74\x70\x5f\x63\x6f\156\164\x65\170\x74") { return $this->getHttpContext(); } return null; } public function setPdfBackend($pdfBackend) { $this->pdfBackend = $pdfBackend; return $this; } public function getPdfBackend() { return $this->pdfBackend; } public function setPdflibLicense($pdflibLicense) { $this->pdflibLicense = $pdflibLicense; return $this; } public function getPdflibLicense() { return $this->pdflibLicense; } public function setChroot($chroot, $delimiter = "\54") { if (is_string($chroot)) { $this->chroot = explode($delimiter, $chroot); } elseif (is_array($chroot)) { $this->chroot = $chroot; } return $this; } public function getAllowedProtocols() { return $this->allowedProtocols; } public function setAllowedProtocols(array $allowedProtocols) { $protocols = array(); foreach ($allowedProtocols as $protocol => $config) { if (is_string($protocol)) { $protocols[$protocol] = array(); if (is_array($config)) { $protocols[$protocol] = $config; } } elseif (is_string($config)) { $protocols[$config] = array(); } } $this->allowedProtocols = array(); foreach ($protocols as $protocol => $config) { $this->addAllowedProtocol($protocol, ...$config["\x72\165\154\145\x73"] ?? array()); } return $this; } public function addAllowedProtocol(string $protocol, callable ...$rules) { $protocol = strtolower($protocol); if (empty($rules)) { $rules = array(); switch ($protocol) { case "\146\151\154\x65\72\x2f\57": $rules[] = array($this, "\x76\141\x6c\x69\x64\141\x74\145\114\157\143\x61\154\x55\x72\x69"); break; case "\150\x74\164\160\x3a\57\x2f": case "\x68\164\164\160\x73\72\x2f\57": $rules[] = array($this, "\x76\x61\x6c\151\144\141\164\x65\122\145\x6d\157\x74\145\125\x72\151"); break; case "\x70\150\141\162\72\x2f\57": $rules[] = array($this, "\x76\141\x6c\x69\144\141\x74\x65\120\150\141\x72\x55\x72\x69"); break; } } $this->allowedProtocols[$protocol] = array("\162\x75\154\145\163" => $rules); return $this; } public function getChroot() { $chroot = array(); if (is_array($this->chroot)) { $chroot = $this->chroot; } return $chroot; } public function setDebugCss($debugCss) { $this->debugCss = $debugCss; return $this; } public function getDebugCss() { return $this->debugCss; } public function setDebugKeepTemp($debugKeepTemp) { $this->debugKeepTemp = $debugKeepTemp; return $this; } public function getDebugKeepTemp() { return $this->debugKeepTemp; } public function setDebugLayout($debugLayout) { $this->debugLayout = $debugLayout; return $this; } public function getDebugLayout() { return $this->debugLayout; } public function setDebugLayoutBlocks($debugLayoutBlocks) { $this->debugLayoutBlocks = $debugLayoutBlocks; return $this; } public function getDebugLayoutBlocks() { return $this->debugLayoutBlocks; } public function setDebugLayoutInline($debugLayoutInline) { $this->debugLayoutInline = $debugLayoutInline; return $this; } public function getDebugLayoutInline() { return $this->debugLayoutInline; } public function setDebugLayoutLines($debugLayoutLines) { $this->debugLayoutLines = $debugLayoutLines; return $this; } public function getDebugLayoutLines() { return $this->debugLayoutLines; } public function setDebugLayoutPaddingBox($debugLayoutPaddingBox) { $this->debugLayoutPaddingBox = $debugLayoutPaddingBox; return $this; } public function getDebugLayoutPaddingBox() { return $this->debugLayoutPaddingBox; } public function setDebugPng($debugPng) { $this->debugPng = $debugPng; return $this; } public function getDebugPng() { return $this->debugPng; } public function setDefaultFont($defaultFont) { if (!($defaultFont === null || trim($defaultFont) === '')) { $this->defaultFont = $defaultFont; } else { $this->defaultFont = "\163\145\162\151\146"; } return $this; } public function getDefaultFont() { return $this->defaultFont; } public function setDefaultMediaType($defaultMediaType) { $this->defaultMediaType = $defaultMediaType; return $this; } public function getDefaultMediaType() { return $this->defaultMediaType; } public function setDefaultPaperSize($defaultPaperSize) : self { $this->defaultPaperSize = $defaultPaperSize; return $this; } public function setDefaultPaperOrientation(string $defaultPaperOrientation) : self { $this->defaultPaperOrientation = $defaultPaperOrientation; return $this; } public function getDefaultPaperSize() { return $this->defaultPaperSize; } public function getDefaultPaperOrientation() : string { return $this->defaultPaperOrientation; } public function setDpi($dpi) { $this->dpi = $dpi; return $this; } public function getDpi() { return $this->dpi; } public function setFontCache($fontCache) { $this->fontCache = $fontCache; return $this; } public function getFontCache() { return $this->fontCache; } public function setFontDir($fontDir) { $this->fontDir = $fontDir; return $this; } public function getFontDir() { return $this->fontDir; } public function setFontHeightRatio($fontHeightRatio) { $this->fontHeightRatio = $fontHeightRatio; return $this; } public function getFontHeightRatio() { return $this->fontHeightRatio; } public function setIsFontSubsettingEnabled($isFontSubsettingEnabled) { $this->isFontSubsettingEnabled = $isFontSubsettingEnabled; return $this; } public function getIsFontSubsettingEnabled() { return $this->isFontSubsettingEnabled; } public function isFontSubsettingEnabled() { return $this->getIsFontSubsettingEnabled(); } public function setIsHtml5ParserEnabled($isHtml5ParserEnabled) { $this->isHtml5ParserEnabled = $isHtml5ParserEnabled; return $this; } public function getIsHtml5ParserEnabled() { return $this->isHtml5ParserEnabled; } public function isHtml5ParserEnabled() { return $this->getIsHtml5ParserEnabled(); } public function setIsJavascriptEnabled($isJavascriptEnabled) { $this->isJavascriptEnabled = $isJavascriptEnabled; return $this; } public function getIsJavascriptEnabled() { return $this->isJavascriptEnabled; } public function isJavascriptEnabled() { return $this->getIsJavascriptEnabled(); } public function setIsPhpEnabled($isPhpEnabled) { $this->isPhpEnabled = $isPhpEnabled; return $this; } public function getIsPhpEnabled() { return $this->isPhpEnabled; } public function isPhpEnabled() { return $this->getIsPhpEnabled(); } public function setIsRemoteEnabled($isRemoteEnabled) { $this->isRemoteEnabled = $isRemoteEnabled; return $this; } public function getIsRemoteEnabled() { return $this->isRemoteEnabled; } public function isRemoteEnabled() { return $this->getIsRemoteEnabled(); } public function setAllowedRemoteHosts($allowedRemoteHosts) { if (is_array($allowedRemoteHosts)) { foreach ($allowedRemoteHosts as &$host) { $host = mb_strtolower($host); } unset($host); } $this->allowedRemoteHosts = $allowedRemoteHosts; return $this; } public function getAllowedRemoteHosts() { return $this->allowedRemoteHosts; } public function setLogOutputFile($logOutputFile) { $this->logOutputFile = $logOutputFile; return $this; } public function getLogOutputFile() { return $this->logOutputFile; } public function setTempDir($tempDir) { $this->tempDir = $tempDir; return $this; } public function getTempDir() { return $this->tempDir; } public function setRootDir($rootDir) { $this->rootDir = $rootDir; return $this; } public function getRootDir() { return $this->rootDir; } public function setHttpContext($httpContext) { $this->httpContext = is_array($httpContext) ? stream_context_create($httpContext) : $httpContext; return $this; } public function getHttpContext() { return $this->httpContext; } public function validateLocalUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "\124\x68\145\x20\125\122\x49\40\x6d\165\163\164\40\156\x6f\x74\x20\142\145\40\145\155\160\x74\171\x2e"); } $realfile = realpath(str_replace("\146\x69\154\x65\72\x2f\x2f", '', $uri)); $dirs = $this->chroot; $dirs[] = $this->rootDir; $chrootValid = false; foreach ($dirs as $chrootPath) { $chrootPath = realpath($chrootPath); if ($chrootPath !== false && strpos($realfile, $chrootPath) === 0) { $chrootValid = true; break; } } if ($chrootValid !== true) { return array(false, "\120\145\162\155\x69\x73\163\x69\157\x6e\40\x64\145\156\151\x65\144\56\x20\x54\x68\x65\40\x66\x69\154\x65\40\143\157\x75\x6c\144\40\156\157\164\x20\x62\x65\x20\146\x6f\x75\x6e\144\40\x75\156\144\145\162\x20\164\150\x65\x20\x70\x61\x74\150\x73\40\163\x70\145\143\x69\146\x69\145\144\x20\x62\171\x20\x4f\x70\164\x69\x6f\x6e\x73\x3a\72\143\x68\x72\157\157\164\x2e"); } if (!$realfile) { return array(false, "\x46\151\x6c\145\x20\156\157\x74\40\146\157\165\156\144\56"); } return array(true, null); } public function validatePharUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "\124\x68\x65\x20\125\122\111\x20\155\165\x73\164\x20\156\x6f\164\40\142\x65\40\x65\155\160\164\x79\x2e"); } $file = substr(substr($uri, 0, strpos($uri, "\x2e\160\150\x61\162") + 5), 7); return $this->validateLocalUri($file); } public function validateRemoteUri(string $uri) { if ($uri === null || strlen($uri) === 0) { return array(false, "\x54\150\x65\x20\x55\122\x49\x20\x6d\165\x73\x74\x20\156\157\164\40\142\x65\x20\145\x6d\x70\164\x79\56"); } if (!$this->isRemoteEnabled) { return array(false, "\122\x65\x6d\x6f\164\145\x20\x66\151\x6c\x65\40\162\x65\161\x75\145\x73\x74\145\x64\54\40\142\165\164\x20\x72\x65\155\x6f\164\145\40\146\151\154\145\x20\144\x6f\167\x6e\154\x6f\x61\144\40\x69\x73\x20\144\x69\x73\141\x62\x6c\145\x64\x2e"); } if (is_array($this->allowedRemoteHosts) && count($this->allowedRemoteHosts) > 0) { $host = parse_url($uri, PHP_URL_HOST); $host = mb_strtolower($host); if (!in_array($host, $this->allowedRemoteHosts, true)) { return array(false, "\x52\x65\x6d\x6f\x74\x65\x20\150\157\163\164\x20\x69\163\40\x6e\x6f\x74\40\x69\x6e\x20\x61\x6c\x6c\157\x77\x65\144\x20\154\x69\163\164\72\40" . $host); } } return array(true, null); } }
Function Calls
None |
Stats
MD5 | 1ea674ccd683350dcc9083ed8f3d339e |
Eval Count | 0 |
Decode Time | 108 ms |