Log in

View Full Version : having trouble with rmdir



motormichael12
12-10-2006, 08:27 PM
i have a file that someone gave me and it contains:


<?php

if ($eraseuser) {

// Attempt to erase member and all files
//
unlink("./accounts/{$eraseuser}_user.php");
eraseallfiles("./accounts/{$eraseuser}_inbox");
eraseallfiles("./accounts/{$eraseuser}_outbox");
rmdir("./accounts/{$eraseuser}_outbox/");
rmdir("./accounts/{$eraseuser}_inbox/");

$file=file("./id_data/member_names_num.txt");
if ($eraseuser) {
$file=file("./id_data/member_names_num.txt");
$file[$l]="Nonexisting \n";
$file3 = fopen("./id_data/member_names_num.txt", "w+");
foreach($file as $v){
fwrite($file3,"$v");
}
fclose($file3);
}
}

when trying to delete the user it won't delete the inbox folder... I have a script so when they register it makes a file in the inbox folder, so that could cause something, but the eraseallfiles should take care of that...

Any suggestions?

thetestingsite
12-10-2006, 09:19 PM
Does it give any errors, and does it delete the outbox folder? Also, could you post the code for eraseallfiles(), it could be something in that.

motormichael12
12-10-2006, 10:27 PM
it does delete the outbox folder and account file... and if by eraseallfiles code you mean what it is set to do, it is:


function eraseallfiles($dir) {
$countstuff = opendir("$dir");
while($file = readdir($countstuff)){
if($file != '.' && $file != '..'){
@unlink("{$dir}$file");
}
}
closedir($countstuff);
}



$dir = "./accounts/";
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {

if ($file != "." || $file != "..") {

if(!is_dir("./accounts/$file")) {
include("./accounts/$file");
$list.= "$email, ";

}


}


}
closedir($dh);
}

chovy
12-11-2006, 12:17 AM
check permissions too.

motormichael12
12-11-2006, 02:48 AM
the directorys were 777

chovy
12-11-2006, 03:04 AM
what about the files within? If it was created by the web server, sometimes it will be 755 (owner/group as 'nobody') which wouldn't let you delete them unless you were root.

motormichael12
12-11-2006, 10:35 PM
i had it set to make the directory 777 and that worked but it still wouldnt let me delete the inbox folder

chovy
12-11-2006, 10:39 PM
try "chmod -R 777 ./directory"

then "rm -rf ./directory" -- will remove everything, if you don't get an error, then check to see who owns .inbox - "ls -l .inbox"

motormichael12
12-13-2006, 03:10 AM
could you give example like put it in the codes, I dont understand that...

when registering there is
mkdir("./accounts/{$lowercase}_inbox/");
mkdir("./accounts/{$lowercase}_outbox/");


and when deleting what do i do...

Sorry, im new at php...