Results 1 to 9 of 9

Thread: having trouble with rmdir

  1. #1
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default having trouble with rmdir

    i have a file that someone gave me and it contains:

    PHP Code:
    <?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?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    it does delete the outbox folder and account file... and if by eraseallfiles code you mean what it is set to do, it is:

    Code:
    function eraseallfiles($dir) {
    $countstuff = opendir("$dir"); 
    while($file = readdir($countstuff)){ 
       if($file != '.' && $file != '..'){ 
          @unlink("{$dir}$file");
       } 
    } 
    closedir($countstuff); 
    }
    Code:
    $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);
       }

  4. #4
    Join Date
    Nov 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    check permissions too.

  5. #5
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    the directorys were 777

  6. #6
    Join Date
    Nov 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  7. #7
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    i had it set to make the directory 777 and that worked but it still wouldnt let me delete the inbox folder

  8. #8
    Join Date
    Nov 2006
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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"

  9. #9
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    could you give example like put it in the codes, I dont understand that...

    when registering there is
    Code:
    mkdir("./accounts/{$lowercase}_inbox/");
    mkdir("./accounts/{$lowercase}_outbox/");
    and when deleting what do i do...

    Sorry, im new at php...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •