Jump to content
Can't remember your login details? Read more... ×
amckern

PHP Script to download from random list of mirriors

Recommended Posts

Hi,

 

At the moment i am transferring up to 150GB a month on my website due to 3 or 4 files.

 

What i would like to do is enable a PHP script to download from a random site on a list of mirrors, 98% of the downloads are made from a link at http://www.zhlt.info and i DO NOT have access to that site to enable the script there, it needs to be enabled from the file name - example;

 

A user clicks http://downloads.ammahls.com/zhlt/zhlt34x86final.zip, i would like that link to run a script that his a list of mirrors that the user will download from

 

http://example.com/zhlt34x86final.zip
http://example.org/zhlt34x86final.zip
http://downloads.ammahls.com/zhlt/zhlt34x86final.zip
http://directlinkdownloads.url/zhlt34x86final.zip

How would i go about it? Or do you have an example i might be able to use?

Share this post


Link to post
Share on other sites

I can think of two ways which might work well for what you're looking at,

 

1/ Catch any requests to that zip, then generate a redirect to a file out of the list.

 

2/ Make a download page, named like the file being downloaded, which returns a page with a download link to the file requested. eg. zhlt34x86final.zip.php

 

 

I don't know enough about PHP to offer specific advice for that language, but these are the approaches I would be looking at.

Share this post


Link to post
Share on other sites

1/ Catch any requests to that zip, then generate a redirect to a file out of the list.

Have you had web dev experience with this?

 

I suspect that my site also has perl, as its got a CGI-BIN folder.

Share this post


Link to post
Share on other sites

I do, but only with ASP.Net and being setup in IIS. Though in my case, it was a custom file handler for my file type as well, not overriding the file handling for a know file type.

 

It probably also depends on your hosting and how much control you have over the server software (probably Apache) using the .htaccess files for setting config.

 

For Apache, you'll likely want to look at this : http://httpd.apache.org/docs/2.0/misc/rewriteguide.html.

 

Make a rule which rewrites the rule for .zip files, which then rewrites the URL to a PHP file like mentioned in option 2; then have that PHP return a redirect to a file out of the list.

 

This link should help explain some of the ins & outs of redirecting, as well as some code, and some explanation of the recent snaffu about banner privacy on Facebook.

http://www.facebook.com/note.php?note_id=392382738919

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×