Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#287845 - 04/10/2006 17:38 PHP and IE issue
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
For those who are tired of the gambling thread and want something more technical...here's a simple problem that has me pulling my non-existent hair out.

I have a php file that displays a PDF file inline. It works under IE and firefox except for one case.

When using HTTPS, IE fails on smaller files (roughly less than 20k) and not bigger ones. I'm not sure of the exact size it begins to fail, but I can reproduce the problem.

here's the code of the script:
Code:


<?
$browser = $_SERVER["HTTP_USER_AGENT"];
$file = $HTTP_GET_VARS['file'];

header('Content-type: application/pdf');
if (stristr("MSIE", $browser)) {
header('Content-Disposition: filename="$file"');
} else {
header('Content-Disposition: inline; filename="file"');
}
header('Content-Transfer-Encoding: binary');
header("Content-Length: " . @filesize("/tmp/$file"));
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header('Pragma: no-cache');

@readfile("/tmp/$file");

exit();
?>



Here's a file that doesn't work and a file that does work

This should be simple...any ideas?
_________________________
~ John

Top
#287846 - 04/10/2006 17:44 Re: PHP and IE issue [Re: JBjorgen]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Hmmm, presumably plain ol' apache can serve up either PDF just fine? It works just fine non SSL? I was going to suggest sniffing the trafic to see what was different between your script and apache, but that's not going to help if it's encrypted.

Matthew

Top
#287847 - 04/10/2006 17:48 Re: PHP and IE issue [Re: matthew_k]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
Quote:
Hmmm, presumably plain ol' apache can serve up either PDF just fine? It works just fine non SSL?


Yes and Yes. Those sample files are on the same server as the app in question.

Incidently, the file works fine over https when linked directly.
_________________________
~ John

Top
#287848 - 04/10/2006 18:31 Re: PHP and IE issue [Re: JBjorgen]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
Both files work for me? Unless the first one is supposed to have more in it.

Top
#287849 - 04/10/2006 18:44 Re: PHP and IE issue [Re: JBjorgen]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
In what way does it fail? Does it show a download box? Does it show the binary data in the browser? Does the plugin fail to load?
_________________________
Bitt Faulk

Top
#287850 - 04/10/2006 19:31 Re: PHP and IE issue [Re: JBjorgen]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
When I click on test1.pdf (FireFox), the final HTTP header line sent is
Quote:
X-Pad: avoid browser bug

I don't see that line when clicking on test2.pdf.

Cheers

Top
#287851 - 04/10/2006 19:35 Re: PHP and IE issue [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14493
Loc: Canada
Here are the HTTP headers I see (using the Live HTTP Headers extension in Firefox) with the User-Agent set to MSIE6:
Quote:
http://www.infodirect.us/test1.pdf

GET /test1.pdf HTTP/1.1
Host: www.infodirect.us
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en,en-us;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://empegbbs.com/ubbthreads/showflat.php/Cat/0/Number/288355/an/0/page/0

HTTP/1.x 200 OK
Date: Wed, 04 Oct 2006 21:32:21 GMT
Server: Apache/2.0.46 (Red Hat)
Last-Modified: Wed, 04 Oct 2006 19:29:30 GMT
Etag: "68c0d7-64b-42069a80"
Accept-Ranges: bytes
Content-Length: 1611
Connection: close
Content-Type: application/pdf
X-Pad: avoid browser bug
----------------------------------------------------------
http://www.infodirect.us/test2.pdf

GET /test2.pdf HTTP/1.1
Host: www.infodirect.us
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en,en-us;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://empegbbs.com/ubbthreads/showflat.php/Cat/0/Number/288355/an/0/page/0

HTTP/1.x 200 OK
Date: Wed, 04 Oct 2006 21:32:29 GMT
Server: Apache/2.0.46 (Red Hat)
Last-Modified: Wed, 04 Oct 2006 19:30:18 GMT
Etag: "68c0d8-6acd-44e30680"
Accept-Ranges: bytes
Content-Length: 27341
Connection: close
Content-Type: application/pdf
----------------------------------------------------------



Edited by mlord (04/10/2006 19:36)

Top
#287852 - 04/10/2006 20:34 Re: PHP and IE issue [Re: mlord]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I think those were just the files, not the files as served up by his PHP script that he implied is where the problem lies.
_________________________
Bitt Faulk

Top
#287853 - 05/10/2006 00:48 Re: PHP and IE issue [Re: wfaulk]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
Quote:
I think those were just the files, not the files as served up by his PHP script that he implied is where the problem lies.


Oops. Bitt is right. Let me fix that...here are the same two files served up through my script:
File that doesn't work:
https://www.infodirect.us/viewpdf.php?key=test1
and the file that works:
https://www.infodirect.us/viewpdf.php?key=test2

EDIT: holy crap....it works from here. That's too weird. Let's try again. Go to the InfoDirect Demo( http://www.infodirect.us/demo ) and login as "family" and "demo". Click on the red envelope button to access the message center and then view the attachments to the messages.

Top
#287854 - 05/10/2006 00:55 Re: PHP and IE issue [Re: JBjorgen]
Anonymous
Unregistered


It works fine for me on IE 6.0 and Adobe Reader 7.0.5.

Top
#287855 - 05/10/2006 01:09 Re: PHP and IE issue *DELETED* [Re: JBjorgen]
Anonymous
Unregistered


Quote:

EDIT: holy crap....it works from here. That's too weird. Let's try again. Go to the InfoDirect Demo( http://www.infodirect.us/demo ) and login as "family" and "demo". Click on the red envelope button to access the message center and then view the attachments to the messages.


I'm able to view the attachments fine. What versions of IE and Adobe are you using?

Top
#287856 - 05/10/2006 01:25 Re: PHP and IE issue *DELETED* [Re: ]
JBjorgen
carpal tunnel

Registered: 19/01/2002
Posts: 3584
Loc: Columbus, OH
Ah...that's it..something I tweaked in the headers caused it to work for IE6 now. Only IE7 is currently broken. I assumed that since I couldn't get it to work in either earlier that it was still broken in IE6 too.

Sorry about the fuss all. Nothing to see here I guess.

/me laments that Microsoft can't make their browser backward compatible or standards compliant.
_________________________
~ John

Top