Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: download script

  1. #1
    Join Date
    Jan 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default download script

    i'm looking for a script or way to list files in a directory as a download list
    that must be dynamic so i dont need to edit the html page when i change files in the directory...

    any help will be appreciated..
    thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    *bumpity*

    I need this also for Serberus (my web server) to save me time

    cr3ative
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  3. #3
    Join Date
    Sep 2004
    Location
    Little Falls, Roodepoort, South Africa
    Posts
    421
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    HI

    Saw these on the web... maybe it can help:
    http://www.broadware.com/lib/menu/script/
    http://forums.naesp.org/script/
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me

  4. #4
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Uhm, I'm confused by those links..

    cr3ative
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  5. #5
    Join Date
    Sep 2004
    Location
    Little Falls, Roodepoort, South Africa
    Posts
    421
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    From what I understand, it's the files for a directory listing script. Have not tried it, got it from a friend.
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me

  6. #6
    Join Date
    Sep 2004
    Location
    UK
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Directory Listing Script

    Apparently Apache Tomcat is a servlet that you need to install on your server. I don't think its primary use is directory listing and I guess those scripts are ones automatically generated for use by it.
    (Ref: http://jakarta.apache.org/tomcat/)

    It could work if you have your own server like cr3ative, but if you want a script instead, or you use a web host which I would assume rlmtech and the majority do, then try this script: (you'll need PHP support - I believe you would have to use a server-side language to do this)

    PHP Code:
    <?php

    $dir 
    ".";

    $directories = array();
    $files = array();
    $dir = (substr($dir, -1) == '/') ? substr($dir0, -1) : $dir;
    if(
    is_dir($dir)){
        if(
    $handle opendir($dir)){
            while(
    false !== ($file readdir($handle))){
                if(
    $file != "." && $file != ".."){
                    if(
    is_dir($dir.'/'.$file)){
                        
    $directories[$file] = filemtime($dir.'/'.$file);
                    } else {
                        
    $files[$file] = filemtime($dir.'/'.$file);
                    }
                }
            }
            
    closedir($handle);
        } else {
            die(
    'Could not open directory.');
        }
    } else {
        die(
    'Invalid directory.');
    }

    if(
    $_GET['sort'] == 'alpha'){
        if(
    $_GET['mode'] == 'desc'){
            
    krsort($files);
            
    $highlight 'alpha_desc';
        } else {
            
    ksort($files);
            
    $highlight 'alpha_asc';
        }
    } else {
        if(
    $_GET['mode'] == 'asc'){
            
    asort($filesSORT_NUMERIC);
            
    $highlight 'date_asc';
        } else {
            
    arsort($filesSORT_NUMERIC);
            
    $highlight 'date_desc';
        }
    }
    $sort_alpha_asc = ($highlight == 'alpha_asc') ? '<b>Asc</b>' '<a href="?sort=alpha&mode=asc">Asc</a>';
    $sort_alpha_desc = ($highlight == 'alpha_desc') ? '<b>Desc</b>' '<a href="?sort=alpha&mode=desc">Desc</a>';
    $sort_date_asc = ($highlight == 'date_asc') ? '<b>Asc</b>' '<a href="?sort=date&mode=asc">Asc</a>';
    $sort_date_desc = ($highlight == 'date_desc') ? '<b>Desc</b>' '<a href="?sort=date&mode=desc">Desc</a>';
    echo 
    "Sort by: Date- $sort_date_asc | $sort_date_desc; Name- $sort_alpha_asc | $sort_alpha_desc<br />\n<br />\n";

    echo 
    "<table border=\"0\">\n<tr><td><u>File</u></td><td width=\"25\"></td><td><u>Size</u></td><td width=\"25\"></td><td><u>Last Modified</u></td></tr>\n";
    foreach(
    $files as $file => $timestamp){
        echo 
    "<tr><td><a href=\"$dir/$file\">$file</a></td><td></td><td>";
        
    $filesize filesize($dir.'/'.$file);
        if(
    $filesize >= 1048576){
            echo 
    round($filesize 10485761).'MB';
        } else {
            echo 
    round($filesize 10241).'kb';
        }
        echo 
    '</td><td></td><td>'.date('M d Y H:i:s'$timestamp)."</td></tr>\n";
    }
    echo 
    '</table>';

    ?>
    It will list all the files in the directory specified in the $dir variable, along with their file size and date last modified. You can also sort by the name/date.

    It won't list sub-directories in case you, for some reason, use these in your website and don't want people poking around in them. You might be able to see it does store them in an array ($directories) so if they are extra download folders, you can do something with it (if you want the script to work with these you'll need a slight mod).

  7. #7
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    nice script.

    were would you add the subdirectory view?

    and is there a way to hide the htasses file?

  8. #8
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

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

    Default

    Apparently Apache Tomcat is a servlet that you need to install on your server.
    Apache Tomcat is a servlet container, and has little or nothing to do with the question at hand.
    and is there a way to hide the htasses file?
    Files beginning with . are not returned by readdir().
    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!

  10. #10
    Join Date
    May 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by cr3ative
    i have it running ,but it is not exacly what im looking for

    see.

    i have a ringtone site and there is lots on my server so i want to make it user freindly for me..

    i just want a script that will show the content but at the same time be able to play the song and download it..

    i think im dreaming ah?lol

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
  •