23/12/2014 - Two more sleeps to Christmas

As we rapidly approach Christmas yet again ... two more sleeps, as my son used to measure time when he was a toddler ... I thought I would take some time to reflect back on the year and the way my website has developed.

The year started badly, as my ISP (Plusnet) outsourced its support of CGI websites (PHP and MySQL). This broke my site pretty badly, and it stayed broken for a good few months. I could set up static HTML easily enough, but I had a significant amount of effort invested in a more dynamic presence than that.

Plusnet had won awards for being a good ISP, and on balance, they have been pretty good, but they flatly refused to support anything that went beyond HTML programming. They do, however, provide a pretty good user forum, and it is through that I eventually tracked down one of their technical gurus who helped get me back online.. Bob Pullen is his name and as far as I am concerned, he is a star. His reaction to my problem was 'We broke your working site, and so it is up to us to get it working again'. Raise a call with the support desk, and if they take the call, they pretty quickly close it again, stating this is outside their remit. Some advanced users have suggested that this is the thin end of the wedge, and soon PlusNet may stop free website hosting altogether. Plusnet host my domain name (origamimark.co.uk), and Bob got that working so that it could fire off index.php instead of index.html. He also got connectivity to my data in the database working, and that was all I needed to bootstrap the rest of the site into life. I would never in a million years have guessed the username I was supposed to use to access my php or database ! And what on earth was I thinking when I originally wrote this code ?

Since then, I have been adding the features I want, as well as experimenting with the site in various ways.

Main Features

Look and feel are now under the control of Cascading Style Sheets (CSS), so I can bugger it up by changing one file.

I can now turn the website on and off from any browser anywhere in the world with a single command.

The main page now displays a digital clock at the top of the screen, along with a random 'quote of the day'.

For 'quote of the day', I now have some code that can bulk-load quotes from a .txt file, and have split the quotes and the quoter attributes into separate tables to save space, as many of the quotes can be attributed to a single source.

For some browsers that support tabs, (for example Internet Expoder and Firefox, but not Chrome apparently) I display the local time in the browser tab.

I have a development environment, which means I do not have to change the live stite, risking breaking it.

I can now set the page header title from within the database, and can tempoarily override this on the command line.

I can turn snow on and off via settings in the database. At the moment it starts falling at the beginning of December each year (unlike real life, for me anyway) and continues for 40 days into the future to cover the Christmas and New Year period.

It is now possible to create simple pages without writing any PHP code, with the advent of the content table and content.php.

If I am logged into the backend maintenance system on the same computer as I am looking at the main site, the main site will display an indicator that this is the case, and also expose certain other features which are not ready for public consumption yet, such as the calendar.

I have ramped up security so that for pages that can change the database, the contents are secured.

I have ramped up activity logging, so that it will calculate time logged in, when I log out, and record this in the database. It also supports other activity events, such as failed login attempts, attempts to run secured code without successfully identifying the user, and failed Feedback attempts.

I have added some security features such as Captcha codes on the Feedback page and Login page, and a logging feature so I know if I am being explored by hackers. This has shown that a Chinese shoe manufacturer has tried (and failed) to send me email about their products from time to time.

Hover over any link and it will automatically stand out.


Feedback is always welcome, but previously I was relying on HTML support for this, which assumes the user has an email client installed, which these days except in a corporate setting is rarely the case. The website now uses server-side email to send feedback to me, and records in the activity table if someone has sent me feedback.


I have reworked photo album support so that it no longer uses FTP to navigate around my file system. Plusnet kindly disabled key functionality that I relied on for 'security reasons'. Suffice it to say that my photos code was buggered. I did a bit of research and found a similar capability built into PHP, and started using that instead.

I have split the photos into categories of albums, which makes them a bit easier to navigate, but the main effort went into writing some code to make creation of the albums much easier. The code allows me to create new albums, and then trawl up and down the file system, selecting pictures to include. The code shows me a thumbnail of any pictures it finds, and even tells me if the picture is already in the album I am currently working on. This makes adding content whilst avoiding duplicates much simpler. With each photo, I like to include some text to explain the image. With bulk loading of photos into albums, this was very tedious to do, so I added a filter I could turn on and off. This setting persists until I change it, making the task much less onerous.


The main purpose of the site is to make it known to the world that I do Origami, and I have started adding new content on the 'Origami' page and in the photo albums to support this. I was once criticised that Origami was not the main theme of the site, and was not the first page displayed. I changed the site so that Origami is now up front and centre, but come on, guys - there is more to life than paper folding.

New Sections

I have added some new sections to the site including an Electronics page, a Calendar, a Blog, and a German page.

Not much in the Electronics section yet, but this may grow when I get time to do more in this fascinating field.

The Calendar started as a stand-alone exercise in using the PHP date functionality. You can see how far I got with this in the PHP section, where there is an example. But then I got to thinking ... why not store events in the database, and display them via the calendar, and the latest incarnation, which is only visible when signed in, can do loads of stuff ... store events, including fixed events like Bank Holidays, birthdays that occur on the same date each year, look ahead a variable number of days, and list events that fall into that window, create repeating events like when I play Go each Tuesday lunch-time, and keep track of my holidays for me.

This Blog page ... how useful is that ? I was not a fan of Blog posts until recently, but it is a good place to post personal observations which others may find interesting. THe pages that make up this feature will flag up Blogs entered in the last 30 days. This can be adjusted via the database.

The German page came about because I subscribe to Private Eye, who run a feature where they capture single German words that describe a particular human condition. AS I get more issues of the magazine, I will be adding to this list. I have a German friend at work who appreciates this.

Behind the Scenes

Behind the scenes I have added a SQL Processor that allows me to enter any arbitrary SQL, and execute it. This means I can create new tables and alter existing ones without having invoke the ISP's rather clunky interface to the database. It's a bit like a simplified Oracle SQL*Plus. I can even save commands that worked for later use, and there is a link to the MySQL reference manual if I need help with the synatx of particular commands. I have added a 'pseudo command' that will tell me how much space I have left in the database.

Most of the tables in the database rely on a unique auto_incremented primary key, so when yopu add a new record, it gets a new key one more than the current maximum. I use this key to sort the table's contents, and sometimes it is useful (though probably contrary to the relational model) to insert a row bteween two existing ones to get the data into the right sequence. To enable this, I built an 'explode' function, which rebuilds the table in question with keys incremented by ten instead of one. Care has to be taken with tables whose primary key is the foreign key of another table (sych as the photos and albums tables, and I have functionality to warn me of such a situation and prevent it happening.

I have written some general purpose code that can allow insert, update, delete and cloning of data in any table in the schema. The cloning feature has proved to be particularly helpful when needing a copy of an existing record where the primary key only is unique.

I have built into the table processing code the ability to search for a keyword in the table, highlighting matches, along with the ability to sort the results in ascending or descnding order of any column.

As mentioned above, the bulk loading of quotes into the database, and splitting of quote and quoter save me a good deal of time. I now try and include the date of birth and death of quoters where I can find them out, and spent a good deal of time cleansing the data in my original quotes table. I now have 1556 quotes attributable to 298 quoters.

The Future

I suppose this effort will never end, as I think of new things I would like.

I think the code I have written so far could do with a bit of consolidation, but whenever I attempt this I end up breaking the site in pretty fundamental ways. The testing capability will help here, but I need to be less ambitious and more incremental in my endeavours.

I would like to explore HTML5 more, as I have seen features on other sites which I would like to include.

... and of course, if you have any ideas, please let me know.

This site © 2017 Mark Plant