Results 1 to 6 of 6

Thread: Delete external files... but there is a trick

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

    Default Delete external files... but there is a trick

    I have soe files in mywebsite that say they aren't there, so it wont let me delete them... however when I tried a delete/unset script it didnt do anything.

    does anyone know how to make a script so that I cna just completely kill the directory they are contained in, since it can still find that directory?

    like the files are in like
    site.com/testing/grr/delete

    and the files are a file named "1", no extensions or anyhthing, and a directory with a shortcut icon (the little arrow in the corner) that is simply named "."

    they were put there when I messed up on a php script... is there a script that will just completely kill the directory /testing so that I can remake the directory and put in my files?

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

    Default

    I've used this function in a filemanager that I was working on, but never finished. Feel free to modify it to your liking.

    PHP Code:
    $home "/home/www/mysite/"//the path to your folder

    remove_directory('testing'); /* call the function with the desired folder you wish to delete */

    function remove_directory($fold) {
    global 
    $home;
      
      if(
    substr($fold, -11) == "/"){
            
    $fold substr($fold0strlen($fold) - 1);
          }
          if (
    $open opendir($home.$fold)) {
            while (
    false !== ($item readdir($open))) {
              if (
    $item != "." && $item != "..") {
                if (
    is_dir($home."$fold/$item")) { remove_directory("$fold/$item");  }
                else { 
    unlink($home."$fold/$item"); }
              }
            }
            
    closedir($open);
            
    rmdir($home.$fold);
          }
     } 
    Enjoy!
    "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

    yay it worked... is that copyrighted or can i give it to other people if they need help wiht that?

    and thanks for all your help... you seem to be the only one that ever helps me

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

    Default

    The above is not copyrighted. I made that function up while working on a File Mananger program, that I never completed. You can give it out to other people and change to your liking.

    Enjoy!
    "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

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

    Default

    okay. Thanks to you I have succesfully deleted and remade the directory... Otherwise I would have had to do an hours worth of work changing urls all over my site.

    Thanks!

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

    Default

    Not a problem at all, let me know if you need any more help.
    "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

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
  •