Articles by Dan

You are currently browsing Dan’s articles.

I just came across a subtle issue affecting Internet Explorer users (well, fancy that!) and HTTPS connections.

One of my clients has a site that downloads a series of results as a CSV file, which they open in Excel. Unfortunately, Internet Explorer was refusing to download the file, and was presenting an error message reading “Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found.”

To add to my confusion, this was happening on the live server (PHP4), but not on my dev server (PHP5) which both use the same code.

In the end, I happened upon a Microsoft Knowledge Base article that explained the problem. Basically, IE obeys any “no-cache” headers you send to the browser. Without caching the file, Office applications cannot open the file when served over HTTPS.

How to solve the issue? Remove the cache header(s) - but how?

The PHP manual doesn’t make it entirely clear, and I found the solution by accident. To remove a header, use the same syntax as for setting a header, but only include a space after the colon.

For example, for the “Pragma” header:

header('pragma: ');

Note: You must include the space after the “:” or the header will not be unset.

My work has just pushed out an update, upgrading our users to Firefox 3. Naturally, we’ve been busy looking through our internally produced sites to check all is fine in the new version.

In 99% of cases, all our sites look the same in Firefox 3, apart from one notable exception. In this one case, there is a 1px gap between the left-hand margin (which is centred using “margin-left: auto”) and the header image. Being the perfectionists we are, we don’t want a 1px white gap in our nice header.

Oddly, this 1px gap would come and go as the browser window is horizontally resized. This behaviour set alarm bells ringing that it’s some kind of rounding error in the “auto” positioning vs the exact pixel dimensions of our centred container.

After a bit of searching, we found an entry in John Resig’s blog (of JQuery fame), where he has stumbled upon the issue and developed a test case for the main browsers. Turns out that fixing it is a challenge, as all the browsers round the numbers differently. Problem is, there’s no standard for how the browsers should round the pixels, so fixing it in one browser will almost certainly break it in another.

Ho hum, here’s hoping for a future standard.

They’re funny things Linux file permissions - the moment you think you understand them, you discover some subtle piece of functionality that means you were wrong all-along…

In this three-part article, I give a brief introduction to file and directory permissions, as well as some of the common gotchas. This part shows you how to interpret permissions on the command line and explains what they mean.

Read the rest of this entry »

I’ve just discovered, totally by accident, how to get HTTP Authentication (when the browser pops up a dialog asking for the username and password - usually set with a .htaccess file) values within PHP. Previously, I’d just assumed that the authentication was a “black box” and I was unable to use it within my scripts. I had done some experimentation to see if any of the information was present in the _POST or _COOKIE arrays to no avail.

Read the rest of this entry »

Having attended the greatly motivational @media conference last week, I’ve come away feeling more enthusiastic about the up and coming microformats movement.

Last year, during @media 2006, I was introduced to the concept for the first time. In its simplest form, it’s a way of wrapping web content within a set of standardised class names. The idea being that if everyone uses these class names, it makes it very simple for other systems to parse and pluck out the data. The example given was marking up personal details as an hCard which could then be linked to the Technorati contact generator. The generator will parse the page and offer you a vCard file for download, which you can then import into Outlook or some other address book software.

Read the rest of this entry »