Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-24-2009, 08:41 AM
|
#1
|
Member
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274
Rep:
|
php readfile http VS https
Hey All,
Doing some force downloading with PHP headers. I have the SAME code on http://www.mywebsite.com and https://secure.mywebsite.com.
I do the following:
Code:
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=' . basename($filename));
header('Content-Transfer-Encoding: binary');
if (readfile("$file"))
{
include "dbconnect.php";
..... CODE to update database .....
mysql_query($query);
mysql_close($dbh);
}
else
echo "FALSE";
When I am on the non secure site, i get the box to download the file, as well as my sql statements execute properly. When I am over SSL, I get the box to download the file, however the database does NOT issue the queries and updates. The interesting thing is that if I remove the header and readfile statements, over ssl, the database queries execute correctly. Thus I believe the problem is over SSL with readfile ??
Anyone have any thoughts or ideas?
Thanks a bunch!
|
|
|
04-27-2009, 01:32 AM
|
#2
|
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Rep:
|
Dunno. The part that *really* surprised me was that it *worked* if you eliminated the header and readfile() statements.
So I guess your next step is to narrow it down to one (header) or the other (readfile).
Please post back what you find!
Thanx in advance .. PSM
|
|
|
04-28-2009, 08:35 AM
|
#3
|
Member
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274
Original Poster
Rep:
|
Hey Paulsm4,
What I have also found is that if I change the ORDER of the code so that the SQL statements execute first, and then i issue the readfile, without checking if(readfile(file)); the SQL statements query properly, and the readfile pushes the file to the browser properly.
Code:
include "dbconnect.php";
..... CODE to update database .....
mysql_query($query);
mysql_close($dbh);
readfile("$file");
So I believe something to be wrong with readfile over SSL. Maybe not "wrong" but functioning differently than over HTTP.
|
|
|
04-29-2009, 12:18 AM
|
#4
|
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Rep:
|
OK, good. So we know the only two variables are:
1. readfile()
2. HTTPS
So the next step is to throw all the error checking ou can at "readfile()" (starting with a meaningful error#, if any).
Keep us posted!
PS:
You might also want to try "is_readable($filename)"...
PPS:
Here are some good tips on PHP error handling/error debugging:
http://www.w3schools.com/php/php_error.asp
http://www.tutorialspoint.com/php/ph...r_handling.htm
Last edited by paulsm4; 04-29-2009 at 02:04 AM.
|
|
|
All times are GMT -5. The time now is 05:55 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|