August 29, 2023
by Matt Raines

Looking back to 2005

« 2003 | 2004 | 2005 | 2006 | 2007 »

Matt working on Lib Dem Image in 2005

After months of hard work we launched our first e-commerce site for Lib Dem Image, official party supplier of branded campaign materials. They’re still with us to this day although it’s now WooCommerce on WordPress. At the time of launch, open source e-commerce applications such as osCommerce did exist but were pretty basic, and I had experience developing bespoke e-commerce applications so building from scratch made sense.

Lib Dem image basket pageThe Alliance Party of Northern Ireland saw what we had achieved for the Lib Dems and chose us for their rebrand. They were lovely people to work with, especially David Ford who always came over to visit us at conference and later took time out of his busy schedule as Minister Of Justice to give the two of us a detailed and intriguing tour of the Parliament Buildings at Stormont in Belfast.

Prater Raines corporate website in 2005Tony Blair’s government returned after the general election with the smallest share of the vote of any majority government in history. The Lib Dems returned 62 seats thanks in part to opposition to the war in Iraq. We watched the count live and entered results into our website platform by hand, so all our Lib Dem sites would update as the results came in. It was our webserver’s busiest day to date with five times the typical number of unique visitors. Much fine-tuning of MySQL and Apache meant the sites continued to respond well throughout but by the end of the year it was clear we needed to move to more powerful servers and we began to look into colocation.

I passed my Zend and MySQL certification exams. We haven’t really kept this up to date as it became increasingly obvious to clients that we were capable coders and database engineers without needing the certifications, but I’ve always enjoyed taking tests so maybe it’s something we’ll get back to at some point. Brainbench provided free tests at the time which also kept me busy acquiring such useful certificates as Technical Writing, Telephone Etiquette, and Managing People (US).

Tools of the trade

Location, location, location

The year in tech

Sample code

<?

if (preg_match("#^[0-9a-zA-Z]+$#", $_POST["MerchantData"])) {
    session_id($_POST["MerchantData"]);
}

require_once("config/db.php");
require_once("config/include.php");

$sessionid = mysql_escape_string($_POST["MerchantData"]);
$saleid = preg_replace("#^LDI-([0-9]+)$#", "$1", $_POST["OrderId"]);
if (!is_numeric($saleid)) {
    $saleid = "NULL";
}

$sale = mysql_fetch_array(mysql_query("
    SELECT s.*,
           SUM(deliverycost * quantity) AS deliverycost,
           SUM(price * quantity) + SUM(deliverycost * quantity) AS amount,
           COUNT(*) AS numberofitems,
           UNIX_TIMESTAMP(stamp) AS unixstamp
    FROM sale AS s
    INNER JOIN purchase USING(saleid)
    WHERE sessionid = '$sessionid'
      AND s.saleid = $saleid
    GROUP BY s.saleid
"));
if ($sale === false) {
    $sale = array("status" => "invalid", "reason" => "transaction mismatch");
}

switch ($sale["status"]) {
    case "approved":
        $title = "Checkout Complete";
        $message = "Thank you for shopping with " . STORE_NAME . ". "
                   . "Your transaction completed successfully and you will shortly "
                   . "be receiving confirmation of your order by e-mail. "
                   . "You may print this page for your records if required.";
    break;
    case "cancelled":
        $title = "Transaction Cancelled";
        $message = "We are sorry that you decided not to complete your transaction "
                   . "with " . STORE_NAME . " on this occasion. "
                   . "If you are having problems ordering, please call us on " . PHONE_NUMBER . ". "
                   . "You have not been charged.";
    break;
    case "declined":
        $title = "Transaction Declined";
        $message = "Unfortunately our bank has declined this transaction. "
                   . "Please call us on " . PHONE_NUMBER . ", quoting the message below, "
                   . "if you require further assistance.";
    break;
    case "invalid":
        $title = "An Error Occurred";
        $message = "We're sorry, but we cannot continue processing your order. "
                   . "Please call us on " . PHONE_NUMBER . ", quoting the message below, "
                   . "if this problem persists.";
    break;
}

writeheader($title);
writebanner();
writetopmenu();
writecategorymenu();

?>
    <td id="contentcell">
        <div id="contentpadding">
            <table id="content">
                <tr>
                    <td>
                        <h2><?=$title?></h2>
                        <? if (TEST_MODE): ?>
                            <p>THIS SITE IS CURRENTLY UNDER DEVELOPMENT AND IS NOT YET OPERATIONAL.</p>
                            <p>YOU HAVE NOT BEEN CHARGED NOR WILL GOODS BE SHIPPED.</p>
                        <? endif; ?>
                        <p><?=$message?></p>
                        <? if ($sale["status"] == "declined" || $sale["status"] == "invalid"): ?>
                            <p><?=ucwords($sale["reason"])?></p>
                            <p>Your order reference is <?=sprintf("LDI-%08d", $sale["saleid"])?></p>
                        <? endif; ?>
                        <? if ($sale["status"] == "approved"): ?>
                            <table>
                                <tr>
                                    <th scope="row">Order Reference:</th>
                                    <td><?=sprintf("LDI-%08d", $sale["saleid"])?></td>
                                </tr>
                                <tr>
                                    <th scope="row">Order Placed At:</th>
                                    <td><?=date("g:ia \o\\n jS F Y", $sale["unixstamp"])?></td>
                                </tr>
                                <tr>
                                    <th scope="row">Number Of Items:</th>
                                    <td><?=$sale["numberofitems"]?></td>
                                </tr>
                                <tr>
                                    <th scope="row">Total Cost:</th>
                                    <td>&pound;<?=sprintf("%.2f", $sale["amount"])?></td>
                                </tr>
                            </table>
                        <? endif; ?>
                    </td>
                </tr>
            </table>
        </div>
    </td>
</tr>
<? writefooter(); ?>
</body>
</html>