I have now test this function since I use it in my download manager but now when I test it it returns the following file list:
.
..
blog.css
blog.php
core.php
default.css
doublejweb.prj
error.php
extension.inc
favicon.ico
javascript.js
link_out.php
and on empty folders it also returns the . and ..
now when I want to remove a dir I first need to delte all files but in the while loop I use it also looks at the . and .. so it returns a false since it cannot remove the files:
[code start="126" highlight="129-140"]
//
//before we are able to delete the folder we need to delete all files inside it.
//
$open_dir = opendir(DJ_FILE_PATH . $category_info['url_name']);
while(($file = readdir($open_dir)) !== false)
{
//
//remove the file.
//
if( !@unlink(DJ_FILE_PATH . $category_info['url_name'] . '/' .$file) )
{
message_die(GENERAL_ERROR, 'Failed to remove file: ' .$file);
}
}
closedir($open_dir);
//
//all files are removed, now we'll remove the dir.
//
if( !@rmdir(DJ_FILE_PATH . $category_info['url_name']) )
{
message_die(GENERAL_ERROR, 'Failed to delete folder: ' .$category_info['url_name']);
}
$message = 'Files deleted succesfully.';[/code]
What can I add so it does not return errors on the . and .. filenames inside the directory?