Merge branch 'MDL-27559-master-v2' of https://github.com/mackensen/moodle

This commit is contained in:
Sam Hemelryk 2012-06-06 08:51:11 +12:00
commit 7df271d9b3
6 changed files with 26 additions and 8 deletions

View file

@ -8,7 +8,9 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
require_once($CFG->dirroot.'/backup/bb/xsl_emulate_xslt.inc');
function get_subdirs($directory){
$opendirectory = opendir( $directory );
if (!$opendirectory = opendir( $directory )) {
return array();
}
while(false !== ($filename = readdir($opendirectory))) {
if (is_dir($directory.$filename) and $filename != ".." and $filename != "."){
$subdirs[] = $filename;

View file

@ -79,7 +79,9 @@ abstract class backup_general_helper extends backup_helper {
return array();
}
$dir = opendir($path);
if (!$dir = opendir($path)) {
return array();
}
while (false !== ($file = readdir($dir))) {
if ($file == '.' || $file == '..') { // Skip dots
continue;

View file

@ -2535,7 +2535,10 @@ function fulldelete($location) {
return false;
}
if (is_dir($location)) {
$currdir = opendir($location);
if (!$currdir = opendir($location)) {
return false;
}
while (false !== ($file = readdir($currdir))) {
if ($file <> ".." && $file <> ".") {
$fullfile = $location."/".$file;

View file

@ -8029,7 +8029,10 @@ function get_list_of_plugins($directory='mod', $exclude='', $basedir='') {
}
if (file_exists($basedir) && filetype($basedir) == 'dir') {
$dirhandle = opendir($basedir);
if (!$dirhandle = opendir($basedir)) {
debugging("Directory permission error for plugin ({$directory}). Directory exists but cannot be read.", DEBUG_DEVELOPER);
return array();
}
while (false !== ($dir = readdir($dirhandle))) {
$firstchar = substr($dir, 0, 1);
if ($firstchar === '.' or $dir === 'CVS' or $dir === '_vti_cnf' or $dir === 'simpletest' or $dir === 'yui' or $dir === 'phpunit' or $dir === $exclude) {
@ -10225,7 +10228,7 @@ function apd_get_profiling() {
}
/**
* Delete directory or only it's content
* Delete directory or only its content
*
* @param string $dir directory path
* @param bool $content_only
@ -10236,7 +10239,9 @@ function remove_dir($dir, $content_only=false) {
// nothing to do
return true;
}
$handle = opendir($dir);
if (!$handle = opendir($dir)) {
return false;
}
$result = true;
while (false!==($item = readdir($handle))) {
if($item != '.' && $item != '..') {

View file

@ -110,7 +110,10 @@ function rss_delete_file($componentname, $instance) {
$dirpath = "$CFG->cachedir/rss/$componentname";
if (is_dir($dirpath)) {
$dh = opendir($dirpath);
if (!$dh = opendir($dirpath)) {
error_log("Directory permission error. RSS directory store for component '{$componentname}' exists but cannot be opened.", DEBUG_DEVELOPER);
return;
}
while (false !== ($filename = readdir($dh))) {
if ($filename!='.' && $filename!='..') {
if (preg_match("/{$instance->id}_/", $filename)) {

View file

@ -946,7 +946,10 @@ EOD;
if ($result) {
// recurse directories
if (is_dir($localpath)) {
$dp = opendir($localpath);
if (!$dp = opendir($localpath)) {
$this->_error_log("Could not open localpath for reading");
return false;
}
$fl = array();
while($filename = readdir($dp)) {
if ((is_file($localpath."/".$filename) || is_dir($localpath."/".$filename)) && $filename!="." && $filename != "..") {