Index: trunk/bin/file_importer.php
===================================================================
--- trunk/bin/file_importer.php	(revision 124)
+++ trunk/bin/file_importer.php	(revision 136)
@@ -7,4 +7,8 @@
 
 require realpath(dirname(__FILE__) . '/..') . '/config/cli_config.inc.php';
+
+$app =& App::getInstance();
+$db =& DB::getInstance();
+	
 
 // Test arguments.
@@ -31,5 +35,5 @@
             preg_match('/BALANCE:\s*\$([\.\d]+)/', $file_text, $amt);
             $file_date = date('Y-m-d', strtotime(preg_replace('|[^_]*_|', '', basename($file))));
-//             DB::query("
+//             $db->query("
 //                 INSERT INTO invoice_tbl (
 //                     client_id,
@@ -43,12 +47,12 @@
 //                     added_datetime
 //                 ) VALUES (
-//                     '" . DB::escapeString(0) . "',
-//                     '" . DB::escapeString('hosting') . "',
-//                     '" . DB::escapeString($file_date) . "',
-//                     '" . DB::escapeString($amt[1]) . "',
-//                     '" . DB::escapeString('Paid') . "',
-//                     '" . DB::escapeString('') . "',
-//                     '" . DB::escapeString($file_text) . "',
-//                     '" . DB::escapeString($file_date) . "',
+//                     '" . $db->escapeString(0) . "',
+//                     '" . $db->escapeString('hosting') . "',
+//                     '" . $db->escapeString($file_date) . "',
+//                     '" . $db->escapeString($amt[1]) . "',
+//                     '" . $db->escapeString('Paid') . "',
+//                     '" . $db->escapeString('') . "',
+//                     '" . $db->escapeString($file_text) . "',
+//                     '" . $db->escapeString($file_date) . "',
 //                     NOW()
 //                 )
@@ -56,10 +60,10 @@
 
         } else {
-            App::logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
         }
     }
-    App::logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
+    $app->logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
 } else {
-    App::logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
+    $app->logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
 }
 
Index: trunk/bin/module_maker/_config.inc.php
===================================================================
--- trunk/bin/module_maker/_config.inc.php	(revision 124)
+++ trunk/bin/module_maker/_config.inc.php	(revision 136)
@@ -30,5 +30,4 @@
 
 $app =& App::getInstance('module_maker');
-
 $app->setParam(array(
     'site_name' => 'Module Maker',
@@ -43,8 +42,13 @@
     'log_screen_priority' => LOG_DEBUG,
 ));
-
 require_once 'global/db_auth.inc.php';
 
+// Start application-based functionality: database, session, environment, ini setup, etc.
+// Most configuration parameters must be set before starting the App.
 $app->start();
 
+// Global DB object. Automatically preconfigured by $app->start().
+$db =& DB::getInstance();
+
+
 ?>
Index: trunk/bin/module_maker/form_template.cli.php
===================================================================
--- trunk/bin/module_maker/form_template.cli.php	(revision 124)
+++ trunk/bin/module_maker/form_template.cli.php	(revision 136)
@@ -17,5 +17,5 @@
 
 // Get DB tables.
-$qid = DB::query("SHOW TABLES");
+$qid = $db->query("SHOW TABLES");
 while (list($row) = mysql_fetch_row($qid)) {
     $tables[] = $row;
@@ -24,9 +24,9 @@
 // Make sure requested table is in database.
 if (!in_array($db_tbl, $tables)) {
-    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
+    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
 }
 
 // Get DB table column info.
-$qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
+$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
 while ($row = mysql_fetch_row($qid)) {
     $cols[] = $row;
@@ -65,7 +65,7 @@
 <label for="$field"<\x3fphp \$fv->err('$field') \x3f>><\x3fphp echo _("$title"); \x3f></label>
 <select name="$field" id="$field" class="sc-small"><\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f></select>
-    <span class="commanditem commandtext"><a href="<\x3fphp echo App::oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span>
+    <span class="commanditem commandtext"><a href="<\x3fphp echo \$app->oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span>
     <\x3fphp if ('' != \$frm['<##>_id']) { \x3f>
-    <span class="commanditem commandtext"><a href="<\x3fphp echo App::oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span>
+    <span class="commanditem commandtext"><a href="<\x3fphp echo \$app->oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span>
     <\x3fphp } \x3f>
 E_O_F;
Index: trunk/bin/module_maker/list_template.cli.php
===================================================================
--- trunk/bin/module_maker/list_template.cli.php	(revision 124)
+++ trunk/bin/module_maker/list_template.cli.php	(revision 136)
@@ -30,5 +30,5 @@
 
 // Get DB tables.
-$qid = DB::query("SHOW TABLES");
+$qid = $db->query("SHOW TABLES");
 while (list($row) = mysql_fetch_row($qid)) {
     $tables[] = $row;
@@ -37,9 +37,9 @@
 // Make sure requested table is in database.
 if (!in_array($db_tbl, $tables)) {
-    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
+    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
 }
 
 // Get DB table column info.
-$qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
+$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
 while ($row = mysql_fetch_row($qid)) {
     $cols[] = $row;
@@ -80,11 +80,11 @@
             $listrows[] = "<\x3fphp echo strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>";
         } else if (preg_match('/.*(begin|start).*date.*/i', $field)) {
-            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
+            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
         } else if (preg_match('/.*(end|expire).*date.*/i', $field)) {
-            $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
+            $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
         } else if (preg_match('/datetime/i', $type)) {
-            $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
+            $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
         } else if (preg_match('/date/i', $type)) {
-            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
+            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
         } else if (preg_match('/(amount|_rate)/i', $field)) {
             $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>";
@@ -110,6 +110,6 @@
 <div id="commandbox">
 <form action="<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>" method="get">
-<\x3fphp App::printHiddenSession(false); \x3f>
-    <span class="sc-nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
+<\x3fphp \$app->printHiddenSession(false); \x3f>
+    <span class="sc-nowrap commandtext"><a href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
     <br />
 
@@ -149,6 +149,6 @@
     <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f>
     <tr>
-        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
-        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
+        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
+        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
 
 E_O_F;
@@ -164,5 +164,5 @@
 
 echo isset($op) ? '' : <<<E_O_F
-        <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
+        <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     </tr>
     <\x3fphp } \x3f>
Index: trunk/bin/module_maker/module.cli.php
===================================================================
--- trunk/bin/module_maker/module.cli.php	(revision 124)
+++ trunk/bin/module_maker/module.cli.php	(revision 136)
@@ -129,5 +129,5 @@
 
 // Get DB tables.
-$qid = DB::query("SHOW TABLES");
+$qid = $db->query("SHOW TABLES");
 while (list($row) = mysql_fetch_row($qid)) {
     $tables[] = $row;
@@ -136,10 +136,10 @@
 // Make sure requested table is in database.
 if (!in_array($db_tbl, $tables)) {
-    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
+    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
 }
 
 // Ensure requested table contains columns.
 // Get DB table column info.
-$qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
+$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
 while ($row = mysql_fetch_row($qid)) {
     $cols[] = $row;
@@ -266,5 +266,5 @@
         // If file upload errors, redirect to edit operation for the inserted record.
         if (\$upload->anyErrors() || false === \$new_file) {
-            App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
+            \$app->dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
         }
 E_O_F;
@@ -300,5 +300,5 @@
 
 $search['date'] = '/%DATE%/';
-$replace['date'] = date(App::getParam('date_format'));
+$replace['date'] = date($app->getParam('date_format'));
 
 $search['name_plural'] = '/%NAME_PLURAL%/';
Index: trunk/bin/module_maker/skel/adm_form.ihtml
===================================================================
--- trunk/bin/module_maker/skel/adm_form.ihtml	(revision 124)
+++ trunk/bin/module_maker/skel/adm_form.ihtml	(revision 136)
@@ -2,5 +2,5 @@
 
 %ADMIN_FORM_TAG_INIT%
-<?php App::printHiddenSession(); ?>
+<?php $app->printHiddenSession(); ?>
 <input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
 <input type="hidden" name="%PRIMARY_KEY%" value="<?php echo $frm['%PRIMARY_KEY%']; ?>" />
Index: trunk/bin/module_maker/skel/adm_list.ihtml
===================================================================
--- trunk/bin/module_maker/skel/adm_list.ihtml	(revision 124)
+++ trunk/bin/module_maker/skel/adm_list.ihtml	(revision 136)
@@ -4,6 +4,6 @@
 <div id="commandbox">
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
-<?php App::printHiddenSession(false); ?>
-    <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span>
+<?php $app->printHiddenSession(false); ?>
+    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span>
     <br />
 
@@ -17,5 +17,5 @@
 
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<?php App::printHiddenSession(); ?>
+<?php $app->printHiddenSession(); ?>
 <?php include 'list_info.ihtml'; ?>
 <table class="list">
@@ -28,8 +28,8 @@
     <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
     <tr>
-        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
-        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo $app->oHREF('/admin/versions.php?record_table=%DB_TBL%&record_key=%PRIMARY_KEY%&boomerang=true&record_val=' . $list[$i]['%PRIMARY_KEY%']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
 %ADM_LIST_ROWS%
-        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['<##>'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['<##>'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&%PRIMARY_KEY%=" . $list[$i]['%PRIMARY_KEY%']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['<##>'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     </tr>
     <?php } ?>
Index: trunk/bin/module_maker/skel/admin.php
===================================================================
--- trunk/bin/module_maker/skel/admin.php	(revision 124)
+++ trunk/bin/module_maker/skel/admin.php	(revision 136)
@@ -11,5 +11,5 @@
 $auth->requireLogin();
 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%);
-App::sslOn();
+$app->sslOn();
 
 require_once 'codebase/lib/PageNumbers.inc.php';
@@ -33,4 +33,6 @@
 $fv = new FormValidator();
 
+$cache =& SessionCache::getInstance();
+
 %SORT_ORDER%
 
@@ -41,6 +43,6 @@
 
 // Search limiters retain their values between page requests.
-App::carryQuery('search_query');
-App::carryQuery('filter_<##>');
+$app->carryQuery('search_query');
+$app->carryQuery('filter_<##>');
 %ADMIN_UPLOAD_CONFIG%
 /******************************************************************************
@@ -51,10 +53,10 @@
 // allows us to remember which page we came from so we can go back there.
 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
+    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
 }
 
 if (getFormData('break_list_cache', false)) {
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 }
 
@@ -81,10 +83,10 @@
 //     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
     deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
-    if (App::validBoomerangURL('%NAME_PLURAL%')) {
+    if ($app->validBoomerangURL('%NAME_PLURAL%')) {
         // Display boomerang page.
-        App::dieBoomerangURL('%NAME_PLURAL%');
+        $app->dieBoomerangURL('%NAME_PLURAL%');
     }
     // Display default page.
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
@@ -92,10 +94,10 @@
 //     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD);
     if (getFormdata('cancel', false)) {
-        if (App::validBoomerangURL('%NAME_PLURAL%')) {
+        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
             // Display boomerang page.
-            App::dieBoomerangURL('%NAME_PLURAL%');
+            $app->dieBoomerangURL('%NAME_PLURAL%');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     validateInput();
@@ -109,11 +111,11 @@
         if (getFormdata('repeat', false)) {
             // Display function again.
-            App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
-        } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
+            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
+        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
             // Display boomerang page.
-            App::dieBoomerangURL('%NAME_PLURAL%');
+            $app->dieBoomerangURL('%NAME_PLURAL%');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     break;
@@ -122,6 +124,6 @@
 //     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_EDIT);
     if (getFormdata('reset', false)) {
-        App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
-        App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
+        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
     }
     if (getFormdata('cancel', false)) {
@@ -129,10 +131,10 @@
         $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%'));
         $lock->remove();
-        if (App::validBoomerangURL('%NAME_PLURAL%')) {
+        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
             // Display boomerang page.
-            App::dieBoomerangURL('%NAME_PLURAL%');
+            $app->dieBoomerangURL('%NAME_PLURAL%');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     validateInput();
@@ -146,16 +148,16 @@
         if (getFormdata('repeat', false)) {
             // Display edit function with next available ID.
-            $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
+            $qid = $db->query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
             if (list($next_id) = mysql_fetch_row($qid)) {
-                App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
+                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
             } else {
-                App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
+                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
             }
-        } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
+        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
             // Display boomerang page.
-            App::dieBoomerangURL('%NAME_PLURAL%');
+            $app->dieBoomerangURL('%NAME_PLURAL%');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     break;
@@ -164,5 +166,5 @@
 //     $auth->requireAccessClearance(ZONE_ADMIN_PROGRAMS_FUNC_REORDER);
     updateRank(getFormData('rank'));
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
@@ -207,5 +209,6 @@
 {
     global $lock;
-
+	$db =& DB::getInstance();
+	
     $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -214,13 +217,13 @@
 
     // Get the information for the form.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM %DB_TBL%
-        WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
+        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
     ");
     if (!$frm = mysql_fetch_assoc($qid)) {
-        App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
-        App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
-        App::dieBoomerangURL();
+        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
+        $app->dieBoomerangURL();
     }
 
@@ -246,5 +249,7 @@
 {
     global $lock;
-
+	$db =& DB::getInstance();
+	$cache =& SessionCache::getInstance();
+	
     $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -253,22 +258,22 @@
 
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
     // Get the information for this object.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT <##>
         FROM %DB_TBL%
-        WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
+        WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
     ");
     if (! list($name) = mysql_fetch_row($qid)) {
-        App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
-        App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
-        App::dieBoomerangURL();
+        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
+        $app->dieBoomerangURL();
     }
 
     // Delete the record.
-    DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'");
-
-    App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
+    $db->query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'");
+
+    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
 
     // Unlock record.
@@ -279,10 +284,12 @@
 {
     global $auth;
-
+	$db =& DB::getInstance();
+	$cache =& SessionCache::getInstance();
+	
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
 %INSERT%
-    $last_insert_id = mysql_insert_id(DB::getDBH());
+    $last_insert_id = mysql_insert_id($db->getDBH());
 
     // Create version.
@@ -290,5 +297,5 @@
     $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
 
-    App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
 
     return $last_insert_id;
@@ -297,6 +304,8 @@
 function updateRecord($frm)
 {
-    global $auth, $lock;
-
+	global $auth, $lock;
+	$app =& App::getInstance();
+    $cache =& SessionCache::getInstance();
+    
     $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -305,5 +314,5 @@
 
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
 %UPDATE%
@@ -313,5 +322,5 @@
     $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
 
-    App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
 
     // Unlock record.
@@ -323,5 +332,8 @@
     global $page;
     global $so;
-
+	$db =& DB::getInstance();
+	$prefs =& Prefs::getInstance();
+	$cache =& SessionCache::getInstance();
+	
     $where_clause = '';
 
@@ -336,9 +348,9 @@
     if (getFormData('filter_<##>', false)) {
         // Limit by filter.
-        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . DB::escapeString(getFormData('filter_<##>')) . "'";
+        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . $db->escapeString(getFormData('filter_<##>')) . "'";
     }
 
     // Count the total number of records so we can do something about the page numbers.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT COUNT(*)
         FROM %DB_TBL%
@@ -371,15 +383,15 @@
     // without knowing the hash.
     $cache_hash = md5($sql . '|' . $page->total_items);
-    if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
-        SessionCache::breakCache($_SERVER['PHP_SELF']);
-        Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
-    }
-
-    if (SessionCache::isCached($_SERVER['PHP_SELF'])) {
+    if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
+        $cache->delete($_SERVER['PHP_SELF']);
+        $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
+    }
+
+    if ($cache->exists($_SERVER['PHP_SELF'])) {
         // Get the cached results.
-        $list = SessionCache::getCache($_SERVER['PHP_SELF']);
+        $list = $cache->get($_SERVER['PHP_SELF']);
     } else {
         // If the list is not already cached, query now.
-        $qid = DB::query($sql);
+        $qid = $db->query($sql);
         // Fill an array with the items for this page.
         while ($row = mysql_fetch_assoc($qid)) {
@@ -389,5 +401,5 @@
         if (isset($list) && !empty($list)) {
             // Cache the results.
-            SessionCache::putCache($list, $_SERVER['PHP_SELF']);
+            $cache->set($list, $_SERVER['PHP_SELF']);
         }
     }
@@ -398,11 +410,14 @@
 function updateRank($ranks)
 {
+	$db =& DB::getInstance();
+	$cache =& SessionCache::getInstance();
+	
     if (!is_array($ranks)) {
-        App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
+        $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
         return false;
     }
 
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
     // Count the ranks with invalid numbers
@@ -416,14 +431,14 @@
             $unspecified_counter++;
         }
-        DB::query("
+        $db->query("
             UPDATE %DB_TBL% SET
-                rank = '" . DB::escapeString($new_rank) . "'
-            WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'
+                rank = '" . $db->escapeString($new_rank) . "'
+            WHERE %PRIMARY_KEY% = '" . $db->escapeString($id) . "'
         ");
     }
 
-    App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
     if ($unspecified_counter > 0) {
-        App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     }
 }
Index: trunk/bin/module_maker/skel/public.ihtml
===================================================================
--- trunk/bin/module_maker/skel/public.ihtml	(revision 124)
+++ trunk/bin/module_maker/skel/public.ihtml	(revision 136)
@@ -1,4 +1,4 @@
 <p><?php echo nl2br(fancyTxt(oTxt($item['content'], true))); ?></p>
-<p><em><?php echo sprintf(_("Published %s"), date(App::getParam('date_format'), strtotime($item['<##>']))); ?></em></p>
+<p><em><?php echo sprintf(_("Published %s"), date($app->getParam('date_format'), strtotime($item['<##>']))); ?></em></p>
 
 <!--
Index: trunk/bin/module_maker/skel/public.php
===================================================================
--- trunk/bin/module_maker/skel/public.php	(revision 124)
+++ trunk/bin/module_maker/skel/public.php	(revision 136)
@@ -34,7 +34,7 @@
 
     // Get requested record.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT * FROM %DB_TBL%
-        WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
+        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
         AND publish = 'true'
         <##>AND (publish_date <= CURDATE() OR publish_date = '0000-00-00')
@@ -42,13 +42,13 @@
     ");
     if (!$item = mysql_fetch_assoc($qid)) {
-        App::raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
-        App::dieBoomerangURL();
+        $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
+        $app->dieBoomerangURL();
     }
 
     // Update the hit counter for this record.
-    DB::query("
+    $db->query("
         UPDATE %DB_TBL%
         SET hit_count = hit_count + 1
-        WHERE %PRIMARY_KEY% = '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "'
+        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
     ");
 
@@ -61,5 +61,5 @@
     // Get the DEFAULT list.
     $%NAME_SINGULAR%_list = array();
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM %DB_TBL%
@@ -79,5 +79,5 @@
     // Get the FEATURED list.
     $featured_list = array();
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM %DB_TBL%
@@ -92,5 +92,5 @@
     // Get the POPULAR list.
     $popular_list = array();
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM %DB_TBL%
@@ -104,5 +104,5 @@
     // Get the RECENT list.
     $recent_list = array();
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM %DB_TBL%
Index: trunk/bin/module_maker/skel/public_list.ihtml
===================================================================
--- trunk/bin/module_maker/skel/public_list.ihtml	(revision 124)
+++ trunk/bin/module_maker/skel/public_list.ihtml	(revision 136)
@@ -5,13 +5,13 @@
         ?>
         <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?>
-            <h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></a></h4>
+            <h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></a></h4>
         <?php } else { ?>
             <h4><?php echo fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['title'])); ?></h4>
         <?php } ?>
         <p>
-        <em><?php echo date(App::getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> &mdash; <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?>
+        <em><?php echo date($app->getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> &mdash; <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?>
 
         <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?>
-            <br /><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a>
+            <br /><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a>
         <?php } ?>
         </p>
@@ -32,5 +32,5 @@
     <?php
     foreach ($featured_list as $item) {
-        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php
+        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php
     }
 }
@@ -44,5 +44,5 @@
     <?php
     foreach ($popular_list as $item) {
-        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
+        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
     }
 }
@@ -56,5 +56,5 @@
     <?php
     foreach ($recent_list as $item) {
-        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
+        ?><h4><a href="<?php echo $app->oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
     }
 }
Index: trunk/bin/module_maker/sql.cli.php
===================================================================
--- trunk/bin/module_maker/sql.cli.php	(revision 124)
+++ trunk/bin/module_maker/sql.cli.php	(revision 136)
@@ -30,5 +30,5 @@
 
 // Get DB tables.
-$qid = DB::query("SHOW TABLES");
+$qid = $db->query("SHOW TABLES");
 while (list($row) = mysql_fetch_row($qid)) {
     $tables[] = $row;
@@ -37,5 +37,5 @@
 // Make sure requested table is in database.
 if (!in_array($db_tbl, $tables)) {
-    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
+    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
 }
 
@@ -46,5 +46,5 @@
 
 // Get DB table column info.
-$qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
+$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
 while ($row = mysql_fetch_row($qid)) {
     $cols[] = $row;
@@ -76,5 +76,5 @@
         } else if ('added_by_user_id' == $field || 'modified_by_user_id' == $field) {
             // Toggle types.
-            $c[$field] = "'\" . DB::escapeString(\$auth->getVal('user_id')) . \"'";
+            $c[$field] = "'\" . \$db->escapeString(\$auth->getVal('user_id')) . \"'";
         } else if ('added_datetime' == $field || 'modified_datetime' == $field) {
             // DB record insertion datetime.
@@ -82,5 +82,5 @@
         } else {
             // Default. Just insert data.
-            $c[$field] = "'\" . DB::escapeString(\$frm['$field']) . \"'";
+            $c[$field] = "'\" . \$db->escapeString(\$frm['$field']) . \"'";
         }
     }
@@ -107,5 +107,5 @@
 echo <<<E_O_F
     // Insert record data.
-    DB::query("
+    \$db->query("
         INSERT INTO $db_tbl (
             $db_keys
@@ -133,7 +133,7 @@
 echo <<<E_O_F
     // Update record data.
-    DB::query("
+    \$db->query("
         UPDATE $db_tbl SET$key_eq_val
-        WHERE $primary_key = '" . DB::escapeString(\$frm['$primary_key']) . "'
+        WHERE $primary_key = '" . \$db->escapeString(\$frm['$primary_key']) . "'
     ");
 E_O_F;
@@ -148,5 +148,5 @@
 $delim = 'WHERE';
 if (!empty($primary_key)) {
-    $where_clause = "            $delim $primary_key = '\" . DB::escapeString(\$frm['$primary_key']) . \"'\n";
+    $where_clause = "            $delim $primary_key = '\" . \$db->escapeString(\$frm['$primary_key']) . \"'\n";
     $delim = 'AND';
 }
@@ -155,10 +155,10 @@
         continue;
     }
-    $where_clause .= "            $delim $k = '\" . DB::escapeString(\$frm['$k']) . \"'\n";
+    $where_clause .= "            $delim $k = '\" . \$db->escapeString(\$frm['$k']) . \"'\n";
     $delim = 'AND';
 }
 echo <<<E_O_F
         // Delete record data.
-        DB::query("
+        \$db->query("
             DELETE FROM $db_tbl
 $where_clause        ");
@@ -183,9 +183,9 @@
 if (!isset($op) || 'search' == $op) {
 $search_skip_columns = array('added_datetime', 'added_by_user_id', 'modified_datetime', 'modified_by_user_id', 'publish', 'featured');
-$search_columns = $db_tbl . '.' . join(" LIKE '%\" . DB::escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
+$search_columns = $db_tbl . '.' . join(" LIKE '%\" . \$db->escapeString(\$qry_words[\$i]) . \"%'\n                    OR $db_tbl.", array_diff(array_keys($c), $search_skip_columns));
 echo <<<E_O_F
             \$where_clause .= (empty(\$where_clause) ? 'WHERE' : 'AND') . "
                 (
-                    $search_columns LIKE '%" . DB::escapeString(\$qry_words[\$i]) . "%'
+                    $search_columns LIKE '%" . \$db->escapeString(\$qry_words[\$i]) . "%'
                 )
             ";
Index: trunk/bin/module_maker/validation.cli.php
===================================================================
--- trunk/bin/module_maker/validation.cli.php	(revision 124)
+++ trunk/bin/module_maker/validation.cli.php	(revision 136)
@@ -17,5 +17,5 @@
 
 // Get DB tables.
-$qid = DB::query("SHOW TABLES");
+$qid = $db->query("SHOW TABLES");
 while (list($row) = mysql_fetch_row($qid)) {
     $tables[] = $row;
@@ -24,9 +24,9 @@
 // Make sure requested table is in database.
 if (!in_array($db_tbl, $tables)) {
-    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
+    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
 }
 
 // Get DB table column info.
-$qid = DB::query("DESCRIBE " . DB::escapeString($db_tbl));
+$qid = $db->query("DESCRIBE " . $db->escapeString($db_tbl));
 while ($row = mysql_fetch_row($qid)) {
     $cols[] = $row;
@@ -277,11 +277,14 @@
 // natsort($o);
 
+// Remove last empty element.
+if ('' == end($o)) {
+    array_pop($o);
+}
+
 echo "function validateInput()
 {
     global \$fv;
 
-    ";
-echo join("\n    ", $o);
-echo "
+    " . join("\n    ", $o) . "
 }";
 ?>
Index: trunk/docs/coding_standards.txt
===================================================================
--- trunk/docs/coding_standards.txt	(revision 124)
+++ trunk/docs/coding_standards.txt	(revision 136)
@@ -183,5 +183,5 @@
         ?>
         <div align="right" class="sc-tiny">
-        [&nbsp;<a href="<?php echo App::oHREF('contact.php') ?>">Contact us</a>&nbsp;]
+        [&nbsp;<a href="<?php echo $app->oHREF('contact.php') ?>">Contact us</a>&nbsp;]
         </div>
         <?php
@@ -214,5 +214,7 @@
     function getSetEnumFieldValues()
     {
-        $qid = DB::query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false);
+		$db =& DB::getInstance();
+        
+        $qid = $db->query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false);
 
         $row = mysql_fetch_row($qid);
Index: trunk/docs/example_config.inc.php
===================================================================
--- trunk/docs/example_config.inc.php	(revision 124)
+++ trunk/docs/example_config.inc.php	(revision 136)
@@ -70,9 +70,13 @@
 // DB credentials for command line scripts stored in a file with read rights
 // given only to the user who will be executing the scripts: -rw-------
-// This file includes App:: method calls so must be included after App.
+// This file includes $app-> method calls so must be included after App.
 require_once 'global/db_auth.inc.php';
 
+// Start application-based functionality: database, session, environment, ini setup, etc.
 // Most configuration parameters must be set before starting the App.
 $app->start();
+
+// Global DB object. Automatically preconfigured by $app->start().
+$db =& DB::getInstance();
 
 // User authentication.
Index: trunk/docs/example_script_template.php
===================================================================
--- trunk/docs/example_script_template.php	(revision 124)
+++ trunk/docs/example_script_template.php	(revision 136)
@@ -11,5 +11,5 @@
 
 $auth->requireLogin();
-App::sslOn();
+$app->sslOn();
 
 require_once 'codebase/lib/FormValidator.inc.php';
Index: trunk/docs/file_layout.txt
===================================================================
--- trunk/docs/file_layout.txt	(revision 124)
+++ trunk/docs/file_layout.txt	(revision 136)
@@ -55,5 +55,5 @@
         RecordVersion.inc.php (db record versioning system)
         ScriptTimer.inc.php (timer for scripts)
-        SessionCache.inc.php (class for accessing a cache in a users session, stores any variables for quick retreival)
+        Cache.inc.php (class for accessing a cache in a users session, stores any variables for quick retreival)
         SortOrder.inc.php (class dealing with sorting of columns in database generated lists)
         SpellCheck.inc.php
Index: trunk/docs/revision_history.txt
===================================================================
--- trunk/docs/revision_history.txt	(revision 124)
+++ trunk/docs/revision_history.txt	(revision 136)
@@ -31,5 +31,5 @@
     - RecordLock
     - RecordVersion
-    - SessionCache
+    - Cache
     - Upload
 
@@ -56,5 +56,5 @@
     - app object can be accessed globally without reference to object name by calling methods statically, e.g. App:logMsg()
     - seperate application and codebase parameters from site configuration variables.
-      Use $app->getParam('var') or App::getParam('var') to get app params.
+      Use $app->getParam('var') or $app->getParam('var') to get app params.
       F or site configurations do whatever you want (I'm using $cfg['node']['features'] format for configurations)
 
@@ -68,5 +68,5 @@
 
 DB object:
-    - Self contained class for DB functions. db::query is the only necessary function. Maintains connections and state independent of App.
+    - Self contained class for DB functions. $db->query is the only necessary function. Maintains connections and state independent of App.
 
 Full test suite for all codebase libraries. Run from the command line: "codebase/tests/run_tests.sh;"
Index: trunk/docs/version.txt
===================================================================
--- trunk/docs/version.txt	(revision 136)
+++ trunk/docs/version.txt	(revision 136)
@@ -0,0 +1,1 @@
+2.1dev
Index: trunk/lib/App.inc.php
===================================================================
--- trunk/lib/App.inc.php	(revision 124)
+++ trunk/lib/App.inc.php	(revision 136)
@@ -7,5 +7,5 @@
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 2.0
+ * @version 2.1
  */
 
@@ -22,8 +22,8 @@
 class App {
 
-    // Name of this application.
-    var $app = '_app_';
-
-    // If App::start has run successfully.
+    // Namespace of this application instance.
+    var $_ns;
+
+    // If $app->start has run successfully.
     var $running = false;
 
@@ -34,5 +34,5 @@
     var $_carry_queries = array();
 
-    // Hash of global application parameters.
+    // Dictionary of global application parameters.
     var $_params = array();
 
@@ -45,8 +45,8 @@
         'site_url' => '', // URL automatically determined by _SERVER['HTTP_HOST'] if not set here.
 
-        // The location the user will go if the system doesn't knew where else to send them.
+        // The location the user will go if the system doesn't know where else to send them.
         'redirect_home_url' => '/',
 
-        // SSL URL used when redirecting with App::sslOn().
+        // SSL URL used when redirecting with $app->sslOn().
         'ssl_domain' => null,
         'ssl_enabled' => false,
@@ -86,5 +86,5 @@
         'db_create_tables' => true,
 
-        // The level of error reporting. Don't set this to 0 to suppress messages, instead use display_errors to control display.
+        // The level of error reporting. Don't change this to suppress messages, instead use display_errors to control display.
         'error_reporting' => E_ALL,
 
@@ -99,5 +99,5 @@
 
         // General application log.
-        'log_filename' => 'app_error_log',
+        'log_filename' => 'app_log',
 
         // Logging priority can be any of the following, or false to deactivate:
@@ -122,4 +122,6 @@
 
         // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'.
+        // Existing password hashes rely on the same key/salt being used to compare encryptions.
+        // Don't change this unless you know existing hashes or signatures will not be affected!
         'signing_key' => 'aae6abd6209d82a691a9f96384a7634a',
     );
@@ -128,14 +130,15 @@
      * This method enforces the singleton pattern for this class. Only one application is running at a time.
      *
-     * @return  object  Reference to the global SessionCache object.
+     * $param   string  $namespace  Name of this application.
+     * @return  object  Reference to the global Cache object.
      * @access  public
      * @static
      */
-    function &getInstance($app=null)
+    function &getInstance($namespace='')
     {
         static $instance = null;
 
         if ($instance === null) {
-            $instance = new App($app);
+            $instance = new App($namespace);
         }
 
@@ -146,9 +149,8 @@
      * Constructor.
      */
-    function App($app=null)
-    {
-        if (isset($app)) {
-            $this->app .= $app;
-        }
+    function App($namespace='')
+    {
+        // Set namespace of application instance.
+        $this->_ns = '_app_' . $namespace;
 
         // Initialize default parameters.
@@ -164,11 +166,7 @@
     function setParam($param=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
         if (isset($param) && is_array($param)) {
             // Merge new parameters with old overriding only those passed.
-            $_this->_params = array_merge($_this->_params, $param);
+            $this->_params = array_merge($this->_params, $param);
         }
     }
@@ -181,14 +179,10 @@
      * @return  mixed               Parameter value, or null if not existing.
      */
-    function &getParam($param=null)
-    {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
+    function getParam($param=null)
+    {
         if ($param === null) {
-            return $_this->_params;
-        } else if (isset($_this->_params[$param])) {
-            return $_this->_params[$param];
+            return $this->_params;
+        } else if (isset($this->_params[$param])) {
+            return $this->_params[$param];
         } else {
             trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
@@ -239,9 +233,7 @@
             }
 
-            // The only instance of the DB object.
+            // There will ever only be one instance of the DB object, and here is where it is instantiated.
             require_once dirname(__FILE__) . '/DB.inc.php';
-
             $this->db =& DB::getInstance();
-
             $this->db->setParam(array(
                 'db_server' => $this->getParam('db_server'),
@@ -270,10 +262,4 @@
         if (true === $this->getParam('enable_session')) {
 
-            // Set the session ID to one provided in GET/POST. This is necessary for linking
-            // between domains and keeping the same session.
-            if ($ses = getFormData($this->getParam('session_name'), false)) {
-                session_id($ses);
-            }
-
             if (true === $this->getParam('enable_db_session_handler') && true === $this->getParam('enable_db')) {
                 // Database session handling.
@@ -295,8 +281,8 @@
             session_start();
 
-            if (!isset($_SESSION[$this->app])) {
+            if (!isset($_SESSION[$this->_ns])) {
                 // Access session data using: $_SESSION['...'].
                 // Initialize here _after_ session has started.
-                $_SESSION[$this->app] = array(
+                $_SESSION[$this->_ns] = array(
                     'messages' => array(),
                     'boomerang' => array('url'),
@@ -324,4 +310,12 @@
         // Character set. This should also be printed in the html header template.
         header('Content-type: text/html; charset=' . $this->getParam('character_set'));
+        
+        // Set the version of the codebase we're using.
+        $codebase_version_file = dirname(__FILE__) . '/../docs/version.txt';
+        if (is_readable($codebase_version_file)) {
+            $codebase_version = trim(file_get_contents($codebase_version_file));
+            header('X-Codebase-Version: ' . $codebase_version);
+            define('CODEBASE_VERSION', $codebase_version);
+        }
 
         $this->running = true;
@@ -360,12 +354,8 @@
     function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
         $message = trim($message);
 
-        if (!$_this->running || '' == $message) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running || '' == $message) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running or message is an empty string.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -373,14 +363,14 @@
         // Save message in session under unique key to avoid duplicate messages.
         $msg_id = md5($type . $message . $file . $line);
-        $_SESSION[$_this->app]['messages'][$msg_id] = array(
+        $_SESSION[$this->_ns]['messages'][$msg_id] = array(
             'type'    => $type,
             'message' => $message,
             'file'    => $file,
             'line'    => $line,
-            'count'   => (isset($_SESSION[$_this->app]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$_this->app]['messages'][$msg_id]['count']) : 1)
+            'count'   => (isset($_SESSION[$this->_ns]['messages'][$msg_id]['count']) ? (1 + $_SESSION[$this->_ns]['messages'][$msg_id]['count']) : 1)
         );
 
         if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
-            $_this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
+            $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_NOTICE, __FILE__, __LINE__);
         }
     }
@@ -396,18 +386,10 @@
     function getRaisedMessages()
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-        
-        $output = array();
-        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
-            $output[] = $message;
-        }
-        return $output;
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+
+        return isset($_SESSION[$this->_ns]['messages']) ? $_SESSION[$this->_ns]['messages'] : array();
     }
     
@@ -421,14 +403,10 @@
     function clearRaisedMessages()
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
         
-        $_SESSION[$_this->app]['messages'] = array();
+        $_SESSION[$this->_ns]['messages'] = array();
     }
 
@@ -442,34 +420,31 @@
     function printRaisedMessages()
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-
-        while (isset($_SESSION[$_this->app]['messages']) && $message = array_shift($_SESSION[$_this->app]['messages'])) {
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+        
+        $messages = $this->getRaisedMessages();
+        foreach ($messages as $m) {
             ?><div class="sc-msg"><?php
-            if (error_reporting() > 0 && $_this->getParam('display_errors')) {
-                echo "\n<!-- [" . $message['file'] . ' : ' . $message['line'] . '] -->';
-            }
-            switch ($message['type']) {
+            if (error_reporting() > 0 && $this->getParam('display_errors') && isset($m['file']) && isset($m['line'])) {
+                echo "\n<!-- [" . $m['file'] . ' : ' . $m['line'] . '] -->';
+            }
+            switch ($m['type']) {
             case MSG_ERR:
-                echo '<div class="sc-msg-error">' . $message['message'] . '</div>';
+                echo '<div class="sc-msg-error">' . $m['message'] . '</div>';
                 break;
 
             case MSG_WARNING:
-                echo '<div class="sc-msg-warning">' . $message['message'] . '</div>';
+                echo '<div class="sc-msg-warning">' . $m['message'] . '</div>';
                 break;
 
             case MSG_SUCCESS:
-                echo '<div class="sc-msg-success">' . $message['message'] . '</div>';
+                echo '<div class="sc-msg-success">' . $m['message'] . '</div>';
                 break;
 
             case MSG_NOTICE:
             default:
-                echo '<div class="sc-msg-notice">' . $message['message'] . '</div>';
+                echo '<div class="sc-msg-notice">' . $m['message'] . '</div>';
                 break;
 
@@ -477,4 +452,5 @@
             ?></div><?php
         }
+        $this->clearRaisedMessages();
     }
 
@@ -501,19 +477,15 @@
         static $previous_events = array();
 
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
         // If priority is not specified, assume the worst.
-        if (!$_this->logPriorityToString($priority)) {
-            $_this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
+        if (!$this->logPriorityToString($priority)) {
+            $this->logMsg(sprintf('Log priority %s not defined. (Message: %s)', $priority, $message), LOG_EMERG, $file, $line);
             $priority = LOG_EMERG;
         }
 
         // If log file is not specified, don't log to a file.
-        if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) {
-            $_this->setParam(array('log_file_priority' => false));
-            // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.
-            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE);
+        if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
+            $this->setParam(array('log_file_priority' => false));
+            // We must use trigger_error to report this problem rather than calling $app->logMsg, which might lead to an infinite loop.
+            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
         }
 
@@ -531,5 +503,5 @@
             $previous_events[$msg_id]++;
             if ($previous_events[$msg_id] == 2) {
-                $_this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
+                $this->logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
             }
             return false;
@@ -543,5 +515,5 @@
             'remote ip' => getRemoteAddr(),
             'pid'       => (substr(PHP_OS, 0, 3) != 'WIN' ? posix_getpid() : ''),
-            'type'      => $_this->logPriorityToString($priority),
+            'type'      => $this->logPriorityToString($priority),
             'file:line' => "$file : $line",
             'url'       => (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''),
@@ -550,11 +522,11 @@
 
         // FILE ACTION
-        if ($_this->getParam('log_file_priority') && $priority <= $_this->getParam('log_file_priority')) {
+        if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
             $event_str = '[' . join('] [', $event) . ']';
-            error_log($event_str . "\n", 3, $_this->getParam('log_directory') . '/' . $_this->getParam('log_filename'));
+            error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
         }
 
         // EMAIL ACTION
-        if ($_this->getParam('log_email_priority') && $priority <= $_this->getParam('log_email_priority')) {
+        if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
             $subject = sprintf('[%s %s] %s', getenv('HTTP_HOST'), $event['type'], $message);
             $email_msg = sprintf("A %s log event occured on %s\n\n", $event['type'], getenv('HTTP_HOST'));
@@ -563,17 +535,17 @@
                 $email_msg .= sprintf("%-11s%s\n", $k, $v);
             }
-            mail($_this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
+            mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
         }
 
         // SMS ACTION
-        if ($_this->getParam('log_sms_priority') && $priority <= $_this->getParam('log_sms_priority')) {
+        if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
             $subject = sprintf('[%s %s]', getenv('HTTP_HOST'), $priority);
             $sms_msg = sprintf('%s [%s:%s]', $event['message'], basename($file), $line);
             $headers = "From: codebase@strangecode.com";
-            mail($_this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
+            mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
         }
 
         // SCREEN ACTION
-        if ($_this->getParam('log_screen_priority') && $priority <= $_this->getParam('log_screen_priority')) {
+        if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
             echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n";
         }
@@ -610,5 +582,5 @@
     /**
      * Sets which query arguments will be carried persistently between requests.
-     * Values in the _carry_queries array will be copied to URLs (via App::url()) and
+     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
      * to hidden input values (via printHiddenSession()).
      *
@@ -620,12 +592,8 @@
     function carryQuery($query_key)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
         // If not already set, and there is a non-empty value provided in the request...
-        if (!isset($_this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
+        if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
             // Copy the value of the specified query argument into the _carry_queries array.
-            $_this->_carry_queries[$query_key] = getFormData($query_key);
+            $this->_carry_queries[$query_key] = getFormData($query_key);
         }
     }
@@ -652,10 +620,6 @@
     function url($url, $carry_args=null, $always_include_sid=false)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -691,5 +655,5 @@
         if ($do_carry_queries) {
             // Join the global _carry_queries and local one_time_carry_queries.
-            $query_args = urlEncodeArray(array_merge($_this->_carry_queries, $one_time_carry_queries));
+            $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
             foreach ($query_args as $key=>$val) {
                 // Check value is set and value does not already exist in the url.
@@ -715,7 +679,7 @@
                     (
                         !isset($_COOKIE[session_name()])
-                        || !$_this->getParam('session_use_cookies')
+                        || !$this->getParam('session_use_cookies')
                     )
-                    && $_this->getParam('enable_session')
+                    && $this->getParam('enable_session')
                     && isMyDomain($url)
                     &&
@@ -738,9 +702,9 @@
 
     /**
-     * Returns a HTML-friendly URL processed with App::url and & replaced with &amp;
+     * Returns a HTML-friendly URL processed with $app->url and & replaced with &amp;
      *
      * @access  public
      * @param   string  $url    Input URL to parse.
-     * @return  string          URL with App::url() and htmlentities() applied.
+     * @return  string          URL with $app->url() and htmlentities() applied.
      * @author  Quinn Comendant <quinn@strangecode.com>
      * @since   09 Dec 2005 17:58:45
@@ -748,9 +712,5 @@
     function oHREF($url, $carry_args=null, $always_include_sid=false)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        $url = $_this->url($url, $carry_args, $always_include_sid);
+        $url = $this->url($url, $carry_args, $always_include_sid);
 
         // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
@@ -772,10 +732,6 @@
     function printHiddenSession($carry_args=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -808,7 +764,7 @@
             // Join the global _carry_queries and local one_time_carry_queries.
             // urlencode is not used here, not for form data!
-            $query_args = array_merge($_this->_carry_queries, $one_time_carry_queries);
+            $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
             foreach ($query_args as $key=>$val) {
-                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
+                printf('<input type="hidden" name="%s" value="%s" />', $key, $val);
             }
         }
@@ -816,5 +772,5 @@
         // Include the SID if cookies are disabled.
         if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
-            echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
+            printf('<input type="hidden" name="%s" value="%s" />', session_name(), session_id());
         }
     }
@@ -829,5 +785,5 @@
      *                                          or FALSE to prevent carrying queries. Can be any of the following formats:
      *                                          -array('key1', key2', key3')  <-- to save these keys if in the form data.
-     *                                          -array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
+     *                                          -array('key1' => 'value', key2' => 'value')  <-- to set keys to default values if not present in form data.
      *                                          -false  <-- To not carry any queries. If URL already has queries those will be retained.
      * @param   bool    $always_include_sid     Force session id to be added to Location header.
@@ -835,10 +791,6 @@
     function dieURL($url, $carry_args=null, $always_include_sid=false)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -846,5 +798,5 @@
         if ('' == $url) {
             // If URL is not specified, use the redirect_home_url.
-            $url = $_this->getParam('redirect_home_url');
+            $url = $this->getParam('redirect_home_url');
         }
 
@@ -856,17 +808,17 @@
         }
 
-        $url = $_this->url($url, $carry_args, $always_include_sid);
+        $url = $this->url($url, $carry_args, $always_include_sid);
 
         header(sprintf('Location: %s', $url));
-        $_this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
+        $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
 
         // End this application.
         // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
-        $_this->stop();
+        $this->stop();
         die;
     }
 
     /*
-    * Redirects a user by calling App::dieURL(). It will use:
+    * Redirects a user by calling $app->dieURL(). It will use:
     * 1. the stored boomerang URL, it it exists
     * 2. a specified $default_url, it it exists
@@ -876,5 +828,5 @@
     * @access   public
     * @param    string  $id             Identifier for this script.
-    * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see App::oHREF()).
+    * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see $app->oHREF()).
     * @param    string  $default_url    A default URL if there is not a valid specified boomerang URL.
     * @return   bool                    False if the session is not running. No return otherwise.
@@ -884,24 +836,20 @@
     function dieBoomerangURL($id=null, $carry_args=null, $default_url=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
 
         // Get URL from stored boomerang. Allow non specific URL if ID not valid.
-        if ($_this->validBoomerangURL($id, true)) {
-            if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
-                $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
-                $_this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+        if ($this->validBoomerangURL($id, true)) {
+            if (isset($id) && isset($_SESSION[$this->_ns]['boomerang']['url'][$id])) {
+                $url = $_SESSION[$this->_ns]['boomerang']['url'][$id];
+                $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
             } else {
-                $url = end($_SESSION[$_this->app]['boomerang']['url']);
-                $_this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+                $url = end($_SESSION[$this->_ns]['boomerang']['url']);
+                $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
             }
             // Delete stored boomerang.
-            $_this->deleteBoomerangURL($id);
+            $this->deleteBoomerangURL($id);
         } else if (isset($default_url)) {
             $url = $default_url;
@@ -909,19 +857,19 @@
             // Ensure that the redirecting page is not also the referrer.
             $url = getenv('HTTP_REFERER');
-            $_this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+            $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
         } else {
             // If URL is not specified, use the redirect_home_url.
-            $url = $_this->getParam('redirect_home_url');
-            $_this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+            $url = $this->getParam('redirect_home_url');
+            $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
         }
 
         // A redirection will never happen immediately twice.
         // Set the time so ensure this doesn't happen.
-        $_SESSION[$_this->app]['boomerang']['time'] = time();
-        $_this->dieURL($url, $carry_args);
-    }
-
-    /**
-     * Set the URL to return to when App::dieBoomerangURL() is called.
+        $_SESSION[$this->_ns]['boomerang']['time'] = time();
+        $this->dieURL($url, $carry_args);
+    }
+
+    /**
+     * Set the URL to return to when $app->dieBoomerangURL() is called.
      *
      * @param string  $url  A fully validated URL.
@@ -931,14 +879,10 @@
     function setBoomerangURL($url=null, $id=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
         // A redirection will never happen immediately after setting the boomerangURL.
-        // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more.
+        // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more.
 
         if ('' != $url && is_string($url)) {
@@ -946,20 +890,20 @@
             $url = preg_replace('/boomerang=[\w]+/', '', $url);
 
-            if (isset($_SESSION[$_this->app]['boomerang']['url']) && is_array($_SESSION[$_this->app]['boomerang']['url']) && !empty($_SESSION[$_this->app]['boomerang']['url'])) {
+            if (isset($_SESSION[$this->_ns]['boomerang']['url']) && is_array($_SESSION[$this->_ns]['boomerang']['url']) && !empty($_SESSION[$this->_ns]['boomerang']['url'])) {
                 // If the URL currently exists in the boomerang array, delete.
-                while ($existing_key = array_search($url, $_SESSION[$_this->app]['boomerang']['url'])) {
-                    unset($_SESSION[$_this->app]['boomerang']['url'][$existing_key]);
+                while ($existing_key = array_search($url, $_SESSION[$this->_ns]['boomerang']['url'])) {
+                    unset($_SESSION[$this->_ns]['boomerang']['url'][$existing_key]);
                 }
             }
 
             if (isset($id)) {
-                $_SESSION[$_this->app]['boomerang']['url'][$id] = $url;
+                $_SESSION[$this->_ns]['boomerang']['url'][$id] = $url;
             } else {
-                $_SESSION[$_this->app]['boomerang']['url'][] = $url;
-            }
-            $_this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+                $_SESSION[$this->_ns]['boomerang']['url'][] = $url;
+            }
+            $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
             return true;
         } else {
-            $_this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
+            $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -973,21 +917,17 @@
     function getBoomerangURL($id=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
 
         if (isset($id)) {
-            if (isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
-                return $_SESSION[$_this->app]['boomerang']['url'][$id];
+            if (isset($_SESSION[$this->_ns]['boomerang']['url'][$id])) {
+                return $_SESSION[$this->_ns]['boomerang']['url'][$id];
             } else {
                 return '';
             }
-        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
-            return end($_SESSION[$_this->app]['boomerang']['url']);
+        } else if (is_array($_SESSION[$this->_ns]['boomerang']['url'])) {
+            return end($_SESSION[$this->_ns]['boomerang']['url']);
         } else {
             return false;
@@ -1002,19 +942,15 @@
     function deleteBoomerangURL($id=null)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-
-        $_this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $_this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
-
-        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
-            unset($_SESSION[$_this->app]['boomerang']['url'][$id]);
-        } else if (is_array($_SESSION[$_this->app]['boomerang']['url'])) {
-            array_pop($_SESSION[$_this->app]['boomerang']['url']);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+
+        $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
+
+        if (isset($id) && isset($_SESSION[$this->_ns]['boomerang']['url'][$id])) {
+            unset($_SESSION[$this->_ns]['boomerang']['url'][$id]);
+        } else if (is_array($_SESSION[$this->_ns]['boomerang']['url'])) {
+            array_pop($_SESSION[$this->_ns]['boomerang']['url']);
         }
     }
@@ -1028,15 +964,11 @@
     function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
-        if (!$_this->running) {
-            $_this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-
-        if (!isset($_SESSION[$_this->app]['boomerang']['url'])) {
-            $_this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
+        if (!$this->running) {
+            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+
+        if (!isset($_SESSION[$this->_ns]['boomerang']['url'])) {
+            $this->logMsg(sprintf('validBoomerangURL(%s) no boomerang URL set.', $id), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
@@ -1045,32 +977,32 @@
         // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
         // or a boomerang being set.
-        $boomerang_time = isset($_SESSION[$_this->app]['boomerang']['time']) ? $_SESSION[$_this->app]['boomerang']['time'] : 0;
+        $boomerang_time = isset($_SESSION[$this->_ns]['boomerang']['time']) ? $_SESSION[$this->_ns]['boomerang']['time'] : 0;
 
         $url = '';
-        if (isset($id) && isset($_SESSION[$_this->app]['boomerang']['url'][$id])) {
-            $url = $_SESSION[$_this->app]['boomerang']['url'][$id];
+        if (isset($id) && isset($_SESSION[$this->_ns]['boomerang']['url'][$id])) {
+            $url = $_SESSION[$this->_ns]['boomerang']['url'][$id];
         } else if (!isset($id) || $use_nonspecificboomerang) {
             // Use non specific boomerang if available.
-            $url = end($_SESSION[$_this->app]['boomerang']['url']);
-        }
-
-        $_this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+            $url = end($_SESSION[$this->_ns]['boomerang']['url']);
+        }
+
+        $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
 
         if ('' == $url) {
-            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
+            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
         if ($url == absoluteMe()) {
             // The URL we are directing to is the current page.
-            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
         if ($boomerang_time >= (time() - 2)) {
             // Last boomerang direction was more than 2 seconds ago.
-            $_this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-
-        $_this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
+            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        }
+
+        $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
         return true;
     }
@@ -1082,8 +1014,4 @@
     function sslOn()
     {
-        if (!isset($_this) || !is_a($_this, 'App') && !is_subclass_of($_this, 'App')) {
-            $_this =& App::getInstance();
-        }
-
         if (function_exists('apache_get_modules')) {
             $modules = apache_get_modules();
@@ -1093,8 +1021,8 @@
         }
 
-        if ('' == getenv('HTTPS') && $_this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
-            $_this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $_this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
+        if ('' == getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
+            $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
             // Always append session because some browsers do not send cookie when crossing to SSL URL.
-            $_this->dieURL('https://' . $_this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
+            $this->dieURL('https://' . $this->getParam('ssl_domain') . getenv('REQUEST_URI'), null, true);
         }
     }
@@ -1107,8 +1035,4 @@
     function sslOff()
     {
-        if (!isset($this) || !is_a($this, 'App') && !is_subclass_of($this, 'App')) {
-            $this =& App::getInstance();
-        }
-
         if ('' != getenv('HTTPS')) {
             $this->dieURL('http://' . getenv('HTTP_HOST') . getenv('REQUEST_URI'), null, true);
Index: trunk/lib/Auth_File.inc.php
===================================================================
--- trunk/lib/Auth_File.inc.php	(revision 124)
+++ trunk/lib/Auth_File.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * The Auth_File:: class provides a htpasswd file implementation for
+ * Auth_File.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The Auth_File class provides a htpasswd file implementation for
  * authentication.
  *
@@ -24,7 +27,9 @@
 
 class Auth_File {
-
-    var $_auth = '';
-    var $_sess = '_auth_';
+    
+    // Namespace of this auth object.
+    var $_ns;
+    
+    // Parameters to be specified by setParam().
     var $_params = array();
     var $_default_params = array(
@@ -61,10 +66,7 @@
      * @param optional array $params  A hash containing parameters.
      */
-    function Auth_File($auth_name=null)
-    {
-        if (isset($auth_name)) {
-            $this->_auth = $auth_name;
-            $this->_sess .= $auth_name;
-        }
+    function Auth_File($namespace='null')
+    {
+        $this->_ns = '_auth_' . $namespace;
 
         // Initialize default parameters.
@@ -95,8 +97,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -110,5 +114,5 @@
     function clearAuth()
     {
-        $_SESSION[$this->_sess] = array('authenticated' => false);
+        $_SESSION[$this->_ns] = array('authenticated' => false);
     }
 
@@ -123,8 +127,8 @@
     function setVal($key, $val)
     {
-        if (!isset($_SESSION[$this->_sess]['user_data'])) {
-            $_SESSION[$this->_sess]['user_data'] = array();
-        }
-        $_SESSION[$this->_sess]['user_data'][$key] = $val;
+        if (!isset($_SESSION[$this->_ns]['user_data'])) {
+            $_SESSION[$this->_ns]['user_data'] = array();
+        }
+        $_SESSION[$this->_ns]['user_data'][$key] = $val;
     }
 
@@ -139,8 +143,8 @@
     function getVal($key, $default='')
     {
-        if (isset($_SESSION[$this->_sess][$key])) {
-            return $_SESSION[$this->_sess][$key];
-        } else if (isset($_SESSION[$this->_sess]['user_data'][$key])) {
-            return $_SESSION[$this->_sess]['user_data'][$key];
+        if (isset($_SESSION[$this->_ns][$key])) {
+            return $_SESSION[$this->_ns][$key];
+        } else if (isset($_SESSION[$this->_ns]['user_data'][$key])) {
+            return $_SESSION[$this->_ns]['user_data'][$key];
         } else {
             return $default;
@@ -160,6 +164,8 @@
     function authenticate($username, $password)
     {
+		$app =& App::getInstance();
+    
         if ('' == trim($password)) {
-            App::logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);
             return false;
         }
@@ -169,10 +175,10 @@
 
         if (!isset($this->_users[$username])) {
-            App::logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__);
             return false;
         }
 
         if ($this->_encrypt($password, $this->_users[$username]) != $this->_users[$username]) {
-            App::logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__);
             return false;
         }
@@ -203,5 +209,5 @@
         }
         
-        $_SESSION[$this->_sess] = array(
+        $_SESSION[$this->_ns] = array(
             'authenticated' => true,
             'username' => $username,
@@ -227,11 +233,13 @@
     function isLoggedIn()
     {
+		$app =& App::getInstance();
+    
         // Some users will access from networks with a changing IP number (i.e. behind a proxy server). These users must be allowed entry by adding their IP to the list of trusted_networks.
         if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
             $user_in_trusted_network = true;
-            App::logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_sess]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_ns]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
         } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
             $user_in_trusted_network = true;
-            App::logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_sess]['username']), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_ns]['username']), LOG_DEBUG, __FILE__, __LINE__);
         } else {
             $user_in_trusted_network = false;
@@ -239,35 +247,35 @@
 
         // Test login with information stored in session. Skip IP matching for users from trusted networks.
-        if (isset($_SESSION[$this->_sess])
-            && true === $_SESSION[$this->_sess]['authenticated']
-            && !empty($_SESSION[$this->_sess]['username'])
-            && strtotime($_SESSION[$this->_sess]['login_datetime']) > time() - $this->_params['login_timeout']
-            && strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - $this->_params['idle_timeout']
-            && ($_SESSION[$this->_sess]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
+        if (isset($_SESSION[$this->_ns])
+            && true === $_SESSION[$this->_ns]['authenticated']
+            && !empty($_SESSION[$this->_ns]['username'])
+            && strtotime($_SESSION[$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
+            && strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
+            && ($_SESSION[$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
         ) {
             // User is authenticated!
-            $_SESSION[$this->_sess]['last_access_datetime'] = date('Y-m-d H:i:s');
+            $_SESSION[$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');
             return true;
-        } else if (isset($_SESSION[$this->_sess]) && true === $_SESSION[$this->_sess]['authenticated']) {
-            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) {
+        } else if (isset($_SESSION[$this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {
+            if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - 43200) {
                 // Only raise message if last session is less than 12 hours old.
-                App::raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
+                $app->raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
             }
 
             // Log the reason for login expiration.
             $expire_reasons = array();
-            if (empty($_SESSION[$this->_sess]['username'])) {
+            if (empty($_SESSION[$this->_ns]['username'])) {
                 $expire_reasons[] = 'username not found';
             }
-            if (strtotime($_SESSION[$this->_sess]['login_datetime']) <= time() - $this->_params['login_timeout']) {
+            if (strtotime($_SESSION[$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {
                 $expire_reasons[] = 'login_timeout expired';
             }
-            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
+            if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
                 $expire_reasons[] = 'idle_timeout expired';
             }
-            if ($_SESSION[$this->_sess]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
-                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr());
-            }
-            App::logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_sess]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
+            if ($_SESSION[$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
+                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_ns]['remote_ip'], getRemoteAddr());
+            }
+            $app->logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_ns]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
         }
 
@@ -287,11 +295,13 @@
     function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
     {
+		$app =& App::getInstance();
+    
         if (!$this->isLoggedIn()) {
             // Display message for requiring login. (RaiseMsg will ignore empty strings.)
-            App::raiseMsg($message, $type, $file, $line);
+            $app->raiseMsg($message, $type, $file, $line);
 
             // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
-            App::setBoomerangURL(absoluteMe(), 'login');
-            App::dieURL($this->_params['login_url']);
+            $app->setBoomerangURL(absoluteMe(), 'login');
+            $app->dieURL($this->_params['login_url']);
         }
     }
@@ -308,8 +318,10 @@
     function _loadHTPasswdFile()
     {
+		$app =& App::getInstance();
+    
         static $users = null;
         
         if (!file_exists($this->_params['htpasswd_file'])) {
-            App::logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -317,5 +329,5 @@
         if (!isset($users)) {
             if (false === ($users = file($this->_params['htpasswd_file']))) {
-                App::logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
Index: trunk/lib/Auth_SQL.inc.php
===================================================================
--- trunk/lib/Auth_SQL.inc.php	(revision 124)
+++ trunk/lib/Auth_SQL.inc.php	(revision 136)
@@ -1,5 +1,5 @@
 <?php
 /**
- * The Auth_SQL:: class provides a SQL implementation for authentication.
+ * The Auth_SQL class provides a SQL implementation for authentication.
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
@@ -8,19 +8,23 @@
 
 // Available encryption types for class Auth_SQL.
-define('AUTH_ENCRYPT_MD5', 1);
+define('AUTH_ENCRYPT_PLAINTEXT', 1);
 define('AUTH_ENCRYPT_CRYPT', 2);
 define('AUTH_ENCRYPT_SHA1', 3);
-define('AUTH_ENCRYPT_PLAINTEXT', 4);
+define('AUTH_ENCRYPT_SHA1_HARDENED', 4);
+define('AUTH_ENCRYPT_MD5', 5);
+define('AUTH_ENCRYPT_MD5_HARDENED', 6);
 
 require_once dirname(__FILE__) . '/Email.inc.php';
 
 class Auth_SQL {
-
-    var $_auth = '';
-    var $_sess = '_auth_';
+        
+    // Namespace of this auth object.
+    var $_ns;
+    
+    // Static var for test.
     var $_authentication_tested;
+
+    // Paramters to be configured by setParam.
     var $_params = array();
-
-    // Default param values.
     var $_default_params = array(
 
@@ -41,5 +45,7 @@
 
         // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
-        'encryption_type' => AUTH_ENCRYPT_SHA1,
+        // Hardened password hashes rely on the same key/salt being used to compare encryptions.
+        // Be aware that when using one of the hardened types the App signing_key or $more_salt below cannot change!
+        'encryption_type' => AUTH_ENCRYPT_MD5,
 
         // The URL to the login script.
@@ -90,10 +96,9 @@
      * @param optional array $params  A hash containing parameters.
      */
-    function Auth_SQL($auth_name=null)
-    {
-        if (isset($auth_name)) {
-            $this->_auth = $auth_name;
-            $this->_sess .= $auth_name;
-        }
+    function Auth_SQL($namespace='')
+    {
+		$app =& App::getInstance();
+        
+        $this->_ns = '_auth_' . $namespace;
 
         // Initialize default parameters.
@@ -101,6 +106,6 @@
 
         // Get create tables config from global context.
-        if (!is_null(App::getParam('db_create_tables'))) {
-            $this->setParam(array('create_table' => App::getParam('db_create_tables')));
+        if (!is_null($app->getParam('db_create_tables'))) {
+            $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
         }
     }
@@ -115,4 +120,8 @@
     function initDB($recreate_db=false)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
+    
         static $_db_tested = false;
 
@@ -121,10 +130,10 @@
             // User table.
             if ($recreate_db) {
-                DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
-                App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
+                $db->query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
+                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
             }
 
             // The minimal columns for a table compatable with the Auth_SQL class.
-            DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
+            $db->query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
                 " . $this->getParam('db_primary_key') . " smallint(11) NOT NULL auto_increment,
                 " . $this->getParam('db_username_column') . " varchar(255) NOT NULL default '',
@@ -152,5 +161,5 @@
             )");
 
-            if (!DB::columnExists($this->getParam('db_table'), array(
+            if (!$db->columnExists($this->getParam('db_table'), array(
                 $this->getParam('db_primary_key'),
                 $this->getParam('db_username_column'),
@@ -173,5 +182,5 @@
                 'modified_datetime',
             ), false, false)) {
-                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
                 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
             }
@@ -180,8 +189,8 @@
             if ($this->getParam('abuse_detection')) {
                 if ($recreate_db) {
-                    DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_login_table'));
-                    App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__);
+                    $db->query("DROP TABLE IF EXISTS " . $this->getParam('db_login_table'));
+                    $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__);
                 }
-                DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_login_table') . " (
+                $db->query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_login_table') . " (
                     " . $this->getParam('db_primary_key') . " smallint(11) NOT NULL default '0',
                     login_datetime datetime NOT NULL default '0000-00-00 00:00:00',
@@ -192,10 +201,10 @@
                 )");
 
-                if (!DB::columnExists($this->getParam('db_login_table'), array(
+                if (!$db->columnExists($this->getParam('db_login_table'), array(
                     $this->getParam('db_primary_key'),
                     'login_datetime',
                     'remote_ip_binary',
                 ), false, false)) {
-                    App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__);
                     trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), E_USER_ERROR);
                 }
@@ -228,8 +237,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -243,7 +254,9 @@
     function clearAuth()
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
-        DB::query("
+        $db->query("
             UPDATE " . $this->_params['db_table'] . " SET
             seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)),
@@ -251,5 +264,5 @@
             WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
         ");
-        $_SESSION[$this->_sess] = array('authenticated' => false);
+        $_SESSION[$this->_ns] = array('authenticated' => false);
     }
 
@@ -263,8 +276,8 @@
     function setVal($key, $val)
     {
-        if (!isset($_SESSION[$this->_sess]['user_data'])) {
-            $_SESSION[$this->_sess]['user_data'] = array();
-        }
-        $_SESSION[$this->_sess]['user_data'][$key] = $val;
+        if (!isset($_SESSION[$this->_ns]['user_data'])) {
+            $_SESSION[$this->_ns]['user_data'] = array();
+        }
+        $_SESSION[$this->_ns]['user_data'][$key] = $val;
     }
 
@@ -279,8 +292,8 @@
     function getVal($key, $default='')
     {
-        if (isset($_SESSION[$this->_sess][$key])) {
-            return $_SESSION[$this->_sess][$key];
-        } else if (isset($_SESSION[$this->_sess]['user_data'][$key])) {
-            return $_SESSION[$this->_sess]['user_data'][$key];
+        if (isset($_SESSION[$this->_ns][$key])) {
+            return $_SESSION[$this->_ns][$key];
+        } else if (isset($_SESSION[$this->_ns]['user_data'][$key])) {
+            return $_SESSION[$this->_ns]['user_data'][$key];
         } else {
             return $default;
@@ -298,4 +311,7 @@
     function authenticate($username, $password)
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+
         $this->initDB();
 
@@ -303,9 +319,9 @@
         case AUTH_ENCRYPT_CRYPT :
             // Query DB for user matching credentials. Compare cyphertext with salted-encrypted password.
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT *, " . $this->_params['db_primary_key'] . " AS user_id
                 FROM " . $this->_params['db_table'] . "
-                WHERE " . $this->_params['db_username_column'] . " = '" . DB::escapeString($username) . "'
-                AND BINARY userpass = ENCRYPT('" . DB::escapeString($password) . "', LEFT(userpass, 2)))
+                WHERE " . $this->_params['db_username_column'] . " = '" . $db->escapeString($username) . "'
+                AND BINARY userpass = ENCRYPT('" . $db->escapeString($password) . "', LEFT(userpass, 2)))
             ");
             break;
@@ -315,9 +331,9 @@
         default :
             // Query DB for user matching credentials. Directly compare cyphertext with result from encryptPassword().
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT *, " . $this->_params['db_primary_key'] . " AS user_id
                 FROM " . $this->_params['db_table'] . "
-                WHERE " . $this->_params['db_username_column'] . " = '" . DB::escapeString($username) . "'
-                AND BINARY userpass = '" . DB::escapeString($this->encryptPassword($password)) . "'
+                WHERE " . $this->_params['db_username_column'] . " = '" . $db->escapeString($username) . "'
+                AND BINARY userpass = '" . $db->escapeString($this->encryptPassword($password)) . "'
             ");
             break;
@@ -326,8 +342,8 @@
         // Return user data if found.
         if ($user_data = mysql_fetch_assoc($qid)) {
-            App::logMsg(sprintf('Authentication successful for %s %s (%s)', $this->_auth, $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Authentication successful for user %s (%s)', $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__);
             return $user_data;
         } else {
-            App::logMsg(sprintf('Authentication failed for %s %s (encrypted attempted password: %s)', $this->_auth, $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Authentication failed for user %s (encrypted attempted password: %s)', $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -344,4 +360,7 @@
     function login($username, $password)
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+	
         $this->initDB();
 
@@ -354,8 +373,7 @@
 
         // Register authenticated session.
-        $_SESSION[$this->_sess] = array(
+        $_SESSION[$this->_ns] = array(
             'authenticated'         => true,
             'user_id'               => $user_data['user_id'],
-            'auth_name'             => $this->_auth,
             'username'              => $username,
             'login_datetime'        => date('Y-m-d H:i:s'),
@@ -372,12 +390,12 @@
             if (!empty($user_data['blocked'])) {
 
-                App::logMsg(sprintf('%s %s (%s) login failed due to blocked account: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
+                $app->logMsg(sprintf('User %s (%s) login failed due to blocked account: %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
 
                 switch ($user_data['blocked_reason']) {
                     case 'account abuse' :
-                        App::raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__);
+                        $app->raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__);
                         break;
                     default :
-                        App::raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__);
+                        $app->raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__);
                         break;
                 }
@@ -395,5 +413,5 @@
         **/
         if ($this->getParam('abuse_detection') && !$this->getVal('login_abuse_exempt')) {
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT COUNT(DISTINCT LEFT(remote_ip_binary, " . $this->_params['login_abuse_ip_bitmask'] . "))
                 FROM " . $this->_params['db_login_table'] . "
@@ -406,16 +424,16 @@
                     // Warn the user with a password reset.
                     $this->resetPassword(null, _("This is a security precaution. We have detected this account has been accessed from multiple computers simultaneously. It is against policy to share login information with others. If further account abuse is detected this account will be blocked."));
-                    App::raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);
-                    App::logMsg(sprintf('Account abuse detected for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
+                    $app->raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Account abuse detected for user %s (%s) from IP %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
                 } else {
                     // Block the account with the reason of account abuse.
                     $this->blockAccount(null, 'account abuse');
-                    App::raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);
-                    App::logMsg(sprintf('Account blocked for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
+                    $app->raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Account blocked for user %s (%s) from IP %s', $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
                 }
                 // Increment user's warning level.
-                DB::query("UPDATE " . $this->_params['db_table'] . " SET abuse_warning_level = abuse_warning_level + 1 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
+                $db->query("UPDATE " . $this->_params['db_table'] . " SET abuse_warning_level = abuse_warning_level + 1 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
                 // Reset the login counter for this user.
-                DB::query("DELETE FROM " . $this->_params['db_login_table'] . " WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
+                $db->query("DELETE FROM " . $this->_params['db_login_table'] . " WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'");
                 // No login: reset password because of account abuse!
                 $this->clearAuth();
@@ -424,5 +442,5 @@
 
             // Update the login counter table with this login access. Convert IP to binary.
-            DB::query("
+            $db->query("
                 INSERT INTO " . $this->_params['db_login_table'] . " (
                     " . $this->_params['db_primary_key'] . ",
@@ -438,5 +456,5 @@
 
         // Update user table with this login.
-        DB::query("
+        $db->query("
             UPDATE " . $this->_params['db_table'] . " SET
                 last_login_datetime = '" . $this->getVal('login_datetime') . "',
@@ -462,11 +480,14 @@
     function isLoggedIn($user_id=null)
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+	
         $this->initDB();
 
         if (isset($user_id)) {
             // Check the login status of a specific user.
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT 1 FROM " . $this->_params['db_table'] . "
-                WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+                WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
                 AND DATE_ADD(last_login_datetime, INTERVAL '" . $this->_params['login_timeout'] . "' SECOND) > NOW()
                 AND DATE_ADD(last_access_datetime, INTERVAL '" . $this->_params['idle_timeout'] . "' SECOND) > NOW()
@@ -476,6 +497,6 @@
 
         // User login test need only be run once per script execution. We cache the result in the session.
-        if ($this->_authentication_tested && isset($_SESSION[$this->_sess]['authenticated'])) {
-            return $_SESSION[$this->_sess]['authenticated'];
+        if ($this->_authentication_tested && isset($_SESSION[$this->_ns]['authenticated'])) {
+            return $_SESSION[$this->_ns]['authenticated'];
         }
 
@@ -486,6 +507,5 @@
         if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
             $user_in_trusted_network = true;
-            App::logMsg(sprintf('%s%s accessing from trusted network %s',
-                ucfirst($this->_auth),
+            $app->logMsg(sprintf('User %s accessing from trusted network %s',
                 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : ''),
                 $trusted_net
@@ -493,6 +513,5 @@
         } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
             $user_in_trusted_network = true;
-            App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com',
-                ucfirst($this->_auth),
+            $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com',
                 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : '')
             ), LOG_DEBUG, __FILE__, __LINE__);
@@ -502,16 +521,16 @@
 
         // Test login with information stored in session. Skip IP matching for users from trusted networks.
-        if (isset($_SESSION[$this->_sess])
-            && true === $_SESSION[$this->_sess]['authenticated']
-            && !empty($_SESSION[$this->_sess]['username'])
-            && strtotime($_SESSION[$this->_sess]['login_datetime']) > time() - $this->_params['login_timeout']
-            && strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - $this->_params['idle_timeout']
-            && ($_SESSION[$this->_sess]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
+        if (isset($_SESSION[$this->_ns])
+            && true === $_SESSION[$this->_ns]['authenticated']
+            && !empty($_SESSION[$this->_ns]['username'])
+            && strtotime($_SESSION[$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
+            && strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
+            && ($_SESSION[$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
         ) {
             // User is authenticated!
-            $_SESSION[$this->_sess]['last_access_datetime'] = date('Y-m-d H:i:s');
+            $_SESSION[$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s');
 
             // Update the DB with the last_access_datetime and increment the seconds_online.
-            DB::query("
+            $db->query("
                 UPDATE " . $this->_params['db_table'] . " SET
                 seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1,
@@ -519,32 +538,32 @@
                 WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
             ");
-            if (mysql_affected_rows(DB::getDBH()) > 0) {
+            if (mysql_affected_rows($db->getDBH()) > 0) {
                 // User record still exists in DB. Do this to ensure user was not delete from DB between accesses. Notice "+ 1" in SQL above to ensure record is modified.
                 return true;
             } else {
-                App::logMsg(sprintf('User update failed. Record not found for %s %s (%s).', $this->_auth, $this->getVal('user_id'), $this->getVal('username')), LOG_NOTICE, __FILE__, __LINE__);
-            }
-        } else if (isset($_SESSION[$this->_sess]) && true === $_SESSION[$this->_sess]['authenticated']) {
+                $app->logMsg(sprintf('User update failed. Record not found for user %s (%s).', $this->getVal('user_id'), $this->getVal('username')), LOG_NOTICE, __FILE__, __LINE__);
+            }
+        } else if (isset($_SESSION[$this->_ns]) && true === $_SESSION[$this->_ns]['authenticated']) {
             // User is authenticated, but login has expired.
-            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) {
+            if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) > time() - 43200) {
                 // Only raise message if last session is less than 12 hours old.
-                App::raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__);
+                $app->raiseMsg(_("Your session has expired. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
             }
 
             // Log the reason for login expiration.
             $expire_reasons = array();
-            if (empty($_SESSION[$this->_sess]['username'])) {
+            if (empty($_SESSION[$this->_ns]['username'])) {
                 $expire_reasons[] = 'username not found';
             }
-            if (strtotime($_SESSION[$this->_sess]['login_datetime']) <= time() - $this->_params['login_timeout']) {
+            if (strtotime($_SESSION[$this->_ns]['login_datetime']) <= time() - $this->_params['login_timeout']) {
                 $expire_reasons[] = 'login_timeout expired';
             }
-            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
+            if (strtotime($_SESSION[$this->_ns]['last_access_datetime']) <= time() - $this->_params['idle_timeout']) {
                 $expire_reasons[] = 'idle_timeout expired';
             }
-            if ($_SESSION[$this->_sess]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
-                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr());
-            }
-            App::logMsg(sprintf('%s %s (%s) session expired: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
+            if ($_SESSION[$this->_ns]['remote_ip'] != getRemoteAddr() && !$user_in_trusted_network) {
+                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_ns]['remote_ip'], getRemoteAddr());
+            }
+            $app->logMsg(sprintf('User %s (%s) session expired: %s', $this->getVal('user_id'), $this->getVal('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
         }
 
@@ -566,11 +585,13 @@
     function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
     {
+		$app =& App::getInstance();
+    
         if (!$this->isLoggedIn()) {
             // Display message for requiring login. (RaiseMsg will ignore empty strings.)
-            App::raiseMsg($message, $type, $file, $line);
+            $app->raiseMsg($message, $type, $file, $line);
 
             // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
-            App::setBoomerangURL(absoluteMe(), 'login');
-            App::dieURL($this->_params['login_url']);
+            $app->setBoomerangURL(absoluteMe(), 'login');
+            $app->dieURL($this->_params['login_url']);
         }
     }
@@ -584,19 +605,22 @@
     function blockAccount($user_id=null, $reason='')
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+	
         $this->initDB();
 
         if ($this->getParam('blocking')) {
-            if (strlen(DB::escapeString($reason)) > 255) {
+            if (strlen($db->escapeString($reason)) > 255) {
                 // blocked_reason field is varchar(255).
-                App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);
             }
 
             // Get user_id if specified.
             $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
-            DB::query("
+            $db->query("
                 UPDATE " . $this->_params['db_table'] . " SET
                 blocked = 'true',
-                blocked_reason = '" . DB::escapeString($reason) . "'
-                WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+                blocked_reason = '" . $db->escapeString($reason) . "'
+                WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
             ");
         }
@@ -608,14 +632,16 @@
     function unblockAccount($user_id=null)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
-
+	
         if ($this->getParam('blocking')) {
             // Get user_id if specified.
             $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
-            DB::query("
+            $db->query("
                 UPDATE " . $this->_params['db_table'] . " SET
                 blocked = '',
                 blocked_reason = ''
-                WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+                WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
             ");
         }
@@ -630,10 +656,12 @@
     function usernameExists($username)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT 1
             FROM " . $this->_params['db_table'] . "
-            WHERE " . $this->_params['db_username_column'] . " = '" . DB::escapeString($username) . "'
+            WHERE " . $this->_params['db_username_column'] . " = '" . $db->escapeString($username) . "'
         ");
         return (mysql_num_rows($qid) > 0);
@@ -648,10 +676,12 @@
     function getUsername($user_id)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT " . $this->_params['db_username_column'] . "
             FROM " . $this->_params['db_table'] . "
-            WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+            WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
         ");
         if (list($username) = mysql_fetch_row($qid)) {
@@ -698,4 +728,10 @@
     function encryptPassword($password, $salt=null)
     {
+        $app =& App::getInstance();
+        
+        // Existing password hashes rely on the same key/salt being used to compare encryptions.
+        // Don't change this unless you know existing hashes or signatures will not be affected!
+        $more_salt = 'B36D18E5-3FE4-4D58-8150-F26642852B81';
+        
         switch ($this->_params['encryption_type']) {
         case AUTH_ENCRYPT_PLAINTEXT :
@@ -709,10 +745,32 @@
 
         case AUTH_ENCRYPT_SHA1 :
-            return sha1(App::getParam('signing_key') . sha1($password));
+            return sha1($password);
             break;
 
+        case AUTH_ENCRYPT_SHA1_HARDENED :
+            $hash = sha1($app->getParam('signing_key') . $password . $more_salt);
+            // Increase key strength by 12 bits.
+            for ($i=0; $i < 4096; $i++) { 
+                $hash = sha1($hash); 
+            } 
+            return $hash;
+            break;
+
         case AUTH_ENCRYPT_MD5 :
+            return md5($password);
+            break;
+
+        case AUTH_ENCRYPT_MD5_HARDENED :
+            // Include salt to improve hash
+            $hash = md5($app->getParam('signing_key') . $password . $more_salt);
+            // Increase key strength by 12 bits.
+            for ($i=0; $i < 4096; $i++) { 
+                $hash = md5($hash); 
+            } 
+            return $hash;
+            break;
         default :
-            return md5(App::getParam('signing_key') . md5($password));
+            $app->logMsg(sprintf('Authentication encrypt type specified is unrecognized: %s', $this->_params['encryption_type']), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
             break;
         }
@@ -724,4 +782,7 @@
     function setPassword($user_id=null, $password)
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+	
         $this->initDB();
 
@@ -730,12 +791,12 @@
 
         // Issue the password change query.
-        DB::query("
+        $db->query("
             UPDATE " . $this->_params['db_table'] . "
-            SET userpass = '" . DB::escapeString($this->encryptPassword($password)) . "'
-            WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+            SET userpass = '" . $db->escapeString($this->encryptPassword($password)) . "'
+            WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
         ");
         
-        if (mysql_affected_rows(DB::getDBH()) != 1) {
-            App::logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__);
+        if (mysql_affected_rows($db->getDBH()) != 1) {
+            $app->logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__);
         }
     }
@@ -750,4 +811,7 @@
     function resetPassword($user_id=null, $reason='')
     {
+		$app =& App::getInstance();
+    	$db =& DB::getInstance();
+	
         $this->initDB();
 
@@ -756,10 +820,10 @@
 
         // Reset password of a specific user.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT * FROM " . $this->_params['db_table'] . "
-            WHERE " . $this->_params['db_primary_key'] . " = '" . DB::escapeString($user_id) . "'
+            WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
         ");
         if (!$user_data = mysql_fetch_assoc($qid)) {
-            App::logMsg(sprintf('Reset password failed. %s %s not found.', ucfirst($this->_auth), $user_id), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Reset password failed. User %s not found.', $user_id), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -773,5 +837,5 @@
         // Make sure user has an email on record before continuing.
         if (!isset($user_data['email']) || '' == trim($user_data['email'])) {
-            App::logMsg(sprintf('Password reset but notification failed, no email address for %s %s (%s).', $this->_auth, $user_data[$this->_params['db_primary_key']], $user_data[$this->_params['db_username_column']]), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Password reset but notification failed, no email address for user %s (%s).', $user_data[$this->_params['db_primary_key']], $user_data[$this->_params['db_username_column']]), LOG_NOTICE, __FILE__, __LINE__);
         } else {
             // Body for email.
@@ -794,11 +858,11 @@
             $email = new Email(array(
                 'to' => $user_data['email'],
-                'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),
-                'subject' => sprintf('%s password change', App::getParam('site_name'))
+                'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')),
+                'subject' => sprintf('%s password change', $app->getParam('site_name'))
             ));
             $email->setString($email_body);
             $email->replace(array(
-                'site_name' => App::getParam('site_name'),
-                'site_url' => App::getParam('site_url'),
+                'site_name' => $app->getParam('site_name'),
+                'site_url' => $app->getParam('site_url'),
                 'name' => ('' != $user_data['first_name'] . $user_data['last_name'] ? $user_data['first_name'] . ' ' . $user_data['last_name'] : $user_data[$this->_params['db_username_column']]),
                 'username' => $user_data[$this->_params['db_username_column']],
@@ -846,4 +910,6 @@
     function requireAccessClearance($security_zone, $message='')
     {
+		$app =& App::getInstance();
+    
         return true;
         $zone_members = preg_split('/,\s*/', $security_zone);
@@ -853,6 +919,6 @@
         if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) {
             $message = empty($message) ? _("You have insufficient privileges to view that page.") : $message;
-            App::raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
-            App::dieBoomerangURL();
+            $app->raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
+            $app->dieBoomerangURL();
         }
     }
Index: trunk/lib/AuthorizeNet.inc.php
===================================================================
--- trunk/lib/AuthorizeNet.inc.php	(revision 124)
+++ trunk/lib/AuthorizeNet.inc.php	(revision 136)
@@ -1,3 +1,15 @@
 <?php
+/**
+ * AuthorizeNet.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The AuthorizeNet class provides an abstract interface for communicating
+ * with authorize.net's AIM interface. Supports Auth.Net v3.1
+ *
+ * @author  Quinn Comendant <quinn@strangecode.com>
+ * @version 1.0
+ * @date 2004-04-06
+ */
+ 
 // Example usage
 // require_once 'codebase/lib/AuthorizeNet.inc.php';
@@ -14,5 +26,5 @@
 //     'x_Exp_Date' => '042008',
 //     'x_Invoice_Num' => '100',
-//     'x_Address' => '10 rue Levouv',
+//     'x_Address' => '10 rue LevouvÃ©',
 //     'x_City' => 'SomeCity',
 //     'x_State' => 'CA',
@@ -27,17 +39,6 @@
 // }
 
-/**
- * The AuthorizeNet class provides an abstract interface for communicating
- * with authorize.net's AIM interface. Supports Auth.Net v3.1
- *
- * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.0
- * @date 2004-04-06
- */
-
-require_once dirname(__FILE__) . '/Utilities.inc.php';
-
-class AuthorizeNet
-{
+class AuthorizeNet {
+
     var $post_url = ''; // The URL to post data to.
     var $md5_hash_value = ','; // A custom value for the response delimination character.
@@ -132,9 +133,11 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+    
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -149,8 +152,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -167,12 +172,14 @@
     function process()
     {
+		$app =& App::getInstance();
+    
         if (empty($this->_params['x_login'])) {
             $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
-            App::logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__);
             return false;
         }
         if (empty($this->_params['x_card_num'])) {
             $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
-            App::logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__);
             return false;
         }
Index: trunk/lib/CSS.inc.php
===================================================================
--- trunk/lib/CSS.inc.php	(revision 124)
+++ trunk/lib/CSS.inc.php	(revision 136)
@@ -28,9 +28,11 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+    
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -45,8 +47,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -58,22 +62,24 @@
      * @access  public
      * @param   string  $file   Include path to css files.
-     * @param   mixed   $apps   App name string or array of app names.
+     * @param   mixed   $realms   Realm name string or array of realm names.
      * @return  bool    True on success, false on failure.
      */
-    function setFile($file, $apps='')
+    function setFile($file, $realms='')
     {
-        if (!is_array($apps)) {
-            $apps = array($apps);
+		$app =& App::getInstance();
+    
+        if (!is_array($realms)) {
+            $realms = array($realms);
         }
 
         if ($fp = fopen($file, 'r', true)) {
-            foreach ($apps as $app) {
-                $app = '' == $app ? 'default' : $app;
-                $this->_css_files[$app][] = $file;
+            foreach ($realms as $realm) {
+                $realm = '' == $realm ? 'default' : $realm;
+                $this->_css_files[$realm][] = $file;
             }
             fclose($fp);
             return true;
         } else {
-            App::logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -87,10 +93,12 @@
      * @return  bool    False if no files have been set.
      */
-    function headers($app='')
+    function headers($realm='')
     {
-        $app = '' == $app ? 'default' : $app;
+		$app =& App::getInstance();
+    
+        $realm = '' == $realm ? 'default' : $realm;
 
-        if (empty($this->_css_files[$app])) {
-            App::logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
+        if (empty($this->_css_files[$realm])) {
+            $app->logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -98,5 +106,5 @@
         // Get time of latest modified file, including this class file.
         $files_mtime = array();
-        foreach (array_merge($this->_css_files[$app], array(__FILE__)) as $file) {
+        foreach (array_merge($this->_css_files[$realm], array(__FILE__)) as $file) {
             $files_mtime[] = statIncludePath($file, 'mtime');
         }
@@ -122,14 +130,14 @@
      * @return  bool    False if no files have been set.
      */
-    function output($app='')
+    function output($realm='')
     {
-        $app = '' == $app ? 'default' : $app;
+        $realm = '' == $realm ? 'default' : $realm;
 
-        if (empty($this->_css_files[$app])) {
-            App::logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
+        if (empty($this->_css_files[$realm])) {
+            $app->logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
 
-        foreach ($this->_css_files[$app] as $file) {
+        foreach ($this->_css_files[$realm] as $file) {
             include $file;
         }
Index: trunk/lib/Captcha.inc.php
===================================================================
--- trunk/lib/Captcha.inc.php	(revision 124)
+++ trunk/lib/Captcha.inc.php	(revision 136)
@@ -118,5 +118,7 @@
     function Captcha()
     {
-        $this->secret_key = App::getParam('signing_key');
+		$app =& App::getInstance();
+    
+        $this->secret_key = $app->getParam('signing_key');
         $this->random_number = $this->_getRandomNumber();
     }
@@ -133,4 +135,6 @@
     function getAsciiNumber($num=null)
     {
+		$app =& App::getInstance();
+    
         if (!isset($num)) {
             $num = $this->random_number;
@@ -138,5 +142,5 @@
 
         if (preg_match('/[^\d]/', $num)) {
-            App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
Index: trunk/lib/DB.inc.php
===================================================================
--- trunk/lib/DB.inc.php	(revision 124)
+++ trunk/lib/DB.inc.php	(revision 136)
@@ -4,16 +4,16 @@
  * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
  *
- * DB abstraction layer.
+ * Very lightweight DB semi-abstraction layer. Mainly to catch errors with mysql_query, with some goodies.
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.0.1
+ * @version 2.1
  */
 
 class DB {
 
-    // If DB::connect has successfully opened a db connection.
+    // If $db->connect has successfully opened a db connection.
     var $_connected = false;
 
-    // Database handler.
+    // Database handle.
     var $dbh;
 
@@ -30,8 +30,12 @@
         'db_pass' => null,
 
-        // Debugging.
-        'db_always_debug' => false, // TRUE = display all SQL queries.
-        'db_debug' => false, // TRUE = display db errors.
-        'db_die_on_failure' => false, // TRUE = script stops on db error.
+        // Display all SQL queries.
+        'db_always_debug' => false,
+
+        // Display db errors.
+        'db_debug' => false,
+        
+        // Script stops on db error.
+        'db_die_on_failure' => false,
     );
 
@@ -49,5 +53,5 @@
      * This method enforces the singleton pattern for this class.
      *
-     * @return  object  Reference to the global SessionCache object.
+     * @return  object  Reference to the global DB object.
      * @access  public
      * @static
@@ -65,55 +69,37 @@
 
     /**
-     * Constructor.
-     */
-    function DB()
-    {
-        // Initialize default params.
+     * Set (or overwrite existing) parameters by passing an array of new parameters.
+     *
+     * @access public
+     *
+     * @param  array    $params     Array of parameters (key => val pairs).
+     */
+    function setParam($params)
+    {
+		$app =& App::getInstance();
+    
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
-        }
-    }
-
-    /**
-     * Set (or overwrite existing) parameters by passing an array of new parameters.
+        } else {
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+        }
+    }
+
+    /**
+     * Return the value of a parameter, if it exists.
      *
      * @access public
-     *
-     * @param  array    $params     Array of parameters (key => val pairs).
-     */
-    function setParam($params)
-    {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (isset($params) && is_array($params)) {
-            // Merge new parameters with old overriding only those passed.
-            $_this->_params = array_merge($_this->_params, $params);
+     * @param string $param        Which parameter to return.
+     * @return mixed               Configured parameter value.
+     */
+    function getParam($param)
+    {
+		$app =& App::getInstance();
+    
+        if (isset($this->_params[$param])) {
+            return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
-        }
-    }
-
-    /**
-     * Return the value of a parameter.
-     *
-     * @access  public
-     *
-     * @param   string  $param      The key of the parameter to return.
-     *
-     * @return  mixed               Parameter value.
-     */
-    function getParam($param)
-    {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (isset($_this->_params[$param])) {
-            return $_this->_params[$param];
-        } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -129,33 +115,29 @@
     function connect()
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) {
-            App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
+		$app =& App::getInstance();
+    
+        if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) {
+            $app->logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
             return false;
         }
 
         // Connect to database. Always create a new link to the server.
-        if ($_this->dbh = mysql_connect($_this->getParam('db_server'), $_this->getParam('db_user'), $_this->getParam('db_pass'), true)) {
+        if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
             // Select database
-            mysql_select_db($_this->getParam('db_name'), $_this->dbh);
+            mysql_select_db($this->getParam('db_name'), $this->dbh);
         }
 
         // Test for connection errors.
-        if (!$_this->dbh || mysql_error($_this->dbh)) {
-            $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.';
-            App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
+        if (!$this->dbh || mysql_error($this->dbh)) {
+            $mysql_error_msg = $this->dbh ? 'Codebase MySQL error: (' . mysql_errno($this->dbh) . ') ' . mysql_error($this->dbh) : 'Codebase MySQL error: Could not connect to server.';
+            $app->logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
 
             // Print helpful or pretty error?
-            if ($_this->getParam('db_debug')) {
+            if ($this->getParam('db_debug')) {
                 echo $mysql_error_msg . "\n";
-            } else {
-                echo _("This page is temporarily unavailable. It should be back up in a few minutes.");
             }
 
             // Die or continue without connection?
-            if ($_this->getParam('db_die_on_failure')) {
+            if ($this->getParam('db_die_on_failure')) {
                 echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
                 die;
@@ -166,8 +148,8 @@
 
         // DB connection success!
-        $_this->_connected = true;
+        $this->_connected = true;
 
         // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01.
-        $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
+        $this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower($app->getParam('character_set'))] . "' */");
 
         return true;
@@ -183,13 +165,9 @@
     function close()
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->_connected) {
-            return false;
-        }
-
-        mysql_close($_this->dbh);
+        if (!$this->_connected) {
+            return false;
+        }
+
+        return mysql_close($this->dbh);
     }
 
@@ -204,13 +182,9 @@
     function getDBH()
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->_connected) {
-            return false;
-        }
-
-        return $_this->dbh;
+        if (!$this->_connected) {
+            return false;
+        }
+
+        return $this->dbh;
     }
 
@@ -224,5 +198,5 @@
     function isConnected()
     {
-        return $this->_connected;
+        return (true === $this->_connected);
     }
     
@@ -238,8 +212,9 @@
     function escapeString($string)
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-        return mysql_real_escape_string($string, $_this->dbh);
+        if (!$this->_connected) {
+            return false;
+        }
+
+        return mysql_real_escape_string($string, $this->dbh);
     }
 
@@ -253,12 +228,9 @@
      */
     function query($query, $debug=false)
-    {
+    {    
         static $_query_count = 0;
-
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->_connected) {
+        $app =& App::getInstance();
+
+        if (!$this->_connected) {
            return false;
         }
@@ -266,20 +238,20 @@
         $_query_count++;
         $debugqry = preg_replace("/\n[\t ]+/", "\n", $query);
-        if ($_this->getParam('db_always_debug') || $debug) {
+        if ($this->getParam('db_always_debug') || $debug) {
             echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n";
         }
 
         // Execute!
-        $qid = mysql_query($query, $_this->dbh);
+        $qid = mysql_query($query, $this->dbh);
 
         // Error checking.
-        if (!$qid || mysql_error($_this->dbh)) {
-            if ($_this->getParam('db_debug')) {
-                echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($_this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
+        if (!$qid || mysql_error($this->dbh)) {
+            if ($this->getParam('db_debug')) {
+                echo '<pre style="padding:2em; background:#ddd; font:9px monaco;">' . wordwrap(mysql_error($this->dbh)) . '<hr>' . htmlspecialchars($debugqry) . '</pre>';
             } else {
                 echo _("This page is temporarily unavailable. It should be back up in a few minutes.");
             }
-            App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
-            if ($_this->getParam('db_die_on_failure')) {
+            $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($this->dbh), mysql_error($this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
+            if ($this->getParam('db_die_on_failure')) {
                 echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
                 die;
@@ -302,23 +274,21 @@
     function tableExists($table, $use_cached_results=true)
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->_connected) {
-            return false;
-        }
-
-        if (!isset($_this->existing_tables) || !$use_cached_results) {
-            $_this->existing_tables = array();
-            $qid = $_this->query("SHOW TABLES");
+		$app =& App::getInstance();
+    
+        if (!$this->_connected) {
+            return false;
+        }
+
+        if (!isset($this->existing_tables) || !$use_cached_results) {
+            $this->existing_tables = array();
+            $qid = $this->query("SHOW TABLES");
             while (list($row) = mysql_fetch_row($qid)) {
-                $_this->existing_tables[] = $row;
-            }
-        }
-        if (in_array($table, $_this->existing_tables)) {
+                $this->existing_tables[] = $row;
+            }
+        }
+        if (in_array($table, $this->existing_tables)) {
             return true;
         } else {
-            App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
+            $app->logMsg(sprintf('nonexistent DB table: %s.%s', $this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
             return false;
         }
@@ -336,14 +306,10 @@
     function columnExists($table, $columns, $strict=true, $use_cached_results=true)
     {
-        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
-            $_this =& DB::getInstance();
-        }
-
-        if (!$_this->_connected) {
+        if (!$this->_connected) {
             return false;
         }
 
         // Ensure the table exists.
-        if (!$_this->tableExists($table, $use_cached_results)) {
+        if (!$this->tableExists($table, $use_cached_results)) {
             return false;
         }
@@ -354,10 +320,10 @@
         }
 
-        if (!isset($_this->table_columns[$table]) || !$use_cached_results) {
+        if (!isset($this->table_columns[$table]) || !$use_cached_results) {
             // Populate and cache array of current columns for this table.
-            $_this->table_columns[$table] = array();
-            $qid = $_this->query("DESCRIBE $table");
+            $this->table_columns[$table] = array();
+            $qid = $this->query("DESCRIBE $table");
             while ($row = mysql_fetch_row($qid)) {
-                $_this->table_columns[$table][] = $row[0];
+                $this->table_columns[$table][] = $row[0];
             }
         }
@@ -366,9 +332,9 @@
             // Do an exact comparison of table schemas.
             sort($columns);
-            sort($_this->table_columns[$table]);
-            return $_this->table_columns[$table] == $columns;
+            sort($this->table_columns[$table]);
+            return $this->table_columns[$table] == $columns;
         } else {
             // Only check that the specified columns are available in the table.
-            $match_columns = array_intersect($_this->table_columns[$table], $columns);
+            $match_columns = array_intersect($this->table_columns[$table], $columns);
             sort($columns);
             sort($match_columns);
Index: trunk/lib/DBSessionHandler.inc.php
===================================================================
--- trunk/lib/DBSessionHandler.inc.php	(revision 124)
+++ trunk/lib/DBSessionHandler.inc.php	(revision 136)
@@ -3,6 +3,7 @@
  * DBSessionHandler.inc.php
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.
+ * 
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.3
+ * @version 2.1
  * @since   1999
  */
@@ -13,8 +14,4 @@
 
     var $_params = array(
-        'db_server' => 'localhost',
-        'db_name' => '',
-        'db_user' => '',
-        'db_pass' => '',
         'db_table' => 'session_tbl',
         'create_table' => true, // Automatically create table and verify columns. Better set to false after site launch.
@@ -30,59 +27,38 @@
      * @since   18 Jul 2005 11:02:50
      */
-    function DBSessionHandler($db=null, $params=array())
+    function DBSessionHandler($db, $params=array())
     {
+		$app =& App::getInstance();
+    
         $this->_params = array_merge($this->_params, $params);
 
-        if (isset($db)) {
-            if (is_a($db, 'DB')) {
-                if ($db->isConnected()) {
-                    // Use existing db connection.
-                    $this->db =& $db;
-                } else {
-                    App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);
+        if (!method_exists($db, 'isConnected')) {
+            $app->logMsg(sprintf('Provided object (%s) is not a valid DB object.', get_class($db)), LOG_ERR, __FILE__, __LINE__);
+        } else {
+            if (!$db->isConnected()) {
+                $app->logMsg('Provided DB object is not connected.', LOG_ERR, __FILE__, __LINE__);
+            } else {
+                // OK! We have a valid, connected DB object.
+                $this->db =& $db;
+
+                // Get create tables config from global context.
+                if (!is_null($app->getParam('db_create_tables'))) {
+                    $this->_params['create_table'] = $app->getParam('db_create_tables');
                 }
-            } else {
-                App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);
+
+                // Ensure db table is fit.
+                $this->initDB();
+
+                ini_set('session.save_handler', 'user');
+                session_set_save_handler(
+                    array(&$this, 'dbSessionOpen'),
+                    array(&$this, 'dbSessionClose'),
+                    array(&$this, 'dbSessionRead'),
+                    array(&$this, 'dbSessionWrite'),
+                    array(&$this, 'dbSessionDestroy'),
+                    array(&$this, 'dbSessionGarbage')
+                );
             }
-        } else {
-            // Create our own new db connection.
-            require_once dirname(__FILE__) . '/DB.inc.php';
-
-            $this->db =& new DB();
-            $this->db->setParam(array(
-                'db_server' => $this->_params['db_server'],
-                'db_name' => $this->_params['db_name'],
-                'db_user' => $this->_params['db_user'],
-                'db_pass' => $this->_params['db_pass'],
-                'db_always_debug' => $this->_params['db_always_debug'],
-                'db_debug' => $this->_params['db_debug'],
-                'db_die_on_failure' => $this->_params['db_die_on_failure'],
-            ));
-
-            // Connect to database.
-            $this->db->connect();
         }
-
-        if (!isset($this) || !is_a($this->db, 'DB') || !$this->db->isConnected()) {
-            trigger_error('Invalid DB object or unable to connect to database.', E_USER_ERROR);
-        }
-
-        // Get create tables config from global context.
-        if (!is_null(App::getParam('db_create_tables'))) {
-            $this->_params['create_table'] = App::getParam('db_create_tables');
-        }
-
-        // Ensure db table is fit.
-        $this->initDB();
-
-        ini_set('session.save_handler', 'user');
-        session_set_save_handler(
-            array(&$this, 'dbSessionOpen'),
-            array(&$this, 'dbSessionClose'),
-            array(&$this, 'dbSessionRead'),
-            array(&$this, 'dbSessionWrite'),
-            array(&$this, 'dbSessionDestroy'),
-            array(&$this, 'dbSessionGarbage')
-        );
     }
 
@@ -96,12 +72,14 @@
     function initDB($recreate_db=false)
     {
+		$app =& App::getInstance();
+    
         static $_db_tested = false;
 
         if ($recreate_db || !$_db_tested && $this->_params['create_table']) {
             if ($recreate_db) {
-                $this->db->query("DROP TABLE IF EXISTS " . $this->_params['db_table']);
-                App::logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__);
+                $this->db->query("DROP TABLE IF EXISTS " . $this->db->escapeString($this->_params['db_table']));
+                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__);
             }
-            $this->db->query("CREATE TABLE IF NOT EXISTS " . $this->_params['db_table'] . " (
+            $this->db->query("CREATE TABLE IF NOT EXISTS " . $this->db->escapeString($this->_params['db_table']) . " (
                 session_id char(32) NOT NULL default '',
                 session_data mediumtext NOT NULL,
@@ -112,5 +90,5 @@
 
             if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) {
-                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
                 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR);
             }
@@ -132,5 +110,5 @@
     {
         // Select the data belonging to session $session_id from the session table
-        $qid = $this->db->query("SELECT session_data FROM " . $this->_params['db_table'] . " WHERE session_id = '" . $this->db->escapeString($session_id) . "'");
+        $qid = $this->db->query("SELECT session_data FROM " . $this->db->escapeString($this->_params['db_table']) . " WHERE session_id = '" . $this->db->escapeString($session_id) . "'");
 
         // Return the session data that was found
@@ -147,5 +125,5 @@
     {
         // Write the serialized session data ($session_data) to the session table
-        $this->db->query("REPLACE INTO " . $this->_params['db_table'] . "(session_id, session_data, last_access) VALUES ('" . $this->db->escapeString($session_id) . "', '" . $this->db->escapeString($session_data) . "', null)");
+        $this->db->query("REPLACE INTO " . $this->db->escapeString($this->_params['db_table']) . "(session_id, session_data, last_access) VALUES ('" . $this->db->escapeString($session_id) . "', '" . $this->db->escapeString($session_data) . "', null)");
 
         return true;
@@ -155,5 +133,5 @@
     {
         // Delete from the table all data for the session $session_id
-        $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE session_id = '" . $this->db->escapeString($session_id) . "'");
+        $this->db->query("DELETE FROM " . $this->db->escapeString($this->_params['db_table']) . " WHERE session_id = '" . $this->db->escapeString($session_id) . "'");
 
         return true;
@@ -163,5 +141,5 @@
     {
         // Delete old values from the session table
-        $qid = $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE UNIX_TIMESTAMP(last_access) < " . (time() - $max_lifetime));
+        $qid = $this->db->query("DELETE FROM " . $this->db->escapeString($this->_params['db_table']) . " WHERE UNIX_TIMESTAMP(last_access) < " . (time() - $max_lifetime));
 
         return true;
Index: trunk/lib/Email.inc.php
===================================================================
--- trunk/lib/Email.inc.php	(revision 124)
+++ trunk/lib/Email.inc.php	(revision 136)
@@ -8,9 +8,10 @@
  * @author  Quinn Comendant <quinn@strangecode.com>
  * @version 1.0
--------------------------------------------------------------------------------------
+ * 
+ 
 // Example.
 $email = new Email(array(
     'to' => array($frm['email'], 'q@lovemachine.local'),
-    'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),
+    'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')),
     'subject' => 'Your account has been activated',
 ));
@@ -18,15 +19,16 @@
 // $email->setString('Or you can pass your message body as a string, also with {VARIABLES}.');
 $email->replace(array(
-    'site_name' => App::getParam('site_name'),
-    'site_url' => App::getParam('site_url'),
+    'site_name' => $app->getParam('site_name'),
+    'site_url' => $app->getParam('site_url'),
     'username' => $frm['username'],
     'password' => $frm['password1'],
 ));
 if ($email->send()) {
-    App::raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__);
 } else {
-    App::logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__);
+    $app->logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__);
 }
--------------------------------------------------------------------------------------
+
+ * 
  */
 class Email {
@@ -88,4 +90,6 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+    
         if (isset($params) && is_array($params)) {
             // Enforce valid email addresses.
@@ -100,5 +104,5 @@
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -113,8 +117,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -131,7 +137,9 @@
     function setTemplate($template)
     {
+		$app =& App::getInstance();
+    
         // Load file, using include_path.
         if (!$this->_template = file_get_contents($template, true)) {
-            App::logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__);
             $this->_template = null;
             $this->_template_replaced = null;
@@ -153,7 +161,9 @@
     function setString($string)
     {
+		$app =& App::getInstance();
+    
         // Load file, using include_path.
         if ('' == trim($string)) {
-            App::logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
             $this->_template_replaced = null;
             return false;
@@ -176,7 +186,9 @@
     function replace($replacements)
     {
+		$app =& App::getInstance();
+    
         // Ensure template exists.
         if (!isset($this->_template)) {
-            App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -184,5 +196,5 @@
         // Ensure replacements argument is an array.
         if (!is_array($replacements)) {
-            App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -211,4 +223,6 @@
     function send($to=null, $from=null, $subject=null, $headers=null)
     {
+		$app =& App::getInstance();
+    
         // Use arguments if provided.
         if (isset($to)) {
@@ -227,14 +241,14 @@
         // Ensure required values exist.
         if (!isset($this->_params['subject'])) {
-            App::logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_template)) {
-            App::logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_params['to'])) {
-            App::logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_params['from'])) {
-            App::logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -245,5 +259,5 @@
         // Ensure all placeholders have been replaced. Find anything with {...} characters.
         if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
-            App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -273,5 +287,5 @@
         $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header));
         if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) {
-            App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
             sleep(3);
             return false;
@@ -280,8 +294,8 @@
         // Ensure message was successfully accepted for delivery.
         if (mail($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header)) {
-            App::logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__);
             return true;
         } else {
-            App::logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -305,4 +319,6 @@
     function validEmail($email)
     {
+		$app =& App::getInstance();
+    
         // If an array, check values recursively.
         if (is_array($email)) {
@@ -318,5 +334,5 @@
                 return true;
             } else {
-                App::logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);
                 return false;
             }
Index: trunk/lib/FormValidator.inc.php
===================================================================
--- trunk/lib/FormValidator.inc.php	(revision 124)
+++ trunk/lib/FormValidator.inc.php	(revision 136)
@@ -4,5 +4,5 @@
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
  *
- * The FormValidator:: class provides a method for validating input from
+ * The FormValidator class provides a method for validating input from
  * http requests and displaying errors.
  *
@@ -10,19 +10,27 @@
  * @version   1.8
  *
- * Examples of use:
- *
- * require_once 'codebase/lib/FormValidator.inc.php';
- * $fv = new FormValidator();
- *
- * $fv->isEmpty('location_name', _("<strong>Location name</strong> cannot be blank."));
- * $fv->checkRegex('cc_exp', '/^\d{4}$|^$/', true, _("CC exp date must be in MMYY format."));
- * $fv->isInteger('client_id', _("<strong>Client id</strong> must be an integer."));
- * $fv->numericRange('client_id', -32768, 32767, _("<strong>Client id</strong> must be a number between -32768 and 32767."));
- * $fv->stringLength('zip', 0, 255, _("<strong>Zip</strong> must contain less than 256 characters."));
- * $fv->validateEmail('invoice_email');
- * $fv->validatePhone('phone1');
+ * Example of use:
+---------------------------------------------------------------------
+// The object that validates form input.
+require_once 'codebase/lib/FormValidator.inc.php';
+$fv = new FormValidator();
+
+$fv->isEmpty('field_name', sprintf(_("%s cannot be blank."), _("Field name")));
+$fv->stringLength('field_name', 0, 255, sprintf(_("%s must be %f-to-%f characters in length."), _("Field name"), 0, 255));
+$fv->isInteger('field_name', sprintf(_("%s must be an integer."), _("Field name")));
+$fv->checkRegex('field_name', '/^\d{4}$|^$/', true, sprintf(_("%s must be in MMYY format."), _("Field name")));
+$fv->numericRange('field_name', 0, 65535, sprintf(_("%s must be a number between %f and %f."), _("Field name"), 0, 65535));
+$fv->validatePhone('field_name');
+$fv->validateEmail('field_name');
+$fv->validateStrDate('field_name', sprintf(_("%s must be a valid date in YYYY-MM-DD format."), _("Field name")));
+if (is_null($var)) {
+    $fv->addError('field_name', sprintf(_("%s is invalid."), _("Field name")));
+}
+if ($fv->anyErrors()) {
+    // Errors!
+}
+---------------------------------------------------------------------
  */
-class FormValidator
-{
+class FormValidator {
 
     // Array filling with error messages.
@@ -103,28 +111,29 @@
     function printErrorMessages()
     {
+        $app =& App::getInstance();
         if ($this->anyErrors()) {
             ?><div class="sc-msg"><?php
             $errors = $this->getErrorList();
-            foreach ($errors as $err) {
-                if (!empty($err['message']) && is_string($err['message'])) {
-                    if (error_reporting() > 0 && isset($err['file']) && isset($err['line'])) {
-                        echo "\n<!-- [" . $err['file'] . ' : ' . $err['line'] . '] -->';
+            foreach ($errors as $e) {
+                if ('' != $e['message'] && is_string($e['message'])) {
+                    if (error_reporting() > 0 && $app->getParam('display_errors') && isset($e['file']) && isset($e['line'])) {
+                        echo "\n<!-- [" . $e['file'] . ' : ' . $e['line'] . '] -->';
                     }
-                    switch ($err['type']) {
+                    switch ($e['type']) {
                     case MSG_ERR:
-                        echo '<div class="sc-msg-error">' . $err['message'] . '</div>';
+                        echo '<div class="sc-msg-error">' . $e['message'] . '</div>';
                         break;
 
                     case MSG_WARNING:
-                        echo '<div class="sc-msg-warning">' . $err['message'] . '</div>';
+                        echo '<div class="sc-msg-warning">' . $e['message'] . '</div>';
                         break;
 
                     case MSG_SUCCESS:
-                        echo '<div class="sc-msg-success">' . $err['message'] . '</div>';
+                        echo '<div class="sc-msg-success">' . $e['message'] . '</div>';
                         break;
 
                     case MSG_NOTICE:
                     default:
-                        echo '<div class="sc-msg-notice">' . $err['message'] . '</div>';
+                        echo '<div class="sc-msg-notice">' . $e['message'] . '</div>';
                         break;
                     }
@@ -389,4 +398,6 @@
     function validateEmail($form_name)
     {
+		$app =& App::getInstance();
+    
         $email = getFormData($form_name);
         if ('' == trim($email)) {
@@ -400,5 +411,5 @@
         if (!preg_match($e->getParam('regex'), $email, $e_parts)) {
             $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email address."), oTxt($email)));
-            App::logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
@@ -412,5 +423,5 @@
         if (strlen($local) > 64 || strlen($domain) > 191) {
             $this->addError($form_name, sprintf(_("<strong>Email address</strong> must contain less than 256 characters."), oTxt($email)));
-            App::logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
@@ -420,5 +431,5 @@
         if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
             $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email domain name"), oTxt($domain)));
-            App::logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__);
             return false;
         }
@@ -454,7 +465,9 @@
     function validateStrDate($form_name, $msg='')
     {
+		$app =& App::getInstance();
+    
         if (($timestamp = strtotime(getFormData($form_name, '0'))) === -1) {
             $this->addError($form_name, $msg);
-            App::logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         } else {
@@ -530,5 +543,5 @@
         for ($i=0; $i<$num; $i++) {
             // Get each digit.
-            $digit = substr($cc_num,$i,1);
+            $digit = substr($cc_num, $i, 1);
 
             //  If it's an odd digit, double it.
@@ -539,5 +552,5 @@
             //  If the result is two digits, add them.
             if (strlen($digit) == 2) {
-                $digit = substr($digit,0,1) + substr($digit,1,1);
+                $digit = substr($digit, 0, 1) + substr($digit, 1, 1);
             }
 
@@ -556,5 +569,5 @@
 
     /**
-     * Check whether uploaded file is valid.
+     * Check whether a file was selected for uploading. If file is missing, it's an error.
      *
      * @param  string $form_name the name of the incoming form variable
@@ -565,5 +578,5 @@
     function validateFile($form_name, $msg='')
     {
-        if (isset($_FILES[$form_name]['tmp_name']) && '' == trim($_FILES[$form_name]['tmp_name'])) {
+        if (!isset($_FILES[$form_name]['tmp_name']) || '' == trim($_FILES[$form_name]['tmp_name'])) {
             $this->addError($form_name, $msg);
             return false;
Index: trunk/lib/Google_API.inc.php
===================================================================
--- trunk/lib/Google_API.inc.php	(revision 124)
+++ trunk/lib/Google_API.inc.php	(revision 136)
@@ -1,4 +1,7 @@
 <?php
 /**
+ * Google_API.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
  * Interface to the Google API using SOAP/Client.php.
  *
@@ -25,13 +28,5 @@
 require_once 'SOAP/Client.php';
 
-
-/**
-* PHP Interface to the Google API
-*
-* @author  Sebastian Bergmann <sb@sebastian-bergmann.de>
-* @access  public
-*/
-class Google_API
-{
+class Google_API {
 
     /**
Index: trunk/lib/Hierarchy.inc.php
===================================================================
--- trunk/lib/Hierarchy.inc.php	(revision 124)
+++ trunk/lib/Hierarchy.inc.php	(revision 136)
@@ -2,8 +2,6 @@
 /**
  * Hierarchy.inc.php
- * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
- */
-
-/**
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ * 
  * Objective: This class provides the tools to organize pieces of data into a
  * hierarchy of nodes. Any form of data (article, product, image) can be
@@ -97,10 +95,12 @@
     function toStringID($child_type=null, $child_id=null)
     {
-        if (!isset($child_type) || !isset($child_id)) {
-            if ($this->node_init) {
-                $child_type =& $this->child_type;
-                $child_id =& $this->child_id;
-            } else {
-                App::logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+			$app =& App::getInstance();
+	
+            if (!isset($child_type) || !isset($child_id)) {
+            if ($this->node_init) {
+                $child_type =& $this->child_type;
+                $child_id =& $this->child_id;
+            } else {
+                $app->logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -129,8 +129,10 @@
     function toArrayID(&$node)
     {
-        if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) {
+			$app =& App::getInstance();
+	
+            if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) {
             return array('node_type' => $node_parts[1], 'node_id' => $node_parts[2]);
         } else {
-            App::logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -147,4 +149,7 @@
     function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='')
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -152,5 +157,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -159,6 +164,6 @@
         // Make sure this is not empty and an array, even if it has only one value.
         if ('' == $parents) {
-            App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
+            $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!is_array($parents)) {
@@ -174,11 +179,11 @@
             $parent = $this->toArrayID($parent_string);
             if ($this->nodeExists($child_type, $child_id, $parent['node_type'], $parent['node_id'], $relationship_type)) {
-                App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
+                $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
             if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) {
-                App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
+                $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -188,5 +193,5 @@
         foreach ($parents as $parent_string) {
             $parent = $this->toArrayID($parent_string);
-            DB::query("
+            $db->query("
                 INSERT INTO node_tbl (
                     parent_type,
@@ -197,13 +202,13 @@
                     title
                 ) VALUES (
-                    '" . DB::escapeString($parent['node_type']) . "',
-                    '" . DB::escapeString($parent['node_id']) . "',
-                    '" . DB::escapeString($child_type) . "',
-                    '" . DB::escapeString($child_id) . "',
-                    " . (is_null($relationship_type) ? "NULL" : "'" . DB::escapeString($relationship_type) . "'") . ",
-                    '" . DB::escapeString($title) . "'
+                    '" . $db->escapeString($parent['node_type']) . "',
+                    '" . $db->escapeString($parent['node_id']) . "',
+                    '" . $db->escapeString($child_type) . "',
+                    '" . $db->escapeString($child_id) . "',
+                    " . (is_null($relationship_type) ? "NULL" : "'" . $db->escapeString($relationship_type) . "'") . ",
+                    '" . $db->escapeString($title) . "'
                 )
             ");
-            App::logMsg(sprintf('insertNode: Added node %s %s with parent %s %s.', $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('insertNode: Added node %s %s with parent %s %s.', $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_DEBUG, __FILE__, __LINE__);
         }
         return true;
@@ -223,4 +228,7 @@
     function deleteNode($child_type=null, $child_id=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -228,5 +236,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -243,10 +251,10 @@
         }
 
-        DB::query("
+        $db->query("
             DELETE FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
         ");
-        App::logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
 
         return true;
@@ -270,10 +278,13 @@
     function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')
     {
-        if (!isset($child_type) || !isset($child_id)) {
-            if ($this->node_init) {
-                $child_type =& $this->child_type;
-                $child_id =& $this->child_id;
-            } else {
-                App::logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+			$app =& App::getInstance();
+			$db =& DB::getInstance();
+
+	        if (!isset($child_type) || !isset($child_id)) {
+            if ($this->node_init) {
+                $child_type =& $this->child_type;
+                $child_id =& $this->child_id;
+            } else {
+                $app->logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -282,6 +293,6 @@
         // Make sure this is not empty and an array, even if it has only one value.
         if (empty($new_parents)) {
-            App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
+            $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!is_array($new_parents)) {
@@ -296,11 +307,11 @@
             $parent = $this->toArrayID($parent_string);
             if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) {
-                App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
+                $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
             if ($this->isAncestor($child_type, $child_id, $parent['node_type'], $parent['node_id'])) {
-                App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
+                $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -309,9 +320,9 @@
         if (empty($title)) {
             // Select the title of the node we are moving, so we can add it again with the same info.
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT title FROM node_tbl
-                WHERE child_type = '" . DB::escapeString($child_type) . "'
-                AND child_id = '" . DB::escapeString($child_id) . "'
-                AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . "
+                WHERE child_type = '" . $db->escapeString($child_type) . "'
+                AND child_id = '" . $db->escapeString($child_id) . "'
+                AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . $db->escapeString($relationship_type) . "'") . "
             ");
             list($title) = mysql_fetch_row($qid);
@@ -319,11 +330,11 @@
 
         // Delete the nodes with the old parents.
-        DB::query("
+        $db->query("
             DELETE FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
-            AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . "
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
+            AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . $db->escapeString($relationship_type) . "'") . "
         ");
-        App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
 
         // Insert new nodes with the new parents.
@@ -344,4 +355,7 @@
     function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='')
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -349,5 +363,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -359,14 +373,14 @@
                 $type_constraint = array($type_constraint);
             }
-            $in_clause = "AND parent_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')";
-        }
-
-        $qid = DB::query("
+            $in_clause = "AND parent_type IN ('" . join("','", array_map(array($db, 'escapeString'), $type_constraint)) . "')";
+        }
+
+        $qid = $db->query("
             SELECT parent_type, parent_id
             FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
             $in_clause
-            " . DB::escapeString($order) . "
+            " . $db->escapeString($order) . "
         ");
 
@@ -392,4 +406,7 @@
     function getNode($child_type=null, $child_id=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -397,14 +414,14 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
-                return false;
-            }
-        }
-
-        $qid = DB::query("
+                $app->logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                return false;
+            }
+        }
+
+        $qid = $db->query("
             SELECT child_type, child_id, title, subnode_quantity
             FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
         ");
 
@@ -433,4 +450,7 @@
     function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='')
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -438,5 +458,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -448,14 +468,14 @@
                 $type_constraint = array($type_constraint);
             }
-            $in_clause = "AND child_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')";
-        }
-
-        $qid = DB::query("
+            $in_clause = "AND child_type IN ('" . join("','", array_map(array($db, 'escapeString'), $type_constraint)) . "')";
+        }
+
+        $qid = $db->query("
             SELECT *
             FROM node_tbl
-            WHERE parent_type = '" . DB::escapeString($child_type) . "'
-            AND parent_id = '" . DB::escapeString($child_id) . "'
+            WHERE parent_type = '" . $db->escapeString($child_type) . "'
+            AND parent_id = '" . $db->escapeString($child_id) . "'
             $in_clause
-            " . DB::escapeString($order) . "
+            " . $db->escapeString($order) . "
         ");
 
@@ -482,4 +502,7 @@
     function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -487,5 +510,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -497,12 +520,12 @@
                 $type_constraint = array($type_constraint);
             }
-            $in_clause = "AND child_type IN ('" . join("','", array_map(array('DB', 'escapeString'), $type_constraint)) . "')";
-        }
-
-        $qid = DB::query("
+            $in_clause = "AND child_type IN ('" . join("','", array_map(array($db, 'escapeString'), $type_constraint)) . "')";
+        }
+
+        $qid = $db->query("
             SELECT COUNT(*)
             FROM node_tbl
-            WHERE parent_type = '" . DB::escapeString($child_type) . "'
-            AND parent_id = '" . DB::escapeString($child_id) . "'
+            WHERE parent_type = '" . $db->escapeString($child_type) . "'
+            AND parent_id = '" . $db->escapeString($child_id) . "'
             $in_clause
         ");
@@ -520,4 +543,6 @@
     function isLeaf($child_type=null, $child_id=null)
     {
+		$app =& App::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -525,5 +550,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -579,12 +604,14 @@
     function getAllAncestors($child_type, $child_id, $go_linear=false, $_return_flag=true)
     {
+		$db =& DB::getInstance();
+	
         static $output = array();
         static $return_flag;
 
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT parent_type, parent_id, child_type, child_id, title, subnode_quantity
             FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
         ");
         while ($row = mysql_fetch_assoc($qid)) {
@@ -631,4 +658,7 @@
     function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+	
         if (!isset($child_type) || !isset($child_id)) {
             if ($this->node_init) {
@@ -636,5 +666,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -642,17 +672,17 @@
 
         if (isset($parent_type) && isset($parent_id)) {
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT 1 FROM node_tbl
-                WHERE parent_type = '" . DB::escapeString($parent_type) . "'
-                AND parent_id = '" . DB::escapeString($parent_id) . "'
-                AND child_type = '" . DB::escapeString($child_type) . "'
-                AND child_id = '" . DB::escapeString($child_id) . "'
-                AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . "
+                WHERE parent_type = '" . $db->escapeString($parent_type) . "'
+                AND parent_id = '" . $db->escapeString($parent_id) . "'
+                AND child_type = '" . $db->escapeString($child_type) . "'
+                AND child_id = '" . $db->escapeString($child_id) . "'
+                AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . $db->escapeString($relationship_type) . "'") . "
             ");
         } else {
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT 1 FROM node_tbl
-                WHERE child_type = '" . DB::escapeString($child_type) . "'
-                AND child_id = '" . DB::escapeString($child_id) . "'
+                WHERE child_type = '" . $db->escapeString($child_type) . "'
+                AND child_id = '" . $db->escapeString($child_id) . "'
             ");
         }
@@ -680,4 +710,6 @@
     function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true)
     {
+		$app =& App::getInstance();
+	
         static $output = array();
         static $is_a_leaf = array();
@@ -688,5 +720,5 @@
                 $child_id =& $this->child_id;
             } else {
-                App::logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -709,5 +741,5 @@
                 // Preventing circular references.
                 if ($my_children[$i]['child_type'] == $child_type && $my_children[$i]['child_id'] == $child_id && !($_return_flag && $include_curr)) {
-                    App::logMsg(sprintf(_("Circular reference detected: %s has itself as a parent."), $this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf(_("Circular reference detected: %s has itself as a parent."), $this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])), LOG_ERR, __FILE__, __LINE__);
                     continue;
                 }
@@ -751,9 +783,11 @@
     function rebuildSubnodeQty($type_constraint=null)
     {
+		$db =& DB::getInstance();
+	
         // Reset all the category counters to zero.
-        DB::query("UPDATE node_tbl SET subnode_quantity = 0");
+        $db->query("UPDATE node_tbl SET subnode_quantity = 0");
 
         // Get all the nodes.
-        $qid = DB::query("SELECT DISTINCT child_type, child_id FROM node_tbl");
+        $qid = $db->query("SELECT DISTINCT child_type, child_id FROM node_tbl");
 
         // For each node count the number of children...
@@ -773,15 +807,17 @@
     function setSubnodeQtyToParents($child_type, $child_id, $num_children)
     {
-        DB::query("
+		$db =& DB::getInstance();
+	
+        $db->query("
             UPDATE node_tbl
-            SET subnode_quantity = subnode_quantity + '" . DB::escapeString($num_children) . "'
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            SET subnode_quantity = subnode_quantity + '" . $db->escapeString($num_children) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
         ",false);
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT parent_type, parent_id
             FROM node_tbl
-            WHERE child_type = '" . DB::escapeString($child_type) . "'
-            AND child_id = '" . DB::escapeString($child_id) . "'
+            WHERE child_type = '" . $db->escapeString($child_type) . "'
+            AND child_id = '" . $db->escapeString($child_id) . "'
         ",false);
         while ((list($parent_type, $parent_id) = mysql_fetch_row($qid)) && $parent_id > 0) {
Index: trunk/lib/Image.inc.php
===================================================================
--- trunk/lib/Image.inc.php	(revision 124)
+++ trunk/lib/Image.inc.php	(revision 136)
@@ -2,5 +2,6 @@
 /**
  * Image.inc.php
- * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
  * @author  Quinn Comendant <quinn@strangecode.com>
  * @version 1.1
Index: trunk/lib/ImageThumb.inc.php
===================================================================
--- trunk/lib/ImageThumb.inc.php	(revision 124)
+++ trunk/lib/ImageThumb.inc.php	(revision 136)
@@ -2,5 +2,5 @@
 /**
  * ImageThumb.inc.php
- * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
  *
  * @author   Quinn Comendant <quinn@strangecode.com>
@@ -95,4 +95,6 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+
         if (isset($params) && is_array($params)) {
 
@@ -102,10 +104,10 @@
                 // Must be directory.
                 if (!is_dir($params['source_dir'])) {
-                    App::logMsg(sprintf('Source directory invalid: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Source directory invalid: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);
                     trigger_error(sprintf('Source directory invalid: %s', $params['source_dir']), E_USER_ERROR);
                 }
                 // Must be readable.
                 if (!is_readable($params['source_dir'])) {
-                    App::logMsg(sprintf('Source directory not readable: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Source directory not readable: %s', $params['source_dir']), LOG_ERR, __FILE__, __LINE__);
                     trigger_error(sprintf('Source directory not readable: %s', $params['source_dir']), E_USER_ERROR);
                 }
@@ -115,5 +117,5 @@
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -128,8 +130,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -144,7 +148,9 @@
     function setSpec($spec, $index=null)
     {
+		$app =& App::getInstance();
+
         // A little sanity checking.
         if (!isset($spec['dest_dir']) || '' == $spec['dest_dir']) {
-            App::logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__);
         }
         if (isset($spec['dest_file_type'])) {
@@ -152,5 +158,5 @@
             case IMG_JPG :
                 if (imagetypes() & IMG_JPG == 0) {
-                    App::logMsg(sprintf('IMG_JPG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('IMG_JPG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
                 }
                 $spec['dest_file_extention'] = 'jpg';
@@ -158,5 +164,5 @@
             case IMG_PNG :
                 if (imagetypes() & IMG_PNG == 0) {
-                    App::logMsg(sprintf('IMG_PNG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('IMG_PNG is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
                 }
                 $spec['dest_file_extention'] = 'png';
@@ -164,5 +170,5 @@
             case IMG_GIF :
                 if (imagetypes() & IMG_GIF == 0) {
-                    App::logMsg(sprintf('IMG_GIF is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('IMG_GIF is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
                 }
                 $spec['dest_file_extention'] = 'gif';
@@ -170,24 +176,24 @@
             case IMG_WBMP :
                 if (imagetypes() & IMG_WBMP == 0) {
-                    App::logMsg(sprintf('IMG_WBMP is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('IMG_WBMP is not supported by this version of PHP GD.', null), LOG_ERR, __FILE__, __LINE__);
                 }
                 $spec['dest_file_extention'] = 'wbmp';
                 break;
             default :
-                App::logMsg(sprintf('Invalid dest_file_type: %s', $spec['dest_file_type']), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Invalid dest_file_type: %s', $spec['dest_file_type']), LOG_ERR, __FILE__, __LINE__);
                 break;
             }
         }
         if (!isset($spec['width']) || !is_int($spec['width'])) {
-            App::logMsg('setSpec error: width not specified.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('setSpec error: width not specified.', LOG_ERR, __FILE__, __LINE__);
         }
         if (!isset($spec['height']) || !is_int($spec['height'])) {
-            App::logMsg('setSpec error: height not specified.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('setSpec error: height not specified.', LOG_ERR, __FILE__, __LINE__);
         }
         if (isset($spec['quality']) && IMG_JPG != $spec['dest_file_type']) {
-            App::logMsg('The "quality" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg('The "quality" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);
         }
         if (isset($spec['progressive']) && IMG_JPG != $spec['dest_file_type']) {
-            App::logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);
         }
         
@@ -213,7 +219,9 @@
     function processAll($runtime_specs=null)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a source.
         if ('' == $this->getParam('source_dir')) {
-            App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -237,5 +245,5 @@
             return 0 === $return_val;
         } else {
-            App::logMsg(sprintf('No images found to thumbnail in directory %s.', $this->getParam('source_dir')), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('No images found to thumbnail in directory %s.', $this->getParam('source_dir')), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -252,4 +260,6 @@
     function processFile($file_name, $runtime_specs=null)
     {
+		$app =& App::getInstance();
+
         // Source file determinted by provided file_name.
         $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name));
@@ -260,5 +270,5 @@
                 $this->setSpec($runtime_specs, 0);
             } else {
-                App::logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__);
                 return false;                
             }
@@ -267,5 +277,5 @@
         // Ensure we have a source.
         if ('' == $this->getParam('source_dir')) {
-            App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -274,5 +284,5 @@
         if (!file_exists($source_file)) {
             $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s was not found."), $file_name), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf('Source image not found: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source image not found: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
             return false;
         }
@@ -281,5 +291,5 @@
         if (!is_readable($source_file)) {
             $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is not readable."), $file_name), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf('Source image not readable: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source image not readable: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
             return false;
         }
@@ -288,5 +298,5 @@
         if (filesize($source_file) <= 0) {
             $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf('Source image is zero bytes: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source image is zero bytes: %s', $source_file), LOG_ALERT, __FILE__, __LINE__);
             return false;
         }
@@ -295,5 +305,5 @@
         if (!$this->_validFileExtension($file_name)) {
             $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s not a valid type. It must have one of the following file name extensions: %s"), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -324,5 +334,5 @@
                 $file_size = filesize($dest_file);
                 if (false !== $file_size && $file_size < $spec['keep_filesize']) {
-                    App::logMsg(sprintf('Skipping thumbnail %s. File already exists and file size is less than %s bytes.', $spec['dest_dir'] . '/' . $file_name, $spec['keep_filesize']), LOG_DEBUG, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Skipping thumbnail %s. File already exists and file size is less than %s bytes.', $spec['dest_dir'] . '/' . $file_name, $spec['keep_filesize']), LOG_DEBUG, __FILE__, __LINE__);
                     continue;
                 }
@@ -333,5 +343,5 @@
             if ($image_size['0'] <= $spec['width'] && $image_size['1'] <= $spec['height'] && !$spec['allow_upscaling']) {
                 $spec['scaling_type'] = IMAGETHUMB_NO_SCALE;
-                App::logMsg(sprintf('Image %s smaller than specified %s thumbnail size. Keeping original size.', $file_name, $spec['dest_dir']), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Image %s smaller than specified %s thumbnail size. Keeping original size.', $file_name, $spec['dest_dir']), LOG_DEBUG, __FILE__, __LINE__);
             }
 
@@ -339,12 +349,12 @@
             if (IMAGETHUMB_METHOD_NETPBM === $this->getParam('resize_method') && file_exists($this->getParam('anytopnm_binary')) && file_exists($this->getParam('pnmscale_binary')) && file_exists($this->getParam('cjpeg_binary'))) {
                 // Resize using Netpbm binaries.
-                App::logMsg(sprintf('Resizing with Netpbm...', null), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Resizing with Netpbm...', null), LOG_DEBUG, __FILE__, __LINE__);
                 $return_val += $this->_resizeWithNetpbm($source_file, $dest_file, $spec);
             } else if (IMAGETHUMB_METHOD_GD === $this->getParam('resize_method') && extension_loaded('gd')) {
                 // Resize with GD.
-                App::logMsg(sprintf('Resizing with GD...', null), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Resizing with GD...', null), LOG_DEBUG, __FILE__, __LINE__);
                 $return_val += $this->_resizeWithGD($source_file, $dest_file, $spec);
             } else {
-                App::logMsg(sprintf('Image thumbnailing failed. Neither Netpbm or GD is available.', null), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Image thumbnailing failed. Neither Netpbm or GD is available.', null), LOG_DEBUG, __FILE__, __LINE__);
                 return false;
             }
@@ -370,4 +380,6 @@
     function _resizeWithNetpbm($source_file, $dest_file, $spec)
     {
+		$app =& App::getInstance();
+
         // Define pnmscale arguments.
         switch ($spec['scaling_type']) {
@@ -405,5 +417,5 @@
             escapeshellcmd($file_name)
         );
-        App::logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__);
         
         // Execute!
@@ -414,8 +426,8 @@
             // Make the thumbnail writable so the user can delete it over ftp without being 'apache'.
             chmod($dest_file, $this->getParam('dest_file_perms'));
-            App::logMsg(sprintf('Successfully resized image %s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Successfully resized image %s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val), LOG_DEBUG, __FILE__, __LINE__);
         } else {
             // An error occurred.
-            App::logMsg(sprintf('Image %s failed resizing with return value: %s%s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Image %s failed resizing with return value: %s%s', $spec['dest_dir'] . '/' . basename($dest_file), $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__);
         }
 
@@ -438,4 +450,6 @@
     function _resizeWithGD($source_file, $dest_file, $spec)
     {
+		$app =& App::getInstance();
+
         // Get original file dimensions and type.
         list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_file);
@@ -487,10 +501,10 @@
             $source_image_resource = imagecreatefromwbmp($source_file);
         default :
-            App::logMsg(sprintf('Source image type %s not supported.', $source_image_type), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source image type %s not supported.', $source_image_type), LOG_WARNING, __FILE__, __LINE__);
             return 1;
             break;
         }
         if (!$source_image_resource) {
-            App::logMsg(sprintf('Error creating %s image in memory from %s', $source_image_type, $source_file), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Error creating %s image in memory from %s', $source_image_type, $source_file), LOG_WARNING, __FILE__, __LINE__);
             return 1;
         }
@@ -501,5 +515,5 @@
         // Resample!
         if (!imagecopyresampled($dest_image_resource, $source_image_resource, 0, 0, 0, 0, $dest_image_width, $dest_image_height, $source_image_width, $source_image_height)) {
-            App::logMsg(sprintf('Error resampling image %s', $source_file), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Error resampling image %s', $source_file), LOG_WARNING, __FILE__, __LINE__);
             return 1;
         }
@@ -528,5 +542,5 @@
             break;
         default :
-            App::logMsg(sprintf('Destination image type %s not supported for image %s.', $spec['dest_file_type'], $dest_file), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Destination image type %s not supported for image %s.', $spec['dest_file_type'], $dest_file), LOG_WARNING, __FILE__, __LINE__);
             return 1;
             break;
@@ -537,9 +551,9 @@
             // Make the thumbnail writable so the user can delete it over ftp without being 'apache'.
             chmod($dest_file, $this->getParam('dest_file_perms'));
-            App::logMsg(sprintf('Successfully resized image %s', $dest_file), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Successfully resized image %s', $dest_file), LOG_DEBUG, __FILE__, __LINE__);
             return 0;
         } else {
             // An error occurred.
-            App::logMsg(sprintf('Image %s failed resizing.', $dest_file), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Image %s failed resizing.', $dest_file), LOG_ERR, __FILE__, __LINE__);
             return 1;
         }
@@ -555,7 +569,9 @@
     function deleteThumbs($file_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a source.
         if ('' == $this->getParam('source_dir')) {
-            App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -567,5 +583,5 @@
                 if (!unlink($dest_file)) {
                     $return_val++;
-                    App::logMsg(sprintf(_("Delete thumbs failed: %s"), $dest_file), LOG_WARNING, __FILE__, __LINE__);
+                    $app->logMsg(sprintf(_("Delete thumbs failed: %s"), $dest_file), LOG_WARNING, __FILE__, __LINE__);
                 }
             }
@@ -584,7 +600,9 @@
     function deleteOriginal($file_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a source.
         if ('' == $this->getParam('source_dir')) {
-            App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -592,5 +610,5 @@
         $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name));
         if (!unlink($source_file)) {
-            App::logMsg(sprintf(_("Delete original failed: %s"), $source_file), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Delete original failed: %s"), $source_file), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -608,7 +626,9 @@
     function exists($file_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a source.
         if ('' == $this->getParam('source_dir')) {
-            App::logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Source directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -639,4 +659,6 @@
     function _createDestDirs()
     {
+		$app =& App::getInstance();
+
         static $already_checked = false;
 
@@ -644,5 +666,5 @@
             // Ensure we have a source.
             if ('' == $this->getParam('source_dir')) {
-                App::logMsg(sprintf('Source directory not set before creating destination directories.'), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Source directory not set before creating destination directories.'), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -654,5 +676,5 @@
                     if (!mkdir($this->getParam('source_dir') . '/' . $spec['dest_dir'], $this->getParam('dest_dir_perms'))) {
                         $return_val++;
-                        App::logMsg(sprintf('mkdir failure: %s', $this->getParam('source_dir') . '/' . $spec['dest_dir']), LOG_ERR, __FILE__, __LINE__);
+                        $app->logMsg(sprintf('mkdir failure: %s', $this->getParam('source_dir') . '/' . $spec['dest_dir']), LOG_ERR, __FILE__, __LINE__);
                     }
                 }
@@ -667,5 +689,5 @@
 
     /**
-     * An alias for App::raiseMsg that only sends messages configured by display_messages.
+     * An alias for $app->raiseMsg that only sends messages configured by display_messages.
      *
      * @access public
@@ -679,6 +701,8 @@
     function _raiseMsg($message, $type, $file, $line)
     {
+		$app =& App::getInstance();
+
         if ($this->getParam('display_messages') === true || (is_int($this->getParam('display_messages')) && $this->getParam('display_messages') & $type > 0)) {
-            App::raiseMsg($message, $type, $file, $line);
+            $app->raiseMsg($message, $type, $file, $line);
         }
     }
Index: trunk/lib/MCVE.inc.php
===================================================================
--- trunk/lib/MCVE.inc.php	(revision 124)
+++ trunk/lib/MCVE.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * The MCVE:: class provides functions for communicating with a MCVE server.
+ * MCVE.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The MCVE class provides functions for communicating with a MCVE server.
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
@@ -22,4 +25,6 @@
     function MCVE($username, $password)
     {
+		$app =& App::getInstance();
+
         // Ensure PHP was compiled with the MCVE functions.
         if (!extension_loaded('mcve')) {
@@ -27,5 +32,5 @@
         }
         if ('' == $username || '' == $password) {
-            App::logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__);
         }
         $this->username = $username;
@@ -35,4 +40,6 @@
     function _connect()
     {
+		$app =& App::getInstance();
+
         if ($this->connected) {
             return true;
@@ -49,5 +56,5 @@
         case 'ip' :
             if (!MCVE_SetIP($this->conn, $this->host, $this->ip_port)) {
-                App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -55,5 +62,5 @@
         case 'ssl' :
             if (!MCVE_SetSSL($this->conn, $this->host, $this->ssl_port)) {
-                App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
@@ -61,10 +68,10 @@
         case 'dropfile' :
             if (!MCVE_SetDropFile($this->conn, '/var/mcve/trans')) {
-                App::logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg('Could not set method to IP.', LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
             break;
         default :
-            App::logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -75,5 +82,5 @@
         // non-blocking, but future versions of php_mcve will default to blocking.
         if (!MCVE_SetBlocking($this->conn, $this->blocking)) {
-            App::logMsg('Could not set blocking mode.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('Could not set blocking mode.', LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -81,5 +88,5 @@
         // Maximum of 30s per transaction allowed. Timeout occurs on server-end, not client-end
         if (!MCVE_SetTimeout($this->conn, $this->timeout)) {
-            App::logMsg('Could not set timeout.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('Could not set timeout.', LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -88,5 +95,5 @@
         if (!MCVE_Connect($this->conn)) {
             $error = MCVE_ConnectionError($this->conn);
-            App::logMsg("Connection failed: $error. Are you sure the MCVE engine is running?", LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg("Connection failed: $error. Are you sure the MCVE engine is running?", LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -117,7 +124,9 @@
     function sendTrans($tid, $type='', $hide_msg=false)
     {
+		$app =& App::getInstance();
+
         // Finalize structuring of  to MCVE and ready it to be sent
         if (!MCVE_TransSend($this->conn, $tid)) {
-            App::logMsg('Transaction improperly structured, possibly not enough info.', LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg('Transaction improperly structured, possibly not enough info.', LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -139,11 +148,11 @@
         // Check to see if transaction was successful or not using a strict success/fail function
         if ($ret_status == MCVE_FAIL) {
-            App::raiseMsg(sprintf('MCVE %s failure: %s %s', $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_WARNING, __FILE__, __LINE__);
+            $app->raiseMsg(sprintf('MCVE %s failure: %s %s', $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_WARNING, __FILE__, __LINE__);
             return false;
         } else if ($ret_status == MCVE_SUCCESS) {
             if (!$hide_msg) {
-                App::raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__);
+                $app->raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__);
             }
-            App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."),
+            $app->logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."),
                 MCVE_TransactionAuth($this->conn, $tid),
                 MCVE_TransactionBatch($this->conn, $tid),
@@ -155,5 +164,5 @@
             return true;
         } else {
-            App::logMsg(sprintf('Transaction failed. Unknown return code: %s', $ret_status), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Transaction failed. Unknown return code: %s', $ret_status), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
Index: trunk/lib/Nav.inc.php
===================================================================
--- trunk/lib/Nav.inc.php	(revision 124)
+++ trunk/lib/Nav.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * The Nav:: class provides a system for working with navigation elements.
+ * Nav.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The Nav class provides a system for working with navigation elements.
  * Currently it supports storing page titles and URLs for printing breadcrumbs
  * and titles, as well as setting page features such as hiding the page title on
@@ -201,4 +204,6 @@
     function getBreadcrumbs($page_id=null)
     {
+		$app =& App::getInstance();
+
         $page_id = $this->_calculatePageID($page_id);
 
@@ -219,5 +224,5 @@
                     } else if ($crumb_count > $this->getFeature('chop_breadcrumb_links')) {
                         // A normal linked crumb.
-                        $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . App::oHREF($page['url']) . '">' . sprintf($this->last_crumb_format, oTxt($page['title'], true)) . '</a>';
+                        $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . $app->oHREF($page['url']) . '">' . sprintf($this->last_crumb_format, oTxt($page['title'], true)) . '</a>';
                     }
                 } else {
@@ -227,5 +232,5 @@
                     } else {
                         // A normal linked crumb.
-                        $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . App::oHREF($page['url']) . '">' . oTxt($page['title'], true) . '</a>';
+                        $breadcrumbs .= oTxt($pathmark, true) . '<a href="' . $app->oHREF($page['url']) . '">' . oTxt($page['title'], true) . '</a>';
                     }
                 }
Index: trunk/lib/PEdit.inc.php
===================================================================
--- trunk/lib/PEdit.inc.php	(revision 124)
+++ trunk/lib/PEdit.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * PEdit:: provides a mechanism to store text in php variables
+ * PEdit.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * PEdit provides a mechanism to store text in php variables
  * which will be printed to the client browser under normal
  * circumstances, but an authenticated user can 'edit' the document--
@@ -11,5 +14,11 @@
  * To use, include this file, initialize variables,
  * and call printing/editing functions where you want data and forms to
- * show up. Below is an example of use:
+ * show up.
+ * 
+ * @author  Quinn Comendant <quinn@strangecode.com>
+ * @concept Beau Smith <beau@beausmith.com>
+ * @version 2.0 
+ * 
+ * Example of use:
  
  // Initialize PEdit object.
@@ -37,7 +46,4 @@
  $pedit->formEnd();
 
- * @author  Quinn Comendant <quinn@strangecode.com>
- * @concept Beau Smith <beau@beausmith.com>
- * @version 2.0
  */
 class PEdit {
@@ -95,9 +101,11 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_WARNING, __FILE__, __LINE__);
         }
     }
@@ -112,8 +120,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -129,4 +139,6 @@
     function start($initialize_data_file=false)
     {
+		$app =& App::getInstance();
+
         if (!is_dir($this->getParam('data_dir'))) {
             trigger_error(sprintf('PEdit data directory not found: %s', $this->getParam('data_dir')), E_USER_WARNING);
@@ -143,15 +155,15 @@
         case 'Save' :
             if ($this->_writeData()) {
-                App::dieURL($_SERVER['PHP_SELF']);
+                $app->dieURL($_SERVER['PHP_SELF']);
             }
             break;
         case 'Restore' :
             if ($this->_restoreVersion(getFormData('version'))) {
-                App::dieURL($_SERVER['PHP_SELF']);
+                $app->dieURL($_SERVER['PHP_SELF']);
             }
             break;
         case 'View' :
             $this->_data_file = sprintf('%s%s__%s.xml', $this->getParam('data_dir'), $_SERVER['PHP_SELF'], getFormData('version'));
-            App::raiseMsg(sprintf(_("This is <em><strong>only a preview</strong></em> of version %s."), getFormData('version')), MSG_NOTICE, __FILE__, __LINE__);
+            $app->raiseMsg(sprintf(_("This is <em><strong>only a preview</strong></em> of version %s."), getFormData('version')), MSG_NOTICE, __FILE__, __LINE__);
             break;
         }
@@ -176,9 +188,11 @@
     function set($name, $options=array())
     {
+		$app =& App::getInstance();
+
         $name = preg_replace('/\s/', '_', $name);
         if (!isset($this->_data[$name])) {
             $this->_data[$name] = array_merge(array('content' => ''), $options);
         } else {
-            App::logMsg(sprintf('Duplicate set data: %s', $name), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Duplicate set data: %s', $name), LOG_NOTICE, __FILE__, __LINE__);
         }
     }
@@ -208,4 +222,6 @@
     function formBegin()
     {
+		$app =& App::getInstance();
+
         if (!$this->_authorized || empty($this->_data)) {
             return false;
@@ -216,5 +232,5 @@
         <input type="hidden" name="file_hash" value="<?php echo $this->_fileHash(); ?>" />
         <?php
-        App::printHiddenSession();
+        $app->printHiddenSession();
         switch ($this->op) {
         case 'Edit' :
@@ -345,4 +361,6 @@
     function printVersions()
     {
+		$app =& App::getInstance();
+
         if ($this->_authorized && $this->op == 'Versions') {
             // Print versions and commands to view/restore.
@@ -362,8 +380,8 @@
                     ?>
                     <tr>
-                        <td><?php echo date(App::getParam('date_format'), $v['unixtime']); ?></td>
-                        <td><?php echo date(App::getParam('time_format'), $v['unixtime']); ?></td>
+                        <td><?php echo date($app->getParam('date_format'), $v['unixtime']); ?></td>
+                        <td><?php echo date($app->getParam('time_format'), $v['unixtime']); ?></td>
                         <td><?php echo humanFileSize($v['filesize']); ?></td>
-                        <td class="sc-nowrap"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=View&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("View"); ?></a> <?php echo _("or"); ?> <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("Restore"); ?></a></td>
+                        <td class="sc-nowrap"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=View&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("View"); ?></a> <?php echo _("or"); ?> <a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=Restore&version=' . $v['unixtime'] . '&file_hash=' . $this->_fileHash()); ?>"><?php echo _("Restore"); ?></a></td>
                     </tr>
                     <?php
@@ -386,5 +404,7 @@
     function _fileHash()
     {
-        return md5(App::getParam('signing_key') . $_SERVER['PHP_SELF']);
+		$app =& App::getInstance();
+
+        return md5($app->getParam('signing_key') . $_SERVER['PHP_SELF']);
     }
 
@@ -399,7 +419,9 @@
     function _loadDataFile()
     {
+		$app =& App::getInstance();
+
         if (!file_exists($this->_data_file)) {
             if (!$this->_initializeDataFile()) {
-                App::logMsg(sprintf('Initializing content file failed: %s', $this->_data_file), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Initializing content file failed: %s', $this->_data_file), LOG_WARNING, __FILE__, __LINE__);
                 return false;
             }
@@ -408,5 +430,5 @@
         $status = $this->xml_unserializer->unserialize($xml_file_contents, false);    
         if (PEAR::isError($status)) {
-            App::logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('XML_Unserialize error: %s', $status->getMessage()), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -436,5 +458,7 @@
     function _initializeDataFile()
     {
-        App::logMsg(sprintf('Initializing data file: %s', $this->_data_file), LOG_INFO, __FILE__, __LINE__);
+		$app =& App::getInstance();
+
+        $app->logMsg(sprintf('Initializing data file: %s', $this->_data_file), LOG_INFO, __FILE__, __LINE__);
         $xml_file_contents = $this->xml_serializer->serialize($this->_data);
         return $this->_filePutContents($this->_data_file, $xml_file_contents);
@@ -450,4 +474,6 @@
     function _writeData()
     {
+		$app =& App::getInstance();
+
         if (!$this->_authorized) {
             return false;
@@ -455,5 +481,5 @@
         if ($this->_fileHash() != getFormData('file_hash')) {
             // Posted data is NOT for this file!
-            App::logMsg(sprintf('File_hash does not match current file.', null), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('File_hash does not match current file.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -466,5 +492,5 @@
             $this->_deleteOldVersions();
             if (!$this->_createVersion()) {
-                App::logMsg(sprintf('Failed creating new version of file.', null), LOG_NOTICE, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Failed creating new version of file.', null), LOG_NOTICE, __FILE__, __LINE__);
                 return false;
             }
@@ -496,7 +522,9 @@
     function _filePutContents($filename, $content)
     {
+		$app =& App::getInstance();
+
         // Ensure requested filename is within the pedit data dir.
         if (strpos($filename, $this->getParam('data_dir')) === false) {
-            App::logMsg(sprintf('Failed writing file outside pedit _data_dir: %s', $filename), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Failed writing file outside pedit _data_dir: %s', $filename), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -510,5 +538,5 @@
             if (!is_dir($curr_path)) {
                 if (!mkdir($curr_path)) {
-                    App::logMsg(sprintf('Failed mkdir: %s', $curr_path), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Failed mkdir: %s', $curr_path), LOG_ERR, __FILE__, __LINE__);
                     return false;
                 }
@@ -522,13 +550,13 @@
                 flock($fp, LOCK_UN);
             } else {
-                App::logMsg(sprintf('Could not lock file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Could not lock file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
             fclose($fp);
             // Success!
-            App::logMsg(sprintf('Wrote to file: %s', $filename), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Wrote to file: %s', $filename), LOG_DEBUG, __FILE__, __LINE__);
             return true;
         } else {
-            App::logMsg(sprintf('Could not open file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Could not open file for writing: %s', $filename), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -544,4 +572,6 @@
     function _createVersion()
     {
+		$app =& App::getInstance();
+
         if (!$this->_authorized) {
             return false;
@@ -549,5 +579,5 @@
         if ($this->_fileHash() != getFormData('file_hash')) {
             // Posted data is NOT for this file!
-            App::logMsg(sprintf('File_hash does not match current file.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('File_hash does not match current file.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -555,5 +585,5 @@
         // Ensure current data file exists.
         if (!file_exists($this->_data_file)) {
-            App::logMsg(sprintf('Data file does not yet exist: %s', $this->_data_file), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Data file does not yet exist: %s', $this->_data_file), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -563,5 +593,5 @@
         $version_file = sprintf('%s__%s.xml', preg_replace('/\.xml$/', '', $this->_data_file), time());
         if (!copy($this->_data_file, $version_file)) {
-            App::logMsg(sprintf('Failed copying new version: %s -> %s', $this->_data_file, $version_file), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Failed copying new version: %s -> %s', $this->_data_file, $version_file), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -580,4 +610,6 @@
     function _deleteOldVersions()
     {
+		$app =& App::getInstance();
+
         $version_files = $this->_getVersions();
         if (is_array($version_files) && sizeof($version_files) > $this->getParam('versions_min_qty')) {
@@ -590,5 +622,5 @@
                 $del_file = dirname($this->_data_file) . '/' . $oldest['filename'];
                 if (!unlink($del_file)) {
-                    App::logMsg(sprintf('Failed deleting version: %s', $del_file), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Failed deleting version: %s', $del_file), LOG_ERR, __FILE__, __LINE__);
                 }
                 $oldest = array_pop($version_files);
@@ -637,4 +669,6 @@
     function _restoreVersion($version)
     {
+		$app =& App::getInstance();
+
         if (!$this->_authorized) {
             return false;
@@ -646,5 +680,5 @@
         // Ensure specified version exists.
         if (!file_exists($version_file)) {
-            App::logMsg(sprintf('Cannot restore non-existant file: %s', $version_file), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot restore non-existant file: %s', $version_file), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -652,5 +686,5 @@
         // Make certain a version is created.
         if (!$this->_createVersion()) {
-            App::logMsg(sprintf('Failed creating new version of file.', null), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Failed creating new version of file.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -658,10 +692,10 @@
         // Do the actual copy.
         if (!copy($version_file, $this->_data_file)) {
-            App::logMsg(sprintf('Failed copying old version: %s -> %s', $version_file, $this->_data_file), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Failed copying old version: %s -> %s', $version_file, $this->_data_file), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
 
         // Success!
-        App::raiseMsg(sprintf(_("Page has been restored to version %s."), $version), MSG_SUCCESS, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Page has been restored to version %s."), $version), MSG_SUCCESS, __FILE__, __LINE__);
         return true;
     }
Index: trunk/lib/PageNumbers.inc.php
===================================================================
--- trunk/lib/PageNumbers.inc.php	(revision 124)
+++ trunk/lib/PageNumbers.inc.php	(revision 136)
@@ -4,5 +4,5 @@
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
  *
- * The PageNumbers:: class provides a common abstracted interface to the
+ * The PageNumbers class provides a common abstracted interface to the
  * multiple pages features. It sets the various numbers needed to display items
  * on a page, and includes functions for working with these numbers.
@@ -72,5 +72,7 @@
     function setPerPage($per_page, $default=25, $save_value=true)
     {
-        // (1) By provided argument, if valid.
+		$prefs =& Prefs::getInstance();
+    
+    	// (1) By provided argument, if valid.
         // (2) By saved preference, if available.
         // (3) Set to default value if provided and valid.
@@ -79,8 +81,8 @@
             $this->_per_page = $per_page;
             if ($save_value) {
-                Prefs::setValue('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']);
-            }
-        } else if ($save_value && Prefs::exists('items_per_page', $_SERVER['PHP_SELF'])) {
-            $this->_per_page = (int)Prefs::getValue('items_per_page', $_SERVER['PHP_SELF']);
+                $prefs->set('items_per_page', $this->_per_page, $_SERVER['PHP_SELF']);
+            }
+        } else if ($save_value && $prefs->exists('items_per_page', $_SERVER['PHP_SELF'])) {
+            $this->_per_page = (int)$prefs->get('items_per_page', $_SERVER['PHP_SELF']);
         } else if (is_numeric($default) && $default > 0) {
             $this->_per_page = $default;
@@ -94,5 +96,7 @@
     function setPageNumber($page_number, $save_value=true)
     {
-        // (1) By provided argument, if valid.
+		$prefs =& Prefs::getInstance();
+    
+    // (1) By provided argument, if valid.
         // (2) By saved preference, if available.
         // (3) Don't change from what was provided at class instantiation.
@@ -105,8 +109,8 @@
             }
             if ($save_value) {
-                Prefs::setValue('page_number', $this->current_page, $_SERVER['PHP_SELF']);
-            }
-        } else if ($save_value && Prefs::exists('page_number', $_SERVER['PHP_SELF'])) {
-            $this->current_page = (int)Prefs::getValue('page_number', $_SERVER['PHP_SELF']);
+                $prefs->set('page_number', $this->current_page, $_SERVER['PHP_SELF']);
+            }
+        } else if ($save_value && $prefs->exists('page_number', $_SERVER['PHP_SELF'])) {
+            $this->current_page = (int)$prefs->get('page_number', $_SERVER['PHP_SELF']);
         }
         $this->set_page_number_initialized = true;
@@ -137,12 +141,14 @@
     function calculate()
     {
+		$app =& App::getInstance();
+
         if (!$this->set_per_page_initialized) {
-            App::logMsg(sprintf('set_per_page not initialized'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('set_per_page not initialized'), LOG_ERR, __FILE__, __LINE__);
         }
         if (!$this->set_page_number_initialized) {
-            App::logMsg(sprintf('set_page_number not initialized'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('set_page_number not initialized'), LOG_ERR, __FILE__, __LINE__);
         }
         if (!$this->set_total_items_initialized) {
-            App::logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__);
         }
 
@@ -189,8 +195,11 @@
     function getLimitSQL()
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         if (is_numeric($this->first_item) && is_numeric($this->_per_page)) {
-            return ' LIMIT ' . DB::escapeString($this->first_item) . ', ' . DB::escapeString($this->_per_page) . ' ';
-        } else {
-            App::logMsg(sprintf('Could not find SQL to LIMIT by %s %s.', $this->first_item, $this->_per_page), LOG_WARNING, __FILE__, __LINE__);
+            return ' LIMIT ' . $db->escapeString($this->first_item) . ', ' . $db->escapeString($this->_per_page) . ' ';
+        } else {
+            $app->logMsg(sprintf('Could not find SQL to LIMIT by %s %s.', $this->first_item, $this->_per_page), LOG_WARNING, __FILE__, __LINE__);
             return '';
         }
@@ -204,4 +213,6 @@
     function printPerPageLinks($query_key='per_page')
     {
+		$app =& App::getInstance();
+
         $sp = '';
         for ($i=0; $i<sizeof($this->per_page_options); $i++) {
@@ -209,5 +220,5 @@
                 printf('%s<a href="%s">%s</a>',
                     $sp,
-                    App::oHREF($_SERVER['PHP_SELF'] . '?' . $query_key . '=' . $this->per_page_options[$i]),
+                    $app->oHREF($_SERVER['PHP_SELF'] . '?' . $query_key . '=' . $this->per_page_options[$i]),
                     $this->per_page_options[$i]
                 );
@@ -220,5 +231,5 @@
 
     /**
-     * Outputs an App::oHREF compatible url that goes to the page $page_number.
+     * Outputs an $app->oHREF compatible url that goes to the page $page_number.
      * Depends on $this->base_url to build the url onto. This is used in the
      * page_number.ihtml template.
@@ -232,5 +243,7 @@
     function getPageNumURL($page_number, $carry_args=null)
     {
-        return App::oHREF($this->url_base . $page_number, $carry_args);
+		$app =& App::getInstance();
+
+        return $app->oHREF($this->url_base . $page_number, $carry_args);
     }
     function printPageNumURL($page_number, $carry_args=null)
Index: trunk/lib/PageSequence.inc.php
===================================================================
--- trunk/lib/PageSequence.inc.php	(revision 124)
+++ trunk/lib/PageSequence.inc.php	(revision 136)
@@ -4,5 +4,5 @@
  * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
  *
- * The PageSequence:: class provides an interface to simplify the creation of a multi-step form.
+ * The PageSequence class provides an interface to simplify the creation of a multi-step form.
  *
  * @requires  This class requires Prefs.inc.php
@@ -133,4 +133,6 @@
     function setCurrent($step_id)
     {
+		$app =& App::getInstance();
+
         if (false !== ($pos = $this->getPosition($step_id))) {
             // Specified step exists (even if numeric).
@@ -138,5 +140,5 @@
         } else {
             // Step with specified key does not exist.
-            App::logMsg(sprintf(_("Step %s not defined in sequence %s"), $step_id, $this->sequence_title), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Step %s not defined in sequence %s"), $step_id, $this->sequence_title), LOG_INFO, __FILE__, __LINE__);
             return false;
         }
@@ -257,7 +259,9 @@
     function printEditLink($step_id=null)
     {
+		$app =& App::getInstance();
+
         $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition();
         if ($_SESSION[$this->seq]['steps'][$pos]['editable']) {
-            printf('[<a href="%s">%s</a>]', App::oHREF($_SERVER['PHP_SELF'] . '?step=' . $pos . '&boomerang=confirmation'), _("edit"));
+            printf('[<a href="%s">%s</a>]', $app->oHREF($_SERVER['PHP_SELF'] . '?step=' . $pos . '&boomerang=confirmation'), _("edit"));
         }
     }
@@ -320,9 +324,11 @@
     function _auto_timeout()
     {
+		$app =& App::getInstance();
+
         if (isset($_SESSION[$this->seq]['last_access_time'])
         && $_SESSION[$this->seq]['last_access_time'] < time() - $this->idle_timeout) {
             // Session has expired, flush all vars to start over.
             $this->startOver();
-            App::dieURL($this->start_url);
+            $app->dieURL($this->start_url);
         } else {
             // Set timer.
Index: trunk/lib/PayPal.inc.php
===================================================================
--- trunk/lib/PayPal.inc.php	(revision 124)
+++ trunk/lib/PayPal.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * The PayPal:: class provides functions for creating PayPal buttons and for
+ * PayPal.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The PayPal class provides functions for creating PayPal buttons and for
  * receiving PayPal's Instant Payment Notification (IPN) service.
  *
@@ -74,6 +77,8 @@
     function setButtonDefaults($type, $options)
     {
+		$app =& App::getInstance();
+
         if (!is_array($options) || empty($options)) {
-            App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -82,5 +87,5 @@
             $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options);
         } else if (!isset($this->_default_button_options[$type])) {
-            App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -104,16 +109,18 @@
     function newButton($type, $name, $options=null)
     {
+		$app =& App::getInstance();
+
         if (!isset($this->_default_button_options[$type])) {
-            App::logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Invalid button type: %s', $type), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
 
         if (!is_array($options) || empty($options)) {
-            App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
 
         if (isset($this->_buttons[$name])) {
-            App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);
         }
 
@@ -137,6 +144,8 @@
     function getLink($name)
     {
+		$app =& App::getInstance();
+
         if (!isset($this->_buttons[$name])) {
-            App::logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Button does not exist: %s', $name), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -207,9 +216,11 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -224,8 +235,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -259,9 +272,11 @@
     function processIPN()
     {
+		$app =& App::getInstance();
+
         if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) {
-            App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
             $url = parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr');
         } else {
-            App::logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Processing PayPal IPN: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
             $url = parse_url($this->getParam('paypal_url'));
         }
@@ -287,5 +302,5 @@
 
         if (!$fp) {
-            App::logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Connection to PayPal URL %s failed with error: %s (%s)', $ssl . $url['host'], $errstr, $errnum), LOG_WARNING, __FILE__, __LINE__);
             return false;
         } else {
@@ -304,5 +319,5 @@
             fclose($fp);
 
-            App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);
+            $app->logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);
             return true;
         }
@@ -318,22 +333,24 @@
     function verifiedIPN()
     {
+		$app =& App::getInstance();
+
         if (!isset($this->_ipn_response)) {
-            App::logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot verify IPN, response not received.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
 
         if (empty($this->_ipn_response)) {
-            App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
 
         if (preg_match('/VERIFIED/', $this->_ipn_response)) {
-            App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);
             return true;
         } else if (preg_match('/INVALID/', $this->_ipn_response)) {
-            App::logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        } else {
-            App::logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('IPN invalid.', null), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        } else {
+            $app->logMsg(sprintf('IPN unknown.', null), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
Index: trunk/lib/Prefs.inc.php
===================================================================
--- trunk/lib/Prefs.inc.php	(revision 124)
+++ trunk/lib/Prefs.inc.php	(revision 136)
@@ -1,42 +1,28 @@
 <?php
 /**
- * Prefs:: provides an API for saving arbitrary values in a user's session.
- * Database save routines to come.
+ * Prefs.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
  *
- * @inspiration  Horde 2.0's Prefs class. This one is much simpler, but
- *               the API for the methods that exist are sort of like Horde's
- *               in case we want to be more like it in the future.
+ * Prefs provides an API for saving arbitrary values in a user's session.
+ *
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.1
+ * @version 2.1
  */
 class Prefs {
 
-    /**
-     * Where these preferences can be used. To differentiate between preferences
-     * for a specific script, application, or global.
-     * @var string $scope
-     */
-    var $scope = 'global';
-
-    /**
-     * Indicator whether we save in the database or not.
-     * @var boolean $_perpetual
-     */
-    var $_perpetual = false;
-
-    /**
-     * Hash containing connection parameters.
-     * @var array $params
-     */
-    var $params = array();
-
+    // Namespace of this instance of Prefs.
+    var $_ns;
 
     /**
      * Prefs constructor.
      */
-    function Prefs($dbh=false, $params=array())
+    function Prefs($namespace='')
     {
-        $this->params = $params;
-        $_perpetual = false; // Until database routines are completed.
+        $this->_ns = '_prefs_' . $namespace;
+        
+        // Initialized the prefs array.
+        if (!isset($_SESSION[$this->_ns])) {
+            $_SESSION[$this->_ns] = array();
+        }
     }
 
@@ -45,39 +31,12 @@
      * is not set already.
      *
-     * @param  string $pref      The name of the preference to modify.
+     * @param  string $key       The name of the preference to modify.
      * @param  string $val       The new value for this preference.
-     * @param  string $scope     The scope for this preference.
-     *
-     * @return boolean  True if the value was successfully set.
      */
-    function setDefault($pref, $val, $scope=null)
+    function setDefault($key, $val)
     {
-        if (!isset($scope)) {
-            $scope =& $this->scope;
-        }
-
-        // No empty values allowed.
-        if ('' == $pref || '' == $val || '' == $scope) {
-            return false;
-        }
-
-        // Initialized the prefs array.
-        if (!isset($_SESSION['_prefs'])) {
-            $_SESSION['_prefs'] = array();
-        }
-
-        // In case boolean or null values are passed as a string.
-        if ($val == 'true') {
-            $val = true;
-        } else if ($val == 'false') {
-            $val = false;
-        } else if ($val == 'null') {
-            $val = null;
-        }
-
         // Set it only if not set already.
-        if (!isset($_SESSION['_prefs'][$scope][$pref])) {
-            $_SESSION['_prefs'][$scope][$pref] = $val;
-            return true;
+        if (!isset($_SESSION[$this->_ns][$key])) {
+            $_SESSION[$this->_ns][$key] = $val;
         }
     }
@@ -86,37 +45,10 @@
      * Sets the given preferences to the specific value,
      *
-     * @param  string $pref      The name of the preference to modify.
+     * @param  string $key       The name of the preference to modify.
      * @param  string $val       The new value for this preference.
-     * @param  string $scope     The scope for this preference.
-     *
-     * @return boolean  True if the value was successfully set.
      */
-    function setValue($pref, $val, $scope=null)
+    function set($key, $val)
     {
-        if (!isset($scope)) {
-            $scope =& $this->scope;
-        }
-
-        // No empty values allowed.
-        if ('' == $pref || '' == $val || '' == $scope) {
-            return false;
-        }
-
-        // Initialized the prefs array.
-        if (!isset($_SESSION['_prefs'])) {
-            $_SESSION['_prefs'] = array();
-        }
-
-        // In case boolean or null values are passed as a string.
-        if ($val == 'true') {
-            $val = true;
-        } else if ($val == 'false') {
-            $val = false;
-        } else if ($val == 'null') {
-            $val = null;
-        }
-
-        $_SESSION['_prefs'][$scope][$pref] = $val;
-        return true;
+        $_SESSION[$this->_ns][$key] = $val;
     }
 
@@ -124,16 +56,11 @@
      * Returns the value of the requested preference.
      *
-     * @param string $pref      The name of the preference to retrieve.
-     * @param string $scope     The scope for this preference.
+     * @param string $key       The name of the preference to retrieve.
      *
      * @return string           The value of the preference.
      */
-    function getValue($pref, $scope=null)
+    function get($key)
     {
-        if (!isset($scope)) {
-            $scope =& $this->scope;
-        }
-
-        return (isset($_SESSION['_prefs'][$scope][$pref])) ? $_SESSION['_prefs'][$scope][$pref] : null;
+        return (isset($_SESSION[$this->_ns][$key])) ? $_SESSION[$this->_ns][$key] : null;
     }
 
@@ -141,17 +68,12 @@
      * To see if a preference has been set.
      *
-     * @param string $pref      The name of the preference to check.
-     * @param string $scope     The scope for this preference.
+     * @param string $key       The name of the preference to check.
      *
      * @return boolean          True if the preference isset and not empty
      *                          false otherwise.
      */
-    function exists($pref, $scope=null)
+    function exists($key)
     {
-        if (!isset($scope)) {
-            $scope =& $this->scope;
-        }
-
-        return isset($_SESSION['_prefs'][$scope][$pref]);
+        return isset($_SESSION[$this->_ns][$key]);
     }
 
@@ -159,75 +81,11 @@
      * Clear a set preference value.
      *
-     * @param string $pref      The name of the preference to check.
-     * @param string $scope     The scope for this preference.
+     * @param string $key       The name of the preference to check.
      */
-    function clearValue($pref, $scope=null)
+    function delete($key)
     {
-        if (!isset($scope)) {
-            $scope =& $this->scope;
+        if (isset($_SESSION[$this->_ns][$key])) {
+            unset($_SESSION[$this->_ns][$key]);
         }
-
-        if (isset($_SESSION['_prefs'][$scope][$pref])) {
-            unset($_SESSION['_prefs'][$scope][$pref]);
-        }
-    }
-
-    /**
-     * Retrieves the requested set of preferences from the user's database
-     * entry.
-     *
-     * @param optional array $prefs  An array listing the preferences to
-     *                     retrieve. If not specified, retrieve all of the
-     *                     preferences listed in the $prefs hash.
-     *
-     * @return mixed       True on success or a PEAR_Error object on failure.
-     */
-    function retrieve()
-    {
-        // Check that we don't have the preferences loaded yet.
-        if ($_SESSION['_prefs']['loaded'] == true || !$_perpetual) {
-            return true;
-        }
-
-        // FIXME: Database query goes here....
-        return false;
-
-        $_SESSION['_prefs']['loaded'] = true;
-    }
-
-    /**
-     * Stores preferences to SQL server.
-     *
-     * @param array $prefs (optional) An array listing the preferences to be
-     *                     stored.  If not specified, store all of the
-     *                     preferences listed in the $prefs hash.
-     *
-     * @return mixed       True on success or a PEAR_Error object on failure.
-     */
-    function store($prefs=array())
-    {
-        // If we are not storing prefs in perpetually.
-        if (!$_perpetual) {
-            return true;
-        }
-
-        /*
-         * If a list of preferences to store hasn't been provided in
-         * $prefs, assume all preferences are desired.
-         */
-        if (empty($prefs)) {
-            $prefs =& $_SESSION['_prefs'];
-        } else if ($_SESSION['_prefs']['loaded'] == true) {
-            $prefs = array_merge($_SESSION['_prefs'], $prefs);
-        }
-
-        if (!is_array($prefs) || empty($prefs)) {
-            App::raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__);
-            App::dieBoomerangURL();
-        }
-
-        // FIXME: Database query goes here....
-        return false;
-
     }
 
@@ -235,12 +93,10 @@
      * Perform cleanup operations.
      */
-    function cleanup()
+    function clear()
     {
-        $_SESSION['_prefs'] = array();
+        $_SESSION[$this->_ns] = array();
     }
 }
 
 
-
-
 ?>
Index: trunk/lib/RecordLock.inc.php
===================================================================
--- trunk/lib/RecordLock.inc.php	(revision 124)
+++ trunk/lib/RecordLock.inc.php	(revision 136)
@@ -1,8 +1,11 @@
 <?php
 /**
- * The RecordLock:: class provides a system for locking abstract DB rows.
+ * RecordLock.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The RecordLock class provides a system for locking abstract DB rows.
  *
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 2.0
+ * @version 2.1
  */
 class RecordLock {
@@ -32,11 +35,11 @@
     function &getInstance($auth_object)
     {
-        static $instances = array();
-
-        if (!isset($instances[$auth_object->getVal('auth_name')])) {
-            $instances[$auth_object->getVal('auth_name')] = new RecordLock($auth_object);
-        }
-
-        return $instances[$auth_object->getVal('auth_name')];
+        static $instance = null;
+
+        if ($instance === null) {
+            $instance = new RecordLock($auth_object);
+        }
+
+        return $instance;
     }
 
@@ -44,10 +47,12 @@
      * Constructor. Pass an Auth object on which to perform user lookups.
      *
-     * @param mixed  $auth_object  An Auth_SQL object.
+     * @param mixed  $auth_object  An Auth_SQL or Auth_FILE object.
      */
     function RecordLock($auth_object)
     {
-        if (!is_a($auth_object, 'Auth_SQL')) {
-            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
+		$app =& App::getInstance();
+
+        if (!method_exists($auth_object, 'getVal') || !method_exists($auth_object, 'getUsername')) {
+            trigger_error('Constructor not provided a valid Auth_* object.', E_USER_ERROR);
         }
 
@@ -55,6 +60,6 @@
 
         // Get create tables config from global context.
-        if (!is_null(App::getParam('db_create_tables'))) {
-            $this->setParam(array('create_table' => App::getParam('db_create_tables')));
+        if (!is_null($app->getParam('db_create_tables'))) {
+            $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
         }
     }
@@ -69,12 +74,15 @@
     function initDB($recreate_db=false)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         static $_db_tested = false;
 
         if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
             if ($recreate_db) {
-                DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
-                App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
+                $db->query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
+                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
             }
-            DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
+            $db->query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
                 lock_id int NOT NULL auto_increment,
                 record_table varchar(255) NOT NULL default '',
@@ -90,5 +98,5 @@
             )");
 
-            if (!DB::columnExists($this->getParam('db_table'), array(
+            if (!$db->columnExists($this->getParam('db_table'), array(
                 'lock_id',
                 'record_table',
@@ -99,5 +107,5 @@
                 'lock_datetime',
             ), false, false)) {
-                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
                 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
             }
@@ -120,16 +128,18 @@
 
     /**
-     * Return the value of a param setting.
-     *
-     * @access  public
-     * @param   string  $params Which param to return.
-     * @return  mixed   Configured param value.
+     * Return the value of a parameter, if it exists.
+     *
+     * @access public
+     * @param string $param        Which parameter to return.
+     * @return mixed               Configured parameter value.
      */
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -147,4 +157,7 @@
     function select($record_table_or_lock_id, $record_key=null, $record_val=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         $this->initDB();
 
@@ -154,24 +167,24 @@
         if (is_numeric($record_table_or_lock_id) && !isset($record_key) && !isset($record_val)) {
             // Get lock data by lock_id.
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT * FROM " . $this->getParam('db_table') . "
-                WHERE lock_id = '" . DB::escapeString($record_table_or_lock_id) . "'
+                WHERE lock_id = '" . $db->escapeString($record_table_or_lock_id) . "'
             ");
         } else {
             // Get lock data by record specs
-            $qid = DB::query("
+            $qid = $db->query("
                 SELECT * FROM " . $this->getParam('db_table') . "
-                WHERE record_table = '" . DB::escapeString($record_table_or_lock_id) . "'
-                AND record_key = '" . DB::escapeString($record_key) . "'
-                AND record_val = '" . DB::escapeString($record_val) . "'
+                WHERE record_table = '" . $db->escapeString($record_table_or_lock_id) . "'
+                AND record_key = '" . $db->escapeString($record_key) . "'
+                AND record_val = '" . $db->escapeString($record_val) . "'
             ");
         }
         if ($this->data = mysql_fetch_assoc($qid)) {
-            App::logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
             /// FIX ME: What if admin set lock, but public user is current lock user?
             $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']);
             return true;
         } else {
-            App::logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
             return false;
         }
@@ -196,8 +209,10 @@
     function isMine()
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
         if (isset($this->data['lock_id'])) {
-            $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . DB::escapeString($this->data['lock_id']) . "'");
+            $qid = $db->query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . $db->escapeString($this->data['lock_id']) . "'");
             if ($lock = mysql_fetch_assoc($qid)) {
                 return ($lock['set_by_admin_id'] == $this->_auth->getVal('user_id'));
@@ -222,4 +237,6 @@
     function set($record_table, $record_key, $record_val, $title='')
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
@@ -228,13 +245,13 @@
 
         // Remove previous locks if exist. Is this better than using a REPLACE INTO?
-        DB::query("
+        $db->query("
             DELETE FROM " . $this->getParam('db_table') . "
-            WHERE record_table = '" . DB::escapeString($record_table) . "'
-            AND record_key = '" . DB::escapeString($record_key) . "'
-            AND record_val = '" . DB::escapeString($record_val) . "'
+            WHERE record_table = '" . $db->escapeString($record_table) . "'
+            AND record_key = '" . $db->escapeString($record_key) . "'
+            AND record_val = '" . $db->escapeString($record_val) . "'
         ");
 
         // Set new lock.
-        DB::query("
+        $db->query("
             INSERT INTO " . $this->getParam('db_table') . " (
                 record_table,
@@ -245,13 +262,13 @@
                 lock_datetime
             ) VALUES (
-                '" . DB::escapeString($record_table) . "',
-                '" . DB::escapeString($record_key) . "',
-                '" . DB::escapeString($record_val) . "',
-                '" . DB::escapeString($title) . "',
-                '" . DB::escapeString($this->_auth->getVal('user_id')) . "',
+                '" . $db->escapeString($record_table) . "',
+                '" . $db->escapeString($record_key) . "',
+                '" . $db->escapeString($record_val) . "',
+                '" . $db->escapeString($title) . "',
+                '" . $db->escapeString($this->_auth->getVal('user_id')) . "',
                 NOW()
             )
         ");
-        $lock_id = mysql_insert_id(DB::getDBH());
+        $lock_id = mysql_insert_id($db->getDBH());
 
         // Must register this locked record as the current.
@@ -266,4 +283,7 @@
     function remove()
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         $this->initDB();
 
@@ -272,10 +292,10 @@
 
         // Delete a specific lock.
-        DB::query("
+        $db->query("
             DELETE FROM " . $this->getParam('db_table') . "
-            WHERE lock_id = '" . DB::escapeString($this->data['lock_id']) . "'
+            WHERE lock_id = '" . $db->escapeString($this->data['lock_id']) . "'
         ");
 
-        App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
     }
 
@@ -285,4 +305,7 @@
     function removeAll($user_id=null)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         $this->initDB();
 
@@ -292,10 +315,10 @@
         if (isset($user_id)) {
             // Delete specific user's locks.
-            DB::query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . DB::escapeString($user_id) . "'");
-            App::logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
+            $db->query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . $db->escapeString($user_id) . "'");
+            $app->logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
         } else {
             // Delete ALL locks.
-            DB::query("DELETE FROM " . $this->getParam('db_table') . "");
-            App::logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__);
+            $db->query("DELETE FROM " . $this->getParam('db_table') . "");
+            $app->logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__);
         }
     }
@@ -306,4 +329,6 @@
     function _auto_timeout()
     {
+		$db =& DB::getInstance();
+	
         static $_timeout_run = false;
 
@@ -312,5 +337,5 @@
         if (!$_timeout_run) {
             // Delete all old locks.
-            DB::query("
+            $db->query("
                 DELETE FROM " . $this->getParam('db_table') . "
                 WHERE DATE_ADD(lock_datetime, INTERVAL '" . $this->getParam('auto_timeout') . "' SECOND) < NOW()
@@ -325,5 +350,7 @@
     function dieErrorPage()
     {
-        App::dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe())));
+		$app =& App::getInstance();
+
+        $app->dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe())));
     }
 
@@ -333,7 +360,9 @@
     function printErrorHTML()
     {
+		$app =& App::getInstance();
+
         ?>
         <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-        <?php App::printHiddenSession() ?>
+        <?php $app->printHiddenSession() ?>
         <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" />
 
Index: trunk/lib/RecordVersion.inc.php
===================================================================
--- trunk/lib/RecordVersion.inc.php	(revision 124)
+++ trunk/lib/RecordVersion.inc.php	(revision 136)
@@ -1,5 +1,8 @@
 <?php
 /**
- * The RecordVersion:: class provides a system for saving, reviewing, and
+ * RecordVersion.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
+ * The RecordVersion class provides a system for saving, reviewing, and
  * restoring versions of a record of any DB table. All the data in the record is
  * serialized, compressed, and saved in a blob in the version_tbl. Restoring a
@@ -14,5 +17,4 @@
  * @version 2.1
  */
-
 class RecordVersion {
 
@@ -33,5 +35,5 @@
      * This method enforces the singleton pattern for this class.
      *
-     * @return  object  Reference to the global RecordVersion object.
+     * @return  object  Reference to the global RecordLock object.
      * @access  public
      * @static
@@ -39,11 +41,11 @@
     function &getInstance($auth_object)
     {
-        static $instances = array();
-
-        if (!isset($instances[$auth_object->getVal('auth_name')])) {
-            $instances[$auth_object->getVal('auth_name')] = new RecordVersion($auth_object);
-        }
-
-        return $instances[$auth_object->getVal('auth_name')];
+        static $instance = null;
+
+        if ($instance === null) {
+            $instance = new RecordVersion($auth_object);
+        }
+
+        return $instance;
     }
 
@@ -55,6 +57,8 @@
     function RecordVersion($auth_object)
     {
-        if (!is_a($auth_object, 'Auth_SQL')) {
-            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
+		$app =& App::getInstance();
+
+        if (!method_exists($auth_object, 'getVal') || !method_exists($auth_object, 'getUsername')) {
+            trigger_error('Constructor not provided a valid Auth_* object.', E_USER_ERROR);
         }
 
@@ -62,6 +66,6 @@
 
         // Get create tables config from global context.
-        if (!is_null(App::getParam('db_create_tables'))) {
-            $this->setParam(array('create_table' => App::getParam('db_create_tables')));
+        if (!is_null($app->getParam('db_create_tables'))) {
+            $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
         }
     }
@@ -76,12 +80,15 @@
     function initDB($recreate_db=false)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         static $_db_tested = false;
 
         if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
             if ($recreate_db) {
-                DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
-                App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
+                $db->query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
+                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
             }
-            DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
+            $db->query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
                 version_id int NOT NULL auto_increment,
                 record_table varchar(255) NOT NULL default '',
@@ -99,5 +106,5 @@
             )");
 
-            if (!DB::columnExists($this->getParam('db_table'), array(
+            if (!$db->columnExists($this->getParam('db_table'), array(
                 'version_id',
                 'record_table',
@@ -110,5 +117,5 @@
                 'version_datetime',
             ), false, false)) {
-                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
                 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
             }
@@ -131,16 +138,18 @@
 
     /**
-     * Return the value of a param setting.
-     *
-     * @access  public
-     * @param   string  $params Which param to return.
-     * @return  mixed   Configured param value.
+     * Return the value of a parameter, if it exists.
+     *
+     * @access public
+     * @param string $param        Which parameter to return.
+     * @return mixed               Configured parameter value.
      */
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -159,9 +168,12 @@
     function create($record_table, $record_key, $record_val, $title='', $notes='')
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         $this->initDB();
 
         // Get current record.
         if (!$record = $this->getCurrent($record_table, $record_key, $record_val)) {
-            App::logMsg(sprintf('Could not create %s version, record not found: %s, %s, %s.', $title, $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Could not create %s version, record not found: %s, %s, %s.', $title, $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -171,5 +183,5 @@
 
         // Save as new version.
-        DB::query("
+        $db->query("
             INSERT INTO " . $this->getParam('db_table') . " (
                 record_table,
@@ -182,16 +194,16 @@
                 version_datetime
             ) VALUES (
-                '" . DB::escapeString($record_table) . "',
-                '" . DB::escapeString($record_key) . "',
-                '" . DB::escapeString($record_val) . "',
-                '" . DB::escapeString(gzcompress(serialize($record), 9)) . "',
-                '" . DB::escapeString($title) . "',
-                '" . DB::escapeString($notes) . "',
-                '" . DB::escapeString($this->_auth->getVal('user_id')) . "',
+                '" . $db->escapeString($record_table) . "',
+                '" . $db->escapeString($record_key) . "',
+                '" . $db->escapeString($record_val) . "',
+                '" . $db->escapeString(gzcompress(serialize($record), 9)) . "',
+                '" . $db->escapeString($title) . "',
+                '" . $db->escapeString($notes) . "',
+                '" . $db->escapeString($this->_auth->getVal('user_id')) . "',
                 NOW()
             )
         ");
 
-        return mysql_insert_id(DB::getDBH());
+        return mysql_insert_id($db->getDBH());
     }
 
@@ -205,14 +217,17 @@
     function restore($version_id)
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         $this->initDB();
 
         // Get version data.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT * FROM " . $this->getParam('db_table') . "
-            WHERE version_id = '" . DB::escapeString($version_id) . "'
+            WHERE version_id = '" . $db->escapeString($version_id) . "'
         ");
         if (!$record = mysql_fetch_assoc($qid)) {
-            App::raiseMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_WARNING, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), LOG_WARNING, __FILE__, __LINE__);
+            $app->raiseMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Version ID %s%s not found."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -220,12 +235,12 @@
 
         // Ensure saved db columns match current table schema.
-        if (!DB::columnExists($record['record_table'], array_keys($data), $this->getParam('db_schema_strict'))) {
-            App::raiseMsg(sprintf(_("Version ID %s%s is not compatible with the current database table."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Version ID %s%s restoration failed, DB schema does not match for table %s."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')'), $record['record_table']), LOG_ALERT, __FILE__, __LINE__);
+        if (!$db->columnExists($record['record_table'], array_keys($data), $this->getParam('db_schema_strict'))) {
+            $app->raiseMsg(sprintf(_("Version ID %s%s is not compatible with the current database table."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')')), MSG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Version ID %s%s restoration failed, DB schema does not match for table %s."), $version_id, (empty($record['version_title']) ? '' : ' (' . $record['version_title'] . ')'), $record['record_table']), LOG_ALERT, __FILE__, __LINE__);
             return false;
         }
 
         // SQLize the keys of the specified versioned record.
-        $replace_keys = join(",\n", array_map(array('DB', 'escapeString'), array_keys($data)));
+        $replace_keys = join(",\n", array_map(array($db, 'escapeString'), array_keys($data)));
 
         // SQLize the keys of the values of the specified versioned record. (These are more complex because we need to account for SQL null values.)
@@ -233,10 +248,10 @@
         $comma = '';
         foreach ($data as $v) {
-            $replace_values .= is_null($v) ? "$comma\nNULL" : "$comma\n'" . DB::escapeString($v) . "'";
+            $replace_values .= is_null($v) ? "$comma\nNULL" : "$comma\n'" . $db->escapeString($v) . "'";
             $comma = ',';
         }
 
         // Replace current record with specified versioned record.
-        DB::query("
+        $db->query("
             REPLACE INTO " . $record['record_table'] . " (
                 $replace_keys
@@ -263,12 +278,14 @@
     function deleteOld($record_table, $record_key, $record_val)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
         // Get total number of versions for this record.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT COUNT(*) FROM " . $this->getParam('db_table') . "
-            WHERE record_table = '" . DB::escapeString($record_table) . "'
-            AND record_key = '" . DB::escapeString($record_key) . "'
-            AND record_val = '" . DB::escapeString($record_val) . "'
+            WHERE record_table = '" . $db->escapeString($record_table) . "'
+            AND record_key = '" . $db->escapeString($record_key) . "'
+            AND record_val = '" . $db->escapeString($record_val) . "'
         ");
         list($v_count) = mysql_fetch_row($qid);
@@ -278,9 +295,9 @@
                 // To prevent a record bomb, limit max number of versions to max_qty.
                 // First query for oldest records, selecting enough to bring total number down to min_qty.
-                $qid = DB::query("
+                $qid = $db->query("
                     SELECT version_id FROM " . $this->getParam('db_table') . "
-                    WHERE record_table = '" . DB::escapeString($record_table) . "'
-                    AND record_key = '" . DB::escapeString($record_key) . "'
-                    AND record_val = '" . DB::escapeString($record_val) . "'
+                    WHERE record_table = '" . $db->escapeString($record_table) . "'
+                    AND record_key = '" . $db->escapeString($record_key) . "'
+                    AND record_val = '" . $db->escapeString($record_val) . "'
                     ORDER BY version_datetime ASC
                     LIMIT " . ($v_count - $this->getParam('min_qty')) . "
@@ -289,5 +306,5 @@
                     $old_versions[] = $old_id;
                 }
-                DB::query("
+                $db->query("
                     DELETE FROM " . $this->getParam('db_table') . "
                     WHERE version_id IN ('" . join("','", $old_versions) . "')
@@ -295,9 +312,9 @@
             } else {
                 // Delete versions older than min_days, while still keeping min_qty.
-                $qid = DB::query("
+                $qid = $db->query("
                     SELECT version_id FROM " . $this->getParam('db_table') . "
-                    WHERE record_table = '" . DB::escapeString($record_table) . "'
-                    AND record_key = '" . DB::escapeString($record_key) . "'
-                    AND record_val = '" . DB::escapeString($record_val) . "'
+                    WHERE record_table = '" . $db->escapeString($record_table) . "'
+                    AND record_key = '" . $db->escapeString($record_key) . "'
+                    AND record_val = '" . $db->escapeString($record_val) . "'
                     AND DATE_ADD(version_datetime, INTERVAL '" . $this->getParam('min_days') . "' DAY) < NOW()
                     ORDER BY version_datetime ASC
@@ -308,5 +325,5 @@
                 }
                 if (sizeof($old_versions) > 0) {
-                    DB::query("
+                    $db->query("
                         DELETE FROM " . $this->getParam('db_table') . "
                         WHERE version_id IN ('" . join("','", $old_versions) . "')
@@ -328,13 +345,15 @@
     function getList($record_table, $record_key, $record_val)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
         // Get versions of this record.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT version_id, saved_by_admin_id, version_datetime, version_title
             FROM " . $this->getParam('db_table') . "
-            WHERE record_table = '" . DB::escapeString($record_table) . "'
-            AND record_key = '" . DB::escapeString($record_key) . "'
-            AND record_val = '" . DB::escapeString($record_val) . "'
+            WHERE record_table = '" . $db->escapeString($record_table) . "'
+            AND record_key = '" . $db->escapeString($record_key) . "'
+            AND record_val = '" . $db->escapeString($record_val) . "'
             ORDER BY version_datetime DESC
         ");
@@ -357,10 +376,12 @@
     function getVerson($version_id)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
         // Get version data.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT * FROM " . $this->getParam('db_table') . "
-            WHERE version_id = '" . DB::escapeString($version_id) . "'
+            WHERE version_id = '" . $db->escapeString($version_id) . "'
         ");
         return mysql_fetch_assoc($qid);
@@ -376,10 +397,12 @@
     function getData($version_id)
     {
+		$db =& DB::getInstance();
+	
         $this->initDB();
 
         // Get version data.
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT * FROM " . $this->getParam('db_table') . "
-            WHERE version_id = '" . DB::escapeString($version_id) . "'
+            WHERE version_id = '" . $db->escapeString($version_id) . "'
         ");
         $record = mysql_fetch_assoc($qid);
@@ -400,9 +423,11 @@
     function getCurrent($record_table, $record_key, $record_val)
     {
-        $this->initDB();
-
-        $qid = DB::query("
-            SELECT * FROM " . DB::escapeString($record_table) . "
-            WHERE " . DB::escapeString($record_key) . " = '" . DB::escapeString($record_val) . "'
+		$db =& DB::getInstance();
+	
+        $this->initDB();
+
+        $qid = $db->query("
+            SELECT * FROM " . $db->escapeString($record_table) . "
+            WHERE " . $db->escapeString($record_key) . " = '" . $db->escapeString($record_val) . "'
         ");
         if ($record = mysql_fetch_assoc($qid)) {
Index: trunk/lib/ScriptTimer.inc.php
===================================================================
--- trunk/lib/ScriptTimer.inc.php	(revision 124)
+++ trunk/lib/ScriptTimer.inc.php	(revision 136)
@@ -1,8 +1,7 @@
 <?php
 /**
- * ScriptTimer.inc.php 
- * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
+ * ScriptTimer.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
  */
- 
 class ScriptTimer {
 
Index: trunk/lib/SessionCache.inc.php
===================================================================
--- trunk/lib/SessionCache.inc.php	(revision 124)
+++ trunk/lib/SessionCache.inc.php	(revision 136)
@@ -1,15 +1,20 @@
 <?php
 /**
- * SessionCache.inc.php
+ * Cache.inc.php
+ * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
+ *
  * Provides an API for storing a limited amount of data
  * intended to have a short lifetime in a user's session.
  *
- * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information.
  * @author  Quinn Comendant <quinn@strangecode.com>
- * @version 1.2
+ * @version 2.1
  * @since   2001
  */
-class SessionCache
-{
+ 
+// Flags.
+define('CACHE_IGNORE_SIZE', 1);
+
+class Cache {
+
     var $_params = array(
         'enabled' => true,
@@ -22,13 +27,14 @@
      * This method enforces the singleton pattern for this class.
      *
-     * @return  object  Reference to the global SessionCache object.
+     * @return  object  Reference to the global Cache object.
      * @access  public
      * @static
      */
-    function &getInstance() {
+    function &getInstance()
+    {
         static $instance = null;
 
         if ($instance === null) {
-            $instance = new SessionCache();
+            $instance = new Cache();
         }
 
@@ -44,13 +50,11 @@
     function setParam($params)
     {
-        if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {
-            $_this =& SessionCache::getInstance();
-        }
+		$app =& App::getInstance();
 
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
-            $_this->_params = array_merge($_this->_params, $params);
-        } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $this->_params = array_merge($this->_params, $params);
+        } else {
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -65,12 +69,10 @@
     function getParam($param)
     {
-        if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {
-            $_this =& SessionCache::getInstance();
-        }
-
-        if (isset($_this->_params[$param])) {
-            return $_this->_params[$param];
-        } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+		$app =& App::getInstance();
+    
+        if (isset($this->_params[$param])) {
+            return $this->_params[$param];
+        } else {
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -78,41 +80,39 @@
 
     /**
-     * Stores a new variable in the session cache. The $var_id is is md5'ed
+     * Stores a new variable in the session cache. The $key is is md5'ed
      * because if a variable id is a very large integer, the array_shift function
-     * will reset the key to the next largest int key. Weird behaviour I can't
+     * will reset the key to the next largest int key. Weird behavior I can't
      * understand. $session_cache[32341234123] will become $session_cache[0]
      * for example. Usage warning: if the variable is too big to fit, or is
      * old and discarded, you must provide alternative ways of accessing the data.
      *
+     * @param str   $key        An identifier for the cached object.
      * @param mixed $var          The var to store in the session cache.
-     * @param str   $var_id       An identifyer for the cached object.
-     * @param bool  $force_it_in  If we have something really big that we
-     *                            still want to cache, setting this true
-     *                            allows this.
-     *
-     * @return string        The $var_id, or false if the object was too big to cache.
-     */
-    function putCache($var, $var_id, $force_it_in=false)
-    {
-        if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {
-            $_this =& SessionCache::getInstance();
-        }
-
-        if (!$_this->getParam('enabled')) {
-            App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
-            return false;
-        }
-
-        $var_id = md5($var_id);
+     * @param bool  $flags      If we have something really big that we
+     *                            still want to cache, setting this to
+     *                            CACHE_IGNORE_SIZE allows this.
+     *
+     * @return bool               True on success, false otherwise.
+     */
+    function set($key, $var, $flags=0)
+    {
+		$app =& App::getInstance();
+
+        if (!$this->getParam('enabled')) {
+            $app->logMsg(sprintf('Cache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
+            return false;
+        }
+
+        $key = md5($key);
         $serialized_var = serialize($var);
         $serialized_var_len = strlen($serialized_var);
 
-        if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) {
-            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
-            return false;
-        }
-
-        if ($serialized_var_len >= $_this->getParam('hard_limit')) {
-            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
+        if ($flags & CACHE_IGNORE_SIZE > 0 && $serialized_var_len >= $this->getParam('soft_limit')) {
+            $app->logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
+            return false;
+        }
+
+        if ($serialized_var_len >= $this->getParam('hard_limit')) {
+            $app->logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
             return false;
         }
@@ -121,18 +121,18 @@
             $_SESSION['_session_cache'] = array();
         } else {
-            unset($_SESSION['_session_cache'][$var_id]);
+            unset($_SESSION['_session_cache'][$key]);
             // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
-            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit')
-            && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) {
+            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
+            && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
                 array_shift($_SESSION['_session_cache']);
             }
         }
-        $_SESSION['_session_cache'][$var_id] =& $serialized_var;
+        $_SESSION['_session_cache'][$key] =& $serialized_var;
 
         if ($serialized_var_len >= 1024000) {
-            App::logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__);
-        }
-
-        return $var_id;
+            $app->logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__);
+        }
+
+        return true;
     }
 
@@ -143,26 +143,22 @@
      * first.
      *
-     * @param string $var_id  The identifyer for the datum to retrieve.
+     * @param string $key  The key for the datum to retrieve.
      *
      * @return mixed          The requested datum, or false on failure.
      */
-    function getCache($var_id)
-    {
-        if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {
-            $_this =& SessionCache::getInstance();
-        }
-
-        if (!$_this->getParam('enabled')) {
-            return false;
-        }
-
-        $var_id = md5($var_id);
-        if (isset($_SESSION['_session_cache'][$var_id])) {
+    function get($key)
+    {
+        if (!$this->getParam('enabled')) {
+            return false;
+        }
+
+        $key = md5($key);
+        if (isset($_SESSION['_session_cache'][$key])) {
             // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
-            $tmp =& $_SESSION['_session_cache'][$var_id];
-            unset($_SESSION['_session_cache'][$var_id]);
-            $_SESSION['_session_cache'][$var_id] =& $tmp;
+            $tmp =& $_SESSION['_session_cache'][$key];
+            unset($_SESSION['_session_cache'][$key]);
+            $_SESSION['_session_cache'][$key] =& $tmp;
             // Return the unserialized datum.
-            return unserialize($_SESSION['_session_cache'][$var_id]);
+            return unserialize($_SESSION['_session_cache'][$key]);
         } else {
             return false;
@@ -173,20 +169,16 @@
      * Tells you if the object is cached.
      *
-     * @param string $var_id  The ID of the object to check.
+     * @param string $key  The key of the object to check.
      *
      * @return bool           The return from isset().
      */
-    function isCached($var_id)
-    {
-        if (!isset($_this) || !is_a($_this, 'SessionCache') && !is_subclass_of($_this, 'SessionCache')) {
-            $_this =& SessionCache::getInstance();
-        }
-
-        if (!$_this->getParam('enabled')) {
-            return false;
-        }
-
-        $var_id = md5($var_id);
-        return isset($_SESSION['_session_cache'][$var_id]);
+    function exists($key)
+    {
+        if (!$this->getParam('enabled')) {
+            return false;
+        }
+
+        $key = md5($key);
+        return isset($_SESSION['_session_cache'][$key]);
     }
 
@@ -194,17 +186,17 @@
      * Tells you if the object is cached.
      *
-     * @param string $var_id  The ID of the object to check.
+     * @param string $key  The key of the object to check.
      *
      * @return bool           The return from isset().
      */
-    function breakCache($var_id)
-    {
-        $var_id = md5($var_id);
-        if (isset($_SESSION['_session_cache'][$var_id])) {
-            unset($_SESSION['_session_cache'][$var_id]);
-        }
-    }
-
-// END SessionCache
+    function delete($key)
+    {
+        $key = md5($key);
+        if (isset($_SESSION['_session_cache'][$key])) {
+            unset($_SESSION['_session_cache'][$key]);
+        }
+    }
+
+// END Cache
 }
 
Index: trunk/lib/SortOrder.inc.php
===================================================================
--- trunk/lib/SortOrder.inc.php	(revision 124)
+++ trunk/lib/SortOrder.inc.php	(revision 136)
@@ -69,4 +69,6 @@
     function setDefault($default_sort = '', $default_order = '')
     {
+		$prefs =& Prefs::getInstance();
+
         // Which column to sort by?
         // (1) By GET or POST specification, if available.
@@ -76,7 +78,7 @@
         if (!empty($new_sort_by)) {
             $this->sort_by = $new_sort_by;
-            Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
-        } else if (Prefs::exists('sort_by', $_SERVER['PHP_SELF'])) {
-            $this->sort_by = Prefs::getValue('sort_by', $_SERVER['PHP_SELF']);
+            $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
+        } else if ($prefs->exists('sort_by', $_SERVER['PHP_SELF'])) {
+            $this->sort_by = $prefs->get('sort_by', $_SERVER['PHP_SELF']);
         } else {
             $this->sort_by = $default_sort;
@@ -90,7 +92,7 @@
         if (!empty($new_order)) {
             $this->order = $new_order;
-            Prefs::setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);
-        } else if (Prefs::exists('sort_order', $_SERVER['PHP_SELF'])) {
-            $this->order = Prefs::getValue('sort_order', $_SERVER['PHP_SELF']);
+            $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']);
+        } else if ($prefs->exists('sort_order', $_SERVER['PHP_SELF'])) {
+            $this->order = $prefs->get('sort_order', $_SERVER['PHP_SELF']);
         } else {
             $this->order = $default_order;
@@ -109,8 +111,10 @@
     function set($sort = null, $order = null)
     {
+		$prefs =& Prefs::getInstance();
+
         // Set new sort value.
         if (isset($sort)) {
             $this->sort_by = $sort;
-            Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
+            $prefs->set('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
         }
 
@@ -118,5 +122,5 @@
         if (isset($order)) {
             $this->order = $order;
-            Prefs::setValue('sort_order', $this->order, $_SERVER['PHP_SELF']);
+            $prefs->set('sort_order', $this->order, $_SERVER['PHP_SELF']);
         }
     }
@@ -128,4 +132,7 @@
     function getSortOrderSQL()
     {
+		$app =& App::getInstance();
+		$db =& DB::getInstance();
+
         if (!isset($this->_columns[strtolower($this->sort_by)])) {
             $this->sort_by = $this->default_sort;
@@ -137,7 +144,7 @@
 
         if (!empty($this->_columns[strtolower($this->sort_by)][strtolower($this->order)])) {
-            return sprintf(' ORDER BY %s ', DB::escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]));
+            return sprintf(' ORDER BY %s ', $db->escapeString($this->_columns[strtolower($this->sort_by)][strtolower($this->order)]));
         } else {
-            App::logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Could not find SQL to sort by %s %s.', $this->sort_by, $this->order), LOG_WARNING, __FILE__, __LINE__);
             return '';
         }
@@ -155,12 +162,14 @@
     function printSortHeader($col, $col_name, $default_order='ASC')
     {
+		$app =& App::getInstance();
+
         if ($this->sort_by == $col) {
             if (strtolower($this->order) == 'desc') {
-                ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php
+                ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=ASC'); ?>" title="<?php echo _("Change to ascending sort order"); ?>"><?php echo $this->desc_widget; ?></a><?php echo $col_name; ?><?php
             } else {
-                ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php
+                ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=DESC'); ?>" title="<?php echo _("Change to descending sort order"); ?>"><?php echo $this->asc_widget; ?></a><?php echo $col_name; ?><?php
             }
         } else {
-            ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php
+            ?><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php
         }
     }
Index: trunk/lib/SpellCheck.inc.php
===================================================================
--- trunk/lib/SpellCheck.inc.php	(revision 124)
+++ trunk/lib/SpellCheck.inc.php	(revision 136)
@@ -62,4 +62,6 @@
     function SpellCheck($params)
     {
+		$app =& App::getInstance();
+
         if (!is_array($params) || empty($params)) {
             trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
@@ -75,9 +77,9 @@
         if ('' != $this->getParam('personal_wordlist')) {
             if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) {
-                App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
             } else {
                 pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist'));
                 $this->_use_personal_wordlist = true;
-                App::logMsg(sprintf('Using personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Using personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
             }
         }
@@ -94,9 +96,11 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+
         if (isset($params) && is_array($params)) {
             // Merge new parameters with old overriding only those passed.
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -111,8 +115,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -184,10 +190,12 @@
     function add($word)
     {
+		$app =& App::getInstance();
+
         if ($this->_use_personal_wordlist) {
             if (pspell_add_to_personal($this->_pspell_handle, $word)) {
-                App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
                 return true;
             } else {
-                App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
                 return false;
             }
@@ -207,10 +215,12 @@
     function save()
     {
+		$app =& App::getInstance();
+
         if ($this->_use_personal_wordlist) {
             if (pspell_save_wordlist($this->_pspell_handle)) {
-                App::logMsg(sprintf('Saved personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Saved personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
                 return true;
             } else {
-                App::logMsg(sprintf('Failed saving personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf('Failed saving personal wordlist: %s', $this->getParam('personal_wordlist')), LOG_ERR, __FILE__, __LINE__);
                 return false;
             }
Index: trunk/lib/TemplateGlue.inc.php
===================================================================
--- trunk/lib/TemplateGlue.inc.php	(revision 124)
+++ trunk/lib/TemplateGlue.inc.php	(revision 136)
@@ -66,5 +66,8 @@
 function getSetEnumFieldValues($db_table, $db_col)
 {
-    $qid = DB::query("SHOW COLUMNS FROM " . DB::escapeString($db_table) . " LIKE '" . DB::escapeString($db_col) . "'",false);
+	$app =& App::getInstance();
+	$db =& DB::getInstance();
+	
+    $qid = $db->query("SHOW COLUMNS FROM " . $db->escapeString($db_table) . " LIKE '" . $db->escapeString($db_col) . "'",false);
 
     $row = mysql_fetch_row($qid);
@@ -72,5 +75,5 @@
         return $enum[1];
     } else {
-        App::logMsg(sprintf('No set or enum fields found.', null), LOG_ERR, __FILE__, __LINE__);
+        $app->logMsg(sprintf('No set or enum fields found.', null), LOG_ERR, __FILE__, __LINE__);
         return false;
     }
@@ -294,4 +297,6 @@
 function printSelectForm($db_table, $key_column, $val_column, $preselected, $blank=false, $extra_clause='')
 {
+	$db =& DB::getInstance();
+	
     // Sometimes preselected comes as a comma list.
     if (!is_array($preselected)) {
@@ -314,5 +319,5 @@
         }
     }
-    $qid = DB::query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false);
+    $qid = $db->query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false);
     while ($row = mysql_fetch_assoc($qid)) {
         $selected = in_array($row[$val_column], $preselected) ? ' selected="selected"' : '';
@@ -335,4 +340,6 @@
 function printDBCheckboxes($db_table, $key_column, $val_column, $preselected, $columns=1, $extra_clause='', $vert_columns=false)
 {
+	$db =& DB::getInstance();
+	
     // Sometimes preselected comes as a comma list.
     if (!is_array($preselected)) {
@@ -348,5 +355,5 @@
     }
 
-    $qid = DB::query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false);
+    $qid = $db->query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false);
     while ($row = mysql_fetch_assoc($qid)) {
         $values[] = $row;
Index: trunk/lib/Upload.inc.php
===================================================================
--- trunk/lib/Upload.inc.php	(revision 124)
+++ trunk/lib/Upload.inc.php	(revision 136)
@@ -56,4 +56,6 @@
     function setParam($params)
     {
+		$app =& App::getInstance();
+
         if (isset($params) && is_array($params)) {
 
@@ -63,8 +65,8 @@
                 // Must be directory.
                 if (!is_dir($params['upload_path'])) {
-                    App::logMsg(sprintf('Attempting to auto-create upload directory: %s', $params['upload_path']), LOG_NOTICE, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Attempting to auto-create upload directory: %s', $params['upload_path']), LOG_NOTICE, __FILE__, __LINE__);
                     mkdir($params['upload_path'], $this->getParam('dest_dir_perms'));
                     if (!is_dir($params['upload_path'])) {
-                        App::logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
+                        $app->logMsg(sprintf('Upload directory invalid: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
                         trigger_error(sprintf('Upload directory invalid: %s', $params['upload_path']), E_USER_ERROR);
                     }
@@ -72,5 +74,5 @@
                 // Must be writable.
                 if (!is_writable($params['upload_path'])) {
-                    App::logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Upload directory not writable: %s', $params['upload_path']), LOG_ERR, __FILE__, __LINE__);
                     trigger_error(sprintf('Upload directory not writable: %s', $params['upload_path']), E_USER_ERROR);
                 }
@@ -80,5 +82,5 @@
             $this->_params = array_merge($this->_params, $params);
         } else {
-            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
         }
     }
@@ -93,8 +95,10 @@
     function getParam($param)
     {
+		$app =& App::getInstance();
+    
         if (isset($this->_params[$param])) {
             return $this->_params[$param];
         } else {
-            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
             return null;
         }
@@ -117,7 +121,9 @@
     function process($form_name, $custom_file_name=null)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a upload directory.
         if (!$this->getParam('upload_path')) {
-            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             $this->_raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
             return false;
@@ -126,5 +132,5 @@
         // Ensure the file form element specified actually exists.
         if (!isset($_FILES[$form_name])) {
-            App::logMsg(sprintf(_("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__);
             $this->_raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
             return false;
@@ -167,9 +173,9 @@
                     $file_name = $custom_file_name;
                     $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__);
-                    App::logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
                 } else {
                     // Invalid custom file name provided. Use uploaded file name.
                     $file_name = $files['name'][$i];
-                    App::logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
                 }
             } else {
@@ -179,9 +185,9 @@
                     $file_name = $custom_file_name[$i];
                     $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), $files['name'][$i], $file_name), MSG_NOTICE, __FILE__, __LINE__);
-                    App::logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Using custom file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
                 } else {
                     // Invalid custom file name provided. Use uploaded file name.
                     $file_name = $files['name'][$i];
-                    App::logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
+                    $app->logMsg(sprintf('Using uploaded file name: %s', $file_name), LOG_DEBUG, __FILE__, __LINE__);
                 }
             }
@@ -190,5 +196,5 @@
             if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_INI_SIZE);
                 continue;
@@ -196,5 +202,5 @@
             if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_FORM_SIZE);
                 continue;
@@ -202,5 +208,5 @@
             if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it was only partially uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_PARTIAL);
                 continue;
@@ -208,5 +214,5 @@
             if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: no file was uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_FILE);
                 continue;
@@ -214,5 +220,5 @@
             if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: temporary upload directory missing."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_ERR_NO_TMP_DIR);
                 continue;
@@ -222,5 +228,5 @@
             if (!is_uploaded_file($files['tmp_name'][$i])) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UPLOADED_FILE);
                 continue;
@@ -230,5 +236,5 @@
             if ($files['size'][$i] <= 0) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it contains zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_EMPTY_FILE);
                 continue;
@@ -238,5 +244,5 @@
             if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: it is an unrecognized type. Files must have one of the following file name extensions: %s."), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_INVALID_EXTENSION);
                 continue;
@@ -246,5 +252,5 @@
             if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading: a file with that name already exists."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_NOT_UNIQUE);
                 continue;
@@ -269,5 +275,5 @@
             if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
                 chmod($file_path_name, $this->getParam('dest_file_perms'));
-                App::logMsg(sprintf('File uploaded: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);
+                $app->logMsg(sprintf('File uploaded: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);
                 $this->_raiseMsg(sprintf(_("The file %s uploaded successfully."), $file_name), MSG_SUCCESS, __FILE__, __LINE__);
                 if (!isset($custom_file_name) && $files['name'][$i] != $file_name) {
@@ -284,5 +290,5 @@
             } else {
                 $this->_raiseMsg(sprintf(_("The file %s failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__);
                 $this->errors[] = array('filename' => $file_name, 'errortype' => UPLOAD_USER_ERR_MOVE_FAILED);
             }
@@ -290,5 +296,5 @@
             // Check file extension with browsers interpretation of file type.
             if (isset($this->mime_extension_map[$file_extension]) && $files['type'][$i] != $this->mime_extension_map[$file_extension]) {
-                App::logMsg(sprintf('File extension (%s) does not match mime type (%s).', $file_extension, $files['type'][$i]), LOG_NOTICE, __FILE__, __LINE__);
+                $app->logMsg(sprintf('File extension (%s) does not match mime type (%s).', $file_extension, $files['type'][$i]), LOG_NOTICE, __FILE__, __LINE__);
             }
         }
@@ -307,7 +313,9 @@
     function deleteFile($file_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a upload directory.
         if (!$this->getParam('upload_path')) {
-            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -316,11 +324,11 @@
 
         if (!is_file($file_path_name)) {
-            App::logMsg(sprintf(_("Error deleting nonexistent file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Error deleting nonexistent file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (unlink($file_path_name)) {
-            App::logMsg(sprintf('Deleted file: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Deleted file: %s', $file_path_name), LOG_INFO, __FILE__, __LINE__);
         } else {
             $this->_raiseMsg(sprintf(_("The file %s could not be deleted."), $file_name), MSG_ERR, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Failed deleting file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Failed deleting file: %s"), $file_path_name), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -337,7 +345,9 @@
     function moveFile($old_name, $new_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have an upload directory.
         if (!$this->getParam('upload_path')) {
-            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -348,13 +358,13 @@
             if (rename($old_file_path_name, $new_file_path_name)) {
                 $this->_raiseMsg(sprintf(_("The file %s has been renamed to %s."), basename($old_file_path_name), basename($new_file_path_name)), MSG_NOTICE, __FILE__, __LINE__);
-                App::logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__);
+                $app->logMsg(sprintf('File renamed from %s to %s', $old_file_path_name, $new_file_path_name), LOG_DEBUG, __FILE__, __LINE__);
             } else {
                 $this->_raiseMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), MSG_WARNING, __FILE__, __LINE__);
-                App::logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_WARNING, __FILE__, __LINE__);
+                $app->logMsg(sprintf(_("Error renaming file to %s"), $new_file_path_name), LOG_WARNING, __FILE__, __LINE__);
                 return false;
             }
         } else {
             $this->_raiseMsg(sprintf(_("Couldn't rename nonexistent file %s."), $old_name), MSG_WARNING, __FILE__, __LINE__);
-            App::logMsg(sprintf(_("Error renaming nonexistent file: %s"), $old_file_path_name), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf(_("Error renaming nonexistent file: %s"), $old_file_path_name), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
@@ -370,7 +380,9 @@
     function exists($file_name)
     {
+		$app =& App::getInstance();
+
         // Ensure we have a upload directory.
         if (!$this->getParam('upload_path')) {
-            App::logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Upload directory not set before processing.'), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -453,5 +465,5 @@
 
     /**
-     * An alias for App::raiseMsg that only sends messages configured by display_messages.
+     * An alias for $app->raiseMsg that only sends messages configured by display_messages.
      *
      * @access public
@@ -465,6 +477,8 @@
     function _raiseMsg($message, $type, $file, $line)
     {
+		$app =& App::getInstance();
+
         if ($this->getParam('display_messages') === true || (is_int($this->getParam('display_messages')) && $this->getParam('display_messages') & $type > 0)) {
-            App::raiseMsg($message, $type, $file, $line);
+            $app->raiseMsg($message, $type, $file, $line);
         }
     }
Index: trunk/lib/Utilities.inc.php
===================================================================
--- trunk/lib/Utilities.inc.php	(revision 124)
+++ trunk/lib/Utilities.inc.php	(revision 136)
@@ -74,4 +74,6 @@
 function oTxt($txt, $preserve_html=false)
 {
+	$app =& App::getInstance();
+
     $search = array();
     $replace = array();
@@ -100,5 +102,5 @@
     $replace['ampersand']       = '&amp;';
 
-    return preg_replace($search, $replace, htmlentities($txt, ENT_QUOTES, App::getParam('character_set')));
+    return preg_replace($search, $replace, htmlentities($txt, ENT_QUOTES, $app->getParam('character_set')));
 }
 
@@ -474,8 +476,10 @@
 function escapedList($in)
 {
+	$db =& DB::getInstance();
+	
     if (is_array($in) && !empty($in)) {
-        return "'" . join("', '", array_map(array('DB', 'escapeString'), $in)) . "'";
-    } else {
-        return DB::escapeString($in);
+        return "'" . join("', '", array_map(array($db, 'escapeString'), $in)) . "'";
+    } else {
+        return $db->escapeString($in);
     }
 }
@@ -596,10 +600,12 @@
 function addSignature($val, $seed_key=null)
 {
+	$app =& App::getInstance();
+	
     if ('' == $val) {
-        App::logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__);
     }
 
     if (!isset($seed_key)) {
-        $seed_key = App::getParam('signing_key');
+        $seed_key = $app->getParam('signing_key');
     }
 
@@ -662,17 +668,19 @@
 function mailmanAddMember($email, $list, $send_welcome_message=false)
 {
-   $add_members = '/var/mailman/bin/add_members';
+	$app =& App::getInstance();
+	
+	$add_members = '/var/mailman/bin/add_members';
     if (is_executable($add_members) && is_readable($add_members)) {
         $welcome_msg = $send_welcome_message ? 'y' : 'n';
         exec(sprintf('/bin/echo %s | /usr/bin/sudo %s -r - --welcome-msg=%s --admin-notify=n %s', escapeshellarg($email), escapeshellarg($add_members), $welcome_msg, escapeshellarg($list)), $stdout, $return_code);
         if (0 == $return_code) {
-            App::logMsg(sprintf('Mailman add member success for list: %s, user: %s', $list, $email, $stdout), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Mailman add member success for list: %s, user: %s', $list, $email, $stdout), LOG_INFO, __FILE__, __LINE__);
             return true;
         } else {
-            App::logMsg(sprintf('Mailman add member failed for list: %s, user: %s, with message: %s', $list, $email, $stdout), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Mailman add member failed for list: %s, user: %s, with message: %s', $list, $email, $stdout), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
     } else {
-        App::logMsg(sprintf('Mailman add member program not executable: %s', $add_members), LOG_ALERT, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Mailman add member program not executable: %s', $add_members), LOG_ALERT, __FILE__, __LINE__);
         return false;
     }
@@ -691,4 +699,6 @@
 function mailmanRemoveMember($email, $list, $send_user_ack=false)
 {
+	$app =& App::getInstance();
+	
     $remove_members = '/var/mailman/bin/remove_members';
     if (is_executable($remove_members) && is_readable($remove_members)) {
@@ -696,12 +706,12 @@
         exec(sprintf('/usr/bin/sudo %s %s --noadminack %s %s', escapeshellarg($remove_members), $userack, escapeshellarg($list), escapeshellarg($email)), $stdout, $return_code);
         if (0 == $return_code) {
-            App::logMsg(sprintf('Mailman remove member success for list: %s, user: %s', $list, $email, $stdout), LOG_INFO, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Mailman remove member success for list: %s, user: %s', $list, $email, $stdout), LOG_INFO, __FILE__, __LINE__);
             return true;
         } else {
-            App::logMsg(sprintf('Mailman remove member failed for list: %s, user: %s, with message: %s', $list, $email, $stdout), LOG_WARNING, __FILE__, __LINE__);
+            $app->logMsg(sprintf('Mailman remove member failed for list: %s, user: %s, with message: %s', $list, $email, $stdout), LOG_WARNING, __FILE__, __LINE__);
             return false;
         }
     } else {
-        App::logMsg(sprintf('Mailman remove member program not executable: %s', $remove_members), LOG_ALERT, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Mailman remove member program not executable: %s', $remove_members), LOG_ALERT, __FILE__, __LINE__);
         return false;
     }
Index: trunk/services/admins.php
===================================================================
--- trunk/services/admins.php	(revision 124)
+++ trunk/services/admins.php	(revision 136)
@@ -8,8 +8,8 @@
 
 $auth->requireLogin();
-App::sslOn();
+$app->sslOn();
 
 require_once 'codebase/lib/PageNumbers.inc.php';
-require_once 'codebase/lib/SessionCache.inc.php';
+require_once 'codebase/lib/Cache.inc.php';
 require_once 'codebase/lib/FormValidator.inc.php';
 require_once 'codebase/lib/SortOrder.inc.php';
@@ -29,4 +29,6 @@
 // The object to validate form input.
 $fv = new FormValidator();
+
+$cache =& Cache::getInstance();
 
 // Instantiate a sorting object with the default sort and order. Add SQL for each column.
@@ -54,5 +56,5 @@
 
 // Search limiters retain their values between page requests.
-App::carryQuery('search_query');
+$app->carryQuery('search_query');
 
 
@@ -64,10 +66,10 @@
 // allows us to remember which page we came from so we can go back there.
 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
+    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
 }
 
 if (getFormData('break_list_cache', false)) {
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 }
 
@@ -91,20 +93,20 @@
 case 'del' :
     deleteRecord(getFormData('admin_id'));
-    if (App::validBoomerangURL('admins')) {
+    if ($app->validBoomerangURL('admins')) {
         // Display boomerang page.
-        App::dieBoomerangURL('admins');
+        $app->dieBoomerangURL('admins');
     }
     // Display default page.
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
 case 'insert' :
     if (getFormdata('cancel', false)) {
-        if (App::validBoomerangURL('admins')) {
+        if ($app->validBoomerangURL('admins')) {
             // Display boomerang page.
-            App::dieBoomerangURL('admins');
+            $app->dieBoomerangURL('admins');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     validateInput();
@@ -118,11 +120,11 @@
         if (getFormdata('repeat', false)) {
             // Display function again.
-            App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
-        } else if (App::validBoomerangURL('admins')) {
+            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
+        } else if ($app->validBoomerangURL('admins')) {
             // Display boomerang page.
-            App::dieBoomerangURL('admins');
+            $app->dieBoomerangURL('admins');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     break;
@@ -130,6 +132,6 @@
 case 'update' :
     if (getFormdata('reset', false)) {
-        App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
-        App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));
+        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));
     }
     if (getFormdata('cancel', false)) {
@@ -137,10 +139,10 @@
         $lock->select('admin_tbl', 'admin_id', getFormData('admin_id'));
         $lock->remove();
-        if (App::validBoomerangURL('admins')) {
+        if ($app->validBoomerangURL('admins')) {
             // Display boomerang page.
-            App::dieBoomerangURL('admins');
+            $app->dieBoomerangURL('admins');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     validateInput();
@@ -154,16 +156,16 @@
         if (getFormdata('repeat', false)) {
             // Display edit function with next available ID.
-            $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . DB::escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");
+            $qid = $db->query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . $db->escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");
             if (list($next_id) = mysql_fetch_row($qid)) {
-                App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
+                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
             } else {
-                App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
+                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
             }
-        } else if (App::validBoomerangURL('admins')) {
+        } else if ($app->validBoomerangURL('admins')) {
             // Display boomerang page.
-            App::dieBoomerangURL('admins');
+            $app->dieBoomerangURL('admins');
         }
         // Display default page.
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     break;
@@ -258,5 +260,7 @@
 {
     global $lock;
-
+	$app =& App::getInstance();
+	$db =& DB::getInstance();
+	
     $lock->select('admin_tbl', 'admin_id', $id);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -265,13 +269,13 @@
 
     // Get the information for the form.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT *
         FROM admin_tbl
-        WHERE admin_id = '" . DB::escapeString($id) . "'
+        WHERE admin_id = '" . $db->escapeString($id) . "'
     ");
     if (!$frm = mysql_fetch_assoc($qid)) {
-        App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
-        App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
-        App::dieBoomerangURL();
+        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
+        $app->dieBoomerangURL();
     }
 
@@ -313,5 +317,8 @@
 {
     global $auth, $lock;
-
+	$app =& App::getInstance();
+	$db =& DB::getInstance();
+	$cache =& Cache::getInstance();
+	
     $lock->select('admin_tbl', 'admin_id', $id);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -320,33 +327,33 @@
 
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
     // Get the information for this object.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT username, user_type from admin_tbl
-        WHERE admin_id = '" . DB::escapeString($id) . "'
+        WHERE admin_id = '" . $db->escapeString($id) . "'
     ");
     if (! list($name, $user_type) = mysql_fetch_row($qid)) {
-        App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
-        App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
-        App::dieBoomerangURL();
+        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
+        $app->dieBoomerangURL();
     }
 
     // Get the information for this object.
-    $qid = DB::query("SELECT COUNT(*) from admin_tbl");
+    $qid = $db->query("SELECT COUNT(*) from admin_tbl");
     list($num_admins) = mysql_fetch_row($qid);
     if ('root' == $user_type && 'root' != $auth->getVal('user_type')) {
         // Only root users can delete root users!
-        App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
     } else if ($num_admins <= 1) {
         // There must always be at least one admnistrator!
-        App::raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__);
     } else if ($auth->getVal('user_id') == $id) {
         // Do not delete yourself!
-        App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
     } else {
         // Delete the record.
-        DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . DB::escapeString($id) . "'");
-        App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
+        $db->query("DELETE FROM admin_tbl WHERE admin_id = '" . $db->escapeString($id) . "'");
+        $app->raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
     }
 
@@ -358,10 +365,13 @@
 {
     global $auth;
-
+	$app =& App::getInstance();
+	$db =& DB::getInstance();
+	$cache =& Cache::getInstance();
+	
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
     // Insert record data.
-    DB::query("
+    $db->query("
         INSERT INTO admin_tbl (
             username,
@@ -373,14 +383,14 @@
             added_datetime
         ) VALUES (
-            '" . DB::escapeString($frm['username']) . "',
-            '" . DB::escapeString($frm['first_name']) . "',
-            '" . DB::escapeString($frm['last_name']) . "',
-            '" . DB::escapeString($frm['email']) . "',
-            '" . DB::escapeString($frm['user_type']) . "',
-            '" . DB::escapeString($auth->getVal('user_id')) . "',
+            '" . $db->escapeString($frm['username']) . "',
+            '" . $db->escapeString($frm['first_name']) . "',
+            '" . $db->escapeString($frm['last_name']) . "',
+            '" . $db->escapeString($frm['email']) . "',
+            '" . $db->escapeString($frm['user_type']) . "',
+            '" . $db->escapeString($auth->getVal('user_id')) . "',
             NOW()
         )
     ");
-    $last_insert_id = mysql_insert_id(DB::getDBH());
+    $last_insert_id = mysql_insert_id($db->getDBH());
 
     // Set admin password.
@@ -391,5 +401,5 @@
     $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
 
-    App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
 
     return $last_insert_id;
@@ -399,5 +409,8 @@
 {
     global $auth, $lock;
-
+	$app =& App::getInstance();
+	$db =& DB::getInstance();
+	$cache =& Cache::getInstance();
+	
     $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
     if ($lock->isLocked() && !$lock->isMine()) {
@@ -406,5 +419,5 @@
 
     // Break the cache because we are changing the list data.
-    SessionCache::breakCache($_SERVER['PHP_SELF']);
+    $cache->delete($_SERVER['PHP_SELF']);
 
     // If the userpass is left blank or with the filler **** characters, we don't want to update it.
@@ -415,14 +428,14 @@
 
     // Update record data.
-    DB::query("
+    $db->query("
         UPDATE admin_tbl SET
-            username = '" . DB::escapeString($frm['username']) . "',
-            first_name = '" . DB::escapeString($frm['first_name']) . "',
-            last_name = '" . DB::escapeString($frm['last_name']) . "',
-            email = '" . DB::escapeString($frm['email']) . "',
-            user_type = '" . DB::escapeString($frm['user_type']) . "',
-            modified_by_user_id = '" . DB::escapeString($auth->getVal('user_id')) . "',
+            username = '" . $db->escapeString($frm['username']) . "',
+            first_name = '" . $db->escapeString($frm['first_name']) . "',
+            last_name = '" . $db->escapeString($frm['last_name']) . "',
+            email = '" . $db->escapeString($frm['email']) . "',
+            user_type = '" . $db->escapeString($frm['user_type']) . "',
+            modified_by_user_id = '" . $db->escapeString($auth->getVal('user_id')) . "',
             modified_datetime = NOW()
-        WHERE admin_id = '" . DB::escapeString($frm['admin_id']) . "'
+        WHERE admin_id = '" . $db->escapeString($frm['admin_id']) . "'
     ");
 
@@ -431,5 +444,5 @@
     $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
 
-    App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
+    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
 
     // Unlock record.
@@ -441,5 +454,8 @@
     global $page;
     global $so;
-
+	$db =& DB::getInstance();
+	$prefs =& Prefs::getInstance();
+	$cache =& Cache::getInstance();
+	
     $where_clause = '';
 
@@ -450,8 +466,8 @@
             $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . "
                 (
-                    admin_tbl.username LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
-                    OR admin_tbl.first_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
-                    OR admin_tbl.last_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
-                    OR admin_tbl.email LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
+                    admin_tbl.username LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
+                    OR admin_tbl.first_name LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
+                    OR admin_tbl.last_name LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
+                    OR admin_tbl.email LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
                 )
             ";
@@ -460,5 +476,5 @@
 
     // Count the total number of records so we can do something about the page numbers.
-    $qid = DB::query("
+    $qid = $db->query("
         SELECT COUNT(*)
         FROM admin_tbl
@@ -491,15 +507,15 @@
     // without knowing the hash.
     $cache_hash = md5($sql . '|' . $page->total_items);
-    if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
-        SessionCache::breakCache($_SERVER['PHP_SELF']);
-        Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
-    }
-
-    if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) {
+    if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
+        $cache->delete($_SERVER['PHP_SELF']);
+        $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
+    }
+
+    if ($cache->exists($_SERVER['PHP_SELF']) && false) {
         // Get the cached results.
-        $list = SessionCache::getCache($_SERVER['PHP_SELF']);
+        $list = $cache->get($_SERVER['PHP_SELF']);
     } else {
         // If the list is not already cached, query now.
-        $qid = DB::query($sql);
+        $qid = $db->query($sql);
         // Fill an array with the items for this page.
         while ($row = mysql_fetch_assoc($qid)) {
@@ -509,5 +525,5 @@
         if (isset($list) && !empty($list)) {
             // Cache the results.
-            SessionCache::putCache($list, $_SERVER['PHP_SELF']);
+            $cache->set($list, $_SERVER['PHP_SELF']);
         }
     }
Index: trunk/services/lock.php
===================================================================
--- trunk/services/lock.php	(revision 124)
+++ trunk/services/lock.php	(revision 136)
@@ -9,12 +9,12 @@
 
 $auth->requireLogin();
-App::sslOn();
+$app->sslOn();
 
 if (getFormData('boomerang', false)) {
     // We remember which page we came from so we can go back there.
     $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
-    App::setBoomerangURL($boom_url, 'lock');
+    $app->setBoomerangURL($boom_url, 'lock');
     if (isset($_SERVER['HTTP_REFERER'])) {
-        App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
+        $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
     }
 }
@@ -26,6 +26,6 @@
 
 if (!$lock->isLocked()) {
-    App::logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
-    App::dieBoomerangURL('lock');
+    $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
+    $app->dieBoomerangURL('lock');
 }
 
@@ -33,10 +33,10 @@
 if (getFormData('unlock', false)) {
     $lock->remove();
-    App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
-    App::dieBoomerangURL('lock');
+    $app->raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
+    $app->dieBoomerangURL('lock');
 } else if (getFormData('cancel', false)) {
     // Since the boomerang URL will go back to the locked record, and the record was not unlocked, we must delete the boomerang URL otherwise we'll come back here.
-    App::deleteBoomerangURL('lock');
-    App::dieBoomerangURL('cancel-lock');
+    $app->deleteBoomerangURL('lock');
+    $app->dieBoomerangURL('cancel-lock');
 }
 
Index: trunk/services/login.php
===================================================================
--- trunk/services/login.php	(revision 124)
+++ trunk/services/login.php	(revision 136)
@@ -8,7 +8,7 @@
 // allows us to remember which page we came from so we can go back there.
 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'login');
+    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'login');
 }
-App::sslOn();
+$app->sslOn();
 
 $frm['username'] = getFormdata('username');
@@ -19,10 +19,10 @@
 
     if ($auth->login($frm['username'], $frm['password'])) {
-        App::raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);
-        App::dieBoomerangURL('login');
-        App::logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);
+        $app->raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);
+        $app->dieBoomerangURL('login');
+        $app->logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);
     } else {
-        App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
     }
 }
Index: trunk/services/logout.php
===================================================================
--- trunk/services/logout.php	(revision 124)
+++ trunk/services/logout.php	(revision 136)
@@ -5,5 +5,5 @@
  */
 
-if (is_a($auth, 'Auth_SQL')) {
+if (isset($auth) && method_exists($auth, 'getVal')) {
     // Delete the current user's record locks.
     require_once 'codebase/lib/RecordLock.inc.php';
@@ -15,6 +15,6 @@
 $auth->clearAuth();
 
-App::raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__);
-App::dieURL(App::getParam('redirect_home_url'));
+$app->raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__);
+$app->dieURL($app->getParam('redirect_home_url'));
 
 ?>
Index: trunk/services/logs.php
===================================================================
--- trunk/services/logs.php	(revision 124)
+++ trunk/services/logs.php	(revision 136)
@@ -9,5 +9,5 @@
 $auth->requireLogin();
 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG);
-App::sslOn();
+$app->sslOn();
 
 require_once 'codebase/lib/PageNumbers.inc.php';
@@ -39,9 +39,10 @@
 
 // Set the defaults and catch incoming settings.
-Prefs::setDefault('log_file', App::getParam('log_filename'), 'logs_module');
-Prefs::setValue('log_file', getFormData('log'), 'logs_module');
+$prefs =& Prefs::getInstance();
+$prefs->setDefault('log_file', $app->getParam('log_filename'), 'logs_module');
+$prefs->set('log_file', getFormData('log'), 'logs_module');
 
 // Titles and navigation header.
-$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), Prefs::getValue('log_file', 'logs_module')), '/admin/logs.php');
+$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->get('log_file', 'logs_module')), '/admin/logs.php');
 
 /******************************************************************************
@@ -56,37 +57,37 @@
 case 'delete' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    deleteLog(Prefs::getValue('log_file', 'logs_module'));
-    Prefs::setValue('log_file', App::getParam('log_filename'), 'logs_module');
-    if (App::validBoomerangURL('app_log')) {
+    deleteLog($prefs->get('log_file', 'logs_module'));
+    $prefs->set('log_file', $app->getParam('log_filename'), 'logs_module');
+    if ($app->validBoomerangURL('app_log')) {
         // Display boomerang page.
-        App::dieBoomerangURL('app_log');
+        $app->dieBoomerangURL('app_log');
     }
     // Display default page.
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
 case 'clear' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    clearLog(Prefs::getValue('log_file', 'logs_module'));
-    if (App::validBoomerangURL('app_log')) {
+    clearLog($prefs->get('log_file', 'logs_module'));
+    if ($app->validBoomerangURL('app_log')) {
         // Display boomerang page.
-        App::dieBoomerangURL('app_log');
+        $app->dieBoomerangURL('app_log');
     }
     // Display default page.
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
 case 'archive' :
 //     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
-    if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) {
+    if (archiveLog($prefs->get('log_file', 'logs_module'))) {
         // Now flush current log.
-        App::dieURL($_SERVER['PHP_SELF'] . '?op=clear');
-    }
-    if (App::validBoomerangURL('app_log')) {
+        $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear');
+    }
+    if ($app->validBoomerangURL('app_log')) {
         // Display boomerang page.
-        App::dieBoomerangURL('app_log');
+        $app->dieBoomerangURL('app_log');
     }
     // Display default page.
-    App::dieURL($_SERVER['PHP_SELF']);
+    $app->dieURL($_SERVER['PHP_SELF']);
     break;
 
@@ -97,11 +98,11 @@
 case 'download' :
     header('Content-Type: application/octet-stream');
-    header(sprintf('Content-Disposition: attachment; filename=%s.txt', Prefs::getValue('log_file', 'logs_module')));
-    printLog(Prefs::getValue('log_file', 'logs_module'));
+    header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->get('log_file', 'logs_module')));
+    printLog($prefs->get('log_file', 'logs_module'));
     die;
     break;
 
 default :
-    $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query'));
+    $list =& getLog($prefs->get('log_file', 'logs_module'), getFormData('search_query'));
     $main_template = 'log_list.ihtml';
     break;
@@ -125,5 +126,5 @@
 include 'header.ihtml';
 if ('output' == $main_template) {
-    printLog(Prefs::getValue('log_file', 'logs_module'));
+    printLog($prefs->get('log_file', 'logs_module'));
 } else {
     include 'codebase/services/templates/' . $main_template;
@@ -138,23 +139,25 @@
 function deleteLog($log_file)
 {
-    if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) {
-        App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('Cannot delete nonexistent log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
-        return false;
-    }
-
-    if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) {
-        App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('Cannot delete log file %s, not writable.', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
-        return false;
-    }
-
-    if (unlink(App::getParam('log_directory') . '/' . $log_file)) {
-        App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__);
+	$app =& App::getInstance();
+
+    if (!file_exists($app->getParam('log_directory') . '/' . $log_file)) {
+        $app->raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Cannot delete nonexistent log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
+        return false;
+    }
+
+    if (!is_writable($app->getParam('log_directory') . '/' . $log_file) && !is_writable($app->getParam('log_directory'))) {
+        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Cannot delete log file %s, not writable.', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
+        return false;
+    }
+
+    if (unlink($app->getParam('log_directory') . '/' . $log_file)) {
+        $app->raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__);
         return true;
     } else {
-        App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('unlink failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('unlink failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
         return false;
     }
@@ -163,7 +166,9 @@
 function clearLog($log_file)
 {
-    if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) {
-        App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('fopen failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
+	$app =& App::getInstance();
+
+    if (!$fp = fopen($app->getParam('log_directory') . '/' . $log_file, 'r+')) {
+        $app->raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('fopen failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
         return false;
     }
@@ -174,10 +179,10 @@
     fclose($fp);
     if (!$ftruncate_return) {
-        App::raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('ftruncate failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('ftruncate failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
         return false;
     } else {
-        App::raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
-        App::logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);
         return true;
     }
@@ -186,19 +191,21 @@
 function archiveLog($log_file)
 {
+	$app =& App::getInstance();
+
     $old_file_name = $log_file;
     $new_file_name = $log_file . '__' . date('Y-m-d');
-    If (!is_writable(App::getParam('log_directory') . '')) {
-        App::raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);
-        return false;
-    }
-    If (!copy(App::getParam('log_directory') . '/' . $old_file_name, App::getParam('log_directory') . '/' . $new_file_name)) {
-        App::raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);
-        return false;
-    }
-
-    App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
-    App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
+    If (!is_writable($app->getParam('log_directory') . '')) {
+        $app->raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);
+        return false;
+    }
+    If (!copy($app->getParam('log_directory') . '/' . $old_file_name, $app->getParam('log_directory') . '/' . $new_file_name)) {
+        $app->raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);
+        return false;
+    }
+
+    $app->raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
+    $app->logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
     return true;
 }
@@ -206,21 +213,25 @@
 function printLog($log_file)
 {
-    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
-        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
-        return false;
-    }
-
-    readfile(App::getParam('log_directory') . '/' . $log_file);
+	$app =& App::getInstance();
+
+    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
+        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
+        return false;
+    }
+
+    readfile($app->getParam('log_directory') . '/' . $log_file);
 }
 
 function &getLog($log_file, $search_query='')
 {
-    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
-        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
-        App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
-        return false;
-    }
-    $log = file(App::getParam('log_directory') . '/' . $log_file);
+	$app =& App::getInstance();
+
+    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
+        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
+        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
+        return false;
+    }
+    $log = file($app->getParam('log_directory') . '/' . $log_file);
 
     if ('' != trim($search_query)) {
@@ -237,14 +248,15 @@
 {
     global $valid_file_extensions;
+	$app =& App::getInstance();
 
     // Get a list of all files in the log directory.
-    $dir_handle = opendir(App::getParam('log_directory'));
+    $dir_handle = opendir($app->getParam('log_directory'));
     $list = array();
     while ($dir_handle && ($file = readdir($dir_handle)) !== false) {
-        if (!preg_match('/^\./', $file) && is_file(App::getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {
+        if (!preg_match('/^\./', $file) && is_file($app->getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {
             $list[] = array(
                 'filename' => $file,
-                'filesize' => filesize(App::getParam('log_directory') . '/' . $file),
-                'modified' => filemtime(App::getParam('log_directory') . '/' . $file),
+                'filesize' => filesize($app->getParam('log_directory') . '/' . $file),
+                'modified' => filemtime($app->getParam('log_directory') . '/' . $file),
             );
         }
Index: trunk/services/password.php
===================================================================
--- trunk/services/password.php	(revision 124)
+++ trunk/services/password.php	(revision 136)
@@ -27,7 +27,7 @@
 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
+    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
 }
-App::sslOn();
+$app->sslOn();
 
 switch (getFormData('op')) {
@@ -50,12 +50,12 @@
     if (!$fv->anyErrors() && false === $auth->authenticate($auth->getVal('username'), $frm['oldpassword'])) {
         $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication."));
-        App::logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);
+        $app->logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);
     }
 
     if (!$fv->anyErrors()) {
         $auth->setPassword(null, $frm['newpassword']);
-        App::logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
-        App::raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
-        App::dieBoomerangURL('admin_password');
+        $app->logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
+        $app->dieBoomerangURL('admin_password');
     }
     break;
Index: trunk/services/templates/admin_form.ihtml
===================================================================
--- trunk/services/templates/admin_form.ihtml	(revision 124)
+++ trunk/services/templates/admin_form.ihtml	(revision 136)
@@ -2,5 +2,5 @@
 
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<?php App::printHiddenSession(); ?>
+<?php $app->printHiddenSession(); ?>
 <input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
 <input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>" />
Index: trunk/services/templates/admin_list.ihtml
===================================================================
--- trunk/services/templates/admin_list.ihtml	(revision 124)
+++ trunk/services/templates/admin_list.ihtml	(revision 136)
@@ -2,7 +2,7 @@
 <?php $fv->printErrorMessages(); ?>
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<?php App::printHiddenSession(false); ?>
+<?php $app->printHiddenSession(false); ?>
 <div id="commandbox">
-    <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span>
+    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span>
     <br />
 
@@ -31,6 +31,6 @@
     <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
     <tr>
-        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
-        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=admin_tbl&record_key=admin_id&boomerang=true&record_val=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF('/admin/versions.php?record_table=admin_tbl&record_key=admin_id&boomerang=true&record_val=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
         <td class="sc-nowrap"><?php echo oTxt($list[$i]['admin_id'], true); ?> &nbsp;</td>
         <td class="sc-nowrap"><?php echo oTxt($list[$i]['username'], true); ?> &nbsp;</td>
@@ -40,14 +40,14 @@
         <td class="sc-nowrap"><?php 
             if ($auth->isLoggedIn($list[$i]['admin_id'])) {
-                ?><strong><?php echo date(App::getParam('date_format'), strtotime($list[$i]['last_login_datetime'])) ?></strong><?php
+                ?><strong><?php echo date($app->getParam('date_format'), strtotime($list[$i]['last_login_datetime'])) ?></strong><?php
             } else {
-                echo '0000-00-00 00:00:00' == $list[$i]['last_login_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['last_login_datetime'])); 
+                echo '0000-00-00 00:00:00' == $list[$i]['last_login_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['last_login_datetime'])); 
             }
         ?> &nbsp;</td>
         <td class="sc-nowrap"><?php echo gethostbyaddr($list[$i]['last_login_ip']); ?> &nbsp;</td>
-        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['added_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['added_datetime'])); ?> &nbsp;</td>
+        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['added_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['added_datetime'])); ?> &nbsp;</td>
         <td class="sc-nowrap"><?php echo oTxt($list[$i]['added_admin_username'], true); ?> &nbsp;</td>
-        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
-        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
+        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
+        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     </tr>
     <?php } ?>
Index: trunk/services/templates/list_info.ihtml
===================================================================
--- trunk/services/templates/list_info.ihtml	(revision 124)
+++ trunk/services/templates/list_info.ihtml	(revision 136)
@@ -5,5 +5,5 @@
     <span class="sc-nowrap commanditem commandtext">
         <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?>
-        &nbsp;&nbsp; <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a>
+        &nbsp;&nbsp; <a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a>
         &nbsp;&nbsp; <?php echo _("Per page"); ?>:&nbsp;<?php $page->printPerPageLinks() ?>
     </span>
Index: trunk/services/templates/lock.ihtml
===================================================================
--- trunk/services/templates/lock.ihtml	(revision 124)
+++ trunk/services/templates/lock.ihtml	(revision 136)
@@ -5,5 +5,5 @@
 ?>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-    <?php App::printHiddenSession() ?>
+    <?php $app->printHiddenSession() ?>
     <input type="hidden" name="lock_id" value="<?php echo $lock->getID(); ?>" />
 
Index: trunk/services/templates/log_list.ihtml
===================================================================
--- trunk/services/templates/log_list.ihtml	(revision 124)
+++ trunk/services/templates/log_list.ihtml	(revision 136)
@@ -1,4 +1,4 @@
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
-<?php App::printHiddenSession(false); ?>
+<?php $app->printHiddenSession(false); ?>
 
 <div id="commandbox">
@@ -10,18 +10,18 @@
         <tr class="commandtext">
             <td>
-                <?php if ($l['filename'] == Prefs::getValue('log_file', 'logs_module')) { ?>
+                <?php if ($l['filename'] == $prefs->get('log_file', 'logs_module')) { ?>
                     <span class="commanditem"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></span>
                 <?php } else { ?>
-                    <span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?log=' . $l['filename']); ?>"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></a></span>
+                    <span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?log=' . $l['filename']); ?>"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></a></span>
                 <?php } ?>
             </td>
             <td>
-                <span class="commanditem"><em><?php echo sprintf(_("%01.1f KB, last modified %s"), ($l['filesize']/1024), date(App::getParam('date_format'), $l['modified'])); ?></em></span>
+                <span class="commanditem"><em><?php echo sprintf(_("%01.1f KB, last modified %s"), ($l['filesize']/1024), date($app->getParam('date_format'), $l['modified'])); ?></em></span>
             </td>
             <td>
-                <?php if (!preg_match($no_download_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=download&log=' . $l['filename']); ?>"><?php echo _("Download"); ?></a></span><?php } ?>
-                <?php if (!preg_match($no_archive_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=archive&log=' . $l['filename']); ?>"><?php echo _("Archive"); ?></a></span><?php } ?>
-                <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a></span><?php } ?>
-                <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a></span><?php } ?>
+                <?php if (!preg_match($no_download_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=download&log=' . $l['filename']); ?>"><?php echo _("Download"); ?></a></span><?php } ?>
+                <?php if (!preg_match($no_archive_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=archive&log=' . $l['filename']); ?>"><?php echo _("Archive"); ?></a></span><?php } ?>
+                <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a></span><?php } ?>
+                <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a></span><?php } ?>
             </td>
         </tr><?php
Index: trunk/services/templates/login_form.ihtml
===================================================================
--- trunk/services/templates/login_form.ihtml	(revision 124)
+++ trunk/services/templates/login_form.ihtml	(revision 136)
@@ -1,4 +1,4 @@
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<?php App::printHiddenSession() ?>
+<?php $app->printHiddenSession() ?>
 <table>
     <tr>
Index: trunk/services/templates/password.ihtml
===================================================================
--- trunk/services/templates/password.ihtml	(revision 124)
+++ trunk/services/templates/password.ihtml	(revision 136)
@@ -2,5 +2,5 @@
 
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<?php App::printHiddenSession() ?>
+<?php $app->printHiddenSession() ?>
 <input type="hidden" name="op" value="update_password" />
 <table>
Index: trunk/services/templates/versions_diff.ihtml
===================================================================
--- trunk/services/templates/versions_diff.ihtml	(revision 124)
+++ trunk/services/templates/versions_diff.ihtml	(revision 136)
@@ -1,5 +1,5 @@
 <div id="commandbox">
 <?php if (!getFormData('current', false)) { ?>
-    <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
+    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
 <?php } else { ?>
     <span class="sc-nowrap commandtext">&nbsp;</span>
Index: trunk/services/templates/versions_list.ihtml
===================================================================
--- trunk/services/templates/versions_list.ihtml	(revision 124)
+++ trunk/services/templates/versions_list.ihtml	(revision 136)
@@ -1,4 +1,4 @@
 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<?php App::printHiddenSession() ?>
+<?php $app->printHiddenSession() ?>
 <input type="submit" name="op" value="<?php echo _("Cancel"); ?>" />
 <table class="list" border="0" cellspacing="0" cellpadding="4">
@@ -14,10 +14,10 @@
 <tr>
     <?php if ($first) { ?>
-    <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=view&current=true&version_id=' . $v['version_id']); ?>">view</a>]</td>
+    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=view&current=true&version_id=' . $v['version_id']); ?>">view</a>]</td>
     <td class="sc-padleft sc-nowrap" colspan="2">(<?php echo _("Current record"); ?>)</td>
     <?php } else { ?>
-    <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=view&version_id=' . $v['version_id']); ?>">view</a>]</td>
-    <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=diff&version_id=' . $v['version_id']); ?>">diff</a>]</td>
-    <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore&version_id=' . $v['version_id']); ?>">restore</a>]</td>
+    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=view&version_id=' . $v['version_id']); ?>">view</a>]</td>
+    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=diff&version_id=' . $v['version_id']); ?>">diff</a>]</td>
+    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore&version_id=' . $v['version_id']); ?>">restore</a>]</td>
     <?php } ?>
     <td class="sc-padleft sc-nowrap"><?php echo $v['version_id']; ?></td>
Index: trunk/services/templates/versions_view.ihtml
===================================================================
--- trunk/services/templates/versions_view.ihtml	(revision 124)
+++ trunk/services/templates/versions_view.ihtml	(revision 136)
@@ -1,5 +1,5 @@
 <div id="commandbox">
 <?php if (!getFormData('current', false)) { ?>
-    <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
+    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
 <?php } else { ?>
     <span class="sc-nowrap commandtext">&nbsp;</span>
Index: trunk/services/versions.php
===================================================================
--- trunk/services/versions.php	(revision 124)
+++ trunk/services/versions.php	(revision 136)
@@ -8,5 +8,5 @@
 
 $auth->requireLogin();
-App::sslOn();
+$app->sslOn();
 
 require_once 'codebase/lib/RecordVersion.inc.php';
@@ -20,8 +20,8 @@
 
 // Query arguments to retain their values between page requests.
-App::carryQuery('record_table');
-App::carryQuery('record_key');
-App::carryQuery('record_val');
-App::carryQuery('version_title');
+$app->carryQuery('record_table');
+$app->carryQuery('record_key');
+$app->carryQuery('record_val');
+$app->carryQuery('version_title');
 
 // Titles and navigation header.
@@ -39,12 +39,12 @@
 
 if ('' == $version_id && ('' == $record_table || '' == $record_key || '' == $record_val)) {
-    App::raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__);
-    App::logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__);
-    App::dieBoomerangURL();
+    $app->raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__);
+    $app->logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__);
+    $app->dieBoomerangURL();
 }
 
 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     // We remember which page we came from so we can go back there.
-    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
+    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
 }
 
@@ -53,5 +53,5 @@
 
 case _("Cancel") :
-    App::dieBoomerangURL('versions', false);
+    $app->dieBoomerangURL('versions', false);
     break;
 
@@ -68,5 +68,5 @@
     $current = $version->getCurrent($record_table, $record_key, $record_val);
     if (serialize($data) == serialize($current)) {
-        App::raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);
+        $app->raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);
     }
     $nav->addPage(sprintf(_("Difference between version %s (%s) and current record."), $version_id, $versionrecord['version_datetime']));
@@ -86,9 +86,9 @@
         // Create version of this restored record as the "current" version.
         $version->create($record_table, $record_key, $record_val, $v['version_title']);
-        App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__);
-        App::dieBoomerangURL('versions', array('break_list_cache'=>'true', false));
+        $app->raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__);
+        $app->dieBoomerangURL('versions', array('break_list_cache'=>'true', false));
     } else {
-        App::raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__);
-        App::dieURL($_SERVER['PHP_SELF']);
+        $app->raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__);
+        $app->dieURL($_SERVER['PHP_SELF']);
     }
     break;
@@ -101,6 +101,6 @@
         $main_template = 'versions_list.ihtml';
     } else {
-        App::raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__);
-        App::dieBoomerangURL('versions');
+        $app->raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__);
+        $app->dieBoomerangURL('versions');
     }
 }
Index: trunk/tests/AppTest.php
===================================================================
--- trunk/tests/AppTest.php	(revision 124)
+++ trunk/tests/AppTest.php	(revision 136)
@@ -32,5 +32,5 @@
     function test_getinstance()
     {
-        $thisapp =& App::getinstance();
+        $thisapp =& App::getInstance();
         $this->assertTrue(serialize($thisapp) == serialize($this->App), 'Objects do not match across instantiations.');
     }
@@ -71,5 +71,7 @@
     function test_dbquery()
     {
-        $qid = DB::query("SELECT 2 + 2");
+		$db =& DB::getInstance();
+	
+        $qid = $db->query("SELECT 2 + 2");
         list($result) = mysql_fetch_row($qid);
         $this->assertEquals('4', $result);
@@ -78,7 +80,8 @@
     function test_raisemsg()
     {
+        $app =& App::getInstance();
         $expected = 'My message';
-        App::raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
-        $msg = current($_SESSION[$this->App->app]['messages']);
+        $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
+        $msg = current($_SESSION[$this->App->_ns]['messages']);
         $this->assertEquals($expected, $msg['message']);
     }
@@ -87,5 +90,6 @@
     {
         ob_start();
-        App::printraisedmessages();
+        $app =& App::getInstance();
+        $app->printraisedmessages();
         $result = ob_get_clean();
         $this->assertContains('My message', $result, 'Raised message not found in output.');
@@ -94,6 +98,7 @@
     function test_logmsg()
     {
+        $app =& App::getInstance();
         $file = $this->App->getParam('log_directory') . '/' . $this->App->getParam('log_filename');
-        App::logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
+        $app->logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
         if ($result = file($file)) {
             $result = end($result);
@@ -106,6 +111,7 @@
     function test_ohref()
     {
+        $app =& App::getInstance();
         $_GET['arg1'] = 'A';
-        $result = App::ohref('/some/url.php', array('arg1'), true);
+        $result = $app->ohref('/some/url.php', array('arg1'), true);
         $this->assertContains(session_name(), $result, 'SSID not found in URL.');
         $this->assertContains('arg1=A', $result, 'Argument not passed through.');
@@ -114,6 +120,7 @@
     function test_printhiddensession()
     {
+        $app =& App::getInstance();
         ob_start();
-        App::printhiddensession();
+        $app->printhiddensession();
         $result = ob_get_clean();
         $this->assertContains(session_name(), $result);
@@ -122,5 +129,6 @@
 //     function test_dieurl()
 //     {
-//         App::dieURL('/die/to/this/url.php');
+//         $app =& App::getInstance();
+//         $app->dieURL('/die/to/this/url.php');
 //     }
 //
Index: trunk/tests/Auth_FileTest.php
===================================================================
--- trunk/tests/Auth_FileTest.php	(revision 124)
+++ trunk/tests/Auth_FileTest.php	(revision 136)
@@ -23,5 +23,6 @@
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Auth_File.inc.php';
-        $this->Auth_File =& new Auth_File(array('htpasswd_file' => dirname(__FILE__) . '/_test_htpasswd'));
+        $this->Auth_File =& new Auth_File('test_auth');
+        $this->Auth_File->setParam(array('htpasswd_file' => dirname(__FILE__) . '/_test_htpasswd'));
     }
 
@@ -44,5 +45,5 @@
         $result = $this->Auth_File->login('testuser', 'testpass');
         $this->assertTrue($result, 'testuser login failed.');
-        $this->assertTrue($_SESSION['_auth']['authenticated'], 'testuser authentication not found in session.');
+        $this->assertTrue($_SESSION[$this->Auth_File->_ns]['authenticated'], 'testuser authentication not found in session.');
     }
 
@@ -51,5 +52,5 @@
         $result = $this->Auth_File->login('testuser', 'testpass');
         $this->Auth_File->clearauth();
-        $this->assertFalse($_SESSION['_auth']['authenticated'], 'testuser authentication not false in session.');
+        $this->assertFalse($_SESSION[$this->Auth_File->_ns]['authenticated'], 'testuser authentication not false in session.');
     }
 
Index: trunk/tests/Auth_SQLTest.php
===================================================================
--- trunk/tests/Auth_SQLTest.php	(revision 124)
+++ trunk/tests/Auth_SQLTest.php	(revision 136)
@@ -21,5 +21,5 @@
     function setUp()
     {
-        require dirname(__FILE__) . '/_config.inc.php';
+	    require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/Auth_SQL.inc.php';
         $this->Auth_SQL =& new Auth_SQL('testauth');
@@ -29,5 +29,6 @@
             'db_login_table'    => 'test_login_tbl',
             'login_url'         => '/login.php',
-            'blocking'          => true
+            'blocking'          => true,
+            'encryption_type' => AUTH_ENCRYPT_MD5_HARDENED,
         ));
 
@@ -36,5 +37,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -46,5 +48,5 @@
             ) VALUES (
                 'testuser',
-                md5('testpass'),
+                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
                 'John',
                 'Doe',
@@ -58,7 +60,9 @@
     function tearDown()
     {
-        unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
+    	$db =& DB::getInstance();
+	
+	    unset($this->Auth_SQL);
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
     }
 
@@ -66,10 +70,10 @@
     {
         $this->Auth_SQL->setval('testuserkey', 'testuserval');
-        $this->assertEquals('testuserval', $_SESSION[$this->Auth_SQL->_sess]['user_data']['testuserkey']);
+        $this->assertEquals('testuserval', $_SESSION[$this->Auth_SQL->_ns]['user_data']['testuserkey']);
     }
 
     function test_getval()
     {
-        $_SESSION[$this->Auth_SQL->_sess]['user_data']['testuserkey'] = 'testuserval';
+        $_SESSION[$this->Auth_SQL->_ns]['user_data']['testuserkey'] = 'testuserval';
         $val = $this->Auth_SQL->getVal('testuserkey');
         $this->assertEquals('testuserval', $val);
@@ -107,5 +111,5 @@
         $this->assertTrue($true, 'User login failed, but should have succeeded.');
 
-        echo "Testing wrong password...\n";
+        // Testing wrong password.
         $false = $this->Auth_SQL->authenticate('testuser', 'wrongpass');
 
@@ -122,6 +126,6 @@
         $after_logged_in = $this->Auth_SQL->isloggedin();
         $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
-
-        echo "Testing wrong password...\n";
+        
+        // Testing wrong password.
         $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
         $this->assertFalse($login2, '4. User login succeeded, but should have failed.');
@@ -140,7 +144,9 @@
     function test_blockaccount()
     {
+		$db =& DB::getInstance();
+	
         $this->Auth_SQL->login('testuser', 'testpass');
         $this->Auth_SQL->blockaccount(null, 'blocktestuser');
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT blocked_reason
             FROM test_user_tbl
@@ -152,10 +158,12 @@
     function test_unblockaccount()
     {
-        DB::query("
+		$db =& DB::getInstance();
+	
+        $db->query("
             UPDATE test_user_tbl SET blocked_reason = 'blocktestuser'
         ");
         $this->Auth_SQL->unblockaccount();
 
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT blocked_reason
             FROM test_user_tbl
@@ -185,17 +193,41 @@
     function test_encryptpassword()
     {
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5));
         $result = $this->Auth_SQL->encryptpassword('123');
         $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5_HARDENED));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_PLAINTEXT));
+        $result = $this->Auth_SQL->encryptpassword('123');
+        $this->assertEquals('123', $result);
+
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_CRYPT));
+        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
+        $this->assertEquals('saEZ6MlWYV9nQ', $result);
     }
 
     function test_setpassword()
     {
+		$db =& DB::getInstance();
+	
+        $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
         $this->Auth_SQL->setpassword(null, '123');
-        $qid = DB::query("
+        $qid = $db->query("
             SELECT userpass
             FROM test_user_tbl
         ");
         list($pass) = mysql_fetch_row($qid);
-        $this->assertEquals('202cb962ac59075b964b07152d234b70', $pass);
+        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $pass);
     }
 
Index: trunk/tests/DBSessionHandlerTest.php
===================================================================
--- trunk/tests/DBSessionHandlerTest.php	(revision 124)
+++ trunk/tests/DBSessionHandlerTest.php	(revision 136)
@@ -24,13 +24,7 @@
         require_once '../lib/DBSessionHandler.inc.php';
         session_write_close();
-        $this->DBSessionHandler = new DBSessionHandler($app->db);
-        $this->DBSessionHandler = new DBSessionHandler(null, array(
-            'db_server' => $app->getParam('db_server'),
-            'db_name' => $app->getParam('db_name'),
-            'db_user' => $app->getParam('db_user'),
-            'db_pass' => $app->getParam('db_pass'),
-            'db_always_debug' => $app->getParam('db_always_debug'),
-            'db_debug' => $app->getParam('db_debug'),
-            'db_die_on_failure' => $app->getParam('db_die_on_failure'),
+        $this->DBSessionHandler = new DBSessionHandler($app->db, array(
+            'db_table' => 'session_tbl',
+            'create_table' => true,
         ));
     }
Index: trunk/tests/RecordLockTest.php
===================================================================
--- trunk/tests/RecordLockTest.php	(revision 124)
+++ trunk/tests/RecordLockTest.php	(revision 136)
@@ -21,10 +21,10 @@
 
     function setUp()
-    {
+    {	
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/RecordLock.inc.php';
         require_once '../lib/Auth_SQL.inc.php';
 
-        $this->Auth_SQL =& new Auth_SQL('testauth');
+        $this->Auth_SQL =& new Auth_SQL('test');
         $this->Auth_SQL->setParam(array(
             'db_table'          => 'test_user_tbl',
@@ -39,5 +39,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -49,5 +50,5 @@
             ) VALUES (
                 'testuser',
-                md5('testpass'),
+                '" . $this->Auth_SQL->encryptPassword('testpass') . "',
                 'John',
                 'Doe',
@@ -57,4 +58,8 @@
         ");
         $this->Auth_SQL->login('testuser', 'testpass');
+
+        if (!$this->Auth_SQL->isLoggedIn()) {
+            trigger_error("User login failed...tests canceled.", E_USER_ERROR);
+        }
 
         $this->RecordLock =& RecordLock::getInstance($this->Auth_SQL);
@@ -67,9 +72,11 @@
     function tearDown()
     {
+		$db =& DB::getInstance();
+	
         unset($this->RecordLock);
         unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
-        DB::query("DROP TABLE IF EXISTS test_lock_tbl");
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_lock_tbl");
     }
 
Index: trunk/tests/RecordVersionTest.php
===================================================================
--- trunk/tests/RecordVersionTest.php	(revision 124)
+++ trunk/tests/RecordVersionTest.php	(revision 136)
@@ -21,5 +21,5 @@
 
     function setUp()
-    {
+    {	
         require dirname(__FILE__) . '/_config.inc.php';
         require_once '../lib/RecordVersion.inc.php';
@@ -39,5 +39,6 @@
 
         // Insert test data.
-        DB::query("
+        $db =& DB::getInstance();
+        $db->query("
             INSERT INTO test_user_tbl (
                 username,
@@ -68,9 +69,11 @@
     function tearDown()
     {
+		$db =& DB::getInstance();
+	
         unset($this->RecordVersion);
         unset($this->Auth_SQL);
-        DB::query("DROP TABLE IF EXISTS test_user_tbl");
-        DB::query("DROP TABLE IF EXISTS test_login_tbl");
-        DB::query("DROP TABLE IF EXISTS test_version_tbl");
+        $db->query("DROP TABLE IF EXISTS test_user_tbl");
+        $db->query("DROP TABLE IF EXISTS test_login_tbl");
+        $db->query("DROP TABLE IF EXISTS test_version_tbl");
     }
 
Index: trunk/tests/SessionCacheTest.php
===================================================================
--- trunk/tests/SessionCacheTest.php	(revision 124)
+++ trunk/tests/SessionCacheTest.php	(revision 136)
@@ -4,5 +4,5 @@
 
 /**
- * PHPUnit test case for SessionCache
+ * PHPUnit test case for Cache
  *
  * The method skeletons below need to be filled in with
@@ -13,9 +13,9 @@
  */
 require_once 'PHPUnit.php';
-class SessionCacheTest extends PHPUnit_TestCase {
+class CacheTest extends PHPUnit_TestCase {
 
-    var $SessionCache;
+    var $Cache;
 
-    function SessionCacheTest($name)
+    function CacheTest($name)
     {
         $this->PHPUnit_TestCase($name);
@@ -25,16 +25,16 @@
     {
         require dirname(__FILE__) . '/_config.inc.php';
-        require_once '../lib/SessionCache.inc.php';
-        $this->SessionCache =& new SessionCache(PARAM);
+        require_once '../lib/Cache.inc.php';
+        $this->Cache =& new Cache(PARAM);
     }
 
     function tearDown()
     {
-        unset($this->SessionCache);
+        unset($this->Cache);
     }
 
     function test_getinstance()
     {
-        $result = $this->SessionCache->getinstance(PARAM);
+        $result = $this->Cache->getinstance(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -43,5 +43,5 @@
     function test_setparam()
     {
-        $result = $this->SessionCache->setparam(PARAM);
+        $result = $this->Cache->setparam(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -50,5 +50,5 @@
     function test_getparam()
     {
-        $result = $this->SessionCache->getparam(PARAM);
+        $result = $this->Cache->getparam(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -57,5 +57,5 @@
     function test_putcache()
     {
-        $result = $this->SessionCache->putcache(PARAM);
+        $result = $this->Cache->putcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -64,5 +64,5 @@
     function test_getcache()
     {
-        $result = $this->SessionCache->getcache(PARAM);
+        $result = $this->Cache->getcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -71,5 +71,5 @@
     function test_iscached()
     {
-        $result = $this->SessionCache->iscached(PARAM);
+        $result = $this->Cache->iscached(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -78,5 +78,5 @@
     function test_breakcache()
     {
-        $result = $this->SessionCache->breakcache(PARAM);
+        $result = $this->Cache->breakcache(PARAM);
         $expected = EXPECTED_VAL;
         $this->assertEquals($expected, $result);
@@ -85,5 +85,5 @@
 }
 // Running the test.
-$suite = new PHPUnit_TestSuite('SessionCacheTest');
+$suite = new PHPUnit_TestSuite('CacheTest');
 $result = PHPUnit::run($suite);
 echo $result->toString();
Index: trunk/tests/_config.inc.php
===================================================================
--- trunk/tests/_config.inc.php	(revision 124)
+++ trunk/tests/_config.inc.php	(revision 136)
@@ -1,5 +1,5 @@
 <?php
 require_once '../lib/App.inc.php';
-$app =& App::getinstance('testapp');
+$app =& App::getInstance('testapp');
 
 $app->setParam(array(
