dan.forys.co.uk
Dan is a web developer in London. He is interested in all things Internet, Linux and Mac.-
Unsetting http headers in PHP
Posted on August 6th, 2008 3 commentsI 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.
-
Intermittent 1px gap in Firefox 3
Posted on July 30th, 2008 No commentsMy 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.
-
Understanding Linux file permissions
Posted on July 29th, 2008 No commentsThey’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.
-
Step by step: Moving code between Subversion repositories
Posted on July 23rd, 2008 4 commentsAs many coders will tell you, there reaches a point where you realise that you absolutely, positively must keep your code in a a revision control system. In my working life, I’ve used Microsoft’s ageing SourceSafe and more recently the vastly superior SubVersion (SVN).
There’s many powerful GUIs out there which you can use to interact with SVN, and make the checking out and checking in very easy. If you primarily use a desktop GUI (like me), then chances are you use a SVN client GUI to interact with SVN on a day-to-day basis.
But what happens when you need to move code between repositories?
-
Novell client on OpenSuse 10.3
Posted on October 8th, 2007 2 commentsThe latest (10.3) version of OpenSuse was released a few days ago. As I use Suse as my main development environment at work, I eagerly downloaded it as soon as I could, and installed it on a virtual machine.
First impressions are very good – very quick startup time, easy 1-click installs and a bright and cheery colour scheme.
Unfortunately, I can’t switch for real as the Novell Client doesn’t work yet, and I need to client to access my shared drives at work. (Although I could use WebDAV, it doesn’t work so well). Attempting to install the Beta 2.0 version yields a single dependency error (wrong version of binutils). Satisfying the dependency results in the Novell Client loading – but not connecting at all. Seemingly, the public Beta 2.0 of the client is no longer available for download.
There was quite a wait on Suse 10.2 for a working Novell Client – which was released in beta form a couple of months ago (and it works very nicely too). I’ll eagerly await and hope that Novell release a new client soon, then I will more than happily switch to the new version.
UPDATE 29th Nov 2007
I”ve just spotted that Novell have posted a way to run the 10.2 client on 10.3, over at coolsolutions.
It has a simple step-by-step guide that just involves entering a few commands into the shell.
-
Removing Windows from Apple’s Bootcamp
Posted on October 1st, 2007 No commentsHaving tried Windows Vista on my shiny new iMac and having a few issues (stuttering sound, slower loading times), I decided to revert back to using Windows XP.
Now, Bootcamp is supposed to make this easy – you just launch the Bootcamp assistant, and click “Restore the startup disk to a single volume”. A few moments later, all seemed well, and I was prompted to reboot.
After the reboot, the Windows XP drive is still visible, and it seems nothing has happened. After trying this multiple times and getting quickly fed up, I ruled out a few other ways to delete Windows:
- I couldn’t run the Windows XP installer disk – rebooting the iMac with the disk in the drive caused a “Press any key to boot from CD…” prompt. Unfortunately, the iMac keyboard doesn’t work at that point.
- Attempting to run the XP installer from within Vista – the “Install Windows XP” option is greyed out and not selectable
- OS X’s disk utility wouldn’t let me unmount or erase the Windows parition
- I was too scared to use fdisk from the command line, just in case I nuked my OS X partition (and didn’t want to reformat the whole lot for the same reason)
So, how did I fix it in the end?
If you can’t delete Windows from your Mac’s bootcamp installation:
- Drag the Windows parition to the Trash to unmount it
- Run the Bootcamp assistant and choose “Restore the startup disk to a single volume”
Guess that’s the risk you take when you use Beta software eh?
-
HTTP Authentication in PHP
Posted on June 12th, 2007 No commentsI’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.
-
Microformats and me
Posted on June 11th, 2007 No commentsHaving 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.



