Post Reply 
looking for a PHP download script
Author Message
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #11
RE: looking for a PHP download script
[Image: tumblr_l56uxbDvTa1qz98a1o1_500.jpg]

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 05:10 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Barcelona
Too Young To Care

Posts: 1,247.2872
Threads: 88
Joined: 10th Jul 2010
Reputation: -0.02892
E-Pigs: 60.4042
Offline
Post: #12
RE: looking for a PHP download script
(14/12/2010 05:10 PM)lembas Wrote:  [Image: tumblr_l56uxbDvTa1qz98a1o1_500.jpg]

Yay

[Image: A73TX.png]
Quotes That Made Me Lol
Joomla12 Wrote:Who are you?
(02/08/2011 08:26 AM)eKusoshisut0 Wrote:  ┻┻ ︵ヽ(`Д´)ノ︵ ┻┻
Previous Signatures
First Signature Wrote:Rep me up or I'll GENTLY CARESS you in the booty!
Second Signature Wrote:Studies have shown that for everyone person that doesn't rep me up, an angel gets a hernea.
Third Signature Wrote:Dead Trademark91 killed me.
Fourth Signature Wrote:Windows Proud
Fifth Signature Wrote:I'm waiting for someone to chime in with an arrow. Any tamed wolves you can be traced back to my forum signature.
Sixth Signature Wrote:[Image: 7hjyW.png]
14/12/2010 05:15 PM
Find all posts by this user Quote this message in a reply
Barcelona
Too Young To Care

Posts: 1,247.2872
Threads: 88
Joined: 10th Jul 2010
Reputation: -0.02892
E-Pigs: 60.4042
Offline
Post: #13
RE: looking for a PHP download script
you could have the download link bring you to a page that has the php code in it, then have the php code download the file, then if they right click and hit save as, it will save the php page
so just in case someones confusesd itll go
download link > php page > php page downloads automatically

so if they right click, theyll actualy donload this
                         |
                         V
download link > php page > php page downloads automatically

instead of that ---------------------|
                                                  V
download link > php page > php page downloads automatically




happy now?

[Image: A73TX.png]
Quotes That Made Me Lol
Joomla12 Wrote:Who are you?
(02/08/2011 08:26 AM)eKusoshisut0 Wrote:  ┻┻ ︵ヽ(`Д´)ノ︵ ┻┻
Previous Signatures
First Signature Wrote:Rep me up or I'll GENTLY CARESS you in the booty!
Second Signature Wrote:Studies have shown that for everyone person that doesn't rep me up, an angel gets a hernea.
Third Signature Wrote:Dead Trademark91 killed me.
Fourth Signature Wrote:Windows Proud
Fifth Signature Wrote:I'm waiting for someone to chime in with an arrow. Any tamed wolves you can be traced back to my forum signature.
Sixth Signature Wrote:[Image: 7hjyW.png]
(This post was last modified: 14/12/2010 06:31 PM by Barcelona.)
14/12/2010 06:30 PM
Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #14
RE: looking for a PHP download script
haha! That is brilliant!

except it totally didn't work like that. :(

download.php =

PHP Code:
<?php
	include 'get.php';
?>


and get.php is the script I posted earlier.

It downloads the file correctly, but 'Save As' still works. :(

poop!


I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 07:16 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #15
RE: looking for a PHP download script
(14/12/2010 04:32 PM)lembas Wrote:  Well I don't really care  if it always works, I'd just like to thwart the average user.

Really, the only reason I'm bothering is to track downloads; to see how many people are downloading our releases, and the tracking script is an 'onclick' one.
Then you're doing it the wrong way.
The PHP script should be counting downloads, JS really shouldn't be tracking downloads.
Perhaps have a little .txt file with the number of downloads stored there, and update it every time a download is hit.

Actually, best method would be just to provide a direct link and count downloads via webserver logs.
With this, you also don't have problems with pausing/resuming downloads, as well as multipart downloading, since the webserver handles all this, but your script doesn't.

By the way, your PHP script needs to check inputs more.
Otherwise, stuff like this works: http://deletefunction.com/download.php?f...wnload.php
Probably not an issue for you, but if you ever put stuff you don't want others to see, you may want to be aware of it.
(This post was last modified: 14/12/2010 07:50 PM by ZiNgA BuRgA.)
14/12/2010 07:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #16
RE: looking for a PHP download script
(14/12/2010 07:48 PM)ZiNgA BuRgA Wrote:  Then you're doing it the wrong way.
The PHP script should be counting downloads, JS really shouldn't be tracking downloads.
Perhaps have a little .txt file with the number of downloads stored there, and update it every time a download is hit.

Actually, best method would be just to provide a direct link and count downloads via webserver logs.
With this, you also don't have problems with pausing/resuming downloads, as well as multipart downloading, since the webserver handles all this, but your script doesn't.

Well, I'm actually tracking downloads with Google Analytics right now, but if there's a better way, feel free to show me. :D

EDIT: I changed the download.php a bit, so it (kind of) tracks downloads. See below:

(14/12/2010 07:48 PM)ZiNgA BuRgA Wrote:  By the way, your PHP script needs to check inputs more.
Otherwise, stuff like this works: http://deletefunction.com/download.php?f...wnload.php
Probably not an issue for you, but if you ever put stuff you don't want others to see, you may want to be aware of it.

lmao.

I'll do something simple:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
	$file=$_GET["file"];

	if($file=="DF001.zip")
	{
		$hits = file_get_contents("df001.txt");
		$hits = $hits + 1;
		$handle = fopen("df001.txt", "w");
		fwrite($handle, $hits);
		fclose($handle);
		include 'get.php';
	}
	elseif($file=="DF002.zip")
	{
		$hits = file_get_contents("df002.txt");
		$hits = $hits + 1;
		$handle = fopen("df002.txt", "w");
		fwrite($handle, $hits);
		fclose($handle);
		include 'get.php';
	}
	else
		die("LOL");
?>


I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
(This post was last modified: 14/12/2010 08:17 PM by lembas.)
14/12/2010 08:07 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #17
RE: looking for a PHP download script
Better:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
	switch($_GET["file"]) {
		case "DF001.zip":
		case "DF002.zip":
			$hitsfile = substr($_GET["file"], 0, -4) . '.txt';
			if($fp = @fopen($hitsfile, 'r+')) {
				flock($fp, LOCK_EX); // prevent two simultaneous downloads corrupting the file
				$hits = intval(fgets($fp)) +1;
				rewind($fp);
			} else {
				// file doesn't exist, create it
				$hits = 1;
				($fp = @fopen($hitsfile, 'w')) or die('Can\'t write file');
				flock($fp, LOCK_EX);
			}
			fputs($fp, strval($hits));
			flock($fp, LOCK_UN);
			fclose($fp);
			
			include 'get.php';
			
			break;
		default:
			header('HTTP/1.1 404 Not Found');
			
	}

?>

14/12/2010 08:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #18
RE: looking for a PHP download script
Awesome, thanks much, Zinga.

Woo

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 08:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Mickey
Down with MJ yo

Posts: 3,663.2843
Threads: 251
Joined: 26th Apr 2008
E-Pigs: 28.7300
Offline
Post: #19
RE: looking for a PHP download script
use javascript to disable right click?

[Image: MiCk3Y.jpg]

[Image: battle.png]

Spoiler for link:
14/12/2010 10:14 PM
Find all posts by this user Quote this message in a reply
lembas
yuri princess

Posts: 4,365.2931
Threads: 184
Joined: 30th Apr 2008
Reputation: -2.56923
E-Pigs: 154.3525
Offline
Post: #20
RE: looking for a PHP download script
I almost considered going that route, but that annoys the spoon out of me when a website is like that. :p

I'm gay.
Spoiler for online game stuff:
[Image: 76561198003967361.png]
[Image: thelemmingbas.png]
3DS FC: 4184-1632-9353
Spoiler:
[Image: wQZsI.jpg]
Spoiler:
In the words of the wise trademark91:
windows Proud
14/12/2010 10:17 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: