All posts by simon

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:
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):


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 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);

Replace with:

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

Find and delete this block (around line 45):

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

stop google from indexing https secure pages of your website

To stop google and other bots from indexing your website https pages you need to create a new version of a robots file and add a conditional to your store’s root htaccess file. Note – your server should be running the Apache mod_rewrite module for this to work.

Simply create and upload a txt file containing the following code to your store’s root directory:

User-agent: Googlebot 
Disallow: / 

User-agent: * 
Disallow: /

modify the store’s htaccess file
Add the following lines near the top of your htaccess file:

RewriteCond %{SERVER_PORT} ^443$ 
RewriteRule ^robots.txt$ robots_ssl.txt

Check your Google Webmaster account to check this is working correctly.

how to set up tax zones for countries with variable state or province tax rates (eg Canada)

Setting up tax correctly in osCommerce-based carts can be confusing. In some countries, each state or province has a different sales tax. The following example uses Canada and the province of Nova Scotia as an example.

Step 1. Set up Tax Class
This is the actual name of the Tax that you will attach to a product or shipping module. If you’re in Canada, it would make sense to call this ‘Canadian Tax.’

In Admin >> Locations/Taxes >> Tax Classes … create the following by clicking New Tax Class – entering the Title and Description – then Insert. So you get:
create a tax class in cre loaded

Step 2a. Set up Tax Zones – Country
In Admin >> Locations/Taxes >> Tax Zones … insert a new Tax Zone called ‘Canada HST/GST 5%.’
Then with this new Tax Zone selected, click on Details and add each of the Canadian provinces to the ‘Canada HST/GST 5%’ zone by selecting Canada then the Province from the dropdowns.
setting a tax zone

Step 2b. Set up Tax Zones – Provinces
Now you need to add in each province on its own as a Tax Zone. Here is Nova Scotia as an example:
nova scotia tax zone

Once again with the Province selected, click Details and add itself to it’s own Tax Zone.
Do this for all provinces, creating a separate Tax Zone for each.

Why is Canada 5% and Nova Scotia 8%? These aren’t the current tax rates for either place.

Many provinces in Canada have a GST rate of 5%. The tax calculation is based on adding (or compounding) tax at a national and regional level (so country and state level) and because both entities must be created as Tax Zones, by setting Canada at 5% tax, you can then just set the province to carry the difference.

The system then adds together both rates to find the tax rate. So as an example, Nova Scotia, which at the moment has a tax rate of 13%, is set up with 8% tax (the difference between its actual rate and the Canadian rate it includes.)

Many provinces currently have a GST rate of 5%, so by making the tax zone ‘Canada’ at 5% the provinces don’t need to have any tax added (but listed with 0% tax.)

Step 3a. Set up Tax Rates – Country
In Admin >> Locations/Taxes >> Tax Rates … insert a New Tax Rate, choose ‘Canadian Tax’ as the Title, choose the Canadian HST/GST 5% Zone, enter the base tax rate of 5% and a description – tip: you can enter your Tax# here and it will print on invoices. Make the Priority 1.

Step 3a. Set up Tax Rates – Provinces
Yes, you guessed it – same for each province as the main Canadian tax rate in 3a. However, remember that the Tax Rate (%) you enter here is the actual provincial rate less the base Canadian rate of 5%. So some provinces will be entered as 0% Tax Rate, because their GST is equal to 5%. Here is Nova Scotia, with a tax rate of 13% total (5% Canada, 8% Nova Scotia):
set tax rate for nova scotia

Do the same for all provinces, creating a separate Tax Rate for each. In the case of provinces like Manitoba (5% tax) you would enter 0% Tax Rate in the right hand Tax Rate (%) box. Make the Tax Priority the same for all (ie 1.)

add tax rates for provinces

Step 4. Attach tax class
Edit your product and from the dropdown select ‘Canadian Tax.’ Now if a customer from Nova Scotia adds this taxable product to her order, the total tax of 13% will be applied to this product at checkout.

tax added to product via dropdown

Edit your shipping module – choose ‘Canadian Tax’ as the Shipping Tax rate. This will add the applicable provincial tax rate to your net shipping charges.
add tax to shipping module