Use flag SKIP_DOTS for RecursiveDirectoryIterator

We should use the flag FilesystemIterator::SKIP_DOTS for the
RecursiveDirectoryIterator in functions_upload.php. This is supported
starting with PHP 5.3. As PHP 5.3.2 is a requirement for phpBB 3.1
this will not break anything.

Fixed #100
This commit is contained in:
Marc Alexander
2012-10-26 13:04:12 +02:00
parent 96e0180f6e
commit 6422c7925b

View File

@@ -105,7 +105,7 @@ class portal_upload
// Now we need to get the files inside the folders
//$folder_contents = $this->cut_folder(scandir($mod_dir));
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($mod_dir)); // requires PHP 5
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($mod_dir, FilesystemIterator::SKIP_DOTS)); // requires PHP 5
foreach($iterator as $cur_file)
{
@@ -114,16 +114,6 @@ class portal_upload
$cur_path = str_replace($mod_dir . '/', '', $cur_path);
$cut_pos = strpos($cur_path, '/');
/*
* We only copy files. The recursive iterator might grab paths depending on
* the PHP version. This will trigger our error handle with trigger_error()
* though. If we are trying to copy a directory just move on.
*/
if (is_dir($cur_path))
{
continue;
}
// Only allow files in adm, language, portal and styles folder and a license.txt
if(!in_array(substr($cur_path, 0, $cut_pos), array('adm', 'language', 'portal', 'styles')) && $cur_file->getFilename() != 'license.txt')
{