Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1

    Default [PHP] - Directory's and their files

    Hello all,

    I'm currently working on a private "uploader" type script. As I'm a lazy idiot, I'm working on an admin page that'll allow me to either:
    - delete the directory and remake it with the appropriate permissions.
    - delete all files in the directory, but leave the directory outstanding.

    Deleting the directory is easy, with a function such as:
    (not created by me
    PHP Code:
    function rmdirr($dirname)
    {
        
    // Sanity check
        
    if (!file_exists($dirname)) {
            return 
    false;
        }

        
    // Simple delete for a file
        
    if (is_file($dirname) || is_link($dirname)) {
            return 
    unlink($dirname);
        }

        
    // Loop through the folder
        
    $dir dir($dirname);
        while (
    false !== $entry $dir->read()) {
            
    // Skip pointers
            
    if ($entry == '.' || $entry == '..') {
                continue;
            }

            
    // Recurse
            
    rmdirr($dirname DIRECTORY_SEPARATOR $entry);
        }

        
    // Clean up
        
    $dir->close();
        return 
    rmdir($dirname);

    Then executing it, with a:
    PHP Code:
    mkdir$directory ); 
    However, is it possible to chmod that by connecting to ftp? I checked out some links and php.net, but would it just be easier to attempt to delete every file in the directory?

    Thanks a lot!

  2. #2
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:


  3. #3

    Default

    Quote Originally Posted by Blob View Post
    Aye, but is it easier to just delete all the files in the directory?

  4. #4
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Not really, it only takes one line to do it.

  5. #5

    Default

    Quote Originally Posted by Blob View Post
    Not really, it only takes one line to do it.
    Aright, thanks a bunch.

Posting Permissions

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