Category Archives: osCommerce-based code

mod pagespeed causes google checkout problems on dreamhost vps

If you’re running a vps (virtual private server), an oscommerce-based cart, a 3rd party google checkout payment module that requires zend optimizer and happen to be with a hosting company that offers ‘web site optimizations’ … (yeah I know, pretty select situation), make sure to take a close look at the web hosting control panel because ‘page speed optimization defaults’ may include the apache module mod_pagespeed, Google’s own bash at making your sites go faster.

A recent job I had was to fix a failing google checkout callback for a client who runs a site on a dreamhost vps. After a lot of of tests and removing various caching and compression features, plus an investigation into php compiled via fastcgi (that I wouldn’t recommend to anyone), I noticed that all the stylesheets were getting linked together in the page source code of the site. For example, a cre loaded site running product page tabs and a social media box might look:

http://mysite.com/cgi-bin/dispatch.fcgi/templates/mytemplate/sty lesheet.css+tabs,_tabpane.css.pagespeed.cc.1234abc.css

Note ‘pagespeed’ in the url – this is an indicator that you too have google’s mod_pagespeed running on your server.

It was easy to deactivate the Page Speed Optimization module (which includes mod_pagespeed – remove a tick in a box) but man, it took some hunting down (mainly because I wasted time looking at the ‘complicated’ when it would be better to check the ‘obvious.’)

You can read a whole lot more about Google’s ‘Page Speed Optimization’ suite of tools (which includes the apache mod_pagespeed) from this url: code [dot] google [dot] com/speed/page-speed/

Here is a list of some of the filters it uses, to give you an idea of what it might do to for your site:

ModPagespeedEnableFilters combine_css
ModPagespeedEnableFilters rewrite_css,rewrite_javascript
ModPagespeedEnableFilters inline_css,inline_javascript
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters insert_img_dimensions
ModPagespeedEnableFilters remove_comments
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters remove_quotes

check for missing unused images on your server

IMAGE CHECK
(aka osCommerce contribution remove_unused_images)

Written for:
any version of cre loaded series 6 cart, but easy to convert for all osCommerce-based carts (including oscMax, zencart)

screenshot of image check

What it does:
Scans and lists all your image files, compares the ones requested by the database products and products_description tables with all of the image files on the server in the /images directory and subdirectories of /images (one level deep.) Then shows a list of any unused images (ie on the server but not being called by the database) with the option of shifting
these into /images/UNUSED.

Ease of use:
Moderate skill needed – you do need to manually set the configuration options in the /admin/image_check.php file. Instructions are included as comments in this file.

Risk from use:
None – no files are actually deleted, only shifted. Low chance of conflict with other store files.

Limitations:
1. When searching product_descriptions, it will only report on images already on the server NOT on the ones called by the database and missing from the server.
2. Will only search one subdirectory deep in the /images folder, so /images/flowers/pic1.jpg will be scanned; /images/flowers/red/pic1.jpg will not be scanned.

Don’t want to try installing it yourself?

No problem – drop me an email and I can install it for you for a minimal amount.

 

how to setup a cronjob in cPanel

A cronjob (short for c(h)ron(ological) job) is like getting the server to automatically perform an action (eg run a php script) on a schedule you specify. It’s straightforward setting up a cronjob using cPanel, all except one step: the command to get the action performed. This article is about setting up a cronjob on a Linux server (part of a LAMP installation) to run a php script.

Step 1: Find out where php is being run from on your server (LAMP server)
This first step is useful for later on and the bit that people new to setting up cronjobs may not be aware of. To enter a command in a cronjob you need to tell the cron handler where php is.

Create where.php and upload to your store’s root directory (eg /public_html):

Then call the script from a browser, eg: www.mysite.com/where.php
Copy the path shown for use in step 5.

(If this doesn’t work, try using usr/bin/php or usr/local/bin/php. If neither of these work, contact your hosting company or tech.)

Step 2: Access cPanel and click the cronjob link:

link to cronjob in cpanel

Step 3: Enter a contact email address
This is so that you can get error messages or completion notifications when the cronjob has run. (However see Step 5 below for a reason why you won’t get any emails.)

email address for cronjob notifications

Step 4: schedule the cronjob
A dropdown of preset timings should be enough for most people. Point and click. I use the ‘every minute’ schedule to test the cronjob, then change this later to however often it’s needed.

scheduling your cronjob

Step 5: THE IMPORTANT ONE – adding in the command
You can break down the command into 3 parts (the [ ] are just there to separate the parts out, but notice the spaces after each part – you need these in the command you write):

[PATH TO PHP] [EXTRA ARGUMENTS] [PATH TO PHP SCRIPT]

This is an example command:

command breakdown used in cronjob

[PATH TO PHP] – you found in Step 1 – here it is /usr/bin/php – this isn’t always the case. Add this at the start of the command. Leave a space after it.
[EXTRA ARGUMENTS] – these are optional, you can use more than one at a time and there are several others. Here I’ve used only -q which is a way of suppressing headers. Leave a space after any arguments.
[PATH TO PHP SCRIPT] – this is the complete path to your php file on your server (not just from the store’s root, the server’s root.)

Added extra (optional)
There is a final piece of code you can add after the [PATH TO PHP SCRIPT]:
>/dev/null 2>&1

Basically this dumps any output from the php script to a ‘blackhole’, so no ‘output’ will be shown on the screen. If you add this to your command it will also stop any email notifications from being sent – as all output is gone, right?

So the image below takes you from Step 4 Scheduling through to now, where you add the command and save the cronjob.

schedule, add in command, add cronjob

The final step is to add the cronjob, which will then result in this success screen:

cronjob added through cPanel

can’t see link to new box added in admin (cre loaded)

Cre Loaded 6.4.x versions have a sort of useful feature that enables specific admin access to specific files. Eg if you don’t want your employees being able to access anything in the Admin >> Reports area, you simply remove the tick from the folder (or file) from their admin group by going through Administrator >> Admin Group >> Set Menu and File Access area.

However this can be a gotcha too when you go to add a new mod and wonder why you and no-one else can see the link in the left column (I’m referring to non-Configuration panel links here which are dragged out of the database.)

So to add a file to the menu, you need obviously to login as a Top Administrator or to have access to the database via phpmyadmin.

If you’re a Top Administrator:
Login and click Administrator >> Menu File Access as shown.

Choose the admin area that your new link is going into by clicking on it:

The using the dropdown on the right, find your new file and click Save (ignore the all yellow look … a beta version obviously):

New file should appear with list of others in this Admin panel and importantly, the link to it will appear in the relevant box in the left column:

If you’re NOT a Top Administrator:
You’re going to need access to the database via something like phpmyadmin, because the first thing you’ll need to do is change your admin_groups_id in the table admin to whatever the Top Administrator group id is (usually 1.) Once this is done, login to the Admin as this new administrator and go through the steps above. Remember to change your admin_group_id back to avoid an issue later on.

But wait, there’s more… give permission to others
So now the file appears in the link … but should you want to give access to other non-Administrator account people (possibly including yourself) you need to be logged in as a member of that Top Administrator group again and go to Admininstrator >> Admin Groups and select the group you want to give access to (1), then click File Permissions (2):

A simple system of tick/no tick comes into play here – folders (read “entire box in the left column”) are in bold; files are not. If ticked – you have access, if not ticked – you don’t have access:

Make sure you click ‘Insert’ at the bottom of the page when done.

cre loaded adserver authsecure annoyance

I was working on a client’s site today and found the admin panel was slow to load. The url it was getting stuck on was one of the adserver.authsecure.com links, one of the Cre direct ‘feeds’ into the admin panel.

Taking a closer look at a some files in the admin revealed a possible solution for Cre Loaded 6.4.x users:

The file is admin/messages.php
Find (around line 27):

case 'upgrade': //index
  $n = 'a6bb2567';
  $zone = '50';
  echo cre_iframe($n,$zone);
  break;

Replace with:

case 'upgrade': //index
  $n = 'a7d7b7d2';
  $zone = '49';
  echo cre_iframe($n,$zone);
  break;

Find and delete this block (around line 45):

case 'login': //std admin login nag
  $n = 'ac49906f';
  $zone = '103';
  echo cre_iframe($n,$zone);
  break;