Tag Archives: upgrade

how to upgrade oscommerce-based scripts from php 5.2.x to php 5.3.x

More and more hosting companies are upgrading their servers to run php 5.3. For most carts, this will mean an error log file full of deprecated error messages – warnings that one day, the functions being used will be removed entirely and the script will break.

If you’re running an older version of your oscommerce-based cart software (eg Cre Loaded 6.4.1, Oscommerce 2.2 etc) you will find that your error log file will fill up with deprecated messages from a number of files still using old calls like ‘ereg’ and ‘ereg_replace.’

You could switch these error messages off if you can control the error_reporting configuration on the server you’re on, but there’s a chance that when php 5.4 is adopted by hosting companies (RC6 of this was released January 2012) many of these deprecated messages now will become broken scripts then.

Updating most of these old calls can be fairly easy – here is a reference table that will help:

ereg() = preg_match()
ereg_replace() = preg_replace()
eregi() = preg_match() with the 'i' modifier
eregi_replace() = preg_replace() with the 'i' modifier
split() = preg_split()
spliti() = preg_split() with the 'i' modifier

As an example – cre loaded 6.4.1a B2B file /includes/functions/general.php :

if (ereg('^[0-9]+$', $value)) {

would become

if (preg_match('/^[0-9]+$/', $value)) {

(note ereg becomes preg_match and the forward slashes (delimiters) are added in)

Other deprecated functions and directives are more involved and may in fact only be configurable by the hosting company if they don’t allow custom php.ini files. There are other examples in the code that can simply be removed to upgrade to php 5.3.x and will stop the deprecated message.

A popular old check in Cre Loaded is a 6.2 version check – this from /admin/includes/runtime/orders/RC_orders_boxesbottom.php:

if (defined('MODULE_ADDONS_RECOVERCARTS_STATUS') && MODULE_ADDONS_RECOVERCARTS_STATUS == 'True') {
  if (defined('PROJECT_VERSION') && ereg('6.2', PROJECT_VERSION)) {
    $rci = tep_admin_files_boxes(FILENAME_RECOVER_ABANDONED_CARTS, BOX_RECOVER_ABANDONED_CARTS, 'SSL','tdate=' . $tdate, '0');
  } else {
    $rci = tep_admin_files_boxes(FILENAME_RECOVER_ABANDONED_CARTS, BOX_RECOVER_ABANDONED_CARTS, 'SSL','tdate=' . $tdate, '2');
  }
}

In this case the ‘upgrade’ would be to remove the old version check (bypassing the need for the deprecated ereg check.)

Third-party modules may cause grief when your hosting company upgrades to php 5.3.
At the time of writing this, Magneticone’s modules that use Zend Optimizer for decoding will break as Zend hasn’t provided a backward compatible version of the ZO for scripts using php 5.2.x. Magneticone’s advice in this situation is to use the ioncube versions of the scripts only (as they haven’t upgraded their modules to use the standalone ZO php 5.3 version either.) Nuisance.

If you’re unsure about these changes, contact me for a quote to help you upgrade from php 5.2 to php 5.3

oscommerce – how to upgrade from v2.2 to v2.3.x

Oscommerce version 2.3 has finally been released, and the improvements over the tired old version 2.2 are good. The main advance is how it looks and handles – there aren’t many new features in the frontend. On the admin side, security improvements have been the focus, with a couple of new features added in.

screenshot of osCommerce version 2.3 frontend

  • Looks cleaner, loads faster.
  • Reviews system is tidied up.
  • Includes social bookmark links.
  • Version Tracker – easy to check if you’ve got the latest version.
  • Security improvements, additions
    Password protection of admin folder; timeout and restricted login attempts if incorrect login details used.
    Action Recorder – keeps a log of details of 3 different areas of the Store: Admin login attempts; Contact Us emails; and Tell A Friend emails.
    Folder Permissions checker – with recommendations of what permission settings should be for each folder.
    Various improvements to session and form handling, password encryption, url cleaning, htaccess implementations etc.

If you’re upgrading from an old oCommerce version 2.2 Store, the steps are simple:

  1. Download a copy of the Upgrade Guide from osCommerce
  2. Update your osCommerce v2.2 database by running the several groups of mySQL statements
    These include statements that change field lengths to existing tables, plus the installation of new tables for the Action Recorder, Directory Permissions checker and Password encryption.
  3. Install the latest osCommerce 2.3.x version as a new Store
    The download is available from the osCommerce Download page.

Before upgrading … please consider the template(s) and other modifications you are currently running. There is a chance they might break in a new osCommerce v2.3.x store.

cre loaded – how to upgrade from an earlier version

Upgrading means migrating your earlier version of Cre Loaded to a more recent version – eg 6.2.x (or 6.3.x) to 6.4.x – where the second and third numbers of the versions are different. Updating means migrating between minor versions – eg 6.4.x to 6.4.x – where the third number differs between the two versions. If you want help with updating, have a read of migrating from 6.4.0 to 6.4.1 here.

The following is an attempt to make the upgrade process a bit easier and is based on an upgrade from Creloaded 6.2 to 6.4.1a.

———————————————————————————————————————–

Before setting off with the Upgrade instructions below, if you currently use the Information infobox and want to upgrade your current 6.2 store’s template, perform the following steps on your existing store:

  1. Switch on Site Maintenance on your store
    Admin >> Configuration >> Site Maintenance >> edit True
  2. Set the Information infobox inactive
    Admin >> Design Controls >> Infobox Configure and set the Information Infobox inactive (red light)
  3. Check which template is your Default template
    Admin >> Design Controls >> Template Manager .. the one in bold is your currently active template.
    There are only two ‘stock’ templates supported in Creloaded 6.4.1 – original_ats and cre63_ats. Both use templates/default/boxes for infoboxes.
    Original_ats uses templates/content for tpl.php files; cre63_ats keeps its tpl.php files in templates/cre63_ats/content. Any other templates will have their own folder in /templates and might use their own /boxes and/or /content folders too.
  4. Keeping the point above in mind, make sure your template has a file called pages.tpl.php.
    If not, go to /templates/content and copy the pages.tpl.php file from there to /templates/your template/content.
  5. Download your /images and your edited /templates/your template/ folders to your computer

———————————————————————————————————————–

The Cre Loaded Upgrade process is described in Cre’s own Installation pdf but it’s a bit tangled up with the New Installation instructions.

You will need:

  1. The ‘upgrade zip’ containing catalog.zip and the Installation.pdf (the pdf referred to is dated March 15 2010)
  2. Access to your server and database manager – possibly through cPanel or your host’s own control panel, or a free (s)ftp programme like Filezilla
  3. 20-30 minutes

Once the above is together, proceed as follows:

  • Step One: Create a ‘new_store’ folder on your server
    Use the File Manager in cPanel or even Filezilla for this
  • Step Two: Create a ‘new_store’ database on your mysql server
    Use the MySQL Manager through your control panel – make sure to set Privileges for the User correctly too. Record the database name, username, user password and hostname (this may be ‘localhost’) for later use
  • Step Three: Open the Installation.pdf and go to page 18
    There are a couple of ways of getting the catalog.zip onto your server. One way is as Cre suggests, which involves unzipping all of the folders and files in the catalog.zip to your computer and uploading each via (s)ftp. I wouldn’t recommend this because – it becomes a 12MB upload when unzipped (instead of 6MB); there are over 3500 items to be uploaded and if your connection to the server fails at some point, something may be only partially uploaded and corrupted.

If you have a Plesk control panel you probably don’t have the option of extracting a .zip through its file manager, in which case you’d have to upload the extracted files and folders from your computer.

  • I’d recommend uploading just the catalog.zip (one file only) to your ‘new_store’ folder and extracting the files on the server. You can do this using Extract from the cPanel File Manager OR if you have command line access, cd to the directory where the catalog.zip is and ‘unzip catalog’ OR ask your host to do this simple process for you.
  • Step Four: Set Permissions on the unzipped folders and files
    There are several folders and files that require permission changes. Once again you can use your control panel or Filezilla (right click on the folder / file >> File Permissions …) to change Permissions.The Installation pdf lists most of the changes required on page 9. Here is the complete list:
    These Files and Folders to Read, Write, eXecute (777) for Owner/Group/Public
    
    /admin/include/configure.php
    /debug/shipwire_debug.txt
    /include/configure.php
    /includes/header_tags.php 
    /includes/languages/english/mainpage.php   
    /includes/languages/english/header_tags.php 
    (7)
    
    /admin/backups 
    /admin/images/graphs 
    /cache 
    /images 
    /images/banners 
    /images/logo 
    /images/events_images 
    /debug 
    /tmp 
    /temp 
    /library - if Pro or B2B 
    (10/11 if Pro or B2B)
    Note: /debug/shipwire_debug.txt is also required to have Read/Write/Execute by Owner/Group (777) permissions set.
  • Step Five: The Upgrade Screen
    Now turn to page 19 of the Installation pdf to continue with the upgrade instructions. Your screen will look like this:
    screenshot of upgrade screen from Cre Loaded 6.4.1 upgrade
    Just choose the ‘PCI Upgrade’ option here, whether your Store held credit card information or not. It doesn’t make any difference if you try to remove non-existent information.The next screen is a Pre-Install Check …. everything must be green to proceed. If you didn’t correct the Permissions in Step Four, you’ll be seeing red here.
    screenshot of cre loaded's pre-install check
    The next screen asks you to confirm the (absolute) pathway to your existing Cre Store that is being upgraded, as per page 20 of the Installation pdf. The follows a check and confirmation of this path (page 21.)
  • Step Six: Follow the Installation pdf through pages 21 – 28
    The rest of the Installation pdf will take you through through Database Settings and Upgrade, PCI Compliance, Summarize your Server Configuration and cover resetting Permissions, Cre Secure and your Payment Modules etc.
  • Step Seven: Template and Image folder upload
    Upload your old store’s /images and /template/your template folders that you downloaded prior to these six steps. Remember to set permissions for these too.

Other recommendations:

  • delete your /Upgrade folder from the server
  • check all permissions on files are set to 644 at most (configure files 444) and on folders to 755 (or 757, avoid 777)
  • protect your Admin folder
  • set up various htaccess protection methods for other folders and files too if possible.

cre loaded – how to update from version 6.4.0 to version 6.4.1

This process is best described as ‘updating’ and I’d only recommend doing this between minor versions in sequence – eg 6.3.1 -> 6.3.2, or 6.4.0 -> 6.4.1. If you’re going to jump from 6.3.x to 6.4.x I’d recommend reading up on how to upgrade between major versions.

‘Updating’ means:

  • your store’s current database gets updated by any changes in the update update patch for the database
  • you manually overwrite your old store’s files and folders using the folders/files from the update
  • you don’t have to create a new blank database or change permissions on folders/files

Sounds straight forward? Should be, but the 6.4.0 -> 6.4.1 update isn’t for some.
Here are the steps I used:

Step 1: make sure you download and extract the correct update to your computer (this is a Pro version update example)

choose the correct cre loaded update example pro version

After extracting the contents from the patch itself, you should have catalog.zip and a pdf Guide to Installation. Delete this guide as nothing in it applies to Updating, only Upgrading. Instead go to the Cre Loaded site and scan the only information they give on the Updating process: Here is Cre Loaded’s official document on updating.

Step 2: backup your current database and store
There are a couple of reasons for doing this – the obvious (if you stuff up the update, you’ve still got the original files) but also if you have a modified site you may lose some or all of these modifications in the update (so you’ll need your originals to get back on track.)

Step 3: upload and overwrite your store’s folders and files as per the update

Step 4: type the url to your store with /upgrade on the end – eg www.mystore.com/upgrade

This will bring up the update page – confusingly called the ‘Upgrade Wizard’ with blah about versions 6.2 and 6.3 and no mention of 6.4.0.

cre loaded update upgrade screen

Once you click the big blue Update button you might be lucky and get this:

You have successfully updated your Cre Loaded database

… or like me, you’ll get this ominous screen of fail:

cre loaded configuration files error on update

Why the ‘Existing configuration files cannot be accessed’ message? Because when Cre wrote the upgrade scripts, they assumed that everyone’s Admin folder is called, well, ‘Admin.’ But if you’ve decided to make hackers work a little harder and renamed your store’s Admin folder to something other than ‘Admin’, this is why you’re seeing this error.

How to fix this: here’s the top part of the script that is at fault:

/upgrade/templates/pages/upgrade.php

<?php
/*
  CRE Loaded , Open Source E-Commerce Solutions
  http://www.creloaded.com
  Portions  Copyright (c) 2003 osCommerce

     Chain Reaction Works, Inc
     Copyright © 2005 - 2007 Chain Reaction Works, Inc.

   Released under the GNU General Public License
*/
  // Test for pro updaters
  require('includes/classes/tableProcessor.php');
  require('includes/languages/' . $language . '/upgrade.php');
  
  $error = '';
  
  $script_filename = $_SERVER['SCRIPT_FILENAME'];
  $script_filename = str_replace('', '/', $script_filename);
  $fs_array = explode('/', dirname($script_filename));
  
  $fs_root_array = array();
  for ($i=0, $n=sizeof($fs_array)-1; $i<$n; $i++) {
    $fs_root_array[] = $fs_array[$i];
  }
  $fs_www_root = implode('/', $fs_root_array) . '/';
  
  
  if (!file_exists($fs_www_root . 'youradminfolder/includes/configure.php') ||
      !is_readable($fs_www_root . 'youradminfolder/includes/configure.php')
     ) {
    $error = TEXT_ERROR_1;
  } else {
    $config = file_get_contents($fs_www_root . 'youradminfolder/includes/configure.php');

The lines you need to edit are 29, 30 and 34, replacing the word ‘youradminfolder’ with the actual name of your admin folder.
Try Step 4 again and your database should be successfully updated.

Maybe next time Cre will create a better updater … please.