From ed818bbdbff3488674b97bd5b3e05a40af78ba19 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Mon, 15 Oct 2007 05:18:58 +0000 Subject: [PATCH] MDL-10905 iterating correctly with readdir (as shown in php doc) --- admin/delete.php | 2 +- backup/bb/restore_bb.php | 2 +- backup/lib.php | 8 ++++---- mod/assignment/db/mysql.php | 2 +- mod/assignment/db/postgres7.php | 2 +- mod/hotpot/lib.php | 2 +- mod/resource/type/ims/finder.php | 2 +- mod/resource/type/ims/repository_deploy.php | 4 ++-- mod/wiki/ewiki/ewiki.php | 2 +- mod/wiki/ewiki/plugins/init.php | 4 ++-- mod/wiki/ewiki/plugins/spages.php | 4 ++-- question/format/blackboard_6/format.php | 2 +- question/format/coursetestmanager/format.php | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/admin/delete.php b/admin/delete.php index 6762cf4419..1498dbfcaa 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -54,7 +54,7 @@ function delete_subdirectories($rootdir) { $dir = opendir($rootdir); - while ($file = readdir($dir)) { + while (false !== ($file = readdir($dir))) { if ($file != '.' and $file != '..') { $fullfile = $rootdir .'/'. $file; if (filetype($fullfile) == 'dir') { diff --git a/backup/bb/restore_bb.php b/backup/bb/restore_bb.php index 4e63c40447..0793a86068 100644 --- a/backup/bb/restore_bb.php +++ b/backup/bb/restore_bb.php @@ -9,7 +9,7 @@ require_once($CFG->dirroot.'/backup/bb/xsl_emulate_xslt.inc'); function get_subdirs($directory){ $opendirectory = opendir( $directory ); - while($filename = readdir($opendirectory)) { + while(false !== ($filename = readdir($opendirectory))) { if (is_dir($directory.$filename) and $filename != ".." and $filename != "."){ $subdirs[] = $filename; } diff --git a/backup/lib.php b/backup/lib.php index 2afe506b6a..25880c6ecb 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -125,7 +125,7 @@ } // Loop through all directory entries, and construct two temporary arrays containing files and sub directories - while($entry = readdir($handle)) { + while(false !== ($entry = readdir($handle))) { if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != "." && $entry != $excludeddir) { $dir_subdirs[] = $dir. $slash .$entry; } @@ -202,7 +202,7 @@ $results = null; $dir = opendir($rootdir); - while ($file=readdir($dir)) { + while (false !== ($file=readdir($dir))) { if ($file=="." || $file=="..") { continue; } @@ -221,7 +221,7 @@ $results = ""; $dir = opendir($rootdir); - while ($file=readdir($dir)) { + while (false !== ($file=readdir($dir))) { if ($file=="." || $file=="..") { continue; } @@ -308,7 +308,7 @@ $status = check_dir_exists($to_file, true, true); } $dir = opendir($from_file); - while ($file=readdir($dir)) { + while (false !== ($file=readdir($dir))) { if ($file=="." || $file=="..") { continue; } diff --git a/mod/assignment/db/mysql.php b/mod/assignment/db/mysql.php index 632e6574ad..b54e4c344f 100644 --- a/mod/assignment/db/mysql.php +++ b/mod/assignment/db/mysql.php @@ -62,7 +62,7 @@ function assignment_upgrade($oldversion) { notify("Moving location of assignment files..."); $basedir = opendir("$CFG->dataroot"); - while ($dir = readdir($basedir)) { + while (false !== ($dir = readdir($basedir))) { if ($dir == "." || $dir == ".." || $dir == "users") { continue; } diff --git a/mod/assignment/db/postgres7.php b/mod/assignment/db/postgres7.php index f00034372b..d7558df165 100644 --- a/mod/assignment/db/postgres7.php +++ b/mod/assignment/db/postgres7.php @@ -60,7 +60,7 @@ function assignment_upgrade($oldversion) { notify("Moving location of assignment files..."); $basedir = opendir("$CFG->dataroot"); - while ($dir = readdir($basedir)) { + while (false !== ($dir = readdir($basedir))) { if ($dir == "." || $dir == ".." || $dir == "users") { continue; } diff --git a/mod/hotpot/lib.php b/mod/hotpot/lib.php index 8d11776757..a8b1bf152f 100644 --- a/mod/hotpot/lib.php +++ b/mod/hotpot/lib.php @@ -472,7 +472,7 @@ function hotpot_add_chain(&$hotpot) { // get list of hotpot files in this folder if ($dh = @opendir($xml_quiz->filepath)) { - while ($file = @readdir($dh)) { + while (false !== ($file = @readdir($dh))) { if (preg_match('/\.(jbc|jcl|jcw|jmt|jmx|jqz|htm|html)$/', $file)) { $hotpot->references[] = "$xml_quiz->reference/$file"; } diff --git a/mod/resource/type/ims/finder.php b/mod/resource/type/ims/finder.php index da68817929..ff52cdb0ec 100644 --- a/mod/resource/type/ims/finder.php +++ b/mod/resource/type/ims/finder.php @@ -30,7 +30,7 @@ /// Loops though dir building a list of all relevent entries. Ignores files. /// Asks for deploy if admin user AND no serialized file found. - while (false != ($filename = readdir($repository_dir))) { + while (false !== ($filename = readdir($repository_dir))) { if ($filename != '.' && $filename != '..' && is_dir("$CFG->repository/$directory/$filename")) { unset($item); $item->type = ''; diff --git a/mod/resource/type/ims/repository_deploy.php b/mod/resource/type/ims/repository_deploy.php index 6f148b5b43..f350995837 100644 --- a/mod/resource/type/ims/repository_deploy.php +++ b/mod/resource/type/ims/repository_deploy.php @@ -7,7 +7,7 @@ // Moodle - Modular Object-Oriented Dynamic Learning Environment // // http://moodle.com // // // -// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // +// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com // // (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com // // // // This program is free software; you can redistribute it and/or modify // @@ -68,7 +68,7 @@ $dirpath = "$CFG->repository/$file"; $dir = opendir($dirpath); - while (false != ($filename = readdir($dir))) { + while (false !== ($filename = readdir($dir))) { if ($filename != '.' && $filename != '..') { $path = $dirpath.'/'.$filename; if (is_dir($path) && file_exists("$path/imsmanifest.xml")) { diff --git a/mod/wiki/ewiki/ewiki.php b/mod/wiki/ewiki/ewiki.php index eeeb2f00a2..be5f40e840 100644 --- a/mod/wiki/ewiki/ewiki.php +++ b/mod/wiki/ewiki/ewiki.php @@ -3189,7 +3189,7 @@ function ewiki_eventually_initialize(&$id, &$data, &$action) { $path=EWIKI_INIT_PAGES; if (!empty($path)) { if ($dh = @opendir($path=EWIKI_INIT_PAGES)) { - while ($filename = readdir($dh)) { + while (false !== ($filename = readdir($dh))) { #### MOODLE CHANGE TO SOLVE BUG #3830. Original doesn't support dots in names. //Orig->if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) { if ($filename == clean_filename($filename) && !is_dir($path.'/'.$filename)) { diff --git a/mod/wiki/ewiki/plugins/init.php b/mod/wiki/ewiki/plugins/init.php index 2359c5a9d0..f53711421e 100644 --- a/mod/wiki/ewiki/plugins/init.php +++ b/mod/wiki/ewiki/plugins/init.php @@ -79,7 +79,7 @@ function ewiki_initialization_wizard($id, &$data, &$action) { else { ewiki_database("INIT", array()); if ($dh = @opendir($path=EWIKI_INIT_PAGES)) { - while ($filename = readdir($dh)) { + while (false !== ($filename = readdir($dh))) { if (preg_match('/^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+\w*)+/', $filename)) { $found = ewiki_database("FIND", array($filename)); if (! $found[$filename]) { @@ -119,4 +119,4 @@ function ewiki_initialization_wizard($id, &$data, &$action) { } -?> \ No newline at end of file +?> diff --git a/mod/wiki/ewiki/plugins/spages.php b/mod/wiki/ewiki/plugins/spages.php index 301ed4be0f..8f062c6d7c 100644 --- a/mod/wiki/ewiki/plugins/spages.php +++ b/mod/wiki/ewiki/plugins/spages.php @@ -141,7 +141,7 @@ function ewiki_init_spages($dirs, $idprep="") { #-- read in one directory $dh = opendir($dir); - while ($fn = readdir($dh)) { + while (false !== ($fn = readdir($dh))) { #-- skip over . and .. if ($fn[0] == ".") { continue; } @@ -179,4 +179,4 @@ function ewiki_init_spages($dirs, $idprep="") { -?> \ No newline at end of file +?> diff --git a/question/format/blackboard_6/format.php b/question/format/blackboard_6/format.php index 10b65b8bf9..efd7915870 100644 --- a/question/format/blackboard_6/format.php +++ b/question/format/blackboard_6/format.php @@ -60,7 +60,7 @@ class qformat_blackboard_6 extends qformat_default { } // Loop through all directory entries, and construct two temporary arrays containing files and sub directories - while($entry = readdir($handle)) { + while(false !== ($entry = readdir($handle))) { if (is_dir($dir. $slash .$entry) && $entry != ".." && $entry != ".") { $dir_subdirs[] = $dir. $slash .$entry; } diff --git a/question/format/coursetestmanager/format.php b/question/format/coursetestmanager/format.php index 206a42d864..f5676bb2e9 100755 --- a/question/format/coursetestmanager/format.php +++ b/question/format/coursetestmanager/format.php @@ -434,7 +434,7 @@ class qformat_coursetestmanager extends qformat_default { function fulldelete($location) { if (is_dir($location)) { $currdir = opendir($location); - while ($file = readdir($currdir)) { + while (false !== ($file = readdir($currdir))) { if ($file <> ".." && $file <> ".") { $fullfile = $location."/".$file; if (is_dir($fullfile)) { -- 2.39.5