About Martijn

Say hi

CCNA Certified (Again)

Cisco Certified CCNA Last friday i went to a local Pearson VUE Testing center. In the past i was CCNA certified, but due to various reasons i had let my certification expire. Quiet stupid if you ask me.

So I had signed me up for the Cisco Certified Network Associate-exam (640-802) again. With a good feeling i went to the testing center. And as expect i passed for my CCNA exam. A score of 907 out of 1000 isn’t that bad at all.

Setting environment variables for your Magento store through .htaccess

Once in a while i get the question, Martijn how can we select a storeview without editting the index.php file, as Magento is prepared for this?!

Well, the Magento index.php file is indeed prepared for this. The full Magento index.php for releases and later is as below.

* Magento
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
* @category   Mage
* @package    Mage
* @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)

if (version_compare(phpversion(), '5.2.0', '<')===true) {
    echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';

* Error reporting
error_reporting(E_ALL | E_STRICT);

* Compilation includes configuration file
$compilerConfig = 'includes/config.php';
if (file_exists($compilerConfig)) {
    include $compilerConfig;

$mageFilename = 'app/Mage.php';
$maintenanceFile = 'maintenance.flag';

if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename." was not found";

if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';

require_once $mageFilename;



#ini_set('display_errors', 1);


/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

Mage::run($mageRunCode, $mageRunType);

On lines 66 you will find a conditional test that would allow you to turn on the Magento Developer-mode. On lines 75 and 78 you will see how the $mageRunCode and $mageRunType is populated by server values.

All three values can be set from the .htaccess files or vhost configurations of your server with the code below.

### Setting environment variables for your Magento store.
SetEnvIf Remote_Addr "your.ip.address.here" MAGE_IS_DEVELOPER_MODE=TRUE
SetEnvIf Host "your.domain.here" MAGE_RUN_CODE=storeview_code

### Next line is important for multi language stores on the same domain.
### When running multiple languages on one domain, the storeview code is
### stored in the frontend cookie. Without this line, your store would
### default back to the storeview set above
SetEnvIfNoCase ^Cookie$ "frontend=(.+)" MAGE_RUN_CODE=

With the code at line 2, you can turn on the developer mode for only the specified ip address. The code at line 3 allows you to set a specific storeview-code to be used while executing the Magento web-app.

However, setting always a specific storeview-code is a bad idea. In multilingual stores you could make it default back to the default language all the time. Therefor i recommend not to set a storeview if a cookie is set with a frontend-id.

I hope this is useful for all the Magento Developers out there. If you like my articles, please spread the word using the Tweet button or the Facebook-‘Recommend’-button.

By the way, don’t forget that Magento redirects by default to your base url. So be aware that you need to set this storeview url for a second store in the General Web section of the System config


Magento Currency Importer

Recently I walked in to a new challenge. A customer needed to import the exchange rates provided by the European Central Bank (ECB).

As each Magento store builder knows, Magento only works with one webservice by default and that one is www.webservicex.net.

On the Magento website their is a wiki-page written about how to extend and implement Yahoo Finance, but the guide is pretty broken. And as I needed the rates from the ECB, I decided to build this in to a small module which I also would release on Magento Connect.

My Currency Importer can be found in the Magento Connect database. I would appreciate a positive feedback if it works for you. If things don’t work, please contact me by leaving a message on Connect or below in the comments (if still open).

The Currency Importer allows you to use ECB or Yahoo Finance for now. ECB has a limited exchange rate set.

Magento Sample Module

Recently on Freenode someone asked me wether i have a small sample module of a Magento module. Attached you can find an older (1.4.x.x) Sample module with the directory structure of a Magento module.

The required module.xml and config.xml’s are present. Extend where needed with your own setup scripts and classes.

Magento Sample Module

Let Spamassassin learn about not recognised spam

Below there is a chart of email processing on my server.

Exim stacked stats (graph)

Exim stacked stats for 19-11-2011@15:55

I process statistics every 5 minutes, So above image will tell you that i get about 4 real emails every 5 minutes. I have about 203 emails every 5 minutes that do not comply with email rules (invalid sender, SPF checks fail, etc) About 24 emails get rejected based on recipient rules (specific rules for one of my mailboxes).

And only 1 email every 5 minutes that would be accepted was recognised as spam. Considering the fact that i get multiple messages per day in my mailbox that should be considered as spam i decided that it is time to train spamassassin again.

Training SpamAssassin is quite easy aslong as you follow some rules and are willing to automate this task. As my server works with DirectAdmin I followed the Knowledge Base article on How to create a cronjob to use sa-learn to teach spamassassin – Maildir

Avaya technical update session for IP Office 500 release 8

Today i went to Avaya Netherlands for an update session given by one of the distributors we work with.

Heard some nice things about the new software version and of course the announcement of the additional CPU unit which can be used for centralized use of voicemail pro and the One-X portal.

Avaya ipo500 r8 software will be available in 2 days we are told.

Problems while opening PDF’s in Internet Explorer

Recently i was with a guy who had some problems opening the Adobe Acrobat PDF files in his browser, once in a while the PDF showed up blank and all subsequent files remained blank as well. Because the PDF was opened in his browser immediatly there was no way to download and examinate them.

The solution was to configuring the browser to open PDF files in an Acrobat window.

If you want the browser to open PDF files in a separate Acrobat window, then configure the browser to use Acrobat or Adobe Reader as a helper application. Then, when you select a PDF file in Internet Explorer, the browser opens the PDF file in an Acrobat window instead of the browser window.

To configure the browser to use Acrobat or Adobe Reader to open PDF files:

  1. Close your web browser.
  2. Start Acrobat or Adobe Reader.
  3. Choose Edit > Preferences.
  4. Select Internet in the list on the left.
  5. Deselect Display PDF in Browser, and click OK.
  6. Restart the browser

Note:The next time you select a link to a PDF file, the browser may prompt you to open or save the file. If you choose to open the file, then the browser opens the file in the helper application that you specified. If you choose to save the file, then the browser downloads the file to the hard disk.

Memorising the OSI-layers

Some people have problem with remembering the OSI-layers, for those who can not memorise them i have this small trick i learned once back in college.

Just keep in mind that all people seem to need data processing.
Where each word corresponds with one of the layers of the OSI model below.

OSI Layers

OSI Layers

So all corresponds with Application, people with Presentation etc.

I hope it will help you as it did for me!