Permalink
Browse files

Fixed an incompatibility with scandir

  • Loading branch information...
bobopinna
bobopinna committed Dec 9, 2004
1 parent 5e36a83 commit bdebf9a5aee7f7805c8d1d886fe0cd17b59650b0
Showing with 21 additions and 9 deletions.
  1. +21 −9 mod/scorm/lib.php
View
@@ -368,15 +368,12 @@ function scorm_validate($manifest)
}
}
-function scorm_delete_files($directory)
-{
- if (is_dir($directory))
- {
- $files=scandir($directory);
- foreach($files as $file)
- {
- if ($file != '.' && $file != '..')
- {
+function scorm_delete_files($directory) {
+ if (is_dir($directory)) {
+ $files=scorm_scandir($directory);
+ //print_r($files);
+ foreach($files as $file) {
+ if (($file != '.') && ($file != '..')) {
if (!is_dir($directory.'/'.$file)) {
//chmod($directory.'/'.$file,0777);
unlink($directory.'/'.$file);
@@ -389,6 +386,21 @@ function scorm_delete_files($directory)
}
}
+function scorm_scandir($directory) {
+ if (version_compare(phpversion(),'5.0.0','>=')) {
+ return scandir($directory);
+ } else {
+ $files = null;
+ if ($dh = opendir($directory)) {
+ while (($file = readdir($dh)) !== false) {
+ $files[] = $file;
+ }
+ closedir($dh);
+ }
+ return $files;
+ }
+}
+
function scorm_startElement($parser, $name, $attrs) {
global $scoes,$i,$resources,$parent,$level,$organization,$manifest,$defaultorg;

0 comments on commit bdebf9a

Please sign in to comment.