Category Archives: PHP

PHP, SSL, File Output and Internet Explorer Error

While working on a project, everything was working on our beta site just fine.  Once we moved the project to the production site, we ran into an issue on a page that exported a csv file of information inline.  The only difference was that the production site was running SSL.

The basic situation is as follows.  A script written on PHP, running on Apache, through a SSL connection is dynamically generating a file (in our case a csv) and then sending it to the client.  This works correctly through Firefox, but returns an error in Internet Explorer.  The error returned is:

Internet Explorer cannot download <url of link>

Internet Explorer was not able to open this Internet site.  The requested site is either unavailable or cannot be found.  Please try again later.

Here’s a hint, no matter how many times you try again later, it will not work.  I started with this code:

header("Content-type: application/csv\n");
header("Content-Disposition: attachment; filename=\"$filename\"; size=$size");

After much research, I found the way to fix this is through the Pragma header, making sure it’s anything BUT off-cache.  Once I add a new header, it worked fine through both Firefox and Internet Explorer:

header("Content-type: application/csv\n");
header("Content-Disposition: attachment; filename=\"$filename\"; size=$size");
header("Pragma: turn-off-cache", true);

I just changed it to turn-off-cache, but anything typed in instead of off-cache would work fine.

ZCE 1000

Looks like Zend is celebrating their 1000 person to receive a ZCE (Zend Certified Engineer) certification.  They sent me an email about it a couple days ago, but I’ve been so busy that I really have not had a chance to look at it until now.  Apparently, they have created a new ZCE logo for the first 1000 ZCE’s to use.  I just happen to be one of the first 1000.  In case you’re not sure what the Zend Certified Engineer means, it basically is a certification for programming with PHP.

ZCE1000.GIF 

PHP Certification

Took the PHP Certification Exam today and passed it.  The exam ended up being a lot more difficult than I thought it would be.  I’m now a Zend Certified Engineer.

Zend Certified Engineer 

Not sure what kind of certification I am planning to go after next.  At this point in time I think I am leaning more to a MySQL Core Certification and MySQL Professional Certification.  The other certifications that I’m interested in getting in the future would be java certifications. 

PHP Session / Cookie in Frames Using Internet Explorer

For the last couple hours, I’ve been frustrated trying to figure out why I’m having an issue creating a session cookie with PHP while browsing with Internet Explorer.  This was testing some software for work that I wrote, or I wouldn’t have been using Internet Explorer emoticon.

Here is the problem that I ran into.  There is a master page that is being ran on a seperate server than the one that will be displaying this content.  The master page displays my servers content in one of the child frames.  When using internet explorer with the default privacy setting, Medium, I am not able to create a session due to the fact that a cookie will not be accepted by Internet Explorer.

I have found a solution to this problem.  The situation is that when the frame has been created by one server, and the child frame then loads content from a second server, Internet Explorer treats all cookies from the second server (in the child frame) as 3rd party cookies.  Under the Medium privacy level, cookies are not allowed from the secondary server because Internet Explorer "Blocks third-party cookies that do not have a compact privacy policy".  To fix this problem, a compact privacy policy must be added to the headers sent to the client before a cookie is attempted to be created.  The quick way is to just send this string in a header to the client ‘P3P: CP="CAO PSA OUR"’.  To get a better understanding of a compact privacy policy, you can go to http://www.w3.org/P3P/.  There is a bunch of commercial software out there to help you create fully detailed compact privacy policies, or you can use the free one that I found at http://www.the-dma.org/privacy/creating.shtml.

One thing to note is that this issue does not only occur with PHP.  Just happens that’s what I was developing with when I found the issue.  It will occur with any development language that tries to create cookies in the situation where a compact privacy policy does not exist, internet explorer is set on medium privacy level, and a frame page served by one server loads a child frame from another server. 

Eclipse IDE Platform

The more and more that I’m using the Eclipse IDE Platform, the more impressed I am with it. I originally started using it just so that Justin and I were on the same level for the php part of our senior design project. That is the nice thing about eclipse, it allows for plugins for additional features. There is even a plugin for PHP that is really nice to use. I haven’t set up the integration of apache and mysql with the local system yet, but it is on my todo list. I also installed the C/C++ plugin which I just finished using for one of my projects for a class. It worked wonderfully for that also. On top of all these great features so far, it has to be the easiest system to use for CVS. A lot of people have problems with CVS, and the GUI’s available are somewhat complicated. The integration of CVS into Eclipse made it very very easy to use even for people with experience with CVS. If you are looking for an IDE to use (no matter what platform you are on since Eclipse is written in java), I would definitely recommend you try this IDE and play around with it. It is a little intimidating at first, but the learning curve is good.