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 if (!defined("\120\110\x50\x45\130\x43\x45\x4c\x5f\122\117\117\124")) { define("\x5..
Decoded Output download
<?php
if (!defined("PHPEXCEL_ROOT")) { define("PHPEXCEL_ROOT", dirname(__FILE__) . "/../../"); require PHPEXCEL_ROOT . "PHPExcel/Autoloader.php"; } class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { protected $inputEncoding = "ANSI"; protected $sheetIndex = 0; protected $formats = array("h1" => array("font" => array("bold" => true, "size" => 24)), "h2" => array("font" => array("bold" => true, "size" => 18)), "h3" => array("font" => array("bold" => true, "size" => 13.5)), "h4" => array("font" => array("bold" => true, "size" => 12)), "h5" => array("font" => array("bold" => true, "size" => 10)), "h6" => array("font" => array("bold" => true, "size" => 7.5)), "a" => array("font" => array("underline" => true, "color" => array("argb" => PHPExcel_Style_Color::COLOR_BLUE))), "hr" => array("borders" => array("bottom" => array("style" => PHPExcel_Style_Border::BORDER_THIN, "color" => array(PHPExcel_Style_Color::COLOR_BLACK))))); protected $rowspan = array(); public function __construct() { $this->readFilter = new PHPExcel_Reader_DefaultReadFilter(); } protected function isValidFormat() { $data = fread($this->fileHandle, 2048); if (strpos($data, "<") !== false && strlen($data) !== strlen(strip_tags($data))) { return true; } return false; } public function load($pFilename) { $objPHPExcel = new PHPExcel(); return $this->loadIntoExisting($pFilename, $objPHPExcel); } public function setInputEncoding($pValue = "ANSI") { $this->inputEncoding = $pValue; return $this; } public function getInputEncoding() { return $this->inputEncoding; } protected $dataArray = array(); protected $tableLevel = 0; protected $nestedColumn = array("A"); protected function setTableStartColumn($column) { if ($this->tableLevel == 0) { $column = "A"; } ++$this->tableLevel; $this->nestedColumn[$this->tableLevel] = $column; return $this->nestedColumn[$this->tableLevel]; } protected function getTableStartColumn() { return $this->nestedColumn[$this->tableLevel]; } protected function releaseTableStartColumn() { --$this->tableLevel; return array_pop($this->nestedColumn); } protected function flushCell($sheet, $column, $row, &$cellContent) { if (is_string($cellContent)) { if (trim($cellContent) > '') { $sheet->setCellValue($column . $row, $cellContent, true); $this->dataArray[$row][$column] = $cellContent; } } else { $this->dataArray[$row][$column] = "RICH TEXT: " . $cellContent; } $cellContent = (string) ''; } protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null) { foreach ($element->childNodes as $child) { if ($child instanceof DOMText) { $domText = preg_replace("/\s+/u", " ", trim($child->nodeValue)); if (is_string($cellContent)) { $cellContent .= $domText; } else { } } elseif ($child instanceof DOMElement) { $attributeArray = array(); foreach ($child->attributes as $attribute) { $attributeArray[$attribute->name] = $attribute->value; } switch ($child->nodeName) { case "meta": foreach ($attributeArray as $attributeName => $attributeValue) { switch ($attributeName) { case "content": break; } } $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "title": $this->processDomElement($child, $sheet, $row, $column, $cellContent); $sheet->setTitle($cellContent); $cellContent = ''; break; case "span": case "div": case "font": case "i": case "em": case "strong": case "b": if ($cellContent > '') { $cellContent .= " "; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); if ($cellContent > '') { $cellContent .= " "; } break; case "hr": $this->flushCell($sheet, $column, $row, $cellContent); ++$row; if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } else { $cellContent = "----------"; $this->flushCell($sheet, $column, $row, $cellContent); } ++$row; case "br": if ($this->tableLevel > 0) { $cellContent .= "\xa"; } else { $this->flushCell($sheet, $column, $row, $cellContent); ++$row; } break; case "a": foreach ($attributeArray as $attributeName => $attributeValue) { switch ($attributeName) { case "href": $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } break; } } $cellContent .= " "; $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": case "ol": case "ul": case "p": if ($this->tableLevel > 0) { $cellContent .= "
"; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { if ($cellContent > '') { $this->flushCell($sheet, $column, $row, $cellContent); $row++; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent); if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } $row++; $column = "A"; } break; case "li": if ($this->tableLevel > 0) { $cellContent .= "
"; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { if ($cellContent > '') { $this->flushCell($sheet, $column, $row, $cellContent); } ++$row; $this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent); $column = "A"; } break; case "table": $this->flushCell($sheet, $column, $row, $cellContent); $column = $this->setTableStartColumn($column); if ($this->tableLevel > 1) { --$row; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); $column = $this->releaseTableStartColumn(); if ($this->tableLevel > 1) { ++$column; } else { ++$row; } break; case "thead": case "tbody": $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "tr": $column = $this->getTableStartColumn(); $cellContent = ''; $this->processDomElement($child, $sheet, $row, $column, $cellContent); ++$row; break; case "th": case "td": $this->processDomElement($child, $sheet, $row, $column, $cellContent); while (isset($this->rowspan[$column . $row])) { ++$column; } $this->flushCell($sheet, $column, $row, $cellContent); if (isset($attributeArray["rowspan"]) && isset($attributeArray["colspan"])) { $columnTo = $column; for ($i = 0; $i < $attributeArray["colspan"] - 1; $i++) { ++$columnTo; } $range = $column . $row . ":" . $columnTo . ($row + $attributeArray["rowspan"] - 1); foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); $column = $columnTo; } elseif (isset($attributeArray["rowspan"])) { $range = $column . $row . ":" . $column . ($row + $attributeArray["rowspan"] - 1); foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); } elseif (isset($attributeArray["colspan"])) { $columnTo = $column; for ($i = 0; $i < $attributeArray["colspan"] - 1; $i++) { ++$columnTo; } $sheet->mergeCells($column . $row . ":" . $columnTo . $row); $column = $columnTo; } ++$column; break; case "body": $row = 1; $column = "A"; $content = ''; $this->tableLevel = 0; $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; default: $this->processDomElement($child, $sheet, $row, $column, $cellContent); } } } } public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { $this->openFile($pFilename); if (!$this->isValidFormat()) { fclose($this->fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file."); } fclose($this->fileHandle); while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) { $objPHPExcel->createSheet(); } $objPHPExcel->setActiveSheetIndex($this->sheetIndex); $dom = new domDocument(); $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), "HTML-ENTITIES", "UTF-8")); if ($loaded === false) { throw new PHPExcel_Reader_Exception("Failed to load " . $pFilename . " as a DOM Document"); } $dom->preserveWhiteSpace = false; $row = 0; $column = "A"; $content = ''; $this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content); return $objPHPExcel; } public function getSheetIndex() { return $this->sheetIndex; } public function setSheetIndex($pValue = 0) { $this->sheetIndex = $pValue; return $this; } public function securityScan($xml) { $pattern = "/\0?" . implode("\0?", str_split("<!ENTITY")) . "\0?/"; if (preg_match($pattern, $xml)) { throw new PHPExcel_Reader_Exception("Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks"); } return $xml; } } ?>
Did this file decode correctly?
Original Code
<?php
if (!defined("\120\110\x50\x45\130\x43\x45\x4c\x5f\122\117\117\124")) { define("\x50\x48\120\x45\x58\103\x45\x4c\137\122\117\117\124", dirname(__FILE__) . "\57\56\56\x2f\x2e\56\57"); require PHPEXCEL_ROOT . "\x50\x48\120\x45\170\x63\x65\154\x2f\x41\165\x74\157\x6c\x6f\x61\144\x65\x72\56\160\x68\160"; } class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { protected $inputEncoding = "\101\x4e\123\x49"; protected $sheetIndex = 0; protected $formats = array("\150\61" => array("\x66\157\156\164" => array("\x62\157\154\144" => true, "\x73\x69\x7a\145" => 24)), "\x68\x32" => array("\146\157\156\x74" => array("\142\157\x6c\144" => true, "\x73\151\172\x65" => 18)), "\x68\x33" => array("\x66\157\156\x74" => array("\x62\157\x6c\x64" => true, "\163\151\x7a\145" => 13.5)), "\150\64" => array("\146\157\156\x74" => array("\x62\157\154\144" => true, "\163\151\x7a\145" => 12)), "\150\x35" => array("\146\x6f\x6e\x74" => array("\x62\157\x6c\x64" => true, "\x73\x69\x7a\x65" => 10)), "\150\x36" => array("\x66\x6f\x6e\x74" => array("\x62\x6f\154\x64" => true, "\163\151\172\145" => 7.5)), "\x61" => array("\x66\x6f\156\x74" => array("\165\156\144\145\162\x6c\151\156\x65" => true, "\x63\x6f\x6c\157\x72" => array("\141\162\147\142" => PHPExcel_Style_Color::COLOR_BLUE))), "\x68\162" => array("\x62\157\162\x64\x65\x72\x73" => array("\x62\x6f\x74\x74\x6f\155" => array("\x73\x74\171\154\145" => PHPExcel_Style_Border::BORDER_THIN, "\143\x6f\x6c\x6f\162" => array(PHPExcel_Style_Color::COLOR_BLACK))))); protected $rowspan = array(); public function __construct() { $this->readFilter = new PHPExcel_Reader_DefaultReadFilter(); } protected function isValidFormat() { $data = fread($this->fileHandle, 2048); if (strpos($data, "\x3c") !== false && strlen($data) !== strlen(strip_tags($data))) { return true; } return false; } public function load($pFilename) { $objPHPExcel = new PHPExcel(); return $this->loadIntoExisting($pFilename, $objPHPExcel); } public function setInputEncoding($pValue = "\101\116\123\x49") { $this->inputEncoding = $pValue; return $this; } public function getInputEncoding() { return $this->inputEncoding; } protected $dataArray = array(); protected $tableLevel = 0; protected $nestedColumn = array("\101"); protected function setTableStartColumn($column) { if ($this->tableLevel == 0) { $column = "\101"; } ++$this->tableLevel; $this->nestedColumn[$this->tableLevel] = $column; return $this->nestedColumn[$this->tableLevel]; } protected function getTableStartColumn() { return $this->nestedColumn[$this->tableLevel]; } protected function releaseTableStartColumn() { --$this->tableLevel; return array_pop($this->nestedColumn); } protected function flushCell($sheet, $column, $row, &$cellContent) { if (is_string($cellContent)) { if (trim($cellContent) > '') { $sheet->setCellValue($column . $row, $cellContent, true); $this->dataArray[$row][$column] = $cellContent; } } else { $this->dataArray[$row][$column] = "\x52\x49\103\x48\x20\124\x45\x58\124\72\40" . $cellContent; } $cellContent = (string) ''; } protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null) { foreach ($element->childNodes as $child) { if ($child instanceof DOMText) { $domText = preg_replace("\57\134\x73\53\x2f\165", "\x20", trim($child->nodeValue)); if (is_string($cellContent)) { $cellContent .= $domText; } else { } } elseif ($child instanceof DOMElement) { $attributeArray = array(); foreach ($child->attributes as $attribute) { $attributeArray[$attribute->name] = $attribute->value; } switch ($child->nodeName) { case "\155\x65\x74\x61": foreach ($attributeArray as $attributeName => $attributeValue) { switch ($attributeName) { case "\x63\x6f\156\x74\x65\x6e\x74": break; } } $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "\164\151\x74\154\x65": $this->processDomElement($child, $sheet, $row, $column, $cellContent); $sheet->setTitle($cellContent); $cellContent = ''; break; case "\163\160\141\x6e": case "\144\151\166": case "\146\x6f\x6e\x74": case "\x69": case "\145\x6d": case "\163\x74\162\157\x6e\147": case "\142": if ($cellContent > '') { $cellContent .= "\x20"; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); if ($cellContent > '') { $cellContent .= "\40"; } break; case "\150\x72": $this->flushCell($sheet, $column, $row, $cellContent); ++$row; if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } else { $cellContent = "\55\x2d\x2d\55\55\x2d\x2d\x2d\x2d\x2d"; $this->flushCell($sheet, $column, $row, $cellContent); } ++$row; case "\x62\x72": if ($this->tableLevel > 0) { $cellContent .= "\xa"; } else { $this->flushCell($sheet, $column, $row, $cellContent); ++$row; } break; case "\x61": foreach ($attributeArray as $attributeName => $attributeValue) { switch ($attributeName) { case "\x68\162\145\146": $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } break; } } $cellContent .= "\40"; $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "\x68\61": case "\150\x32": case "\150\63": case "\150\x34": case "\150\65": case "\x68\66": case "\x6f\x6c": case "\165\x6c": case "\160": if ($this->tableLevel > 0) { $cellContent .= "\12"; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { if ($cellContent > '') { $this->flushCell($sheet, $column, $row, $cellContent); $row++; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent); if (isset($this->formats[$child->nodeName])) { $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]); } $row++; $column = "\101"; } break; case "\154\151": if ($this->tableLevel > 0) { $cellContent .= "\12"; $this->processDomElement($child, $sheet, $row, $column, $cellContent); } else { if ($cellContent > '') { $this->flushCell($sheet, $column, $row, $cellContent); } ++$row; $this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent); $column = "\101"; } break; case "\x74\141\x62\x6c\x65": $this->flushCell($sheet, $column, $row, $cellContent); $column = $this->setTableStartColumn($column); if ($this->tableLevel > 1) { --$row; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); $column = $this->releaseTableStartColumn(); if ($this->tableLevel > 1) { ++$column; } else { ++$row; } break; case "\164\150\145\x61\144": case "\164\142\x6f\x64\x79": $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; case "\x74\162": $column = $this->getTableStartColumn(); $cellContent = ''; $this->processDomElement($child, $sheet, $row, $column, $cellContent); ++$row; break; case "\164\150": case "\164\x64": $this->processDomElement($child, $sheet, $row, $column, $cellContent); while (isset($this->rowspan[$column . $row])) { ++$column; } $this->flushCell($sheet, $column, $row, $cellContent); if (isset($attributeArray["\162\x6f\167\x73\160\x61\x6e"]) && isset($attributeArray["\x63\157\x6c\163\x70\141\x6e"])) { $columnTo = $column; for ($i = 0; $i < $attributeArray["\143\x6f\x6c\163\160\x61\x6e"] - 1; $i++) { ++$columnTo; } $range = $column . $row . "\72" . $columnTo . ($row + $attributeArray["\162\157\167\163\160\141\156"] - 1); foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); $column = $columnTo; } elseif (isset($attributeArray["\x72\x6f\x77\x73\x70\x61\x6e"])) { $range = $column . $row . "\x3a" . $column . ($row + $attributeArray["\162\x6f\x77\x73\x70\x61\156"] - 1); foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) { $this->rowspan[$value] = true; } $sheet->mergeCells($range); } elseif (isset($attributeArray["\x63\x6f\x6c\x73\x70\141\156"])) { $columnTo = $column; for ($i = 0; $i < $attributeArray["\143\157\154\163\160\141\156"] - 1; $i++) { ++$columnTo; } $sheet->mergeCells($column . $row . "\72" . $columnTo . $row); $column = $columnTo; } ++$column; break; case "\142\x6f\x64\x79": $row = 1; $column = "\101"; $content = ''; $this->tableLevel = 0; $this->processDomElement($child, $sheet, $row, $column, $cellContent); break; default: $this->processDomElement($child, $sheet, $row, $column, $cellContent); } } } } public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) { $this->openFile($pFilename); if (!$this->isValidFormat()) { fclose($this->fileHandle); throw new PHPExcel_Reader_Exception($pFilename . "\40\x69\163\x20\141\x6e\x20\111\156\x76\x61\154\x69\144\40\x48\x54\x4d\x4c\x20\146\151\154\145\56"); } fclose($this->fileHandle); while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) { $objPHPExcel->createSheet(); } $objPHPExcel->setActiveSheetIndex($this->sheetIndex); $dom = new domDocument(); $loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), "\x48\124\x4d\x4c\x2d\105\116\124\111\x54\x49\105\123", "\125\x54\x46\x2d\x38")); if ($loaded === false) { throw new PHPExcel_Reader_Exception("\106\141\151\154\x65\144\x20\x74\157\x20\x6c\157\141\144\x20" . $pFilename . "\40\141\x73\40\141\x20\x44\x4f\115\x20\104\x6f\x63\x75\155\145\x6e\164"); } $dom->preserveWhiteSpace = false; $row = 0; $column = "\x41"; $content = ''; $this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content); return $objPHPExcel; } public function getSheetIndex() { return $this->sheetIndex; } public function setSheetIndex($pValue = 0) { $this->sheetIndex = $pValue; return $this; } public function securityScan($xml) { $pattern = "\x2f\x5c\x30\x3f" . implode("\x5c\x30\77", str_split("\x3c\41\105\116\x54\111\x54\131")) . "\134\60\x3f\57"; if (preg_match($pattern, $xml)) { throw new PHPExcel_Reader_Exception("\104\x65\164\145\143\x74\145\144\40\x75\x73\x65\40\157\x66\x20\105\116\124\111\124\131\40\151\x6e\40\130\x4d\x4c\x2c\40\x73\x70\162\145\141\x64\x73\150\x65\x65\x74\40\x66\x69\154\x65\x20\x6c\x6f\x61\144\x28\x29\x20\x61\142\157\x72\x74\x65\144\x20\164\157\x20\160\162\145\x76\145\156\x74\x20\x58\x58\105\57\x58\x45\105\x20\x61\164\x74\x61\x63\153\163"); } return $xml; } }
Function Calls
None |
Stats
MD5 | b5536a563a288ffe7d64ff42279d2dae |
Eval Count | 0 |
Decode Time | 88 ms |