Friday, December 11th 2009

UKFast – Installing cPanel on fresh CentOS x_64
posted @ 10:28 am in [ Apache -Hosting -osCommerce -PHP -Technology -Web2.0 ]

We’re just starting to move one of our clients Merc ( onto a new webserver as their site has been doing so well that it need a faster, more optimised server to cope with the traffic and went with a new Cloud CentOS x_64 server from UK Fast for a very reasonable Ā£70.00 odd per month.

The server seems lightening quick which is great, but didn’t come with a nice install of Plesk or cPanel or similar so we decided to install cPanel.

It’s actually really easy to do – just follow this really helpful guide here from Network Data Center in the US and you are up and running with a full blown cPanel in a couple of hours.

Job done! šŸ™‚


Tuesday, October 20th 2009

Plesk error 500 and [apc-error] apc_mmap: mmap failed: No space left on device
posted @ 10:55 am in [ Media Temple -PHP -Technology -Web Design ]

Upgrade Plesk 8.0.3 to Plesk 9.0.x on a Media Temple DV server and it dies šŸ™

Error 500, nothing in the log files, no where to turn.

Anyways… after a chunk of digging around the problem is to do with running out of memory on the container that Mediatemple allocate for the DV server.

So… you can fix it by lowering the PHP memory requirements in the Plesk 9 PHP.ini file

cd /usr/local/psa/admin/conf/
vi php.ini

Then the setting you want to change is apc.shm_size from the default setting of 40 (Mb?) to 10

apc.shm_size = 10

And then check Plesk to see if it is working

/usr/bin/sw-engine-cgi -c /usr/local/psa/admin/conf/php.ini -d auto_prepend_file=auth.php3 -u psaadm

..and with a bit of luck you should be away! More details in a good discussion on the Plesk forums here

Friday, July 10th 2009

Reading Raw POST Data in PHP
posted @ 3:46 am in [ Apache -PHP -Web Design ]

We’ve been having fun trying to proxy array inputs such as radio fields in PHP, and it turns out that their is a great way to access the POST fields data that PHP receives _before_ PHP does any manipulations to it.

What this means is that if you need to pass data from one server to another, totally unaltered, then using the file_get_contents("php://input"); is the answer.

Here’s the original post I was pointed to about this by the very helpful team on the PHP/Curl Mailing List [curl-and-php at]

“Sometimes, albeit rarely, I’ve needed to get at the raw POST data in a PHP file. You can of course get the POST data using $_POST, however, this is after PHP has processed it (i.e. magic quotes may have been applied, thus escaping the data). You can access the raw POST information using the following:

$data = file_get_contents("php://input");

You can access the php://input wrapper as if it were a file, and use the Filesystem functions. More information on the PHP wrappers can be found in the PHP Manual.”


Tuesday, June 30th 2009

Dots not valid characters in PHP POST variables, and replaced with underbars
posted @ 8:01 am in [ Fixing Things -PHP -Web Design ]

So here I am, throwing my hands up and shouting at the screen, as as far as I can tell PHP is converting POST variables names from Market Live like




anyway… it is !!!!!

Aparrantly .s are not valid in variables names in PHP so it converts them to _s automatically!

Wow ā€“ how annoying is that ā€“ and just thought Iā€™d share the pain with everyone else…..

Tuesday, January 27th 2009

HSBC XML API for OSCommerce based systems
posted @ 2:24 pm in [ osCommerce -PHP -Technology -Web Design ]

We recently developed an XML API for connecting to the HSBC bank in the UK for OSCommerce based systems which is free for everyone to download, update and even improve. I forgot to post a link to it so here it is and it should help everyone who wants to use them get up to speed pretty quickly


Support Forum:

Thursday, August 14th 2008

HSBC Module for OSCommerce with XML API
posted @ 9:11 am in [ osCommerce -PHP -Technology -Web Design ]

I’ve been meaning to write about this one for a while since we did it, but we’ve written a fully XML API compliant OSCOmmerce payment module for the HSBC bank in the UK.

It is based quite heavily around the Protx Direct XML module which uses very similar techniques to POST data to the payment servers in XML, and then to decode the XML response in PHP for the OSCommerce system.

I’d like to improve the features when we have more time and allow refunding and voiding _directly_ from the OSCommerce administrator interface, rather than as current where you have to login the the HSBC interface separately to do this, but that’s all about time which is a precious commodity at the moment šŸ™‚

The module can be downloaded from here and the support forum is here

Wednesday, March 26th 2008

Media Temple and PHP5 cooking tips…
posted @ 12:05 pm in [ Apache -PHP -Technology -Web Design ]

I know I know, nobody really wants to run PHP5 on their Media Temple Dedicated Server when PHP4 works just fine – well actually yes we did as one of our team is becoming a dab hand at writing PHP5 dependant classes and then having to find servers to run them.

Media Temple provide their own link on how to upgrade the system ( however this was having none of it for us so here’s a quick heads-up on how to do it our way.

1. Install YUM

There’s a few great articles on how to do this on the web (Google for CentOS and YUM) but the trick is to remember when you have it installed is that the packages missing from the central CentOS distribution can still be accessed with YUM you just need to use CentOSPlus.

yum --enablerepo=centosplus install <your package name>

2. Roll your own PHP 5

Download the latest PHP tar ball, unpack and start configuring. Here’s our config file which will help you build in all the dependencies that Media Temple has (zend, mysql, zlib etc.) – you will need to use YUM to get various packages and libraries, and some have to be located on the source websites, but here’s a hints to help.

– installing mcrypt


 rpmbuild -ta libmcrypt-2.5.7.tar.gz

 rpm -ivh /usr/src/redhat/RPMS/i386/libmcrypt-2.5.7-1.i386.rpm /usr/src/redhat/RPMS/i386/libmcrypt-devel-2.5.7-1.i386.rpm

 yum --enablerepo=centosplus install php-mcrypt

– installing mhash


 bunzip2 mhash-0.9.9.tar.bz2

 tar xvf mhash-0.9.9.tar

 cd mhash-0.9.9


 make install

– configuring php5
























































Restart your PSA system (

/usr/local/psa/admin/sbin/websrvmng -a -v

) and you should be cooking on a lovely PHP 5 install with everything else still as it was.

Wednesday, March 12th 2008

Recursive ftp with wget
posted @ 10:49 am in [ Apache -PHP -Technology -Web Design ]

Sometimes when the servers won’t give you ssh access, and you want to copy files from one machine where you don’t have ssh access to one that does, recursive ftp with wget is the answer

wget -r ftp://username:[email protected]/directory

For example to get all the files from my server at with username fish and password cakes, in my homedirectory I would use

wget -r ftp://fish:[email protected]/~/*

Prolem solved…

Thursday, January 24th 2008

Receiving and Decoding MMS messages using Apache
posted @ 8:02 am in [ Apache -Kannel -MBuni -MMS -Mobile -PHP ]

A quick follow onto the post below of how to use Apache to serve MMS messages, one other interesting thing you can do with Apache is use it to receive MMS messages from a phone.

Basically, this just requires a little bit of lateral thinking, and some clever PHP and then you can see exactly which headers a phone uses to create the MMS messages it sends itself – and in our case use this to work out which fields we should be including in our MMS messages.

Step 1: Configure your phone to send MMS messages to your own Apache server, not the default operator MMSC.

This really depends on what phone you have, but if you dig around in the MMS settings within the phone, you will eventually find a menu option labelled MMS Server Name or similar. On a Motorola Razor V3 for example this is in Messages -> (option menu) -> Message Setup -> Change -> Server Info ->(option menu) -> Edit -> Server Name

Change this to be your own Apache server, for example in our case, or an IP address if you have one may be even better if your operator doesn’t support DNS look-ups.

Step 2: Create your MMS on the phone

Step 3: Add you MMS receiving code to your Apache server

There’s lots of good packages out there to do this, including mBlogging software such as b2evolution and Peffisaur however for our decoding we used a nice piece of PHP coding from the following article on creating an MMSC.

Step 4: Send your message from your phone to your server

Step 5: Decode your MMS message

Now you have the MMS message as a binary file, but you really want something handy to decode it for you, so this is where a handy PHP class called MMS Decoder comes in handy. By default this reads from an HTTP stream, but with the following few modifications you can make it read from files instead.

$filename = "test.mms";

if (is_readable($filename)) {
	$handle = fopen($filename, "r");
	$mmsdata = fread($handle, filesize($filename));

// parse MMS
$mms = new MMSDecoder($mmsdata);

// The MMS is parsed, so let's get the mms data from the class by the print_r() function,echo(print_r($mms, true));


Voila! All the headers from your phone built MMS ready for you to emulate in your own messages to ensure the phone receives them.

Thursday, January 24th 2008

Serving MMS messages with Apache
posted @ 7:29 am in [ Apache -Kannel -MBuni -MMS -Mobile -PHP ]

Now you would have thought after the number of years I’ve been playing around with MMS messages, using libraries like the Nokia MMS Java library to build them and servers like Kannel (SMS) and MBuni (MMS) to serve them, that we wouldn’t have any problems trying to serve MMS content ourselves using SMS binary push and .MMS encoded files.

Well, basically we did – and it all comes down to one thing – phones needing be specifically told that .MMS messages have a certain MIME type.

Some phones, the Motorola V3 Razor for example, automatically assume that all MMS messages are going to be an acceptable type, no matter what MIME type you serve them as. Therefore using a standard Apache server, a binary created MMS file (try the Nokia MMS Java library for Java, and MMSLib for PHP to build the messages) and a binary SMS push (either made yourself or using HTTP API’s such as Clickatell’s) these phones recieve the messages just fine.

However, a lot of other phones (notably Blackberry’s and Sony Ericsson’s) require specific instructions to treat the .mms file as type application/vnd.wap.mms-message

Therefore for these phones, add into the directory where the .mms files are stored the following .htaccess file and Apache will start serving the content in exactly the right way.

AddType application/vnd.wap.mms-message mms

Job done – and I bet if you’re reading because this is what you’re trying to do, we hopefully just saved you hours of going mad!