FIXED: Zen Cart Broken when upgraded from php 5.2 to 5.3

Fixing a very broken Zen Cart when upgrading php to 5.3

Finally solved a problem that had been nagging on a site today, we found that a zen cart e commerce site was returning the white screen of death – it turned out to be the server having been upgraded to php 5.3 from 5.2.

Having searched the internet for people with similar issues, we found a few solutions that when combined together worked perfectly for us. I’m not a massive fan of zen cart or such tecchy systems, so I’m not the one to ask if you need further information from here. I’ll just show you the files I changed that made the site work again.. so PLEASE make sure you back up ALL your files before you get started, and I can’t b responsible for your site not working.

I was getting log files returning issues like this (amongst others!)
PHP Deprecated: Function set_magic_quotes_runtime() is deprecated

1. Find: “set_magic_quotes_runtime” and prefix with an ‘@’ in application_top.php
Found in: application_top.php and /admin/includes/application_top.php

2. Find “ereg(‘whatever’, $whatever)” and replace it with “preg_match(‘/whatever/’, $whatever)” don’t forget that there are added forward slashes in there, look at the code carefully.
Found in: includes/classes/db/mysql/query_factory.php
Example: “ereg(‘^[0-9]‘, $key)” should be replaced by “preg_match(‘/^[0-9]/’, $key)”

3. Find “date_diff” and replace it with something like zen_date_diff
Found in:
admin/orders.php
admin/includes/header.php
admin/includes/modules/orders_download.php
admin/includes/functions/general.php
includes/modules/payment/paypal/paypal_functions.php
includes/functions/functions_general.php

That’s all that I needed to get it working – so good luck if you try it.. let me know if it works for you.
I’ve got a list of the original links etc, so let me know if you need them. This link was the most helpful.

WordPress: Is your is_front_page() not working in your side bar?

If you’re modifying your sidebar in the wordpress sidebar and can’t get your is_front_page() or is_home() working… try adding a reset query just before. Worked for me.

IE I was adding a advert that would only show on the homepage of the wordpress blog, rather than throughout the entire website this should work fine. [Use the code at your own risk etc etc]

How to move time machine to a bigger hard drive

Ever needed to move your time machine to a new and bigger hard drive – IE migrate your data? This is something I’ve been doing over the last day as my 1TB external drive is now full, so I bought a brand new 2TB drive (Western Digital 2TB) and got it sorted.

This is what I did: (Use at your own risk)
1. Turn off Time machine
2. Launch Disk Utility – located here: /applications/utilities/
3. Select drive from list of disks (Chose the disk (will have the simpler name), not the volume)
4. Format with GUID Partition Table – WARNING: Formatting the hard drive will erase any data on the drive.
5. Once formatted it’ll mount on your desktop
6. Right click newly mounted drive on desktop, and make sure ‘Ignore ownership on this volume’ isn’t checked.
7. Copy your old time machine backup (Backups.backupdb folder) from your old drive to your new drive
8. Once complete, open timemachine and select disk – select your new drive and click the use for backup button.
9. Time machine will start, verify and start backing up again – just double check it’s all ok – it should be.
10. Don’t delete your old drive until you have to – extra redundancy is always a good thing!

For a more detailed walkthough please read this article.

Wordtracker Strategizer – Investigating your keyword market share.

One thing I do really like about Wordtracker Strategizer is the ability see the size of a target niche, and compare that with the number of visitors that you currently get for a specific search term, allowing you to judge the right niches to invest the most amount of time in. Clever.

So for instance, on a client site I found for a two word ‘keyword / key phrase’ the site was sitting a nice number one position in Google, and taking 23% of the entire market share for that specific keyword. Interesting stuff, relates back to an article I was reading a few weeks back highlighting that position one should get you around 35% of all clicks from page one… so running at 23% isn’t too bad. It show there is plenty more scope for that keyword too.

Interesting how you can interpret those stats.

On one hand you could say you’ve got 23%, so let’s explore that keyword niche a little more and see what other low hanging fruit we can grab on the way – before thinking about targeting new keywords,

… but then you cold argue the other way and target something new entirely.

Personally I’m one for investigating that niche further and seeing what other variations there are to be had…

Automatic backup of you WordPress database – A decent plugin

I’ve been using the WP-DBManager plugin for over a year now, and it has reliably sent a copy of my database to me each morning at 8am – straight to my inbox. When you look after a million WordPress sites (I think I look after about 15-20 at the moment) this plugin is a surefire lifesaver. Don’t forget you still need to backup you files on your server, and don’t forget to backup your uploads folder… some people always forget this one!

Anyway – a worthwhile install, and certainly adds to a bit of piece of mind in the fast moving world of WordPress!

http://wordpress.org/extend/plugins/wp-dbmanager/

Good free URL redirection plugin for WordPress

If like me you have some sites that have a million links to sites, people, places and products you need to me able to manage them well. I stumbled across a redirection plugin for WordPress that seems to do the job pretty well. I’ve used this plugin for the last year or so on a couple of sites and has been super helpful. IMO the best use is for links that might change over time, you can update the target URL whenever you like and it won’t change your hard coded links in your website. So it means you can easily target broken links in the future, and you only have to change it in one place rather than hundreds. you just add a variable after go/yourquicklink and it’ll send it on from there. Very clever. Can also be used to tidy up affiliate links heading out your site, a much neater and better looking link, without any of the problems that are usually associated.

Have a look here at the (Free) GoCodes Plugin

Remove the default ‘category’ prefix from your wordpress URL

On new WordPress installs, I’ve used the plugin ‘Top Level Categories’ more than a few times, and can certainly recommend it. Just be aware when fiddling with your categories that sometimes it creates weird structures if you set up the individual categories first – the last time I used it I installed the plugin first, then assigned each post a new category. This seemed to solve the problem. I would suggest using the /%category%/%postname%/ permalink structure, and twinned with an SEO plugin controller you’ll have pretty good control over your URL and site structure… best to get it as soon as possible before you make too many pages!

Top Level Categories

Removes the prefix from the URL for a category. For instance, if your old category link was /category/catname it will now be /catname

Zen Cart – Change the template design on the home page only

Here’s a little one I found that might simplify things for you. I wanted to override the homepage template on the index page of a zen cart powered website, basically so I could show a big ad type image on the homepage under the navigation, so that it would appear on teh homepage only, like a big call to action / visual impact to start the visitors journey off. I needed it to load in the top section of the code, rather than the individual content pages so I needed to make the changes in the tpl_main_page.php main page template file.(tpl_main_page.php in your /yourtheme/common/ folder)

I duplicated the header file and made my template adjustments, and then using a bit of php told the site that when it loads, check the pagename – and if the pagename is ‘homepage’ then load the modified headerfile (tpl_header_home.php) – and if it’s anything other than homepage, just load the original.

Anyway, after a bit of fiddling around I found this to work pretty well.

<?php /* ----- prepares and displays header output ----- */

  if ($this_is_home_page) {
    require($template->get_template_dir('tpl_header_home.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header_home.php');
  }
  else
  { require($template->get_template_dir('tpl_header.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_header.php');}

?>