Changeset 127
- Timestamp:
- May 25, 2006 10:21:07 PM (18 years ago)
- Location:
- branches/2.0singleton
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/bin/file_importer.php
r111 r127 7 7 8 8 require realpath(dirname(__FILE__) . '/..') . '/config/cli_config.inc.php'; 9 10 $app =& App::getInstance(); 9 11 10 12 // Test arguments. … … 56 58 57 59 } else { 58 App::logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);60 $app->logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__); 59 61 } 60 62 } 61 App::logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);63 $app->logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__); 62 64 } else { 63 App::logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);65 $app->logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__); 64 66 } 65 67 -
branches/2.0singleton/bin/module_maker/form_template.cli.php
r121 r127 24 24 // Make sure requested table is in database. 25 25 if (!in_array($db_tbl, $tables)) { 26 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)));26 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))); 27 27 } 28 28 … … 65 65 <label for="$field"<\x3fphp \$fv->err('$field') \x3f>><\x3fphp echo _("$title"); \x3f></label> 66 66 <select name="$field" id="$field" class="sc-small"><\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '—', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f></select> 67 <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>67 <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> 68 68 <\x3fphp if ('' != \$frm['<##>_id']) { \x3f> 69 <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>69 <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> 70 70 <\x3fphp } \x3f> 71 71 E_O_F; -
branches/2.0singleton/bin/module_maker/list_template.cli.php
r121 r127 37 37 // Make sure requested table is in database. 38 38 if (!in_array($db_tbl, $tables)) { 39 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)));39 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))); 40 40 } 41 41 … … 80 80 $listrows[] = "<\x3fphp echo strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>"; 81 81 } else if (preg_match('/.*(begin|start).*date.*/i', $field)) { 82 $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date( App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";82 $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; 83 83 } else if (preg_match('/.*(end|expire).*date.*/i', $field)) { 84 $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date( App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";84 $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; 85 85 } else if (preg_match('/datetime/i', $type)) { 86 $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date( App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";86 $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; 87 87 } else if (preg_match('/date/i', $type)) { 88 $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date( App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";88 $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>"; 89 89 } else if (preg_match('/(amount|_rate)/i', $field)) { 90 90 $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>"; … … 110 110 <div id="commandbox"> 111 111 <form action="<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>" method="get"> 112 <\x3fphp App::printHiddenSession(false); \x3f>113 <span class="sc-nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>112 <\x3fphp \$app->printHiddenSession(false); \x3f> 113 <span class="sc-nowrap commandtext"><a href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span> 114 114 <br /> 115 115 … … 149 149 <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f> 150 150 <tr> 151 <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> </td>152 <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> </td>151 <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> </td> 152 <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> </td> 153 153 154 154 E_O_F; … … 164 164 165 165 echo isset($op) ? '' : <<<E_O_F 166 <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> </td>166 <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> </td> 167 167 </tr> 168 168 <\x3fphp } \x3f> -
branches/2.0singleton/bin/module_maker/module.cli.php
r119 r127 136 136 // Make sure requested table is in database. 137 137 if (!in_array($db_tbl, $tables)) { 138 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)));138 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))); 139 139 } 140 140 … … 266 266 // If file upload errors, redirect to edit operation for the inserted record. 267 267 if (\$upload->anyErrors() || false === \$new_file) { 268 App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);268 \$app->dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%); 269 269 } 270 270 E_O_F; … … 300 300 301 301 $search['date'] = '/%DATE%/'; 302 $replace['date'] = date( App::getParam('date_format'));302 $replace['date'] = date($app->getParam('date_format')); 303 303 304 304 $search['name_plural'] = '/%NAME_PLURAL%/'; -
branches/2.0singleton/bin/module_maker/skel/admin.php
r111 r127 11 11 $auth->requireLogin(); 12 12 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%); 13 App::sslOn();13 $app->sslOn(); 14 14 15 15 require_once 'codebase/lib/PageNumbers.inc.php'; … … 41 41 42 42 // Search limiters retain their values between page requests. 43 App::carryQuery('search_query');44 App::carryQuery('filter_<##>');43 $app->carryQuery('search_query'); 44 $app->carryQuery('filter_<##>'); 45 45 %ADMIN_UPLOAD_CONFIG% 46 46 /****************************************************************************** … … 51 51 // allows us to remember which page we came from so we can go back there. 52 52 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { 53 App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');53 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%'); 54 54 } 55 55 … … 81 81 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE); 82 82 deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL% 83 if ( App::validBoomerangURL('%NAME_PLURAL%')) {83 if ($app->validBoomerangURL('%NAME_PLURAL%')) { 84 84 // Display boomerang page. 85 App::dieBoomerangURL('%NAME_PLURAL%');85 $app->dieBoomerangURL('%NAME_PLURAL%'); 86 86 } 87 87 // Display default page. 88 App::dieURL($_SERVER['PHP_SELF']);88 $app->dieURL($_SERVER['PHP_SELF']); 89 89 break; 90 90 … … 92 92 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD); 93 93 if (getFormdata('cancel', false)) { 94 if ( App::validBoomerangURL('%NAME_PLURAL%')) {94 if ($app->validBoomerangURL('%NAME_PLURAL%')) { 95 95 // Display boomerang page. 96 App::dieBoomerangURL('%NAME_PLURAL%');96 $app->dieBoomerangURL('%NAME_PLURAL%'); 97 97 } 98 98 // Display default page. 99 App::dieURL($_SERVER['PHP_SELF']);99 $app->dieURL($_SERVER['PHP_SELF']); 100 100 } 101 101 validateInput(); … … 109 109 if (getFormdata('repeat', false)) { 110 110 // Display function again. 111 App::dieURL($_SERVER['PHP_SELF'] . '?op=add');112 } else if ( App::validBoomerangURL('%NAME_PLURAL%')) {111 $app->dieURL($_SERVER['PHP_SELF'] . '?op=add'); 112 } else if ($app->validBoomerangURL('%NAME_PLURAL%')) { 113 113 // Display boomerang page. 114 App::dieBoomerangURL('%NAME_PLURAL%');114 $app->dieBoomerangURL('%NAME_PLURAL%'); 115 115 } 116 116 // Display default page. 117 App::dieURL($_SERVER['PHP_SELF']);117 $app->dieURL($_SERVER['PHP_SELF']); 118 118 } 119 119 break; … … 122 122 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_EDIT); 123 123 if (getFormdata('reset', false)) { 124 App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);125 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));124 $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__); 125 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%')); 126 126 } 127 127 if (getFormdata('cancel', false)) { … … 129 129 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%')); 130 130 $lock->remove(); 131 if ( App::validBoomerangURL('%NAME_PLURAL%')) {131 if ($app->validBoomerangURL('%NAME_PLURAL%')) { 132 132 // Display boomerang page. 133 App::dieBoomerangURL('%NAME_PLURAL%');133 $app->dieBoomerangURL('%NAME_PLURAL%'); 134 134 } 135 135 // Display default page. 136 App::dieURL($_SERVER['PHP_SELF']);136 $app->dieURL($_SERVER['PHP_SELF']); 137 137 } 138 138 validateInput(); … … 148 148 $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1"); 149 149 if (list($next_id) = mysql_fetch_row($qid)) { 150 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);150 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id); 151 151 } else { 152 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);152 $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__); 153 153 } 154 } else if ( App::validBoomerangURL('%NAME_PLURAL%')) {154 } else if ($app->validBoomerangURL('%NAME_PLURAL%')) { 155 155 // Display boomerang page. 156 App::dieBoomerangURL('%NAME_PLURAL%');156 $app->dieBoomerangURL('%NAME_PLURAL%'); 157 157 } 158 158 // Display default page. 159 App::dieURL($_SERVER['PHP_SELF']);159 $app->dieURL($_SERVER['PHP_SELF']); 160 160 } 161 161 break; … … 164 164 // $auth->requireAccessClearance(ZONE_ADMIN_PROGRAMS_FUNC_REORDER); 165 165 updateRank(getFormData('rank')); 166 App::dieURL($_SERVER['PHP_SELF']);166 $app->dieURL($_SERVER['PHP_SELF']); 167 167 break; 168 168 … … 220 220 "); 221 221 if (!$frm = mysql_fetch_assoc($qid)) { 222 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);223 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);224 App::dieBoomerangURL();222 $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 223 $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 224 $app->dieBoomerangURL(); 225 225 } 226 226 … … 262 262 "); 263 263 if (! list($name) = mysql_fetch_row($qid)) { 264 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);265 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);266 App::dieBoomerangURL();264 $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 265 $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 266 $app->dieBoomerangURL(); 267 267 } 268 268 … … 270 270 DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'"); 271 271 272 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);272 $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 273 273 274 274 // Unlock record. … … 290 290 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']); 291 291 292 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);292 $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__); 293 293 294 294 return $last_insert_id; … … 313 313 $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']); 314 314 315 App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);315 $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__); 316 316 317 317 // Unlock record. … … 399 399 { 400 400 if (!is_array($ranks)) { 401 App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);401 $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__); 402 402 return false; 403 403 } … … 423 423 } 424 424 425 App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);425 $app->raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__); 426 426 if ($unspecified_counter > 0) { 427 App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);427 $app->raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__); 428 428 } 429 429 } -
branches/2.0singleton/bin/module_maker/skel/public.php
r111 r127 42 42 "); 43 43 if (!$item = mysql_fetch_assoc($qid)) { 44 App::raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);45 App::dieBoomerangURL();44 $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__); 45 $app->dieBoomerangURL(); 46 46 } 47 47 -
branches/2.0singleton/bin/module_maker/sql.cli.php
r111 r127 37 37 // Make sure requested table is in database. 38 38 if (!in_array($db_tbl, $tables)) { 39 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)));39 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))); 40 40 } 41 41 -
branches/2.0singleton/bin/module_maker/validation.cli.php
r111 r127 24 24 // Make sure requested table is in database. 25 25 if (!in_array($db_tbl, $tables)) { 26 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)));26 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))); 27 27 } 28 28 -
branches/2.0singleton/docs/coding_standards.txt
r121 r127 183 183 ?> 184 184 <div align="right" class="sc-tiny"> 185 [ <a href="<?php echo App::oHREF('contact.php') ?>">Contact us</a> ]185 [ <a href="<?php echo $app->oHREF('contact.php') ?>">Contact us</a> ] 186 186 </div> 187 187 <?php -
branches/2.0singleton/docs/example_config.inc.php
r101 r127 70 70 // DB credentials for command line scripts stored in a file with read rights 71 71 // given only to the user who will be executing the scripts: -rw------- 72 // This file includes App::method calls so must be included after App.72 // This file includes $app-> method calls so must be included after App. 73 73 require_once 'global/db_auth.inc.php'; 74 74 -
branches/2.0singleton/docs/example_script_template.php
r21 r127 11 11 12 12 $auth->requireLogin(); 13 App::sslOn();13 $app->sslOn(); 14 14 15 15 require_once 'codebase/lib/FormValidator.inc.php'; -
branches/2.0singleton/lib/App.inc.php
r123 r127 25 25 var $app = '_app_'; 26 26 27 // If App::start has run successfully.27 // If $app->start has run successfully. 28 28 var $running = false; 29 29 … … 48 48 'redirect_home_url' => '/', 49 49 50 // SSL URL used when redirecting with App::sslOn().50 // SSL URL used when redirecting with $app->sslOn(). 51 51 'ssl_domain' => null, 52 52 'ssl_enabled' => false, … … 514 514 if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) { 515 515 $_this->setParam(array('log_file_priority' => false)); 516 // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.516 // We must use trigger_error to report this problem rather than calling $app->logMsg, which might lead to an infinite loop. 517 517 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE); 518 518 } … … 610 610 /** 611 611 * Sets which query arguments will be carried persistently between requests. 612 * Values in the _carry_queries array will be copied to URLs (via App::url()) and612 * Values in the _carry_queries array will be copied to URLs (via $app->url()) and 613 613 * to hidden input values (via printHiddenSession()). 614 614 * … … 738 738 739 739 /** 740 * Returns a HTML-friendly URL processed with App::url and & replaced with &740 * Returns a HTML-friendly URL processed with $app->url and & replaced with & 741 741 * 742 742 * @access public 743 743 * @param string $url Input URL to parse. 744 * @return string URL with App::url() and htmlentities() applied.744 * @return string URL with $app->url() and htmlentities() applied. 745 745 * @author Quinn Comendant <quinn@strangecode.com> 746 746 * @since 09 Dec 2005 17:58:45 … … 868 868 869 869 /* 870 * Redirects a user by calling App::dieURL(). It will use:870 * Redirects a user by calling $app->dieURL(). It will use: 871 871 * 1. the stored boomerang URL, it it exists 872 872 * 2. a specified $default_url, it it exists … … 876 876 * @access public 877 877 * @param string $id Identifier for this script. 878 * @param mixed $carry_args Additional arguments to carry in the URL automatically (see App::oHREF()).878 * @param mixed $carry_args Additional arguments to carry in the URL automatically (see $app->oHREF()). 879 879 * @param string $default_url A default URL if there is not a valid specified boomerang URL. 880 880 * @return bool False if the session is not running. No return otherwise. … … 923 923 924 924 /** 925 * Set the URL to return to when App::dieBoomerangURL() is called.925 * Set the URL to return to when $app->dieBoomerangURL() is called. 926 926 * 927 927 * @param string $url A fully validated URL. … … 940 940 } 941 941 // A redirection will never happen immediately after setting the boomerangURL. 942 // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more.942 // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more. 943 943 944 944 if ('' != $url && is_string($url)) { -
branches/2.0singleton/lib/Auth_File.inc.php
r103 r127 95 95 function getParam($param) 96 96 { 97 $app =& App::getInstance(); 98 97 99 if (isset($this->_params[$param])) { 98 100 return $this->_params[$param]; 99 101 } else { 100 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);102 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 101 103 return null; 102 104 } … … 160 162 function authenticate($username, $password) 161 163 { 164 $app =& App::getInstance(); 165 162 166 if ('' == trim($password)) { 163 App::logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);167 $app->logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__); 164 168 return false; 165 169 } … … 169 173 170 174 if (!isset($this->_users[$username])) { 171 App::logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__);175 $app->logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__); 172 176 return false; 173 177 } 174 178 175 179 if ($this->_encrypt($password, $this->_users[$username]) != $this->_users[$username]) { 176 App::logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__);180 $app->logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__); 177 181 return false; 178 182 } … … 227 231 function isLoggedIn() 228 232 { 233 $app =& App::getInstance(); 234 229 235 // 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. 230 236 if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) { 231 237 $user_in_trusted_network = true; 232 App::logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_sess]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);238 $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_sess]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__); 233 239 } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) { 234 240 $user_in_trusted_network = true; 235 App::logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_sess]['username']), LOG_DEBUG, __FILE__, __LINE__);241 $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_sess]['username']), LOG_DEBUG, __FILE__, __LINE__); 236 242 } else { 237 243 $user_in_trusted_network = false; … … 252 258 if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) { 253 259 // Only raise message if last session is less than 12 hours old. 254 App::raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);260 $app->raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__); 255 261 } 256 262 … … 269 275 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr()); 270 276 } 271 App::logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_sess]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);277 $app->logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_sess]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__); 272 278 } 273 279 … … 287 293 function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null) 288 294 { 295 $app =& App::getInstance(); 296 289 297 if (!$this->isLoggedIn()) { 290 298 // Display message for requiring login. (RaiseMsg will ignore empty strings.) 291 App::raiseMsg($message, $type, $file, $line);299 $app->raiseMsg($message, $type, $file, $line); 292 300 293 301 // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation. 294 App::setBoomerangURL(absoluteMe(), 'login');295 App::dieURL($this->_params['login_url']);302 $app->setBoomerangURL(absoluteMe(), 'login'); 303 $app->dieURL($this->_params['login_url']); 296 304 } 297 305 } … … 308 316 function _loadHTPasswdFile() 309 317 { 318 $app =& App::getInstance(); 319 310 320 static $users = null; 311 321 312 322 if (!file_exists($this->_params['htpasswd_file'])) { 313 App::logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);323 $app->logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__); 314 324 return false; 315 325 } … … 317 327 if (!isset($users)) { 318 328 if (false === ($users = file($this->_params['htpasswd_file']))) { 319 App::logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);329 $app->logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__); 320 330 return false; 321 331 } -
branches/2.0singleton/lib/Auth_SQL.inc.php
r121 r127 92 92 function Auth_SQL($auth_name=null) 93 93 { 94 $app =& App::getInstance(); 95 94 96 if (isset($auth_name)) { 95 97 $this->_auth = $auth_name; … … 101 103 102 104 // Get create tables config from global context. 103 if (!is_null( App::getParam('db_create_tables'))) {104 $this->setParam(array('create_table' => App::getParam('db_create_tables')));105 if (!is_null($app->getParam('db_create_tables'))) { 106 $this->setParam(array('create_table' => $app->getParam('db_create_tables'))); 105 107 } 106 108 } … … 115 117 function initDB($recreate_db=false) 116 118 { 119 $app =& App::getInstance(); 120 117 121 static $_db_tested = false; 118 122 … … 122 126 if ($recreate_db) { 123 127 DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table')); 124 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);128 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__); 125 129 } 126 130 … … 173 177 'modified_datetime', 174 178 ), false, false)) { 175 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);179 $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__); 176 180 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 177 181 } … … 181 185 if ($recreate_db) { 182 186 DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_login_table')); 183 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__);187 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__); 184 188 } 185 189 DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_login_table') . " ( … … 197 201 'remote_ip_binary', 198 202 ), false, false)) { 199 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__);203 $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__); 200 204 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), E_USER_ERROR); 201 205 } … … 228 232 function getParam($param) 229 233 { 234 $app =& App::getInstance(); 235 230 236 if (isset($this->_params[$param])) { 231 237 return $this->_params[$param]; 232 238 } else { 233 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);239 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 234 240 return null; 235 241 } … … 298 304 function authenticate($username, $password) 299 305 { 306 $app =& App::getInstance(); 307 300 308 $this->initDB(); 301 309 … … 311 319 // Return user data if found. 312 320 if ($user_data = mysql_fetch_assoc($qid)) { 313 App::logMsg(sprintf('Authentication successful for %s %s (%s)', $this->_auth, $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__);321 $app->logMsg(sprintf('Authentication successful for %s %s (%s)', $this->_auth, $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__); 314 322 return $user_data; 315 323 } else { 316 App::logMsg(sprintf('Authentication failed for %s %s (encrypted attempted password: %s)', $this->_auth, $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__);324 $app->logMsg(sprintf('Authentication failed for %s %s (encrypted attempted password: %s)', $this->_auth, $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__); 317 325 return false; 318 326 } … … 329 337 function login($username, $password) 330 338 { 339 $app =& App::getInstance(); 340 331 341 $this->initDB(); 332 342 … … 357 367 if (!empty($user_data['blocked'])) { 358 368 359 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__);369 $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__); 360 370 361 371 switch ($user_data['blocked_reason']) { 362 372 case 'account abuse' : 363 App::raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__);373 $app->raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__); 364 374 break; 365 375 default : 366 App::raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__);376 $app->raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__); 367 377 break; 368 378 } … … 391 401 // Warn the user with a password reset. 392 402 $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.")); 393 App::raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);394 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__);403 $app->raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__); 404 $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__); 395 405 } else { 396 406 // Block the account with the reason of account abuse. 397 407 $this->blockAccount(null, 'account abuse'); 398 App::raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);399 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__);408 $app->raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__); 409 $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__); 400 410 } 401 411 // Increment user's warning level. … … 447 457 function isLoggedIn($user_id=null) 448 458 { 459 $app =& App::getInstance(); 460 449 461 $this->initDB(); 450 462 … … 471 483 if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) { 472 484 $user_in_trusted_network = true; 473 App::logMsg(sprintf('%s%s accessing from trusted network %s',485 $app->logMsg(sprintf('%s%s accessing from trusted network %s', 474 486 ucfirst($this->_auth), 475 487 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' . $this->getVal('username') . ')' : ''), … … 478 490 } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) { 479 491 $user_in_trusted_network = true; 480 App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com',492 $app->logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com', 481 493 ucfirst($this->_auth), 482 494 ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' . $this->getVal('username') . ')' : '') … … 508 520 return true; 509 521 } else { 510 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__);522 $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__); 511 523 } 512 524 } else if (isset($_SESSION[$this->_sess]) && true === $_SESSION[$this->_sess]['authenticated']) { … … 514 526 if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) { 515 527 // Only raise message if last session is less than 12 hours old. 516 App::raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__);528 $app->raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__); 517 529 } 518 530 … … 531 543 $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr()); 532 544 } 533 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__);545 $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__); 534 546 } 535 547 … … 551 563 function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null) 552 564 { 565 $app =& App::getInstance(); 566 553 567 if (!$this->isLoggedIn()) { 554 568 // Display message for requiring login. (RaiseMsg will ignore empty strings.) 555 App::raiseMsg($message, $type, $file, $line);569 $app->raiseMsg($message, $type, $file, $line); 556 570 557 571 // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation. 558 App::setBoomerangURL(absoluteMe(), 'login');559 App::dieURL($this->_params['login_url']);572 $app->setBoomerangURL(absoluteMe(), 'login'); 573 $app->dieURL($this->_params['login_url']); 560 574 } 561 575 } … … 569 583 function blockAccount($user_id=null, $reason='') 570 584 { 585 $app =& App::getInstance(); 586 571 587 $this->initDB(); 572 588 … … 574 590 if (strlen(DB::escapeString($reason)) > 255) { 575 591 // blocked_reason field is varchar(255). 576 App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);592 $app->logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__); 577 593 } 578 594 … … 709 725 function setPassword($user_id=null, $password) 710 726 { 727 $app =& App::getInstance(); 728 711 729 $this->initDB(); 712 730 … … 722 740 723 741 if (mysql_affected_rows(DB::getDBH()) != 1) { 724 App::logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__);742 $app->logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__); 725 743 } 726 744 } … … 735 753 function resetPassword($user_id=null, $reason='') 736 754 { 755 $app =& App::getInstance(); 756 737 757 $this->initDB(); 738 758 … … 746 766 "); 747 767 if (!$user_data = mysql_fetch_assoc($qid)) { 748 App::logMsg(sprintf('Reset password failed. %s %s not found.', ucfirst($this->_auth), $user_id), LOG_NOTICE, __FILE__, __LINE__);768 $app->logMsg(sprintf('Reset password failed. %s %s not found.', ucfirst($this->_auth), $user_id), LOG_NOTICE, __FILE__, __LINE__); 749 769 return false; 750 770 } … … 758 778 // Make sure user has an email on record before continuing. 759 779 if (!isset($user_data['email']) || '' == trim($user_data['email'])) { 760 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__);780 $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__); 761 781 } else { 762 782 // Body for email. … … 779 799 $email = new Email(array( 780 800 'to' => $user_data['email'], 781 'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),782 'subject' => sprintf('%s password change', App::getParam('site_name'))801 'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')), 802 'subject' => sprintf('%s password change', $app->getParam('site_name')) 783 803 )); 784 804 $email->setString($email_body); 785 805 $email->replace(array( 786 'site_name' => App::getParam('site_name'),787 'site_url' => App::getParam('site_url'),806 'site_name' => $app->getParam('site_name'), 807 'site_url' => $app->getParam('site_url'), 788 808 'name' => ('' != $user_data['first_name'] . $user_data['last_name'] ? $user_data['first_name'] . ' ' . $user_data['last_name'] : $user_data[$this->_params['db_username_column']]), 789 809 'username' => $user_data[$this->_params['db_username_column']], … … 831 851 function requireAccessClearance($security_zone, $message='') 832 852 { 853 $app =& App::getInstance(); 854 833 855 return true; 834 856 $zone_members = preg_split('/,\s*/', $security_zone); … … 838 860 if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) { 839 861 $message = empty($message) ? _("You have insufficient privileges to view that page.") : $message; 840 App::raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);841 App::dieBoomerangURL();862 $app->raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__); 863 $app->dieBoomerangURL(); 842 864 } 843 865 } -
branches/2.0singleton/lib/AuthorizeNet.inc.php
r42 r127 132 132 function setParam($params) 133 133 { 134 $app =& App::getInstance(); 135 134 136 if (isset($params) && is_array($params)) { 135 137 // Merge new parameters with old overriding only those passed. 136 138 $this->_params = array_merge($this->_params, $params); 137 139 } else { 138 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);140 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 139 141 } 140 142 } … … 149 151 function getParam($param) 150 152 { 153 $app =& App::getInstance(); 154 151 155 if (isset($this->_params[$param])) { 152 156 return $this->_params[$param]; 153 157 } else { 154 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);158 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 155 159 return null; 156 160 } … … 167 171 function process() 168 172 { 173 $app =& App::getInstance(); 174 169 175 if (empty($this->_params['x_login'])) { 170 176 $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later."); 171 App::logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__);177 $app->logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__); 172 178 return false; 173 179 } 174 180 if (empty($this->_params['x_card_num'])) { 175 181 $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later."); 176 App::logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__);182 $app->logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__); 177 183 return false; 178 184 } -
branches/2.0singleton/lib/CSS.inc.php
r92 r127 28 28 function setParam($params) 29 29 { 30 $app =& App::getInstance(); 31 30 32 if (isset($params) && is_array($params)) { 31 33 // Merge new parameters with old overriding only those passed. 32 34 $this->_params = array_merge($this->_params, $params); 33 35 } else { 34 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);36 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 35 37 } 36 38 } … … 45 47 function getParam($param) 46 48 { 49 $app =& App::getInstance(); 50 47 51 if (isset($this->_params[$param])) { 48 52 return $this->_params[$param]; 49 53 } else { 50 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);54 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 51 55 return null; 52 56 } … … 58 62 * @access public 59 63 * @param string $file Include path to css files. 60 * @param mixed $ apps App name string or array of appnames.64 * @param mixed $realms Realm name string or array of realm names. 61 65 * @return bool True on success, false on failure. 62 66 */ 63 function setFile($file, $ apps='')67 function setFile($file, $realms='') 64 68 { 65 if (!is_array($apps)) { 66 $apps = array($apps); 69 $app =& App::getInstance(); 70 71 if (!is_array($realms)) { 72 $realms = array($realms); 67 73 } 68 74 69 75 if ($fp = fopen($file, 'r', true)) { 70 foreach ($ apps as $app) {71 $ app = '' == $app ? 'default' : $app;72 $this->_css_files[$ app][] = $file;76 foreach ($realms as $realm) { 77 $realm = '' == $realm ? 'default' : $realm; 78 $this->_css_files[$realm][] = $file; 73 79 } 74 80 fclose($fp); 75 81 return true; 76 82 } else { 77 App::logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);83 $app->logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__); 78 84 return false; 79 85 } … … 87 93 * @return bool False if no files have been set. 88 94 */ 89 function headers($ app='')95 function headers($realm='') 90 96 { 91 $app = '' == $app ? 'default' : $app; 97 $app =& App::getInstance(); 98 99 $realm = '' == $realm ? 'default' : $realm; 92 100 93 if (empty($this->_css_files[$ app])) {94 App::logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);101 if (empty($this->_css_files[$realm])) { 102 $app->logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__); 95 103 return false; 96 104 } … … 98 106 // Get time of latest modified file, including this class file. 99 107 $files_mtime = array(); 100 foreach (array_merge($this->_css_files[$ app], array(__FILE__)) as $file) {108 foreach (array_merge($this->_css_files[$realm], array(__FILE__)) as $file) { 101 109 $files_mtime[] = statIncludePath($file, 'mtime'); 102 110 } … … 122 130 * @return bool False if no files have been set. 123 131 */ 124 function output($ app='')132 function output($realm='') 125 133 { 126 $ app = '' == $app ? 'default' : $app;134 $realm = '' == $realm ? 'default' : $realm; 127 135 128 if (empty($this->_css_files[$ app])) {129 App::logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);136 if (empty($this->_css_files[$realm])) { 137 $app->logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__); 130 138 return false; 131 139 } 132 140 133 foreach ($this->_css_files[$ app] as $file) {141 foreach ($this->_css_files[$realm] as $file) { 134 142 include $file; 135 143 } -
branches/2.0singleton/lib/Captcha.inc.php
r121 r127 118 118 function Captcha() 119 119 { 120 $this->secret_key = App::getParam('signing_key'); 120 $app =& App::getInstance(); 121 122 $this->secret_key = $app->getParam('signing_key'); 121 123 $this->random_number = $this->_getRandomNumber(); 122 124 } … … 133 135 function getAsciiNumber($num=null) 134 136 { 137 $app =& App::getInstance(); 138 135 139 if (!isset($num)) { 136 140 $num = $this->random_number; … … 138 142 139 143 if (preg_match('/[^\d]/', $num)) { 140 App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);144 $app->logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__); 141 145 return false; 142 146 } -
branches/2.0singleton/lib/DB.inc.php
r119 r127 85 85 function setParam($params) 86 86 { 87 $app =& App::getInstance(); 88 87 89 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 88 90 $_this =& DB::getInstance(); … … 93 95 $_this->_params = array_merge($_this->_params, $params); 94 96 } else { 95 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);97 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 96 98 } 97 99 } … … 108 110 function getParam($param) 109 111 { 112 $app =& App::getInstance(); 113 110 114 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 111 115 $_this =& DB::getInstance(); … … 115 119 return $_this->_params[$param]; 116 120 } else { 117 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);121 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__); 118 122 return null; 119 123 } … … 129 133 function connect() 130 134 { 135 $app =& App::getInstance(); 136 131 137 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 132 138 $_this =& DB::getInstance(); … … 134 140 135 141 if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) { 136 App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);142 $app->logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__); 137 143 return false; 138 144 } … … 147 153 if (!$_this->dbh || mysql_error($_this->dbh)) { 148 154 $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.'; 149 App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);155 $app->logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__); 150 156 151 157 // Print helpful or pretty error? … … 169 175 170 176 // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01. 171 $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower( App::getParam('character_set'))] . "' */");177 $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower($app->getParam('character_set'))] . "' */"); 172 178 173 179 return true; … … 254 260 function query($query, $debug=false) 255 261 { 262 $app =& App::getInstance(); 263 256 264 static $_query_count = 0; 257 265 … … 280 288 echo _("This page is temporarily unavailable. It should be back up in a few minutes."); 281 289 } 282 App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);290 $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__); 283 291 if ($_this->getParam('db_die_on_failure')) { 284 292 echo "\n\n<!-- Script execution stopped out of embarrassment. -->"; … … 302 310 function tableExists($table, $use_cached_results=true) 303 311 { 312 $app =& App::getInstance(); 313 304 314 if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) { 305 315 $_this =& DB::getInstance(); … … 320 330 return true; 321 331 } else { 322 App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);332 $app->logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__); 323 333 return false; 324 334 } -
branches/2.0singleton/lib/DBSessionHandler.inc.php
r110 r127 32 32 function DBSessionHandler($db=null, $params=array()) 33 33 { 34 $app =& App::getInstance(); 35 34 36 $this->_params = array_merge($this->_params, $params); 35 37 … … 40 42 $this->db =& $db; 41 43 } else { 42 App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);44 $app->logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__); 43 45 } 44 46 } else { 45 App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);47 $app->logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__); 46 48 } 47 49 } else { … … 69 71 70 72 // Get create tables config from global context. 71 if (!is_null( App::getParam('db_create_tables'))) {72 $this->_params['create_table'] = App::getParam('db_create_tables');73 if (!is_null($app->getParam('db_create_tables'))) { 74 $this->_params['create_table'] = $app->getParam('db_create_tables'); 73 75 } 74 76 … … 96 98 function initDB($recreate_db=false) 97 99 { 100 $app =& App::getInstance(); 101 98 102 static $_db_tested = false; 99 103 … … 101 105 if ($recreate_db) { 102 106 $this->db->query("DROP TABLE IF EXISTS " . $this->_params['db_table']); 103 App::logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__);107 $app->logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__); 104 108 } 105 109 $this->db->query("CREATE TABLE IF NOT EXISTS " . $this->_params['db_table'] . " ( … … 112 116 113 117 if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) { 114 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);118 $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__); 115 119 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR); 116 120 } -
branches/2.0singleton/lib/Email.inc.php
r119 r127 12 12 $email = new Email(array( 13 13 'to' => array($frm['email'], 'q@lovemachine.local'), 14 'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),14 'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')), 15 15 'subject' => 'Your account has been activated', 16 16 )); … … 18 18 // $email->setString('Or you can pass your message body as a string, also with {VARIABLES}.'); 19 19 $email->replace(array( 20 'site_name' => App::getParam('site_name'),21 'site_url' => App::getParam('site_url'),20 'site_name' => $app->getParam('site_name'), 21 'site_url' => $app->getParam('site_url'), 22 22 'username' => $frm['username'], 23 23 'password' => $frm['password1'], 24 24 )); 25 25 if ($email->send()) { 26 App::raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__);26 $app->raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__); 27 27 } else { 28 App::logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__);28 $app->logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__); 29 29 } 30 30 ------------------------------------------------------------------------------------- … … 88 88 function setParam($params) 89 89 { 90 $app =& App::getInstance(); 91 90 92 if (isset($params) && is_array($params)) { 91 93 // Enforce valid email addresses. … … 100 102 $this->_params = array_merge($this->_params, $params); 101 103 } else { 102 App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);104 $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__); 103 105 } 104 106 } … … 113 115 function getParam($param) 114 116 { 117 $app =& App::getInstance(); 118 115 119 if (isset($this->_params[$param])) { 116 120 return $this->_params[$param]; 117 121 } else { 118 App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);122 $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__); 119 123 return null; 120 124 } … … 131 135 function setTemplate($template) 132 136 { 137 $app =& App::getInstance(); 138 133 139 // Load file, using include_path. 134 140 if (!$this->_template = file_get_contents($template, true)) { 135 App::logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__);141 $app->logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__); 136 142 $this->_template = null; 137 143 $this->_template_replaced = null; … … 153 159 function setString($string) 154 160 { 161 $app =& App::getInstance(); 162 155 163 // Load file, using include_path. 156 164 if ('' == trim($string)) { 157 App::logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);165 $app->logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__); 158 166 $this->_template_replaced = null; 159 167 return false; … … 176 184 function replace($replacements) 177 185 { 186 $app =& App::getInstance(); 187 178 188 // Ensure template exists. 179 189 if (!isset($this->_template)) { 180 App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);190 $app->logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__); 181 191 return false; 182 192 } … … 184 194 // Ensure replacements argument is an array. 185 195 if (!is_array($replacements)) { 186 App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);196 $app->logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__); 187 197 return false; 188 198 } … … 211 221 function send($to=null, $from=null, $subject=null, $headers=null) 212 222 { 223 $app =& App::getInstance(); 224 213 225 // Use arguments if provided. 214 226 if (isset($to)) { … … 227 239 // Ensure required values exist. 228 240 if (!isset($this->_params['subject'])) { 229 App::logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__);241 $app->logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__); 230 242 return false; 231 243 } else if (!isset($this->_template)) { 232 App::logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);244 $app->logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__); 233 245 return false; 234 246 } else if (!isset($this->_params['to'])) { 235 App::logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__);247 $app->logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__); 236 248 return false; 237 249 } else if (!isset($this->_params['from'])) { 238 App::logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);250 $app->logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__); 239 251 return false; 240 252 } … … 245 257 // Ensure all placeholders have been replaced. Find anything with {...} characters. 246 258 if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) { 247 App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);259 $app->logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__); 248 260 return false; 249 261 } … … 273 285 $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header)); 274 286 if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) { 275 App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);287 $app->logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__); 276 288 sleep(3); 277 289 return false; … … 280 292 // Ensure message was successfully accepted for delivery. 281 293 if (mail($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header)) { 282 App::logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__);294 $app->logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__); 283 295 return true; 284 296 } else { 285 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__);297 $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__); 286 298 return false; 287 299 } … … 305 317 function validEmail($email) 306 318 { 319 $app =& App::getInstance(); 320 307 321 // If an array, check values recursively. 308 322 if (is_array($email)) { … … 318 332 return true; 319 333 } else { 320 App::logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);334 $app->logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__); 321 335 return false; 322 336 } -
branches/2.0singleton/lib/FormValidator.inc.php
r121 r127 389 389 function validateEmail($form_name) 390 390 { 391 $app =& App::getInstance(); 392 391 393 $email = getFormData($form_name); 392 394 if ('' == trim($email)) { … … 400 402 if (!preg_match($e->getParam('regex'), $email, $e_parts)) { 401 403 $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email address."), oTxt($email))); 402 App::logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);404 $app->logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__); 403 405 return false; 404 406 } … … 412 414 if (strlen($local) > 64 || strlen($domain) > 191) { 413 415 $this->addError($form_name, sprintf(_("<strong>Email address</strong> must contain less than 256 characters."), oTxt($email))); 414 App::logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);416 $app->logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__); 415 417 return false; 416 418 } … … 420 422 if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) { 421 423 $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email domain name"), oTxt($domain))); 422 App::logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__);424 $app->logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__); 423 425 return false; 424 426 } … … 454 456 function validateStrDate($form_name, $msg='') 455 457 { 458 $app =& App::getInstance(); 459 456 460 if (($timestamp = strtotime(getFormData($form_name, '0'))) === -1) { 457 461 $this->addError($form_name, $msg); 458 App::logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);462 $app->logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__); 459 463 return false; 460 464 } else { -
branches/2.0singleton/lib/Hierarchy.inc.php
r111 r127 97 97 function toStringID($child_type=null, $child_id=null) 98 98 { 99 if (!isset($child_type) || !isset($child_id)) { 100 if ($this->node_init) { 101 $child_type =& $this->child_type; 102 $child_id =& $this->child_id; 103 } else { 104 App::logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 99 $app =& App::getInstance(); 100 101 if (!isset($child_type) || !isset($child_id)) { 102 if ($this->node_init) { 103 $child_type =& $this->child_type; 104 $child_id =& $this->child_id; 105 } else { 106 $app->logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 105 107 return false; 106 108 } … … 129 131 function toArrayID(&$node) 130 132 { 131 if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) { 133 $app =& App::getInstance(); 134 135 if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) { 132 136 return array('node_type' => $node_parts[1], 'node_id' => $node_parts[2]); 133 137 } else { 134 App::logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__);138 $app->logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__); 135 139 return false; 136 140 } … … 147 151 function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='') 148 152 { 153 $app =& App::getInstance(); 154 149 155 if (!isset($child_type) || !isset($child_id)) { 150 156 if ($this->node_init) { … … 152 158 $child_id =& $this->child_id; 153 159 } else { 154 App::logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);160 $app->logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 155 161 return false; 156 162 } … … 159 165 // Make sure this is not empty and an array, even if it has only one value. 160 166 if ('' == $parents) { 161 App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);162 App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);167 $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__); 168 $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__); 163 169 return false; 164 170 } else if (!is_array($parents)) { … … 174 180 $parent = $this->toArrayID($parent_string); 175 181 if ($this->nodeExists($child_type, $child_id, $parent['node_type'], $parent['node_id'], $relationship_type)) { 176 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__);177 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__);182 $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__); 183 $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__); 178 184 return false; 179 185 } 180 186 if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) { 181 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__);182 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__);187 $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__); 188 $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__); 183 189 return false; 184 190 } … … 205 211 ) 206 212 "); 207 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__);213 $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__); 208 214 } 209 215 return true; … … 223 229 function deleteNode($child_type=null, $child_id=null) 224 230 { 231 $app =& App::getInstance(); 232 225 233 if (!isset($child_type) || !isset($child_id)) { 226 234 if ($this->node_init) { … … 228 236 $child_id =& $this->child_id; 229 237 } else { 230 App::logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);238 $app->logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 231 239 return false; 232 240 } … … 248 256 AND child_id = '" . DB::escapeString($child_id) . "' 249 257 "); 250 App::logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);258 $app->logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__); 251 259 252 260 return true; … … 270 278 function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='') 271 279 { 272 if (!isset($child_type) || !isset($child_id)) { 273 if ($this->node_init) { 274 $child_type =& $this->child_type; 275 $child_id =& $this->child_id; 276 } else { 277 App::logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 280 $app =& App::getInstance(); 281 282 if (!isset($child_type) || !isset($child_id)) { 283 if ($this->node_init) { 284 $child_type =& $this->child_type; 285 $child_id =& $this->child_id; 286 } else { 287 $app->logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 278 288 return false; 279 289 } … … 282 292 // Make sure this is not empty and an array, even if it has only one value. 283 293 if (empty($new_parents)) { 284 App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);285 App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);294 $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__); 295 $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__); 286 296 return false; 287 297 } else if (!is_array($new_parents)) { … … 296 306 $parent = $this->toArrayID($parent_string); 297 307 if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) { 298 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__);299 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__);308 $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__); 309 $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__); 300 310 return false; 301 311 } 302 312 if ($this->isAncestor($child_type, $child_id, $parent['node_type'], $parent['node_id'])) { 303 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__);304 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__);313 $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__); 314 $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__); 305 315 return false; 306 316 } … … 325 335 AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . " 326 336 "); 327 App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);337 $app->logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__); 328 338 329 339 // Insert new nodes with the new parents. … … 344 354 function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='') 345 355 { 356 $app =& App::getInstance(); 357 346 358 if (!isset($child_type) || !isset($child_id)) { 347 359 if ($this->node_init) { … … 349 361 $child_id =& $this->child_id; 350 362 } else { 351 App::logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);363 $app->logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 352 364 return false; 353 365 } … … 392 404 function getNode($child_type=null, $child_id=null) 393 405 { 406 $app =& App::getInstance(); 407 394 408 if (!isset($child_type) || !isset($child_id)) { 395 409 if ($this->node_init) { … … 397 411 $child_id =& $this->child_id; 398 412 } else { 399 App::logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);413 $app->logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 400 414 return false; 401 415 } … … 433 447 function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='') 434 448 { 449 $app =& App::getInstance(); 450 435 451 if (!isset($child_type) || !isset($child_id)) { 436 452 if ($this->node_init) { … … 438 454 $child_id =& $this->child_id; 439 455 } else { 440 App::logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);456 $app->logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 441 457 return false; 442 458 } … … 482 498 function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null) 483 499 { 500 $app =& App::getInstance(); 501 484 502 if (!isset($child_type) || !isset($child_id)) { 485 503 if ($this->node_init) { … … 487 505 $child_id =& $this->child_id; 488 506 } else { 489 App::logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);507 $app->logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 490 508 return false; 491 509 } … … 520 538 function isLeaf($child_type=null, $child_id=null) 521 539 { 540 $app =& App::getInstance(); 541 522 542 if (!isset($child_type) || !isset($child_id)) { 523 543 if ($this->node_init) { … … 525 545 $child_id =& $this->child_id; 526 546 } else { 527 App::logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);547 $app->logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 528 548 return false; 529 549 } … … 631 651 function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null) 632 652 { 653 $app =& App::getInstance(); 654 633 655 if (!isset($child_type) || !isset($child_id)) { 634 656 if ($this->node_init) { … … 636 658 $child_id =& $this->child_id; 637 659 } else { 638 App::logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);660 $app->logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 639 661 return false; 640 662 } … … 680 702 function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true) 681 703 { 704 $app =& App::getInstance(); 705 682 706 static $output = array(); 683 707 static $is_a_leaf = array(); … … 688 712 $child_id =& $this->child_id; 689 713 } else { 690 App::logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);714 $app->logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__); 691 715 return false; 692 716 } … … 709 733 // Preventing circular references. 710 734 if ($my_children[$i]['child_type'] == $child_type && $my_children[$i]['child_id'] == $child_id && !($_return_flag && $include_curr)) { 711 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__);735 $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__); 712 736 continue; 713 737 }
Note: See TracChangeset
for help on using the changeset viewer.