Development Software
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementDevelopment Software

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 2nd, 2004, 07:39 PM
foyleman foyleman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 39 foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 2 m 56 sec
Reputation Power: 6
Question downloads manager system

I am in the market for a downloads manager/system/controller for my website and I can't find anything anywhere that suits my needs. I am really hoping that someone here can point me in the right direction.

I want something similar to fileplanet.com or fileshack.com.

- I have a number of site members already registered
- I want to offer them downloads on a somewhat restricted level.
- - - a limited number of general members can download at one time. all others are placed in a queue
- - - general members can only download one file at a time
- - - general members have a cap on download speed
- - - preferred members have no limit

That's really all I need, but I can't seem to find a solution. I am a php and html programmer and those two languages just aren't cutting it here. I am thinking I need something like javascript or perhaps an applet.

I am limited to running on a unix (Redhat) server so IIS is out.

help.... please

Reply With Quote
  #2  
Old March 9th, 2004, 10:26 AM
drgroove's Avatar
drgroove drgroove is offline
pushing envelopes, not pencils
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Feb 2002
Posts: 6,224 drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level)drgroove User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Day 4 h 34 m 57 sec
Reputation Power: 174
Quote:
I am a php and html programmer and those two languages just aren't cutting it here.


If you're a PHP developer, all of this could be coded in PHP; I'm not quite sure why you think you wouldn't be able to do this in PHP.

None of the features you described need to be client-side (i.e. Javascript or Java Applet); all of this could be server-side.

Have you checked Sourceforge for an app like this?
__________________
Give a person code, and they'll hack for a day; Teach them how to code, and they'll hack forever.
Analyze twice; hack once.
The world's first existential ITIL question: If a change is released into production without a ticket to track it,
was it actually released?


About DrGroove: ITIL-Certified IT Process Engineer - Enterprise Application Architect -
Freelance IT Journalist - Devshed Moderator - Funk Bassist Extraordinaire


Reply With Quote
  #3  
Old March 9th, 2004, 10:36 AM
foyleman foyleman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 39 foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 2 m 56 sec
Reputation Power: 6
yup... checked sourceforge, hotscripts, scriptsearch, phpclasses, etc.

If it's possible to do this in php, then I have been mislead. Based on all of my test programming and responses in various forum posts, I can't do what I am looking to do.

based on tests, php can't
- limit the speed of a file download
- estimate the connection speed to determine remaining download time
- determine how much of a file has been downloaded to know how much is left

php can read a file using fread (or something similar), but the resulting download of, let's say, a zip file ends in a corrupted file. All of the bytes aren't read during the download.

I have come very close to a reliable script to limit the number of simultaneous downloads, but it's somewhat unpredictable in special circumstances. I can't be sure which circumstances, but sometimes when a download is cancelled, the server doesn't realize it.

If I am wrong, I would love it. It would mean that what I am trying to accomplish can be done.

Reply With Quote
  #4  
Old March 16th, 2004, 07:04 AM
cybrey cybrey is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 cybrey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 58 sec
Reputation Power: 0
I searched high and low ( and still am to certain extent) for just such a system. About the only thing I came across was etreed.

It certainly has the all the basic elements of what your asking, and gives good examples on how to write a proper file delivery system. I started on abstracting the code but never got around to fully implementing it.

Let me know if you find it useful.. or if make anything out of it as I would certainly be interested.

Reply With Quote
  #5  
Old July 29th, 2004, 01:39 PM
chorgheavyinc chorgheavyinc is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 chorgheavyinc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i have a solution for the php download problem

hi, i have a solution for you php download problem. lmk if you still need it.

Reply With Quote
  #6  
Old July 29th, 2004, 01:46 PM
foyleman foyleman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 39 foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 2 m 56 sec
Reputation Power: 6
Actually, I FINALLY found a solution to the situation. It was a long road, but I've got it all working now.

Still, I appreciate that you left a message here.

Looking for something even for sale isn't an option since there is nothing out there.

Reply With Quote
  #7  
Old July 30th, 2004, 05:01 AM
cybrey cybrey is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 cybrey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 58 sec
Reputation Power: 0
Any chance either of you could let me have any details of the systems that you've come up with..

Reply With Quote
  #8  
Old July 30th, 2004, 07:15 AM
foyleman foyleman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 39 foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 2 m 56 sec
Reputation Power: 6
I will share and hopefully this will help and not confuse.

a little background:
I am running two servers. One webserver and one fileserver. I wanted to perform the action I described in earlier posts and also create a system to mask the actual location of the file so that it couldn't be leeched.

To fix the leeching, I am creating links on the fly. These links are a combination of file id, user id, a little random math and most importantly the time the link was created. This way the link is only good for 3 minutes and then it expires and the page has to be reloaded for another link to download the file. That solved the problem of the leechers.

Now for controlling the file during download:
- I am running 3 files.
- 1 gets the information about the file and reports any errors after decoding the 3 minute link. It also determines if the user is allowed to download the file (if they are a registered member with an active account). If no errors, then the user is entered into the database for the next process:
Code:
INSERT INTO tres_downloads_serv (dl_start_time, dl_update_time, dl_remaining_time, dl_id, dl_link, dl_cat_folder, dl_title, dl_size, user_id, user_uname, user_email, user_status, max_connect, speed_multiplier, dl_status, serv_id, user_ip) VALUES ('".time()."', '".time()."', '".round($file_size/($speed_multiplier*1024))."', '$dl_id', '$dl_link', '$dl_cat_folder', '$dl_title', '$file_size', '$user_id', '$user_uname', '$user_email', '$user_status', '$max_connect', '$speed_multiplier', '2', '$id', '$_SERVER[REMOTE_ADDR]')

- 2 determines if they have to wait online or if they can download the file right away. This is done after checking the database for how many users there and whatever other criteria you have specified.
- if they have to wait online, then the page keeps refreshing and checking the database until their wait is over. They are then presented a link to start the download. This link is also only good for 3 minutes.
- 3 downloads the file. I think this is what you are really interested in and I will go into more detail.

The download page setups up the headers, download speed, and reads the files to the user. I determine the $ctype of the file which could be application/force-download as default. Here are the headers:
Code:
	header("Pragma: public");
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
	header("Content-Type: $ctype");

	$user_agent = strtolower ($_SERVER["HTTP_USER_AGENT"]);
	if ((is_integer (strpos($user_agent, "msie"))) && (is_integer (strpos($user_agent, "win")))) {
		header( "Content-Disposition: filename=".basename($filename).";" );
		} else {
		header( "Content-Disposition: attachment; filename=".basename($filename).";" );
		}
	header("Content-Transfer-Encoding: binary");
	header("Content-Length: $serv[dl_size]");


little more info before the code:
- To monitor the download in the database, I keep calling and updating the database during the download.
- the speed multipler is a whole number (1,2,3,100,1000, whatever) and then must be multiplied by 1024. This is how large each chunk of the file is read. Pausing between these chunks limits the speed accordingly. so, 60*1024 in this program will allow about 60kbps download speed.

Code:
	$start_time = time();
	$sessid = $start_time+30;

	$sql = mysql_query("UPDATE tres_downloads_serv SET
						dl_update_time    = '".time()."',
						dl_remaining_time = '".($serv[dl_size] / ($serv[speed_multiplier]*1000))."',
						user_ip           = '$_SERVER[REMOTE_ADDR]:$_SERVER[REMOTE_PORT]'
						WHERE serv_id = '$id'");

	$fp = fopen($filename, 'r');

	$speed=($serv[speed_multiplier] * 1024);
	while (!feof($fp)) { 
		echo(fread($fp, $speed)); 
		flush();

		sleep(1);
		if(time() > $sessid) {
			$sessid = $sessid+30;
			$currenty = ftell($fp);
			$elapsed = time() - $start_time;
			$time_left = ($serv[dl_size]/($currenty/$elapsed)) - $elapsed;

			$netstat = eregi("$_SERVER[REMOTE_ADDR]:$_SERVER[REMOTE_PORT]", shell_exec("netstat -n |grep ".$_SERVER[REMOTE_ADDR].":".$_SERVER[REMOTE_PORT].".*EST"));
			if(empty($netstat)) {
				$sql = mysql_query("DELETE FROM tres_downloads_serv WHERE serv_id = '$id' AND user_ip = '$_SERVER[REMOTE_ADDR]:$_SERVER[REMOTE_PORT]'");
				die;
				}

			$sql = mysql_query("UPDATE tres_downloads_serv SET
								dl_update_time    = '".time()."',
								dl_remaining_time = '$time_left'
								WHERE serv_id = '$id'");
			}
		}
	fclose ($fp);

	$sql = mysql_query("DELETE FROM tres_downloads_serv WHERE serv_id = '$id'");

	die;


I hope that helps.

Reply With Quote
  #9  
Old August 11th, 2004, 05:35 AM
cybrey cybrey is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 12 cybrey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 58 sec
Reputation Power: 0
Just to let people know I've created a project for my version of a solution to this problem at Sourceforge.. its called Tramitto.

I've already got a working solution to the problem above, with queing etc in and I hope to have this released over the weekend.

I'm now extending the idea even futher to implement a zipping system as well so that users can request a directory, the system will zip the files in the directory and send the zip file instead.

If you want to help email through the sourceforge site.

Reply With Quote
  #10  
Old September 22nd, 2004, 10:01 AM
Faces Faces is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 Faces User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have actually just done something similar.

It is without file queing or speed limiting, but manages files.

Im still building the usersystem, which enables users to add information to files in there folders on the server, as i run a extreme sport video hosting site.

It can be seen at http://www.trials-shack.co.uk

It is still very much young, and has some problems, one which one of you might actually have solved, so thought this might be a good place to ask .

Basically, my system uses .htaccess to load up a html page when you click a link to a video. You then click a button, which uses $_POST then some header() and fp()'s to load up a save dialog box.

However, because i host videos, some people use "download resumers". If you have heard of these, they basically can pause/restart downloads from where you stopped/got disconnected from.

But ofcourse, when the programs requests the video again, it isnt there as its a php page. So if anyone uses .htaccess in there scripts, and finds a solution for the resuming, please share

Reply With Quote
  #11  
Old September 22nd, 2004, 11:11 AM
foyleman foyleman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 39 foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level)foyleman User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 3 h 2 m 56 sec
Reputation Power: 6
Since I limit the age of each download to prevent leaching... I don't allow download managers to run. In a sense, What I have created is a download manager.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementDevelopment Software > downloads manager system


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |