Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<? $method = 'find'; echo "mem before:".memory_get_peak_usage(true)."\n"; echo "Start..
Decoded Output download
<?
$method = 'find';
echo "mem before:".memory_get_peak_usage(true)."
";
echo "Starting $method()
";
clearstatcache();
$startTime = microtime(true);
$allFiles = DirectoryParser::$method('C:/');
echo "Zeit: ".(microtime(true) - $startTime)." sec
";
echo "mem after:".memory_get_peak_usage(true)."
";
echo count($allFiles)."
";
class DirectoryParser
{
public static function createTestFolders($dir) {
for($i=0; $i<10000; $i++) {
@mkdir($dir.'/'.$i);
for ($u=0; $u<10; $u++) {
touch($dir.'/'.$i.'/'.rand(10000, 999999).'.txt');
}
}
}
public static function dirRead($dir, &$fileinfo = array()) {
if ($handle = dir($dir)) {
while (false !== ($file = $handle->read())) {
if (!is_dir($dir.'/'.$file)) {
$fileinfo[] = array($file, filesize($dir.'/'.$file));
} elseif (is_dir($dir.'/'.$file) && $file != '.' && $file != '..') {
echo $file."
";
self::dirRead($dir.'/'.$file, $fileinfo);
}
}
$handle->close();
}
return $fileinfo;
}
public static function find($dir) {
echo substr(php_uname(), 0, 7);
if (substr(php_uname(), 0, 7) == "Windows") {
foreach (explode("
",` cd "$dir" && dir /S /B /A-D `) as $fullFilename) {
if ($fullFilename != '') {
echo $fullFilename."
";
$fileinfo[] = array($fullFilename, filesize($fullFilename));
}
}
} else {
foreach (explode("
",` cd $dir && find -maxdepth 3 -type f ! -name ".*" -printf "%f
%s
" `) as $fileInfos) {
if ($fileInfos != '') {
$fileinfo[] = explode("
", $fileInfos);
}
}
}
return $fileinfo;
}
public static function glob($dir, &$fileinfo = array()) {
foreach (glob($dir.'/*') as $file) {
if (is_dir($file)) {
self::glob($file, $fileinfo);
} else {
$fileinfo[] = array(basename($file), filesize($file));
}
}
return $fileinfo;
}
public static function scandir($outerDir){
$dirs = array_diff(scandir($outerDir), array(".", ".."));
$fileArray = array();
foreach ($dirs as $d) {
if (is_dir($outerDir."/".$d)) {
$fileArray = array_merge($fileArray, self::scandir($outerDir."/".$d));
} else {
$fileArray[] = array($d, filesize($outerDir."/".$d));
}
}
return $fileArray;
}
public static function opendir($dir, &$fileinfo = array()) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($dir.'/'.$file)) {
$fileinfo[] = array($file, filesize($dir.'/'.$file));
} elseif (is_dir($dir.'/'.$file) && $file != '.' && $file != '..') {
self::opendir($dir.'/'.$file, $fileinfo);
}
}
closedir($handle);
}
return $fileinfo;
}
public static function directoryIterator($dir) {
$iterator = new RecursiveDirectoryIterator($dir);
foreach(new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if (false == $file->isDir()) {
$fileinfo[] = array($file->getFilename(), $file->getSize());
}
}
return $fileinfo;
}
} ?>
Did this file decode correctly?
Original Code
<?
$method = 'find';
echo "mem before:".memory_get_peak_usage(true)."\n";
echo "Starting $method()\n";
clearstatcache();
$startTime = microtime(true);
$allFiles = DirectoryParser::$method('C:/');
echo "Zeit: ".(microtime(true) - $startTime)." sec\n";
echo "mem after:".memory_get_peak_usage(true)."\n";
echo count($allFiles)."\n\n";
class DirectoryParser
{
public static function createTestFolders($dir) {
for($i=0; $i<10000; $i++) {
@mkdir($dir.'/'.$i);
for ($u=0; $u<10; $u++) {
touch($dir.'/'.$i.'/'.rand(10000, 999999).'.txt');
}
}
}
public static function dirRead($dir, &$fileinfo = array()) {
if ($handle = dir($dir)) {
while (false !== ($file = $handle->read())) {
if (!is_dir($dir.'/'.$file)) {
$fileinfo[] = array($file, filesize($dir.'/'.$file));
} elseif (is_dir($dir.'/'.$file) && $file != '.' && $file != '..') {
echo $file."\n";
self::dirRead($dir.'/'.$file, $fileinfo);
}
}
$handle->close();
}
return $fileinfo;
}
public static function find($dir) {
echo substr(php_uname(), 0, 7);
if (substr(php_uname(), 0, 7) == "Windows") {
foreach (explode("\n",` cd "$dir" && dir /S /B /A-D `) as $fullFilename) {
if ($fullFilename != '') {
echo $fullFilename."\n";
$fileinfo[] = array($fullFilename, filesize($fullFilename));
}
}
} else {
foreach (explode("\n",` cd $dir && find -maxdepth 3 -type f ! -name ".*" -printf "%f\r%s\n" `) as $fileInfos) {
if ($fileInfos != '') {
$fileinfo[] = explode("\r", $fileInfos);
}
}
}
return $fileinfo;
}
public static function glob($dir, &$fileinfo = array()) {
foreach (glob($dir.'/*') as $file) {
if (is_dir($file)) {
self::glob($file, $fileinfo);
} else {
$fileinfo[] = array(basename($file), filesize($file));
}
}
return $fileinfo;
}
public static function scandir($outerDir){
$dirs = array_diff(scandir($outerDir), array(".", ".."));
$fileArray = array();
foreach ($dirs as $d) {
if (is_dir($outerDir."/".$d)) {
$fileArray = array_merge($fileArray, self::scandir($outerDir."/".$d));
} else {
$fileArray[] = array($d, filesize($outerDir."/".$d));
}
}
return $fileArray;
}
public static function opendir($dir, &$fileinfo = array()) {
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($dir.'/'.$file)) {
$fileinfo[] = array($file, filesize($dir.'/'.$file));
} elseif (is_dir($dir.'/'.$file) && $file != '.' && $file != '..') {
self::opendir($dir.'/'.$file, $fileinfo);
}
}
closedir($handle);
}
return $fileinfo;
}
public static function directoryIterator($dir) {
$iterator = new RecursiveDirectoryIterator($dir);
foreach(new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if (false == $file->isDir()) {
$fileinfo[] = array($file->getFilename(), $file->getSize());
}
}
return $fileinfo;
}
}
Function Calls
| None |
Stats
| MD5 | 679e060104cfd7d93e5c330d94944dd7 |
| Eval Count | 0 |
| Decode Time | 83 ms |