Commit a647f84c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Check blog upload directory exists before reading it

parent 601e8fbf
...@@ -126,24 +126,26 @@ function xmldb_artefact_blog_upgrade($oldversion=0) { ...@@ -126,24 +126,26 @@ function xmldb_artefact_blog_upgrade($oldversion=0) {
if ($oldversion < 2009033100) { if ($oldversion < 2009033100) {
$bloguploadbase = get_config('dataroot') . 'artefact/blog/uploads/'; $bloguploadbase = get_config('dataroot') . 'artefact/blog/uploads/';
if ($basedir = opendir($bloguploadbase)) { if (is_dir($bloguploadbase)) {
while (false !== ($sessionupload = readdir($basedir))) { if ($basedir = opendir($bloguploadbase)) {
if ($sessionupload != "." && $sessionupload != "..") { while (false !== ($sessionupload = readdir($basedir))) {
$sessionupload = $bloguploadbase . $sessionupload; if ($sessionupload != "." && $sessionupload != "..") {
$subdir = opendir($sessionupload); $sessionupload = $bloguploadbase . $sessionupload;
$subdir = opendir($sessionupload);
while (false !== ($uploadfile = readdir($subdir))) { while (false !== ($uploadfile = readdir($subdir))) {
if ($uploadfile != "." && $uploadfile != "..") { if ($uploadfile != "." && $uploadfile != "..") {
$uploadfile = $sessionupload . '/' . $uploadfile; $uploadfile = $sessionupload . '/' . $uploadfile;
unlink($uploadfile); unlink($uploadfile);
}
} }
closedir($subdir);
rmdir($sessionupload);
} }
closedir($subdir);
rmdir($sessionupload);
} }
} }
@rmdir($bloguploadbase);
} }
@rmdir($bloguploadbase);
} }
return true; return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment