Ok I have a registration/permissions system setup, and I want to limit different user groups to only allow for an amount of downloads. (and non-logged in users to not have the ability to download anything at all). The files are stored in a public directory on my web server. I have a decent php knowledge and have worked with mysql a fair bit, so database stuff is no probs.
Any ideas on how I could limit user access to files?
Thanks, Josh
7 1616
I haven't done much (any) work in this area so, my ideas may not be the best. I apologise in advance.
You could log, in the database, the time their last download was and check it against the current time to see if x amount of time has passed. If so, allow the download, else, don't.
Cheers.
Atli 5,058
Expert 4TB
If the files are in a public directory you won't have any control over it.
You would have to either put it outside the web-root, where it can't be reached via a URL, or into a database, where you would have to use a script to fetch it.
Either way you could simply log each download and check that total amount. If the user is allowed to download it, just set the appropriate Content-Type header and echo the contents of the file from wherever it is actually stored.
yeh, I will be logging the users activity / download count ect, thats not a problem.
So say I had a folder outside the root directory say "downloads" how would I go about fetching the files for download (I realize it would be in something like download.php?f=bytes.exe) but how do I actually bring up the download?
Also will this apply for uploads as well? can i allow some restricted users to upload to the dir.
Thanks, Josh
awesome thanks guys. Last thing, when choosing target location for uploads, can i use the same principle, and choose a location not in the public domain?
Thanks heaps, Josh
Just wanted to leave a note for anyone the future who has a similar problem.
You may use what PhMods said, by uploading files to a place not in public_html, so in a private directory, then using readfile to read them.
Also a good mysql query that allows you to check how many logged downloads a user has downloaded (which i used) is: -
SELECT * FROM records WHERE userid = '".mysql_real_escape_string($userid)."' AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= date_downloaded
-
This checks from a download-records table how many downloads have been done in the past "1 day" or 24 hours.
Thanks, Josh
awesome thanks guys. Last thing, when choosing target location for uploads, can i use the same principle, and choose a location not in the public domain?
Thanks heaps, Josh
Yes. To put it simply.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: deko |
last post by:
I have a login script that creates a SESSION for authenticated users. But
authenticated users still need access to particular directories (which
contain files for download). My hosting provider...
|
by: Brian Piotrowski |
last post by:
Hi All,
I'm trying to run a simple query from an ASP page. I want the query to
select each individual field in a table and compare it to another table. If
the value doesn't exist, I want it...
|
by: James Macbell |
last post by:
I think I have pushed ASP.NET to the limit, I am not sure if I have done
anything wrong in the code because I am trying to make 2 pieces of code (C#
vs PHP) using the same algorithm. Anyways, here...
|
by: chipgraphics |
last post by:
:confused::confused:
I have been on the quest to find a php script that can serve files for downloads and limit the speed at which the file is transfered to the user. I want a faster download...
|
by: coosa |
last post by:
Hi all, I get this message when trying to update a tabel i have which
has nested hierarchies.
The current hierarchies beginning from root = 1 are up to the level 5.
Before going into details and...
|
by: google |
last post by:
Hello,
I am working on an Acc2003 app for my company. In the interest of
reducing chances of corruption due to unstable network connectivity, I
would like to either prevent users from running it...
|
by: Harold |
last post by:
Hi,
I'm writing software which should download some files. I want to limit
the number of simultanioulsy downloads to two. I'm using the
ServicePointManager object for this. But I still can...
|
by: bigpoppa |
last post by:
Hey, I need a script that will limit download speed and I want it integrated into the script I am using below. The script below forces downloads and hides url paths and logs stastics of downloads and...
|
by: Nu |
last post by:
I want to protect myself from if someone with a fast connection hammers my
site. It's not denial of service attacks, but offline downloaders (of course
that don't show they're offline downloaders...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |