Undercrank

Scripting

May 19, 2004

ALA's PHP Switcher revisited

Recently, the webzine A List Apart published an article by Chris Clark that demonstrated stylesheet switching using PHP.

The technique works all fine and dandy unless you're using a more recent installation that (sensibly) doesn't have register_globals set, whereupon nothing much happens at all.

Fortunately, a couple of easy modifications script using the predefined variables syntax now in use since PHP 4.1.0 will take care of this.

First up, the code in "STAGE ONE: Setting styles" for the switcher.php file should read:

<?php setcookie("sitestyle", $_GET["set"], time() + 31536000, "/", "yourdomain.com", 0); header("Location: $HTTP_REFERER"); ?>

Secondly, the code in "STAGE TWO: Detecting styles" should be:

<link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo isset($_COOKIE['sitestyle']) ? $_COOKIE['sitestyle'] : 'defaultstyle' ?>.css" />

And that should be just about it.

More of the same RSS

Yahoo! Web Services news over Atom

aka: "When you realise Yahoo! already serve their news over RSS..."

Yahoo! Web Services news over RSS

I've put together a small project that will create an dynamic RSS 2.0 feed based on the Yahoo! News Search hooks.

Despamming Shortstat (Part 2)

Further to my earlier post about Despamming Shortstat, I've made a small update to the code that has a few improvements on the original.

Importing CSV files to SQLite

"SQLite is different from most other SQL database engines in that its primary design goal is to be simple". Which isn't strictly true...

Trackbacks

Trackback URL for this entry is:

Post a comment

Remember personal info?