Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Friday, September 21, 2012

Installing Magento without Mcrypt


problem
Can't install magento as mcrypt is not enabled on php server, that happend on most of shared hosting

Solution:

Step One: edit /app/code/core/Mage/Install/Installer/Env.php, and find

                Mage::getSingleton('install/session')->addError(
                    Mage::helper('install')->__('PHP Extension "%s" must be loaded', $extension)
                );
just above it, add

                if ($extension == 'mcrypt') {
                    return true;   
                }
Step Two: create /lib/Varien/Crypt/Base64.php and throw this into it

<?php

class Varien_Crypt_Base64 extends Varien_Crypt_Abstract {
    public function __construct(array $data=array()) {
        parent::__construct($data);
    }

    public function init($key) {
         return $this;
    }

    public function encrypt($data) {
        if (!strlen($data)) {
            return $data;
        }
        
        return base64_encode($data);
    }
    
    public function decrypt($data) {
        if (!strlen($data)) {
            return $data;
        } 

        return  base64_decode($data);
    }
}
Last Step: edit /lib/Varien/Crypt.php and change

    static public function factory($method='mcrypt')

with

    static public function factory($method='base64')

just done.