Download... a question for the experts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
romeo
Forum Contributor
Posts: 138
Joined: Sun Apr 21, 2002 12:50 pm

Download... a question for the experts

Post by romeo »

I know it's possable, just not a clue how I would even start it...

To feed a script a URL and have it pull down all the links to .zip files and download the .zip files to the server...

Does anyone know how, or have a clue where to find a script like this
will
Forum Contributor
Posts: 120
Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN

Re: Download... a question for the experts

Post by will »

romeo wrote:I know it's possable, just not a clue how I would even start it...

To feed a script a URL and have it pull down all the links to .zip files and download the .zip files to the server...

Does anyone know how, or have a clue where to find a script like this
(assuming apache is used), this would depend on the "Indexes" option of the apache configuration. This directive allows/disallows the user to view the entire contents of a directory if there is no DirectoryIndex file present (such as index.html or index.php). if this is a server that you administer, i'd be happy to show you how to set apache to allow such a thing

<edit>
oops, i guess i misread the question...i was thinking you were looking to download all zip files in a given directory
</edit>
Last edited by will on Mon Jun 24, 2002 10:11 am, edited 1 time in total.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

It's possible.

Post by BDKR »

Just retrieve the document and parse it for <a> and </a> tags. When it finds those, parse for file type. Make a list of the hits (so to speak), then go back and download those files.

Check out this link. http://www.php.net/manual/en/function.fsockopen.php.
Look at example one and build from there.

Later on,
BDKR (TRC)
romeo
Forum Contributor
Posts: 138
Joined: Sun Apr 21, 2002 12:50 pm

So like this

Post by romeo »

The First part I think I can handle.. the sockets however confuse me...

does

Code: Select all

<?php
$fp = fsockopen ("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) &#123;
    echo "$errstr ($errno)<br>\n";
&#125; else &#123;
    fputs ($fp, "GET / HTTP/1.0\r\nHost: www.example.com/tough.zip");
    while (!feof($fp)) &#123;
        echo fgets ($fp,128);
    &#125;
    fclose ($fp);
&#125;
?>

download the zip file?
romeo
Forum Contributor
Posts: 138
Joined: Sun Apr 21, 2002 12:50 pm

Post by romeo »

bump
romeo
Forum Contributor
Posts: 138
Joined: Sun Apr 21, 2002 12:50 pm

Post by romeo »

()()()
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Why not try it out and tell us if it does?
Post Reply