Update to GimpFM

Written by

I have just updated one of the many sites I help maintain, GimpFM, to bring it into a more modern web standard.

For those interested, I have used bootstrap as the base framework. I typically use Zurb’s Foundation but after a bit of hype I thought I’d give bootstrap a go.

Overall I’m pleased with the outcome of the site and bootstrap has potential and is very well featured but foundation seems faster and easier to make the site responsive during development.

Anyway, that’s all for now.

X-Cart Cleanup and XCache

Written by

So my work’s site has X-Cache setup and so any changes made to the site is usually cached in two places, X-Cache and with X-Carts Smarty.

So to make things simple, I’ve integrated the cleanup of the cache’s into the default x-cart cleanup page.

So just edit cleanup.php to include these lines:


// Remove XCache cache if it's installed.
if (function_exists("xcache_clear_cache")) {
	echo "XCache ";
	while ( $i < xcache_count(0)) {
		@xcache_clear_cache(0, $i);
		echo "php#".$i.", ";
	while ( $i < xcache_count(1)) {
		@xcache_clear_cache(1, $i);#
		echo "var#".$i.", ";
	echo " Removed.";

X-Cart Product Images with a Static Cookieless Domain

Written by

So today, I was working on an older x-cart site after implementing some of the previous CDN / static domain hacks, I looked at the product images which were being displayed via the main domain. Because CleanURLs were enabled, I couldn’t just edit the thumbnail template file but rather edit the CleanURL creator function. So here’s my edits for X-Cart 4.3 and xcart 4.5.

Edit /func/func.files.php

approx. line 254 (xcart 4.3) or line 374 (xcart 4.5)

return $current_location.str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir))));


if ($_SERVER['HTTPS'] != 'on') {
    return "http://cdn.domain.tld".str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir))));
} else {
    return $current_location.str_replace(DIRECTORY_SEPARATOR, "/", substr($image_path, strlen(preg_replace("/".preg_quote(DIRECTORY_SEPARATOR, "/")."$/S", "", $xcart_dir))));

The issue that needs to be then addressed is how to balance the previous edits with this one over x number of domains so the file requests can be parallel and not blocking, after looking, putting javascripts and css files on one domain, catalogue images on anotherand possibly any remaining requests manually written in via a third? in this scenario, {$skin}/{$alt_skinDir} and {$images}/{$alt_imagesDir} (being remembered from memory) could be over two domains and then the catalogue images on the third.

Ideally you want to even out the requests (no less than 5 to 10 requests) over the domains with upto 3 sub-domains maximum to reduce the number of DNS lookups but depending on what’s being serviced and checkign with online tools will help test which is the best layout.

PHP: Find text between two strings without regex

Written by

So today, my friend asked me for some regex to get text between two given strings; I can’t do regex so I came up with a simple line of code and then turned it into a function so it can be re-used.

I thought I’d pop the code here for others too.

 * @title:        Lazy Regex
 * @descr:        Find any text between two strings.
 * @author:        Adam Boutcher
 * @email:        admin@aboutcher.co.uk
 * @web:        www.aboutcher.co.uk
 * @usage:
 *                string lazy_regex (string $haystack, string $needle_first, string $needle_last)
 * @Params:        
 *                $haystack - the text you which to search
 *                $needle_first - Find this text as the start of the pointer.
 *                $needle_first - Find this text as the end of the pointer.
 * @notes:        
 *                Returns false on failure, this maybe non-bool false, use === to test (see PHP: substr).
 *                Returns the start and end needles including the text beween on success.

function lazy_regex($haystack, $needle_first, $needle_last) {
    if ((empty($haystack))||(empty($needle_first))||(empty($needle_last))) { return false; }
    return substr($haystack, stripos($haystack, $needle_first), ((stripos($haystack, $needle_last)+strlen($needle_last))-stripos($haystack, $needle_first)));

A weekend of Linux fiddling…

Written by

So this weekend I’ve been fiddling getting Linux as my main OS on my laptop again; this post is just some odds and ends I’ve done.

Conky BOFH Excuses

I wanted some BOFH style excuses being displayed on my conky, so I took an excuses list and then popped it on my webserver and it outputs a single line at random. The conky script reloads once every 6 hours.

${execi 21600 curl http://bofh.aboutcher.co.uk | fold -w35 }


Fix Legend of Grimrock Error

I was getting this error with Legend of Grimrock on my fresh install on debian:


so I took to the internet and had a search about, turns out I’m missing a dependency that the installer doesn’t check for but there was a helpful post on their forums and I installed it, if you have the same issue then install this:

apt-get install libtxc-dxtn-s2tc0
yum install libtxc_dxtn


Debian Wheezy x64 and WINE…

So as you’ve seen my preferred distro is Debian and I have previously written a post on installing a newer version of WINE that what is in the Debian repo’s for better computability. Today I followed my own instructions and to my surprise it didn’t work, mainly because the guide was aimed at squeeze and there are some big differences in the way Debian implements multi-arch and wine depends on some 32bit libs.

So here’s my attempt at a newer guide.

  1. Install libpng12-0 and libpng12-dev
  2. Download Wine-Gecko from the Mepis Repo for Mepis 8.0
  3. Download Wine from the Mepis Repo for Mepis 8.0
  4. Install Wine-Gecko
  5. For x64 download ia32libs from Debian Repo for Squeeze
  6. Install ia32libs
  7. Install Wine

Now that should all work, Wheezy’s method of installing ia32libs it to include i386 in the architecture list in dpkg which results in better compatibility but also a larger system which isn’t always wanted.


Firefox and Debian

Linux Mint also provides a small repo for Debian which includes newer or non-free software that isn’t in the Debian repo. From here you can download and install a Debian version of Firefox instead of using Iceweasel which isn’t always upto date.

  1. Download firefox-l10n-en-gb (or your lanaguage).
  2. Download firefox
  3. Install firefox-l10n-en-gb (or your lanaguage).
  4. Install firefox

You should now have firefox setup correctly even in update-alternatives and gnome etc.


Debian and MATE Desktop

This one’s fairly simple but strangely not documented on their website. If you liked Gnome2 but not Gnome3 then presumably you don’t want to have to install all of Gnome3’s libs to run the ‘classic’ or fallback desktop. This is where MATE comes in which is a fork of the Gnome2 code with some updates and changes. To install it just do the following:

echo "deb http://packages.mate-desktop.org/repo/debian wheezy main" >> /etc/apt/sources.list
apt-get update
apt-get install mate-archive-keyring
apt-get update
apt-get install mate-core mate-desktop-environment

and there you go, you should now have mate installed.


That’s all for now but I do have more stuff for another day.