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 Psy\Readline\Hoa; class FileFinder implements \IteratorAggregate { protec..

Decoded Output download

<?php
 namespace Psy\Readline\Hoa; class FileFinder implements \IteratorAggregate { protected $_splFileInfo = \SplFileInfo::class; protected $_paths = array(); protected $_maxDepth = -1; protected $_filters = array(); protected $_flags = -1; protected $_types = array(); protected $_first = -1; protected $_sorts = array(); public function __construct() { $this->_flags = IteratorFileSystem::KEY_AS_PATHNAME | IteratorFileSystem::CURRENT_AS_FILEINFO | IteratorFileSystem::SKIP_DOTS; $this->_first = \RecursiveIteratorIterator::SELF_FIRST; return; } public function in($paths) : self { if (!\is_array($paths)) { $paths = array($paths); } foreach ($paths as $path) { if (1 === \preg_match("/[\*\?\[\]]/", $path)) { $iterator = new \CallbackFilterIterator(new \GlobIterator(\rtrim($path, \DIRECTORY_SEPARATOR)), function ($current) { return $current->isDir(); }); foreach ($iterator as $fileInfo) { $this->_paths[] = $fileInfo->getPathname(); } } else { $this->_paths[] = $path; } } return $this; } public function maxDepth(int $depth) : self { $this->_maxDepth = $depth; return $this; } public function files() : self { $this->_types[] = "file"; return $this; } public function directories() : self { $this->_types[] = "dir"; return $this; } public function links() : self { $this->_types[] = "link"; return $this; } public function followSymlinks(bool $flag = true) : self { if (true === $flag) { $this->_flags ^= IteratorFileSystem::FOLLOW_SYMLINKS; } else { $this->_flags |= IteratorFileSystem::FOLLOW_SYMLINKS; } return $this; } public function name(string $regex) : self { $this->_filters[] = function (\SplFileInfo $current) use($regex) { return 0 !== \preg_match($regex, $current->getBasename()); }; return $this; } public function notIn(string $regex) : self { $this->_filters[] = function (\SplFileInfo $current) use($regex) { foreach (\explode(\DIRECTORY_SEPARATOR, $current->getPathname()) as $part) { if (0 !== \preg_match($regex, $part)) { return false; } } return true; }; return $this; } public function size(string $size) : self { if (0 === \preg_match("#^(<|<=|>|>=|=)\s*(\d+)\s*((?:[KMGTPEZY])b)?$#", $size, $matches)) { return $this; } $number = (double) $matches[2]; $unit = $matches[3] ?? "b"; $operator = $matches[1]; switch ($unit) { case "b": break; case "Kb": $number <<= 10; break; case "Mb": $number <<= 20; break; case "Gb": $number <<= 30; break; case "Tb": $number *= 1099511627776; break; case "Pb": $number *= 1024 ** 5; break; case "Eb": $number *= 1024 ** 6; break; case "Zb": $number *= 1024 ** 7; break; case "Yb": $number *= 1024 ** 8; break; } $filter = null; switch ($operator) { case "<": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() < $number; }; break; case "<=": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() <= $number; }; break; case ">": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() > $number; }; break; case ">=": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() >= $number; }; break; case "=": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() === $number; }; break; } $this->_filters[] = $filter; return $this; } public function dots(bool $flag = true) : self { if (true === $flag) { $this->_flags ^= IteratorFileSystem::SKIP_DOTS; } else { $this->_flags |= IteratorFileSystem::SKIP_DOTS; } return $this; } public function owner(int $owner) : self { $this->_filters[] = function (\SplFileInfo $current) use($owner) { return $current->getOwner() === $owner; }; return $this; } protected function formatDate(string $date, &$operator) : int { $operator = -1; if (0 === \preg_match("#\bago\b#", $date)) { $date .= " ago"; } if (0 !== \preg_match("#^(since|until)\b(.+)$#", $date, $matches)) { $time = \strtotime($matches[2]); if ("until" === $matches[1]) { $operator = 1; } } else { $time = \strtotime($date); } return $time; } public function changed(string $date) : self { $time = $this->formatDate($date, $operator); if (-1 === $operator) { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getCTime() >= $time; }; } else { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getCTime() < $time; }; } return $this; } public function modified(string $date) : self { $time = $this->formatDate($date, $operator); if (-1 === $operator) { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getMTime() >= $time; }; } else { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getMTime() < $time; }; } return $this; } public function filter($callback) : self { $this->_filters[] = $callback; return $this; } public function sortByName(string $locale = "root") : self { if (true === \class_exists("Collator", false)) { $collator = new \Collator($locale); $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) use($collator) { return $collator->compare($a->getPathname(), $b->getPathname()); }; } else { $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) { return \strcmp($a->getPathname(), $b->getPathname()); }; } return $this; } public function sortBySize() : self { $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) { return $a->getSize() < $b->getSize(); }; return $this; } public function sort($callable) : self { $this->_sorts[] = $callable; return $this; } public function childFirst() : self { $this->_first = \RecursiveIteratorIterator::CHILD_FIRST; return $this; } public function getIterator() { $_iterator = new \AppendIterator(); $types = $this->getTypes(); if (!empty($types)) { $this->_filters[] = function (\SplFileInfo $current) use($types) { return \in_array($current->getType(), $types); }; } $maxDepth = $this->getMaxDepth(); $splFileInfo = $this->getSplFileInfo(); foreach ($this->getPaths() as $path) { if (1 === $maxDepth) { $iterator = new \IteratorIterator(new IteratorRecursiveDirectory($path, $this->getFlags(), $splFileInfo), $this->getFirst()); } else { $iterator = new \RecursiveIteratorIterator(new IteratorRecursiveDirectory($path, $this->getFlags(), $splFileInfo), $this->getFirst()); if (1 < $maxDepth) { $iterator->setMaxDepth($maxDepth - 1); } } $_iterator->append($iterator); } foreach ($this->getFilters() as $filter) { $_iterator = new \CallbackFilterIterator($_iterator, $filter); } $sorts = $this->getSorts(); if (empty($sorts)) { return $_iterator; } $array = \iterator_to_array($_iterator); foreach ($sorts as $sort) { \uasort($array, $sort); } return new \ArrayIterator($array); } public function setSplFileInfo(string $splFileInfo) : string { $old = $this->_splFileInfo; $this->_splFileInfo = $splFileInfo; return $old; } public function getSplFileInfo() : string { return $this->_splFileInfo; } protected function getPaths() : array { return $this->_paths; } public function getMaxDepth() : int { return $this->_maxDepth; } public function getTypes() : array { return $this->_types; } protected function getFilters() : array { return $this->_filters; } protected function getSorts() : array { return $this->_sorts; } public function getFlags() : int { return $this->_flags; } public function getFirst() : int { return $this->_first; } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Psy\Readline\Hoa; class FileFinder implements \IteratorAggregate { protected $_splFileInfo = \SplFileInfo::class; protected $_paths = array(); protected $_maxDepth = -1; protected $_filters = array(); protected $_flags = -1; protected $_types = array(); protected $_first = -1; protected $_sorts = array(); public function __construct() { $this->_flags = IteratorFileSystem::KEY_AS_PATHNAME | IteratorFileSystem::CURRENT_AS_FILEINFO | IteratorFileSystem::SKIP_DOTS; $this->_first = \RecursiveIteratorIterator::SELF_FIRST; return; } public function in($paths) : self { if (!\is_array($paths)) { $paths = array($paths); } foreach ($paths as $path) { if (1 === \preg_match("\x2f\x5b\134\52\x5c\x3f\134\133\134\x5d\x5d\57", $path)) { $iterator = new \CallbackFilterIterator(new \GlobIterator(\rtrim($path, \DIRECTORY_SEPARATOR)), function ($current) { return $current->isDir(); }); foreach ($iterator as $fileInfo) { $this->_paths[] = $fileInfo->getPathname(); } } else { $this->_paths[] = $path; } } return $this; } public function maxDepth(int $depth) : self { $this->_maxDepth = $depth; return $this; } public function files() : self { $this->_types[] = "\146\x69\x6c\x65"; return $this; } public function directories() : self { $this->_types[] = "\x64\151\x72"; return $this; } public function links() : self { $this->_types[] = "\x6c\151\156\x6b"; return $this; } public function followSymlinks(bool $flag = true) : self { if (true === $flag) { $this->_flags ^= IteratorFileSystem::FOLLOW_SYMLINKS; } else { $this->_flags |= IteratorFileSystem::FOLLOW_SYMLINKS; } return $this; } public function name(string $regex) : self { $this->_filters[] = function (\SplFileInfo $current) use($regex) { return 0 !== \preg_match($regex, $current->getBasename()); }; return $this; } public function notIn(string $regex) : self { $this->_filters[] = function (\SplFileInfo $current) use($regex) { foreach (\explode(\DIRECTORY_SEPARATOR, $current->getPathname()) as $part) { if (0 !== \preg_match($regex, $part)) { return false; } } return true; }; return $this; } public function size(string $size) : self { if (0 === \preg_match("\43\136\x28\74\174\x3c\x3d\174\x3e\174\76\x3d\174\x3d\x29\x5c\163\x2a\50\134\144\x2b\51\x5c\163\x2a\50\50\x3f\x3a\133\113\x4d\x47\124\120\x45\132\131\x5d\x29\142\x29\77\44\x23", $size, $matches)) { return $this; } $number = (double) $matches[2]; $unit = $matches[3] ?? "\142"; $operator = $matches[1]; switch ($unit) { case "\142": break; case "\113\x62": $number <<= 10; break; case "\x4d\x62": $number <<= 20; break; case "\107\x62": $number <<= 30; break; case "\x54\142": $number *= 1099511627776; break; case "\x50\x62": $number *= 1024 ** 5; break; case "\x45\142": $number *= 1024 ** 6; break; case "\132\x62": $number *= 1024 ** 7; break; case "\x59\x62": $number *= 1024 ** 8; break; } $filter = null; switch ($operator) { case "\x3c": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() < $number; }; break; case "\x3c\x3d": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() <= $number; }; break; case "\76": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() > $number; }; break; case "\x3e\x3d": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() >= $number; }; break; case "\x3d": $filter = function (\SplFileInfo $current) use($number) { return $current->getSize() === $number; }; break; } $this->_filters[] = $filter; return $this; } public function dots(bool $flag = true) : self { if (true === $flag) { $this->_flags ^= IteratorFileSystem::SKIP_DOTS; } else { $this->_flags |= IteratorFileSystem::SKIP_DOTS; } return $this; } public function owner(int $owner) : self { $this->_filters[] = function (\SplFileInfo $current) use($owner) { return $current->getOwner() === $owner; }; return $this; } protected function formatDate(string $date, &$operator) : int { $operator = -1; if (0 === \preg_match("\43\x5c\142\x61\x67\x6f\134\x62\43", $date)) { $date .= "\x20\141\147\x6f"; } if (0 !== \preg_match("\43\x5e\x28\x73\x69\156\x63\x65\x7c\x75\x6e\164\x69\154\x29\134\142\x28\x2e\53\51\44\43", $date, $matches)) { $time = \strtotime($matches[2]); if ("\x75\x6e\x74\x69\154" === $matches[1]) { $operator = 1; } } else { $time = \strtotime($date); } return $time; } public function changed(string $date) : self { $time = $this->formatDate($date, $operator); if (-1 === $operator) { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getCTime() >= $time; }; } else { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getCTime() < $time; }; } return $this; } public function modified(string $date) : self { $time = $this->formatDate($date, $operator); if (-1 === $operator) { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getMTime() >= $time; }; } else { $this->_filters[] = function (\SplFileInfo $current) use($time) { return $current->getMTime() < $time; }; } return $this; } public function filter($callback) : self { $this->_filters[] = $callback; return $this; } public function sortByName(string $locale = "\x72\x6f\x6f\164") : self { if (true === \class_exists("\103\x6f\154\x6c\141\x74\157\162", false)) { $collator = new \Collator($locale); $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) use($collator) { return $collator->compare($a->getPathname(), $b->getPathname()); }; } else { $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) { return \strcmp($a->getPathname(), $b->getPathname()); }; } return $this; } public function sortBySize() : self { $this->_sorts[] = function (\SplFileInfo $a, \SplFileInfo $b) { return $a->getSize() < $b->getSize(); }; return $this; } public function sort($callable) : self { $this->_sorts[] = $callable; return $this; } public function childFirst() : self { $this->_first = \RecursiveIteratorIterator::CHILD_FIRST; return $this; } public function getIterator() { $_iterator = new \AppendIterator(); $types = $this->getTypes(); if (!empty($types)) { $this->_filters[] = function (\SplFileInfo $current) use($types) { return \in_array($current->getType(), $types); }; } $maxDepth = $this->getMaxDepth(); $splFileInfo = $this->getSplFileInfo(); foreach ($this->getPaths() as $path) { if (1 === $maxDepth) { $iterator = new \IteratorIterator(new IteratorRecursiveDirectory($path, $this->getFlags(), $splFileInfo), $this->getFirst()); } else { $iterator = new \RecursiveIteratorIterator(new IteratorRecursiveDirectory($path, $this->getFlags(), $splFileInfo), $this->getFirst()); if (1 < $maxDepth) { $iterator->setMaxDepth($maxDepth - 1); } } $_iterator->append($iterator); } foreach ($this->getFilters() as $filter) { $_iterator = new \CallbackFilterIterator($_iterator, $filter); } $sorts = $this->getSorts(); if (empty($sorts)) { return $_iterator; } $array = \iterator_to_array($_iterator); foreach ($sorts as $sort) { \uasort($array, $sort); } return new \ArrayIterator($array); } public function setSplFileInfo(string $splFileInfo) : string { $old = $this->_splFileInfo; $this->_splFileInfo = $splFileInfo; return $old; } public function getSplFileInfo() : string { return $this->_splFileInfo; } protected function getPaths() : array { return $this->_paths; } public function getMaxDepth() : int { return $this->_maxDepth; } public function getTypes() : array { return $this->_types; } protected function getFilters() : array { return $this->_filters; } protected function getSorts() : array { return $this->_sorts; } public function getFlags() : int { return $this->_flags; } public function getFirst() : int { return $this->_first; } }

Function Calls

None

Variables

None

Stats

MD5 dc31c4e3e69d8603573df57dd3d3d0e8
Eval Count 0
Decode Time 80 ms