Results 1 to 8 of 8

Thread: Directory Compilation.

  1. #1
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Directory Compilation.

    is there any existing program that scans a directory (presumabally the one your webpage is in) and creates a html file with links to every file in that directory?
    eg:
    Directory
    ___\_->sub folder
    _________\_->1.mp3
    _____________2.mp3
    _____________3.mp3
    ______sub folder
    _________\_->a.mp3
    _____________b.mp3
    _____________c.mp3
    ______sub folder
    _________\_->x.mp3
    _____________y.mp3
    _____________z.mp3

    Html file
    link to 1.mp3
    " "2.mp3
    " "3.mp3
    " "a.mp3
    " "b.mp3
    " "c.mp3
    " "x.mp3
    " "y.mp3
    " "z.mp3

    Thankyou for your time.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not in HTML, you can't. But in a server-side language it's easy; in PHP, for example, it would be:
    Code:
    <?php
      $cwd = $_SERVER['REQUEST_URI'];
      $cwd = substr($cwd, 0, strrpos($cwd, '/' + 1));
    
      function paintUndersideOfFox($c) {
        global $cwd;
        echo('<ul class="dirlist">');
        $d = opendir($c);
        while($f = readdir($d)) {
          if(strpos($f, '.') === 0) continue;
          $ff = $c . '/' . $f;
          echo('<li><a href="' . $cwd . $ff . '">' . $ff . '</a></li>');
          if(is_dir($ff)) paintUndersideOfFox($ff);
        }
        echo('</ul>');
      }
    
      paintUndersideOfFox('.');
    ?>
    Last edited by Twey; 08-27-2006 at 11:27 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Thankyou. now i just have to install php...
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Your server may be able to generate a directory listing automatically. With Apache, for example, the mod_autoindex module is responsible for generating listings when an index (like index.html or default.html; whatever the server is configured to use) isn't present.

    You might want to ask your host if the module (or a similar feature on other servers) is enabled, or if they will provide it for you before delving too far into server-side scripting.

    Mike

  5. #5
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I am my own host... and talking to myself isnt exactly o good thing to do.... i have Abyss installed on my computer and it works fine. on their website it gives a step by step procedure of how to enable it. and the Code works great Pr. Twey, your a genuis.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    talking to myself isnt exactly o good thing to do...
    Really? :-\ Damn...
    and the Code works great Pr. Twey, your a genuis.
    Genius or cracked as grandma's gravy boat, one or the other
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    just a quick addition: there's a potential security hole if anyone would use "globbing" (i.e. ../../../../), normally the server would ignore the overstepping up dirs, however php will not unless you chroot the script onto document root or strip "../" from the $cwd

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Or... just check user input before using the function with it, like you should be doing anyway The OP didn't mention user input, so I naturally assumed that s/he wouldn't be using it -- or that s/he is smart enough to know that all user input must be validated before use anyway.
    "globbing" (i.e. ../../../../)
    That's not globbing. .. exists as an actual directory on the filesystem.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh 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
  •