I discovered that certain components do not create or implement SEF links when using SEF_Advance (from Sakic.Net).

For example, the URL: http://www.juicymedia.co.uk/option,com_virtuemart/page,shop.browse/category_id,1/Itemid,54/lang,en/

So we need to make the links more friendly using the “Aliases” option under the SEF_Advance administrative area. After logging in select the component from the admin menu. A list should appear (or empty if its not been used before) and the system will allow you to add a new “alias” to any static URL.

So, using the new tool I made: See Tools Menu

Paste in the none-SEF URL from the website and click the “Submit Query” button. This will generate a super-non-friendly URL which is required by the SEF_Advance alias management which looks like this:

index.php?option=com_virtuemart&page=shop.browse&category_id=1&Itemid=54&lang=en

This generated URL can then be pasted into the aliases URL followed by a description (friendly) url such as “catalogue/Land-Rover-Defender” which is then translated on the website (NB: the text is converted to lowercase automatically).

For this example, this will need doing on each category within the Virtue Mart shopping cart system.

pdavies | Joomla | 26 June, 10:59am | Comment on this

Whilst creating this website, I realised that the mechanisms in place for saving an Microsoft Word document as HTML (filtered webpage) and then importing the source into the Jaws CMS caused quite a few issues. For example, the supposedly "filtered" saved output from MS Word is far from filtered and is likely to destroy any existing formatting that had been created by the CMS.

This got me thinking and through some simple code using a recently updated HTML Purifier, I managed to extract a filtered HTML document that was suitable for generating the articles you see on the right-hand side. Through the following code I have reduced the time it takes to convert a Word document to a fully formed XHTML document.

The PHP code is based around the PHP5 version of HTML Purifier 2.0:

if ($_POST['q']){
        $dirty_html = $_POST['q'];
        if (!$dirty_html) {
                echo ('You must write some HTML!');
        } else {
                $config = HTMLPurifier_Config::createDefault();
                $config->set('Core', 'Encoding', 'ISO-8859-1');
                $config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional');
                $config->set('HTML', 'TidyLevel', 'heavy');
                $config->set('Core','AcceptFullDocuments',true);
                $config->set('HTML', 'Allowed', 'a[href|title],em,p,blockquote,img');
               
                $purifier = new HTMLPurifier($config);
                $clean_html = $purifier->purify( $dirty_html );
                echo $clean_html;
        }
}
 

Access to the working demo will be available soon in a new "tools" area of the site. Of course the combination of PHP4 and PHP5 might prove interesting - maybe link to the development server might do face-smile.png

pdavies | PHP Programming | 23 June, 12:19pm | 1 comments

If you have had an error popup whilst attempting to access mambots in Joomla its most likley that your running version 1.0.11?

If so you will need to get an official fix from the Joomla forums (registration required but it's free): http://forum.joomla.org/index.php/topic,89866.msg455550.html#msg455550

Then simply upload the fix from the zip file (the zip file is called admin.mambots.php.zip) to the directory on the server containing the old file:

/administrator/components/com_mambots

This should fix the issue - Or simply upgrade to the latest version (1.0.12 at the time of writing).

pdavies | Joomla | 20 June, 10:29am | 1 comments

I recently had an issue with IE7 and I found a suggestion on Google by a MS Developer working on the tab system. His suggestion was to try IE7 without the extensions loaded. Well, luckily this worked allowing me to identify that on my machine the Epson laser printer toolbar was at fault.

The command was: "iexplore.exe -extoff"

pdavies | Miscellaneous | 20 June, 10:16am | Comment on this

Ok, I have no idea where this originally came from but its been very useful the past few years for converting the standard "0000-00-00 00:00:00" format into something useable (and that the client accepts):

function mysql_timestamp_to_human($dt){
     $yr=strval(substr($dt,0,4));
     $mo=strval(substr($dt,4,2));
     $da=strval(substr($dt,6,2));
     $hr=strval(substr($dt,8,2));
     $mi=strval(substr($dt,10,2));
     //$se=strval(substr($dt,12,2));
       
     return date("m/d/Y H:i", mktime ($hr,$mi,0,$mo,$da,$yr))." GMT";
}
 
pdavies | MySQL | 18 June, 11:03am | Comment on this

Whilst working various OpenSource projects I have created various functions for constructing Backbase (client edition) code through a simple PHP class (still in development).

One of the most useful functions is combobox creation.

public function combobox($name, $values_array, $default=null, $size=300, $required=false){
    $req_bxml = ($required)? " b:required=\"true\"" : "";
    $bxml  = '<b:combobox b:width="'. $size .'px" b:name="'. $name .'" b:text="'. $default .'"'. $req_bxml .'>';
    foreach ($values_array as $value) {
        $bxml .= '<b:combo-option b:value="'. $value['value'] .'">'. $value['name'] .'</b:combo-option>';
    }
    $bxml .= '</b:combobox>';
    return $bxml;
}
 

With this code you simply pass it a name followed by an array of values. The other options allow you to define a "selected" value, then the size of the combobox and whether or not it is required. The required functionality is not yet implemented into the Backbase control so best ignore it for the time being.

pdavies | AJAX | 18 June, 9:34am | Comment on this

This script will simply copy a series of files, tar and then gzip the files:

#!/bin/sh
# temporary backup script

Back_Dir="/root/scripts/backups"
Vhosts_Dir="/home/httpd/vhosts" 

# get the date for the filename.
shdate=`date +%b%d%y`

# save our current directory location.
tmp_dir=$PWD

# change to the Backup file directory.
cd $Back_Dir

# create a gzip compressed tar file of the webs directory.
tar -czf ${shdate}.bak.tar.gz $Vhosts_Dir

# return to the previous working directory.
cd $tmp_dir
 

It might help a few users!

pdavies | Linux Backups | 18 June, 1:10am | Comment on this

Here is a simple script for optimizing MySQL table. You will need to set the username and password for a user with "admin" like privileges.

#!/usr/bin/perl
use DBI;

$dbi_host="localhost";

# all databases
@dbi_u=("admin_user");
@dbi_p=("qwerty");

#set the max count value
$ending_value = scalar(_at_dbi_u);

#loop throuogh each of the above databases
for($counter=0 ; $counter < $ending_value ; $counter++){
        # connect to data input table
        $dbh_in = DBI->connect("dbi:mysql:host=$dbi_host", $dbi_u[$counter], $dbi_p[$counter], { RaiseError => 0, AutoCommit => 1 }) or die "cannot connect to server" . $DBI::errstr;
        $sth_dbs = $dbh_in -> prepare("SHOW DATABASES");
        $sth_dbs -> execute();
       
        for($loop_db=0; $loop_db<$sth_dbs -> rows; $loop_db++){
                @row = $sth_dbs -> fetchrow_array;
       
                # databases with a '-' in their name are not handled very well
                if (index($row[0], '-') == -1){
                        # gen query
                        $sth = $dbh_in -> prepare("SHOW TABLES FROM ".$row[0]);
                        $sth -> execute();
                        $query = "";
       
                        for($loop_t=0; $loop_t<$sth -> rows; $loop_t++) {
                                @row2 = $sth -> fetchrow_array;
       
                                if ($query eq ""){
                                        $query = "OPTIMIZE TABLE ";
                                }else{
                                        $query .= ", ";
                                }
       
                                $query .= $row[0].".".$row2[0];
                        }
                       
                        # skip databases without tables
                        if ($query ne ""){
                                print "Optimizing ".$row[0]."...\n";
                                $sth = $dbh_in -> prepare($query);
                                $sth -> execute();
                        }
                }
        }
}
 

All it does it loop through each database and optimise the tables. I would suggest a simple weekly or monthly cron job to execute the script. The script though will e-mail the cron user a list of optimised databases - simply add " >/dev/null 2>&1" to the end of the crontab line to send the data to nowhere.

pdavies | MySQL | 18 June, 1:03am | Comment on this

Ok, after following ZF from its infancy I often see fundamental changes every time a new version is released. Now that the release candidate (version 1) has been released, some fundamental changes have been developed.

The following PHP code pretty much solves any issues related to converting an older pre v1 RC 1 of the ZF face-smile.png . Its a slight generalisation together with the change in "toArray" in the majority of functions:

/* -- set a non-existent error handler + view renderer -- */
$controller->returnResponse(true);
$controller->setParam('useDefaultControllerAlways', true);
$controller->setParam('noErrorHandler', true);
$controller->setParam('noViewRenderer', true);
$response = $controller->dispatch();

The idea being that during the next release of any software that uses the above code, you re-engineer the system to cope with errors, and the new view rendering process.

pdavies | Zend Framework | 18 June, 12:21am | Comment on this

This is the first posting on the new Dotcommers website which is built using a new CMS called Jaws. This CMS unlike some of the other larger-scale applications (such as Joomla) provides a very simple mechanism for inputting new articles.

The Jaws application provides extensive blogging capabilities together with sophisticated RSS and ATOM feed generation.

This "blog" as such will have articles and downloads available for anybody to view, together with many random articles relating to whatever might popup during a days work.

pdavies | General | 17 June, 12:21am | Comment on this

Category Cloud

Link Dump Tag Cloud