diff --git a/files.php b/files.php index e56d466..194ed32 100644 --- a/files.php +++ b/files.php @@ -31,8 +31,26 @@ class SortingIterator implements IteratorAggregate { } } +class IgnorantRecursiveDirectoryIterator extends RecursiveDirectoryIterator { + function getChildren() { + try { +// echo "
".var_export( $this->key(), true ).""; +// echo "
".var_export( $this->getSubPath(), true ).""; +// echo "
".var_export( $this->getSubPathname(), true ).""; + if ( (!isset($GLOBALS['ICEcoder']['bannedPaths'])) || + (! (in_array( $this->key(), $GLOBALS['ICEcoder']['bannedPaths'] ))) ) { + return parent::getChildren(); + } else { + return new RecursiveArrayIterator(array()); + } + } catch(UnexpectedValueException $e) { + return new RecursiveArrayIterator(array()); + } + } +} + // Get a full list of dirs & files and begin sorting using above class & function -$objectList = new SortingIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($docRoot.$iceRoot), RecursiveIteratorIterator::SELF_FIRST), 'alphasort'); +$objectList = new SortingIterator(new RecursiveIteratorIterator(new IgnorantRecursiveDirectoryIterator($docRoot.$iceRoot), RecursiveIteratorIterator::SELF_FIRST), 'alphasort'); // With that done, create arrays for out final ordered list and a temp container of files $finalArray = $tempArray = array(); diff --git a/lib/config.php b/lib/config.php index 9cc6da1..9875309 100644 --- a/lib/config.php +++ b/lib/config.php @@ -10,6 +10,7 @@ $ICEcoder = array( "lockedNav" => true, "accountPassword" => "", "bannedFiles" => array("_coder","ICEcoder"), +"bannedPaths" => array("/var/www/.git","/var/www/sites/all/modules","/var/www/sites/default/files"), "allowedIPs" => array("*"), "plugins" => array( array("Adminer","plugins/adminer/icon.png","margin-top: 3px","plugins/adminer/adminer-3.4.0-mysql-en.php","_blank",""), @@ -22,4 +23,4 @@ $ICEcoder = array( "previousFiles" => "", "last10Files" => "" ); -?> \ No newline at end of file +?>