Escape characters don’t work in vqgen

February 15th, 2012 | Posted by ChrisG in vQmod - (0 Comments)

vqgen (downloadable from:  http://www.opencart-extensions.co.uk/vqgen/) is a great little script generator for vQmod that saves you having to write xml files for vQmod…

However while creating xml files using vqgen I noticed that any escape characters in the replacement code wasn’t being included in the generated xml file. This was causing my scripts to fail.

To fix the problem I removed all the stripslashes commands from the code that generates the vqmod xml file.

ie.

in vqgen/inc/actions.php
lines 80 – 131

should read…

// Generate a new file
if(isset($_POST['generatexml'])){
    $file = PATH . stripText($_POST['filename']) . '.xml_';

    $output = '<!-- Created using vQmod XML Generator by UKSB - http://www.opencart-extensions.co.uk //-->'."\n";
    $output .= '<modification>'."\n";
    $output .= "\t" . '<id><![CDATA[' . ($_POST['fileid']) . ']]></id>' . "\n";
    $output .= "\t" . '<version><![CDATA[' . ($_POST['version']) . ']]></version>' . "\n";
    $output .= "\t" . '<vqmver><![CDATA[' . ($_POST['vqmodver']) . ']]></vqmver>' . "\n";
    $output .= "\t" . '<author><![CDATA[' . ($_POST['author']) . ']]></author>';

    foreach ($_POST['file'] as $key => $value){
        if(!isset($_POST['remove_'.$key])){
            $output .= "\n\t" . '<file name="' . ($value) . '">';

            foreach ($_POST['search'][$key] as $key2 => $val) {
                if(!isset($_POST['remove_'.$key.'_'.$key2])){
                    $output .= "\n\t\t" . '<operation>';
                    $output .= "\n\t\t\t" . '<search';
                    $output .= ' position="' . $_POST['position'][$key][$key2] . '"';
                    $output .= ((int)$_POST['offset'][$key][$key2]>0?' offset="'.(int)$_POST['offset'][$key][$key2].'"':'');
                    $output .= ((int)$_POST['index'][$key][$key2]>0?' index="'.(int)$_POST['index'][$key][$key2].'"':'');
                    $output .= ($_POST['error'][$key][$key2]!='abort'?' error="' . $_POST['error'][$key][$key2] . '"':'');
                    $output .= ($_POST['regex'][$key][$key2]=='true'?' regex="true"':'');
                    $output .= '>';
                    $output .= '<![CDATA[' . ($val) . ']]></search>';
                    $output .= "\n\t\t\t" . '<add><![CDATA[' . ($_POST['add'][$key][$key2])  . ']]></add>';
                    $output .= "\n\t\t" . '</operation>';

                    if($_POST['newop'][$key][$key2]>0){
                        for($i=0; $i< $_POST['newop'][$key][$key2]; $i++){
                            $output .= "\n\t\t" . '<operation>';
                            $output .= "\n\t\t\t" . '<search';
                            $output .= ' position="replace">';
                            $output .= '<![CDATA[]]></search>';
                            $output .= "\n\t\t\t" . '<add><![CDATA[]]></add>';
                            $output .= "\n\t\t" . '</operation>';
                        }
                    }
                }
            }
            $output .= "\n\t" . '</file>';
        }
    }
    $output .= "\n" . '</modification>';

    $fp = fopen( $file , "w" );
    $fout = fwrite( $fp , $output );
    fclose( $fp );
    chmod($file, 0777);
    header("Location:./?generated=1&file=" . stripText($_POST['filename']). '.xml_');
}

 

vQmod doesn’t seem to be doing anything?!?

February 10th, 2012 | Posted by ChrisG in vQmod - (0 Comments)

So here’s the deal.

I installed vQmod successfully and created some XML files using vqgen, but when I ran opencart the updates weren’t working. It appeared that vQmod wasn’t actually doing anything.

After about on hour of checking web forums, files and privileges I realised that the files generated by vqgen ended in .xml_ and not .xml

Dumb noob mistake!

Make sure the files are enabled in vqgen!

  • Click on the vQmod files tab in vqgen
  • Click the green tick next to the file to enable the file

how to enable vQmod files in vqgen

Note also that the files become disabled everytime you edit them, so don’t forget to re-enable them.

uniCenta oPOS DB Diagrams

January 19th, 2012 | Posted by ChrisG in uniCenta oPOS - (0 Comments)

Database Diagrams for the open source POS software uniCenta oPOS
View diagram here

uniCenta oPOS is an open source Point of Sale (POS) application aimed as small retail businesses and restaurants. It is written in Java and can run on Windows, Mac or Linux. The default installation uses Apache Derby DB but it can be configured to use other databases such as MySQL, PostgreSQL and Oracle. This short post describes how to set uniCenta oPOS to use MySQL.

For setting up on Windows

  1. Download uniCenta oPOS from SourceForge. I used version 2.80 as it includes the mysql.jar.
  2. Before installing you’ll need to create a mySQL database and user for unicenta.
  3. Run the installation .exe for uniCenta
  4. Run uniCenta oPOS configuration and enter the following for the database information:
    - Driver Library: mysql.jar (You should find this in the uniCenta library directory)
    - Driver Class: com.mysql.jdbc.Driver
    - URL: com.mysql.jdbc.Driver
    - User: [user created in Step 2]
    - Password: [password used in Step 2]
  5. Run uniCenta oPOS. The first time you run the program it will create the default database
  6. Check that the mySQL database tables have been created.

If you need to get hold of the Java source code for uniCenta oPOS go to the uniCenta oPOS FAQ page and click the “Want the source code” link. You need to send them an email request.

Analyse Image Colors Using PHP

December 4th, 2011 | Posted by ChrisG in Code Snippets - (Comments Off)

Analyse Image Colors Using PHP
PHP code to analyse colors in an image against color swatchs and then showing the most common colors used in the image. This code can be used as the basis for a search images by color function.

The basic program uses the PHP GD library to process the images and follows these general steps.

  1. Define the colors in the color swatches
  2. Create an image object using the image that is to be analysed, resizing the image if it is too large
  3. Create an image object and load the colors from the the color swatches into image palette. This is the palette that a GIF image uses. This is the comparison palette that the colors in the image being analysed will be compared to.
  4. Loop through all the pixels in the image and tally it against the closest match to the pixel in the comparison palette.
  5. Sort the tally results in descending order
  6. Display the top results

Click here to view full blog

A-Star Pathfinder Test Application

November 25th, 2011 | Posted by ChrisG in Artificial Intelligence - (Comments Off)

This application demonstrates how the A-Star pathfinding algorithm works in realtime. It is written in C++ and all source files as well the .exe file are include in the zip file. Click on the link below for more information.
Click here to view A-Star Pathfinder Test Application

OpenCart 1.5 DB Diagrams

November 25th, 2011 | Posted by ChrisG in OpenCart - (Comments Off)

This page contains database diagrams for the open source application OpenCart 1.5.
Click here to view OpenCart 1.5 DB Diagrams

How to select an OpenCart Tab

November 25th, 2011 | Posted by ChrisG in OpenCart - (4 Comments)

OpenCart supports jQuery tabs. An example of this is when editing products in the admin area. The problem I was having was how to open a page with a tab (other than the first tab) already selected.

For example to open the page with the Colour Definitions tab selected…

After a lot of messing around in jQuery and not having much luck I went old school and just used some javascript to activate the tab links once the page loads. This has the same affect as the user clicking the jQuery tab link.

So to do this, in the template (.tpl) file

1. Give the tab links ids.

<!-- Menu Tabs --> <div id="tabs" class="htabs"> <a id="tab_general" href="#tab-general">General Settings</a>  <a id="tab_definitions" href="#tab-definitions">Colour Definitions</a>  <a id="tab_categories" href="#tab-categories">Colour Categories</a>  <a id="tab_image" href="#tab-image">Image Colour Data</a> </div> <!-- End Menu Tabs -->

2. At the bottom after

$('#tabs a').tabs();

add the line

document.getElementById('tab_definitions').click();

now when the page opens it opens with the Colour Definitions tab selected