By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,441 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,441 IT Pros & Developers. It's quick & easy.

Bandwidth and download question

P: n/a
Hello,

I have a website that is hosted by another company. Is there some kind
of php script to limit downloading to a certain amount size? And is
there kind thing I can do to the .htaccess file to limit this as
well???

For example I have a little media file say about 3MB or something.
Once someone visits the site and wants to download this file (ie.
http://www.domain.com/dir/file.wmv), I would like something check
something to see if they have the max download per day before it lets
them download it.

thanks for any help.

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I also want to add, it doesn't have to limit the wmv file, whatever
file is in a directory as well.

Jul 17 '05 #2

P: n/a
"Samir" <dl*****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I also want to add, it doesn't have to limit the wmv file, whatever
file is in a directory as well.


This is really something handled better by the webserver software (i.e.
apache). It COULD be done w/ PHP, but it would be a little tricky.

-Joe
Jul 17 '05 #3

P: n/a
NC
Samir wrote:

I have a website that is hosted by another company.
Is there some kind of php script to limit downloading
to a certain amount size?


This is not a trivial task. It is possible to create a
script that will keep track of files that users ATTEMPTED
to download. Whether those downloads succeeded or not is
difficult to tell from the server side...

Cheers,
NC

Jul 17 '05 #4

P: n/a
Where would the best place to do? Can you give me some pointers and
hints?

Jul 17 '05 #5

P: n/a
NC
Samir wrote:

Where would the best place to do? Can you give me some
pointers and hints?


OK, if I understand your problem correctly, you need an
application with four major functions:

1. Authorization
A user must provide valid credentials (login name and
password) before using the service. User data (login
name, hash of password, e-mail address and any other
information you require at sign-up) should be stored
in a database table. If you plan to have different
download quotas for different users, this should also
be reflected in this table.

2. File storage
Files should be stored in a directory protected from
direct access via HTTP (either located outside of document
root or blocked with a "deny from all" directive in
an .htacces file). Basic information about files
(name, size, and perhaps MIME type) shoule be stored
in another database table.

3. Accounting and delivery
Downloads should be implemented via PHP script. Let's
say a properly authorized used requests file whose
ID number is 234. A query executed on the file
storage data table returns that file number 234 is
named 'somesong.mp3', is 1,234,567 bytes long, and
has a MIME type 'application/mp3'. Then, you can
implement the download like this:

header('Content-Type: application/mp3');
header('Content-Disposition: attachment; filename=somesong.mp3');
header('Content-Length: 1234567');
readfile('files/somesomg.mp3');

Direct downloads from file storage directory should not
be allowed. Every attempted download via script should
be recorded in a third database table listing user ID,
time of download, and the ID of file being downloaded.
Prior to the commencement of the download, a check should
be run on whether the user has exceeded his/her download
quota.

4. Administration
The project administrator (meaning, you) should have
a Web interface for file uploads, managing users, etc.

Scared yet? :)

Cheers,
NC

Jul 17 '05 #6

P: n/a
Thanks for all the info...I am testing out the phpnuke, it is something
I am going for. I have managed to set up links in a hidden directory
for download and disguise the link as well. I finished writing the
script by checking whether or not they are a registered user or not as
well. I learned quite a bit. I did things a little differently but I
like the ways yours was written as well for hiding the download file.

Just one more thing I guess, Is there a way to deteremine whether a
file has finished downloading or not. I just don't want to count the
click as a download without knowing whether the download completed or
just cancled by the user. I think I am trying to say I would like to
know if there is a way to count how many bytes the user has taken at
the finish of the dowload or cancel button.

Thanks again:)

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.