A better phpinfo

The phpinfo() command comes in very useful when you want to check details about your PHP install and server setup. However, there is a lot of output and you won’t need it all. Not everyone knows that you can pass parameters to the function to narrow the scope of the information displayed.

I came up with this simple method to view the results of using these parameters and make it easy to switch between them.

< ?php

	$options = array('CONFIGURATION', 'ENVIRONMENT', 'MODULES', 'VARIABLES', 'GENERAL', 'CREDITS', 'LICENSE', 'ALL');
	$display = (empty($_GET['display']) || !in_array(strtoupper($_GET['display']), $options)) ? 'ALL' : strtoupper($_GET['display']);

	$navigation = array();

	foreach($options as $key=>$value) {
		$navigation[] = ($value != $display) ? '<a href="' . $_SERVER['SCRIPT_NAME'] . '?display=' . $value . '">' . $value . '</a>' : '<strong>' . $value . '</strong>';
	}

	ob_start();

	switch($display) {
		case 'CONFIGURATION':
			phpinfo(INFO_CONFIGURATION);
			break;

		case 'ENVIRONMENT':
			phpinfo(INFO_ENVIRONMENT);
			break;

		case 'MODULES':
			phpinfo(INFO_MODULES);
			break;

		case 'VARIABLES':
			phpinfo(INFO_VARIABLES);
			break;

		case 'GENERAL':
			phpinfo(INFO_GENERAL);
			break;

		case 'CREDITS':
			phpinfo(INFO_CREDITS);
			break;

		case 'LICENSE':
			phpinfo(INFO_LICENSE);
			break;

		case 'ALL': default:
			phpinfo();
			break;
	}

	$content = ob_get_clean();

	if (('CREDITS' === $display) &amp; preg_match('/<h1><a href="([^"]+?)">PHP Credits< \/a>< \/h1>/', $content, $matches) & !empty($matches)) {
		$content = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . $matches[1]);
	}

	echo str_replace('<body>', '</body><body><div class="center options"><p>' . implode(' | ', $navigation) . '</p></div>', $content);

?>

It’s also worth pointing out that the information exposed by this function can be useful to people who want to locate any weaknesses in your system so I would recommend restricting access to this file with a password, by an IP address range or only uploading the file to your webserver temporarily and removing it as soon as you’re finished with it.

Lessons

A word to the wise: when upgrading your Wordpress installations, always remember to deactivate your plugins before you start.

Yup, I overlooked / ignored the recommended steps for upgrading and managed to screw things up somewhat. Apart from the absence of posts (like that’s anything new) you have not likely noticed anything actually wrong but suffice to say that the admin pages were unusable for a while.

All is well again now though and a flurry of posts will ensue . . .

Choices

After Google I/O a few weeks ago I got to playing with some of the HTML5 demos that were used during the keynote presentation. I was impressed by performance and browser support: the latest releases of Firefox, Chrome, Opera and Safari all embrace HTML5. True-to-form, IE is a long way behind. As Ian Hickson correctly identifies, browser vendors have the ultimate veto on a specification: if they don’t implement it then it might as well not exist. In this way a consensus between vendors can lead the development of a specification as opposed to the other way round. I wouldn’t say that it’s exactly a collusion to drive people away from IE but even if it was, few developers would mourn its passing.

I attended a talk given by Tristan Nitot at Internet World last year where he extolled the virtues of openness and the dangers of lock-in. The ownership of a standard implies control. Systems without control lead to cooperation, transparency, participation, equality and freedom. In a system with control, you get to decide who can see what and what to charge them. I’m not saying that this is the goal of Adobe. They may very well keep content available for everyone without charge but the danger that people could be pushed towards content from which Adobe receive a payment is palpable.

Microsoft’s Silverlight was actually a welcome competitor but it is still a proprietary technology and it’s safe to say that adoption rates have been less then stellar. Major League Baseball dropped Silverlight recently and even Bing – Microsoft’s newly branded search engine – favours Flash.

The majority of the time that I encounter Flash on the Internet it’s used simply to present video. The native <video> tag as used by YouTube and Dailymotion could put a serious dent in the importance of Flash despite the near ubiquitous install base.

Fun in the sun

Last weekend was a great example of why I love living in Edinburgh. I chose to give the Edinburgh Rugby 7s a miss and spent Saturday afternoon lounging in the glorious sunshine with a couple of litres of water on the Meadows while my hangover subsided. All was very peaceful until I was rudely interrupted by some continental bongo-playing hippie who chose to take up position directly behind me and knock out some sounds. Eventually he took a break and I met some friends to head on down to the Grassmarket to watch some of the racing at the first event of the 2009 Nocturne series and then we planned to go onwards to Holyrood for a friends birthday barbecue.

We stayed around for the first bike race as even on a small course it was kind of hard to follow what was going on but there were a fair few distractions. For example, Marshalls were giving away pasta pots – probably a good thing as I don’t think many people would have paid for them after the first customers tried them.

Far nicer food by far was to be found down in Inverleith park for the Taste of Edinburgh Festival on the Sunday. Demonstrations from Jean-Christophe Novelli, a welcome cocktail from Courvoisier and amazingly good food like Malmaisons burgers (at least judging by the queues – being pescetarian I was enjoying the salmon fishcakes from Tigerlily) and Bordeaux wine tasting (although there were no 2005s!) all made for a fantastic afternoon.

Certainly far more relaxing and indulgent than, say, running the Edinburgh Marathon in 22° heat like roughly 13,000 people attempted. I like to think that I made a wise judgement call this time.

A new reality

I’m very excited at the moment. It’s only a couple of weeks until WWDC in San Francisco and I’m expecting some big announcements from Apple. The new Snow Leopard and iPhone 3.0 operating systems should be ready and a new iPhone model is pretty much guaranteed.

Among the new features already known to be on the third iteration of the iPhone will be video recording, an improved camera and a magnetometer or digital compass. It’s this last item that is the source of my anticipation. A device that knows where it is by using GPS, knows its orientation using accelerometers, knows which way it is pointing from the digital compass and knows what it can see through the camera should be able to do some amazing things – especially when you have large screen to display things on.

I’ve been more excited about this concept since watching this demonstration and playing with Sky Map on a colleagues Android G1. This kind of augmented reality, where virtual digital data is overlaid on top of what you actually see through your camera will be huge in the next five or so years.

The next logical step – though this is a good way away yet – will be to have the same technology available through wearable lightweight glasses and then on to a contact lens type system. This coupled with facial recognition will mean that you’ll never be unable to put a name to a face again!

Memories

I was watching Jonathan Ross interview Tom Hanks last night and Tom started talking about the swimming training he did for Angels and Demons. There’s a bonus at the end of the clip: Tom does the rap from Big.

I was impressed that he could remember the words just like that after 21 years. However something was itching away at the back of my mind about the name of the guy who trained him to swim: Michael Newman, an ex-firefighter and lifeguard. Then it hit me. This just had to be Michael “Newmy” Newman from Baywatch fame. He didn’t have a major role but I still remember him and I don’t know why.

Probably for the same reasons that I can remember most of the cast and characters from ‘Allo ‘Allo or that the wooden Indian in Neighbours years ago was called Frank. Of course this recall seems to be arbitrary – my memory didn’t make exams a breeze, professionally it doesn’t help me remember which function arguments come in which order when coding but it certainly comes in useful in a pub quiz.

Twitter effect

As has been witnessed before by many people who blog, activity elsewhere can have a detrimental effect on the frequency of your posts. Not only have I not updated my blog for a good couple of weeks but I’ve also noticed that my Facebook activity has all but stopped completely.

It’s not just excessive tweeting and other online distractions that have occupied me recently. A couple of weddings, a stag weekend and a very busy period at work (about which I shouldn’t really moan too much, all things considered1) have all colluded to keep me from blogging recently. Things don’t seem to be getting any quieter in the near future either. For a start, this weekend sees the christening and first birthday of my gorgeous niece who I don’t see nearly enough of. I’m going to use the long weekend visiting my brother and sister-in-law to try and get them comfortable with using Skype.

1 I refuse to employ the overused term “current climate”.

RIP 96, YNWA

Silence for Hillsborough victims (from the BBC).

I don’t think I need to say anything more.

Too little, too late?

Microsoft released Internet Explorer 8 just under a month ago now and I was interested to see what kind of market share it had achieved. Admittedly my blog doesn’t have the highest footfall but the 1.5% of visits that come from IE8 appears to be consistent with more popular sites. This is roughly half the impact that Google’s Chrome had when it was first released.

Of course, different sites attract different demographics. The more technical minded of users are, frankly, unlikely to use any version of IE so these figures will be lower for a site like slashdot than HoTMaiL for instance. Developing for your target audience is of huge importance. It’s no secret that getting things to work for IE6 has become the daily source of frustration of many web developers. Many governmental departments and large companies with monolithic IT support still haven’t upgraded from IE6 citing spurious reasons like insufficient testing. I can easily see IE8 taking away browser share away from IE7 in the coming months and use of IE6 keeping constant for a good while yet.

The public at large is better educated and now many know there are alternatives to the blue e that sits on their desktop. As long as they have a choice in the matter and aren’t locked down to an aged and obsolete browser that is.

How many zeroes is that?

One trillion has 12 zeroes. This was the headline dollar figure which was agreed at the London G20 summit last week in an attempt to tackle the global economic crisis.

It’s kind of hard to wrap your mind around such an astronomical figure which the BBC has also picked up on. I tweeted a few things I’d either found or fathomed about this at the time but in case you missed them, or aren’t following me yet, I’ve gathered them together in one place.

XKCD Comic 558

From XKCD