Latest Publications

Google Down! World Stops!

Well, it’s been going on for about an hour now. Google Mail appears to be having problems. The logon page is slow, logging in times out. Active sessions are broken.

I’ll mark this day in my calendar.

This has also affected Google Apps mail systems, including the educational packages that I’ve set some clients up with.

Will we ever recover? Will the world care? What impact will this have on the global economy?

Only time will tell.

CodeIgniter’s Form Helper doesn’t respect POST arrays

I’ve been working on my first ‘proper’ CodeIgniter project this week. It’s been quite gruelling, as there are some moments where I have definitely sped up my production. But it’s constantly getting hampered by the learning curve. It may be slight, but is frustrating when I hit a wall.

One issue that just cam up is that I want to send multi-dimensional post data to the set_value function in the Form Helper. As you’re passing a string, the array is completely disregarded, and you’re left with nothing.

I’ve created an extension to the helper to temporarily get around the problem until I can look at it and fix it properly:

MY_form_helper.php

<?php
if ( ! function_exists('set_value_arr'))
{
	function set_value_arr($field = '', $id = '0', $default = '')
	{
		if (FALSE === ($OBJ =& _get_validation_object()))
		{
			if ( ! isset($_POST[$field][$id]))
			{
				return $default;
			}

			return form_prep($_POST[$field][$id]);
		}

		return form_prep($OBJ->set_value($field, $default));
	}
}

?>

This sets a second parameter as the array index. This way, you should be able to access form elements sent into the POST array as arrays themselves.

PHP Toggle Variable

A neat trick I use in PHP is a toggle variable, usually when I’m creating tables and want to alternate the styles.

To use a toggle variable:

#Create the variable
$toggle=true;
#Switch it
$toggle=(!$toggle);

Simple!

TrueCrypt Autorun Script for USB

You can easily create an Autorun file on a USB pen drive to mount and dismount the encrypted file systems. This is very useful for carry portable TrueCrypt USB drives.

The only downside is that using TrueCrypt on the move means that you need administrator rights to access the disk.

Once you plug in the USB stick, you should see the typical Windows menu pop up. You can also right-click on the drive icon to mount, dismount and run the truecrypt application.

AUTORUN.INF

[autorun]
label=MyData
icon=truecrypt.exe
action=Mount TrueCrypt Volume
open=truecrypt /v MyData.tc /li /q /a /m rm /e
shell=mounttc
shell\mounttc=&amp;Mount
shell\mounttc\command=truecrypt /v MyData.tc /li /q /a /m rm /e
shell=dismounttc
shell\dismounttc=Dismount
shell\dismounttc\command=truecrypt /di /q
shell=runtc
shell\runtc=Run TrueCrypt
shell\runtc\command=truecrypt

Disney Celebrate my Birthday!

Finally, I have the recognition I so dearly deserve…

Access VirtualBox SSH and Web Server

One of the thing that differs VirtualBox from Microsoft’s Virtual PC is that VB puts guest on a subnet of the computer that you are working on. This means that it cannot be directly accessed from other computers on your network.

To enable access, you need to configure your computer to allow ports to be forwarded to the guest. Thankfully, this is quite straightforward with the VBoxManage tool, and Allister Sanchez covers it well here: Additions and SSH Access to a VirtualBox Guest.
I’m assuming that your Vitual Machine is called MyVBoxSystem. Replace this with the name of your VM.

To enable SSH:

On the host computer, run the following commands:

VBoxManage setextradata MyVBoxSystem "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 22
VBoxManage setextradataMyVBoxSystem"VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradataMyVBoxSystem"VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP

This is essentially telling VirtualBox to map any access on port 22 (the host port) to 22 on the guest. On a Windows system, this is fine as you are unlikely to be running an ssh server. If you are though, just change the HostPort parameter to a port that you know is free.

To enable HTTP:

VBoxManage setextradataMyVBoxSystem"VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" 80
VBoxManage setextradataMyVBoxSystem"VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" 80
VBoxManage setextradataMyVBoxSystem"VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" TCP

Once again, we’re passing TCP ports forward. If you already have a web server installed such as Apache or IIS, then you will probably need to change the HostPort to something like 8080.

Make sure that your VM isn’t running when you run these commands. To check that the settings are saved, you can run the following command:

VBoxManage getextradata MyVBoxSystem enumerate

Alternatively, open up the VM .xml file which is found in .VirtualBox/Machines/MyVBoxSystem/MyVBoxSystem.xml. The settings are found in the ExtraData node:

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8080"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="222"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/>