A potpourri of Web Developmemt, Linux, and Windows tidbits and observations

My Favorite Joomla Extensions

Posted by imperialWicket | Joomla | Thursday 29 July 2010 6:32 pm

There are a lot of Joomla extensions out there, many of which are free (or at least offer limited release or branded versions for free). There are so many, I would say, that it can be frustrating to search for an extension when you need one. I can not fix this problem, but I hope I can reduce the search time for others when it comes to a few common extension needs.

My short list of must-have, FREE Joomla Extensions

Components:
1. akeebaBackup (formerly joomlapack) – Since updating to akeebaBackup, I think this particular component has started to cater to its commercial version a little too heavily. Nonetheless, it stands as the best backup utility that I have used. It backups the entire file system (allowing custom exclusions, and including standard exclusions for directories like tmp), it generates a backup of the database (including all the tables, not just the standard installation tables), and it creates its own custom installation directory for restoring the site using the file system and db backups. I use akeebaBackup for moving sites between my test servers, and among live servers. I also have akeebaBackups pre-built with all of my preferred extensions and templates installed, so I can hit the ground running on my new projects.
2. JCE (Joomla Content Editor) – Joomla Content Editor takes Tiny MCE project to the next level within Joomla sites. It occasionally causes issues with editor buttons, but these are worth troubleshooting, as the JCE interface is much more manageable, and offers a lot of configuration options. This component requires the JCE plugin to reach its full glory.
3. Phoca Gallery – I have posted a couple of hacks to alter Phoca Gallery plugins, and I am generally a big fan of their projects. Phoca Downloads, Phoca Maps, Phoca Documentation, and Phoca PDF have all served my needs well for projects – but I must admit to not investigating alternatives in these cases. As far as galleries go, I think the Phoca Gallery really has the best combination of user-friendly administration, feature-rich without being bloated with parameters (although it does have quite a few), and a great suite of complimentary Modules and Plugins (I never install the Phoca Gallery without the Phoca Image Module and Phoca Search Plugin).
4. ChronoForms – I wish forms would just go away. They’re ugly, annoying, browser-specific, and did I mention ugly and annoying? Anyway, they are not going anywhere, and I have spent a lot of time looking for a good (free) form component that can meet all my form building needs. I think ChronoForms is a bit lacking in UI elements, but it by far the best option I have found for putting forms in my Joomla sites.
5. JEvents – For event management. UI, options, functionality are all where they should be for a free component. JEvents is popular for a reason, and I use it when I need events data on a site. There are also good modules/plugins available to complement.
6. XMap – Everyone is concerned about SEO and making sure Google has their latest and greatest site map and has indexed every last word they posted. XMap easily takes care of this, and also provides a means to include your site map on your site.
7. VirtueMart – I prefer VirtueMart for e-commerce in Joomla. I hope I am not starting a war here.
8. My Custom Blank Component. I searched long and hard for a blank component, but could not seem to track one down. I know you should use a different template, or you can include a show component option in your template. But many times I just have one page, where all I want is to show a bunch of modules. In those cases, I just want to assign a menu item that is going to leave the component blank. So I made a blank component, and I use it a LOT.

This is getting long, so I’ll skim the modules:
1. Extended Menu Module – If you are not using this already, you should be.
2. AiDaNews Module – A good enhancement to the Latest News plugin that comes pre-installed.
3. Simple Image Holder – I use this thing everywhere. It is probably my most used extension on a per page basis.
4. Simple Image Rotator – I am fairly anti-flash, and I generally opt for the Simple Image Rotator over alternatives.

My Plugins are all complements to my components. Since I tend to avoid flash, my articles tend to be images and text. The only times I require plugins are when I want an article to interface with a component, hence you will find all my top Plugins at the links previously provided.

And for templates, I will defer to a good article I caught recently at JoomlaPraise. I will also say that many of my Joomla projects start with one of the free JoomlaPraise templates.

I intentionally did not list a flash player (I usually turn to the Flash Module or Embedia – moseasymedia, are these really the best?) or an all encompassing media component. I have tried too many to count, and just can’t seem to find one (or even two or three) that will meet all of my needs. Hopefully someone can recommend a good media component (plugin/module) or suite of utilities and help me figure what I am doing wrong on this front.

Well, other than the media component/flash player are there any others I missed? Or, does anyone have reasonable alternatives or disagreements?

PHP Reserved Words

Posted by dale | PHP | Wednesday 21 July 2010 11:24 am

This is a quick reference list of PHP key words.  These words all have separate meanings in PHP and thus can not be used for constants, class names, functions, or methods.  You could use these as variables, but for obvious reasons, this could lead to problems and is not recommended.

This list combines keywords, functions, classes, and language constructs into a single alphabetical list you can scan quickly to determine if the name you want to use is on the list and thus should not be used.

abstract
and
array
as
break
case
catch
class
clone
const
continue
declare
default
do
die
echo
else
elseif
empty
enddeclare
endfor
endforeach
endif
endswitch
endwhile
eval
exit
extends
final
for
foreach
function
global
goto
if
implements
include
include_once
interface
isset
instanceof
list
namespace
new
or
parent
print
private
protected
public
require
require_once
return
self
static
switch
throw
try
unset
use
var
while
xor

MySQL Workbench 5.2.25 Released

Posted by dale | MySQL | Tuesday 13 July 2010 9:16 pm

I reviewed Release Candidate 5.2.22 on June 27th. In that review, I said, “I would look for the official release to follow closely after this RC 3 release.”

Not, that I had any inside knowledge, I just knew from reviewing the Release Candidate that most of the bugs were gone, and the release could not be far away.

Sure enough, in just 3 days, July 1st, the release became official. My review of June 27th stands, this post is for those who decided to wait for the official release. Well, it’s here.

On the release, the developers stated, “We hope you will make MySQL Workbench your preferred tool for Design, Development, and Administration of your MySQL database.”   We agree.

Download MySQL Workbench here. Any one working with MySQL will quickly find the tool has many enhancements from the older MySQL Administrator and its companion MySQL Query Builder, which are now retired.   MySQL Workbench should become a much used tool in your toolbox.

PHP – Code Snippet – a Quick Variable Checker

Posted by dale | PHP | Monday 5 July 2010 9:37 pm

When your writing a controller you often ask yourself whether menu choices and form data are getting to the controller file without any errors, are the variables set up properly, and are the form selects selecting properly.

And you have your $_SESSION variables. Is the one variable you put in the $_SESSION variable three files ago still there?

This often leads you to making a series of echo statements, where you jump back and form from the form file to the controller file checking if the variable is good, or you misspelled a name. This is time consuming, and sometimes frustrating when creating a new form with a lot of entries.

Most of the time you endure, because your into that moment, and the thought of stopping to think of an easier way does not enter your mind.

With this little snippet of code, you can do all your checking with one line of code, with a simple include file, which will tell you everything you want to know. This allows you to fix every problem encountered with passing variables, and when everything works correctly, you simply remove the one include line, and you’ve finished your variable checking.

Here’s a simple piece of code, which loops through your $_COOKIE array, your $_SESSION array, your $_GET array and your $_POST array, listing each variable name and their corresponding value currently available to the page. There is nothing complicated here, just simple foreach loops looping through each array. Just put the file in your application, and call it when needed with an include.

Here’s the code. Save it to a file, like “var_check.php” for example, and put it in a folder in your application.


function var_check()
{
echo "VARIABLES IN YOUR GLOBAL ARRAYS ";
echo "These are the current COOKIE variables ";
    foreach( $_COOKIE as $key_name => $key_value)
    {
	echo $key_name . " = " . $key_value . "" ;
    }

echo "These are your current SESSION variables:" ;
    foreach( $_SESSION as $key_name => $key_value)
    {
	echo $key_name . " = " . $key_value . "" ;
    }

echo "These are your current GET variables:";
    foreach( $_GET as $key_name => $key_value)
    {
	echo $key_name . " = " . $key_value . "";
    }

echo "These are your current POST variables: " ;
    foreach( $_POST as $key_name => $key_value)
    {
	echo $key_name . " = " . $key_value . "";
    }
}  // end of the var_check function

function server_check()
{
    echo "These are your SERVER variables: " ;
    foreach( $_SERVER as $key_name => $key_value)
    {
	echo $key_name . " = " . $key_value . "";
    }
}  // end of the server_check function

var_check();

You’ll notice, I call the function at the end of the include file, so you don’t have to include the function call as a separate line when you drop it in your file.

Here’s the one line that you put at the top of your controller to list all your variables.


include("../files/test/var_check.php");

Here’s the output of the function call.

VARIABLES IN YOUR GLOBAL ARRAYS
These are the current COOKIE variables
PHPSESSID = dpo4glbo7314hs3frr6bvd2fu1

These are your current SESSION variables:
username = dale
user_id = 2
login_status = OK
LOGIN_MESSAGE =
news_id =

These are your current GET variables:

These are your current POST variables:
projname = dsafdsaf
dept = 3
prjyear = 2010
description = dsaf ad fads
stat = 5
lead = 2
statnote = dasfds a dfsadf
execorder = 11
cgoal = 2
ngoal = 3
mandates = adfa
objectives = dafdsf
measures = dsaf  dsfa  sadf
comms = dsfds adsf asddf
keymess = sdafsda asddfsad
tools = adfsd
saveprj_mile = save project & add a milestone

To check each one of these variables separately would involve a line of code something like this example:

echo "this checks the stat variable: " . $_POST['stat']  ;

Then you would have to remember the value you set “stat” to in your form. So this could save you quite a bit of time going back and forth between the view and controller files.

As an added bonus I included a function you can call separately called, “server_check()” which will loop through your server globals and show you the information available there.

Here’s how to use the server_check function in your file.

include("../files/config/var_check.php");
server_check();

Here’s the sample output from the server_check() function.


HTTP_HOST = localhost
HTTP_USER_AGENT = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
HTTP_ACCEPT = text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE = en-us,en;q=0.5
HTTP_ACCEPT_ENCODING = gzip,deflate
HTTP_ACCEPT_CHARSET = ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_KEEP_ALIVE = 115
HTTP_CONNECTION = keep-alive
HTTP_REFERER = http://localhost/intranet3/views/pp_new.php
HTTP_COOKIE = PHPSESSID=dpo4glbo7314hs3frr6bvd2fu1
HTTP_CACHE_CONTROL = max-age=0
CONTENT_TYPE = application/x-www-form-urlencoded
CONTENT_LENGTH = 205
PATH = c:\Program Files\NVIDIA Corporation\PhysX\Common;C:\wamp\bin\php\php5.3.0\;C:\Program Files\ActiveState Komodo Edit 5\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Git\cmd;C:\Program Files\Git\bin
SystemRoot = C:\WINDOWS
COMSPEC = C:\WINDOWS\system32\cmd.exe
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
WINDIR = C:\WINDOWS
SERVER_SIGNATURE =
SERVER_SOFTWARE = Apache/2.2.11 (Win32) PHP/5.3.0
SERVER_NAME = localhost
SERVER_ADDR = 224.10.0.1
SERVER_PORT = 80
REMOTE_ADDR = 224.10.0.1
DOCUMENT_ROOT = C:/wamp/www/
SERVER_ADMIN = admin@localhost
SCRIPT_FILENAME = C:/wamp/www/intranet3/rules/ru_pp_new.php
REMOTE_PORT = 2247
GATEWAY_INTERFACE = CGI/1.1
SERVER_PROTOCOL = HTTP/1.1
REQUEST_METHOD = POST
QUERY_STRING =
REQUEST_URI = /intranet3/rules/ru_pp_new.php
SCRIPT_NAME = /intranet3/rules/ru_pp_new.php
PHP_SELF = /intranet3/rules/ru_pp_new.php
REQUEST_TIME = 1278368120

That’s about it. Enjoy.

Use Joomla Login Credentials Outside of Joomla

Posted by imperialWicket | Joomla | Friday 2 July 2010 1:24 pm

On several occasions I needed to interface with a Joomla installation from a satellite web application. In these scenarios, it is useful to integrate a login check that accesses the Joomla username and password data. While this integration is not terribly difficult, I spent a long time digging around forums before I located helpful information. In the interest of saving time for others, here is what I found.

First, the Joomla process for creating a new user goes like this:
1. Validate that username is unique.
2. Generate a random 32 character “salt” value.
3. Combine the password + salt, and encrypt the compounded value.
4. Store the encrypted result followed by the salt value used to generate it.

For example, when I create a new user with username ‘joomla_user’ and password ‘joomla_password’, Joomla does the following:
1. Make sure there is not an existing ‘joomla_user’ username value in jos_users.
2. Generate a random 32 character salt (ex: TUIG6Wyx2gPavlcPm73mdpN4uWjZ8dvv).
3. Combine password and salt, then encrypt the entire value:
$value = ( md5(‘joomla_password’.'TUIG6Wyx2gPavlcPm73mdpN4uWjZ8dvv’);
4. Store encrypted value followed by original salt in database (separated by colon):
$value.’:TUIG6Wyx2gPavlcPm73mdpN4uWjZ8dvv’ is inserted.

In order to integrate your web application with the Joomla login, retrieve the appropriate values from the database, separate the salt and the encrypted password + salt combination, salt and encrypt the entered password value, and compare your result to the value in the database. Looks like this in PHP:

$dbhostname = 'localhost';
$dbusername = 'root';
$dbpassword = 'password';
$dbdatabase = 'joomla15';

// Get these from your form...
$username_for_check = 'admin';
$password_for_check = 'admin';

$joomla_user;
$joomla_pass;
$joomla_salt;

$mysqli = new mysqli($dbhostname,$dbusername,$dbpassword,$dbdatabase);

if ($result = $mysqli->query('SELECT j.username,j.password FROM joomla15.jos_users j WHERE j.username="'.$username_for_check.'" LIMIT 1;')) {

  if ($result->num_rows == 0){
      echo 'Username does not exist.';
  }else{
    while ($row = $result->fetch_object()) {
      $joomla_user = $row->username;

      $pass_array = explode(':',$row->password);
      $joomla_pass = $pass_array[0];
      $joomla_salt = $pass_array[1];
    }

    if($joomla_pass == md5($password_for_check.$joomla_salt)){
      echo 'Username and password combination validated.';
    }else{
      echo 'Invalid password for username.';
    }
  }
} else {
  echo 'LOGIN VALIDATION: MySQL Error - '.$mysqli->error;
}

$mysqli->close();
Next Page »