errors with download/display pdf

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Balubaer
Posts: 39
Joined: Wed 16. Aug 2006, 15:50
Location: Berlin

errors with download/display pdf

Post by Balubaer »

hi out there, dear community.

i think, i was a little bit too hasty with my reply on seedy's problem with firefox 2.0 and his download problems. (http://www.phpwcms.de/forum/viewtopic.php?t=13199)

i made some tests and hope that anyone can comprehend these results... and hopefully have a helping suggestion.

i tested my pages with firefox (in version 1.5.x and 2.x) and internet explorer (version 6) and got the following astonishing results:

setting inline_download = 1:
displaying pdf was stopped (message "angehalten") with firefox
displaying pdf in internet explorer worked well

setting inline_download = 0:
downloading pdf in firefox worked well (open with application and saving on hardisk)
downloading pdf in internet explorer only worked with downloading on harddisk, but not "open with application" (error message "file not found")

so now i have the problem that i cannot decide what option to take....

the websites are hostet on apache 1.3.3 (unix) and php 4.4.4. (but i cannot change this.)

can anyone help me please?

thanks in advance, :(
dennis
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

this is solved in coming release.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Balubaer
Posts: 39
Joined: Wed 16. Aug 2006, 15:50
Location: Berlin

Post by Balubaer »

hi oliver,

i know this must be one the annoying questions, but when will the new release be public?

i think there will be many things fixed. ;)

greetz,
dennis
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

no comment - ich denke zeitnah (was auch immer das heißen mag). Nun hat es so lange gedauert, dass ich 1-2 Sachen auf jeden Fall noch integriere...

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Balubaer
Posts: 39
Joined: Wed 16. Aug 2006, 15:50
Location: Berlin

Post by Balubaer »

hab ich's mir doch gedacht, dass ich dich nicht zu einer wirklichen aussage überreden kann. :roll:

dann sei mal schön fleissig...


... to be continued ...
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

download.php

Post by sebby »

Any interim solution before the patch is out? The current version is unstable both on IE and FF...

Should we use 'download.php' from previous distro?

Seb
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

yes you can.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Hello Oliver,

I tried the file 'download.php' included into last spring's distro (v.1.2.6) and I get the following error message:

error while retrieving file download infos

Any other suggestion?

Seb
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Hi-

All I get is "404 File Not Found" :(

seb
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

Then you might have another problem. Maybe permissions wrong.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Hello-

filestorage dir is 777 and all file in it are 644 (nobody:nobody). I tried 777 for all files and directories in filestorage without further success....

Is there anything else I missed ?
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

After I changed all file permissions to 777 (in filestorage dir) and set the inline_download = 0, the original 'download.php' included in the 1.2.8 distro appear to be working just fine.... I'll run some more tests and I'll keep you guys posted.

Seb
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Hello Oliver,

As my tests were not conclusive with v126, I turned back to the 'download.php' v129pre that Oliver provided earlier and I noticed that it had a new way of processing the query string... As I did not install the complete overnight distro (pre129), I uploaded only 'download.php' and edited it as follow:

I commented these two lines:

Code: Select all

$countonly	= empty($_GET['countonly']) ? false : true;
$hash 		= empty($_GET['f']) ? '' : clean_slweg($_GET['f']);
and replaced it with the following:

Code: Select all

if(!empty($_SERVER['QUERY_STRING'])) {
	list($hash) = explode('&', $_SERVER['QUERY_STRING']);
	$hash = trim(str_replace('=', '', $hash));
		
	if(!empty($_GET['target'])) {
		$phpwcms["inline_download"] = 1;
	} elseif(isset($_GET['target']) && $_GET['target'] == '0') {
		$phpwcms["inline_download"] = 0;
	}
}
I seems to be working just fine (w inline download disabled). Again, I'll run some more tests and I'll keep you guys posted.

Thanks for your assistance.

Seb
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

After much investigation, I found what was compromising the 'download.php'. In the 'dl_file_resume' function ('inc_lib/functions.file.inc.php'), where all the headers are written you will find the following code:

Code: Select all

	header("Accept-Ranges: bytes");
	
	$size=filesize($file);
	//check if http_range is sent by browser (or download manager)
	if(isset($_SERVER['HTTP_RANGE'])) {
		list($a, $range)=explode("=",$_SERVER['HTTP_RANGE']);
		//if yes, download missing part
		str_replace($range, "-", $range);
		$size2=$size-1;
		$new_length=$size2-$range;
		header("HTTP/1.1 206 Partial Content");
		header("Content-Length: ".$new_length);
		header("Content-Range: bytes $range$size2/$size");
	} else {
		$size2=$size-1;
		header("Content-Range: bytes 0-$size2/$size");
		header("Content-Length: ".$size);
	}
It appears that the http range thing is causing problems especially with pdfs (moreover, $_server['HTTP_RANGE'] is not configured on my server). So I changed the first line to :

Code: Select all

header("Accept-Ranges: none");
and everything went back to normal ( distro 1.2.8 ).

Any thoughts on this config?

Seb
Post Reply