CMS issue, do you know the answer?

Forum > Programming

Evan

Posts: 1
07/04/2006 06:42 am
Ok, to begin with, I am trying to finish up my own CMS. It is mostly done except for the function I built that SHOULD delete an entire directory.

Look at the following function:

function rmdirAll($path){
if($handle = opendir($path)){
chmod($path, 0777);
while(($file = readdir($handle)) !== false){
if(is_file($path.'/'.$file)){
unlink($path.'/'.$file);
}
if(is_dir($path.'/'.$file)){
if($file != "." && $file != ".."){
chmod($path.'/'.$file, 0777);
rmdirAll($path.'/'.$file);
}
}
}
rmdir($path);
}
}

I know you are working on your 2nd installment on your CMS, but have you managed to figure this issue out? If the first folder's attributes were set by a different program to lock it, then chmod is useless. Have you figured a way around it without using FTP functions?

Miles

Posts: 128
09/04/2006 12:50 pm
As you have said, the problem here is that if PHP/Apache doesn't have the group ownership privillages for a file for whatever reason, it will neither be able to change its CHMOD properties nor delete the file, and in that case I don't think there's any way to remove such files unless FTP functions are used. Since it's a security/access feature, I really don't think there's a way around it using the standard set of file manipulation functions.

If I find out differently, I'll let you know though.

Quick Reply