Monthly Archive for June, 2009

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.