Changeset 129
- Timestamp:
- May 26, 2006 9:40:35 PM (18 years ago)
- Location:
- branches/2.0singleton
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/services/admins.php
r111 r129 8 8 9 9 $auth->requireLogin(); 10 App::sslOn();10 $app->sslOn(); 11 11 12 12 require_once 'codebase/lib/PageNumbers.inc.php'; … … 54 54 55 55 // Search limiters retain their values between page requests. 56 App::carryQuery('search_query');56 $app->carryQuery('search_query'); 57 57 58 58 … … 64 64 // allows us to remember which page we came from so we can go back there. 65 65 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { 66 App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');66 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins'); 67 67 } 68 68 … … 91 91 case 'del' : 92 92 deleteRecord(getFormData('admin_id')); 93 if ( App::validBoomerangURL('admins')) {93 if ($app->validBoomerangURL('admins')) { 94 94 // Display boomerang page. 95 App::dieBoomerangURL('admins');95 $app->dieBoomerangURL('admins'); 96 96 } 97 97 // Display default page. 98 App::dieURL($_SERVER['PHP_SELF']);98 $app->dieURL($_SERVER['PHP_SELF']); 99 99 break; 100 100 101 101 case 'insert' : 102 102 if (getFormdata('cancel', false)) { 103 if ( App::validBoomerangURL('admins')) {103 if ($app->validBoomerangURL('admins')) { 104 104 // Display boomerang page. 105 App::dieBoomerangURL('admins');105 $app->dieBoomerangURL('admins'); 106 106 } 107 107 // Display default page. 108 App::dieURL($_SERVER['PHP_SELF']);108 $app->dieURL($_SERVER['PHP_SELF']); 109 109 } 110 110 validateInput(); … … 118 118 if (getFormdata('repeat', false)) { 119 119 // Display function again. 120 App::dieURL($_SERVER['PHP_SELF'] . '?op=add');121 } else if ( App::validBoomerangURL('admins')) {120 $app->dieURL($_SERVER['PHP_SELF'] . '?op=add'); 121 } else if ($app->validBoomerangURL('admins')) { 122 122 // Display boomerang page. 123 App::dieBoomerangURL('admins');123 $app->dieBoomerangURL('admins'); 124 124 } 125 125 // Display default page. 126 App::dieURL($_SERVER['PHP_SELF']);126 $app->dieURL($_SERVER['PHP_SELF']); 127 127 } 128 128 break; … … 130 130 case 'update' : 131 131 if (getFormdata('reset', false)) { 132 App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);133 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));132 $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__); 133 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id')); 134 134 } 135 135 if (getFormdata('cancel', false)) { … … 137 137 $lock->select('admin_tbl', 'admin_id', getFormData('admin_id')); 138 138 $lock->remove(); 139 if ( App::validBoomerangURL('admins')) {139 if ($app->validBoomerangURL('admins')) { 140 140 // Display boomerang page. 141 App::dieBoomerangURL('admins');141 $app->dieBoomerangURL('admins'); 142 142 } 143 143 // Display default page. 144 App::dieURL($_SERVER['PHP_SELF']);144 $app->dieURL($_SERVER['PHP_SELF']); 145 145 } 146 146 validateInput(); … … 156 156 $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . DB::escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1"); 157 157 if (list($next_id) = mysql_fetch_row($qid)) { 158 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);158 $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id); 159 159 } else { 160 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);160 $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__); 161 161 } 162 } else if ( App::validBoomerangURL('admins')) {162 } else if ($app->validBoomerangURL('admins')) { 163 163 // Display boomerang page. 164 App::dieBoomerangURL('admins');164 $app->dieBoomerangURL('admins'); 165 165 } 166 166 // Display default page. 167 App::dieURL($_SERVER['PHP_SELF']);167 $app->dieURL($_SERVER['PHP_SELF']); 168 168 } 169 169 break; … … 258 258 { 259 259 global $lock; 260 $app =& App::getInstance(); 260 261 261 262 $lock->select('admin_tbl', 'admin_id', $id); … … 271 272 "); 272 273 if (!$frm = mysql_fetch_assoc($qid)) { 273 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);274 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);275 App::dieBoomerangURL();274 $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 275 $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 276 $app->dieBoomerangURL(); 276 277 } 277 278 … … 313 314 { 314 315 global $auth, $lock; 316 $app =& App::getInstance(); 315 317 316 318 $lock->select('admin_tbl', 'admin_id', $id); … … 328 330 "); 329 331 if (! list($name, $user_type) = mysql_fetch_row($qid)) { 330 App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);331 App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);332 App::dieBoomerangURL();332 $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__); 333 $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__); 334 $app->dieBoomerangURL(); 333 335 } 334 336 … … 338 340 if ('root' == $user_type && 'root' != $auth->getVal('user_type')) { 339 341 // Only root users can delete root users! 340 App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);342 $app->raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__); 341 343 } else if ($num_admins <= 1) { 342 344 // There must always be at least one admnistrator! 343 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__);345 $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__); 344 346 } else if ($auth->getVal('user_id') == $id) { 345 347 // Do not delete yourself! 346 App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);348 $app->raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__); 347 349 } else { 348 350 // Delete the record. 349 351 DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . DB::escapeString($id) . "'"); 350 App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);352 $app->raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__); 351 353 } 352 354 … … 358 360 { 359 361 global $auth; 362 $app =& App::getInstance(); 360 363 361 364 // Break the cache because we are changing the list data. … … 391 394 $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']); 392 395 393 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);396 $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 394 397 395 398 return $last_insert_id; … … 399 402 { 400 403 global $auth, $lock; 404 $app =& App::getInstance(); 401 405 402 406 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); … … 431 435 $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']); 432 436 433 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);437 $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 434 438 435 439 // Unlock record. -
branches/2.0singleton/services/lock.php
r53 r129 9 9 10 10 $auth->requireLogin(); 11 App::sslOn();11 $app->sslOn(); 12 12 13 13 if (getFormData('boomerang', false)) { 14 14 // We remember which page we came from so we can go back there. 15 15 $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER']; 16 App::setBoomerangURL($boom_url, 'lock');16 $app->setBoomerangURL($boom_url, 'lock'); 17 17 if (isset($_SERVER['HTTP_REFERER'])) { 18 App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');18 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock'); 19 19 } 20 20 } … … 26 26 27 27 if (!$lock->isLocked()) { 28 App::logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);29 App::dieBoomerangURL('lock');28 $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__); 29 $app->dieBoomerangURL('lock'); 30 30 } 31 31 … … 33 33 if (getFormData('unlock', false)) { 34 34 $lock->remove(); 35 App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);36 App::dieBoomerangURL('lock');35 $app->raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__); 36 $app->dieBoomerangURL('lock'); 37 37 } else if (getFormData('cancel', false)) { 38 38 // 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. 39 App::deleteBoomerangURL('lock');40 App::dieBoomerangURL('cancel-lock');39 $app->deleteBoomerangURL('lock'); 40 $app->dieBoomerangURL('cancel-lock'); 41 41 } 42 42 -
branches/2.0singleton/services/login.php
r103 r129 8 8 // allows us to remember which page we came from so we can go back there. 9 9 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { 10 App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'login');10 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'login'); 11 11 } 12 App::sslOn();12 $app->sslOn(); 13 13 14 14 $frm['username'] = getFormdata('username'); … … 19 19 20 20 if ($auth->login($frm['username'], $frm['password'])) { 21 App::raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);22 App::dieBoomerangURL('login');23 App::logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);21 $app->raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__); 22 $app->dieBoomerangURL('login'); 23 $app->logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__); 24 24 } else { 25 App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);26 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__);25 $app->raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__); 26 $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__); 27 27 } 28 28 } -
branches/2.0singleton/services/logout.php
r108 r129 15 15 $auth->clearAuth(); 16 16 17 App::raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__);18 App::dieURL(App::getParam('redirect_home_url'));17 $app->raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__); 18 $app->dieURL($app->getParam('redirect_home_url')); 19 19 20 20 ?> -
branches/2.0singleton/services/logs.php
r42 r129 9 9 $auth->requireLogin(); 10 10 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG); 11 App::sslOn();11 $app->sslOn(); 12 12 13 13 require_once 'codebase/lib/PageNumbers.inc.php'; … … 39 39 40 40 // Set the defaults and catch incoming settings. 41 Prefs::setDefault('log_file', App::getParam('log_filename'), 'logs_module');41 Prefs::setDefault('log_file', $app->getParam('log_filename'), 'logs_module'); 42 42 Prefs::setValue('log_file', getFormData('log'), 'logs_module'); 43 43 … … 57 57 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); 58 58 deleteLog(Prefs::getValue('log_file', 'logs_module')); 59 Prefs::setValue('log_file', App::getParam('log_filename'), 'logs_module');60 if ( App::validBoomerangURL('app_log')) {59 Prefs::setValue('log_file', $app->getParam('log_filename'), 'logs_module'); 60 if ($app->validBoomerangURL('app_log')) { 61 61 // Display boomerang page. 62 App::dieBoomerangURL('app_log');62 $app->dieBoomerangURL('app_log'); 63 63 } 64 64 // Display default page. 65 App::dieURL($_SERVER['PHP_SELF']);65 $app->dieURL($_SERVER['PHP_SELF']); 66 66 break; 67 67 … … 69 69 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); 70 70 clearLog(Prefs::getValue('log_file', 'logs_module')); 71 if ( App::validBoomerangURL('app_log')) {71 if ($app->validBoomerangURL('app_log')) { 72 72 // Display boomerang page. 73 App::dieBoomerangURL('app_log');73 $app->dieBoomerangURL('app_log'); 74 74 } 75 75 // Display default page. 76 App::dieURL($_SERVER['PHP_SELF']);76 $app->dieURL($_SERVER['PHP_SELF']); 77 77 break; 78 78 … … 81 81 if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) { 82 82 // Now flush current log. 83 App::dieURL($_SERVER['PHP_SELF'] . '?op=clear');84 } 85 if ( App::validBoomerangURL('app_log')) {83 $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear'); 84 } 85 if ($app->validBoomerangURL('app_log')) { 86 86 // Display boomerang page. 87 App::dieBoomerangURL('app_log');87 $app->dieBoomerangURL('app_log'); 88 88 } 89 89 // Display default page. 90 App::dieURL($_SERVER['PHP_SELF']);90 $app->dieURL($_SERVER['PHP_SELF']); 91 91 break; 92 92 … … 138 138 function deleteLog($log_file) 139 139 { 140 if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) { 141 App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 142 App::logMsg(sprintf('Cannot delete nonexistent log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 143 return false; 144 } 145 146 if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) { 147 App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 148 App::logMsg(sprintf('Cannot delete log file %s, not writable.', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 149 return false; 150 } 151 152 if (unlink(App::getParam('log_directory') . '/' . $log_file)) { 153 App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 154 App::logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__); 140 $app =& App::getInstance(); 141 142 if (!file_exists($app->getParam('log_directory') . '/' . $log_file)) { 143 $app->raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 144 $app->logMsg(sprintf('Cannot delete nonexistent log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 145 return false; 146 } 147 148 if (!is_writable($app->getParam('log_directory') . '/' . $log_file) && !is_writable($app->getParam('log_directory'))) { 149 $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 150 $app->logMsg(sprintf('Cannot delete log file %s, not writable.', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 151 return false; 152 } 153 154 if (unlink($app->getParam('log_directory') . '/' . $log_file)) { 155 $app->raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 156 $app->logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__); 155 157 return true; 156 158 } else { 157 App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);158 App::logMsg(sprintf('unlink failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);159 $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__); 160 $app->logMsg(sprintf('unlink failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 159 161 return false; 160 162 } … … 163 165 function clearLog($log_file) 164 166 { 165 if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) { 166 App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 167 App::logMsg(sprintf('fopen failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 167 $app =& App::getInstance(); 168 169 if (!$fp = fopen($app->getParam('log_directory') . '/' . $log_file, 'r+')) { 170 $app->raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 171 $app->logMsg(sprintf('fopen failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__); 168 172 return false; 169 173 } … … 174 178 fclose($fp); 175 179 if (!$ftruncate_return) { 176 App::raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);177 App::logMsg(sprintf('ftruncate failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);180 $app->raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__); 181 $app->logMsg(sprintf('ftruncate failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 178 182 return false; 179 183 } else { 180 App::raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);181 App::logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);184 $app->raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__); 185 $app->logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__); 182 186 return true; 183 187 } … … 186 190 function archiveLog($log_file) 187 191 { 192 $app =& App::getInstance(); 193 188 194 $old_file_name = $log_file; 189 195 $new_file_name = $log_file . '__' . date('Y-m-d'); 190 If (!is_writable( App::getParam('log_directory') . '')) {191 App::raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);192 App::logMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);193 return false; 194 } 195 If (!copy( App::getParam('log_directory') . '/' . $old_file_name, App::getParam('log_directory') . '/' . $new_file_name)) {196 App::raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);197 App::logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);198 return false; 199 } 200 201 App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);202 App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);196 If (!is_writable($app->getParam('log_directory') . '')) { 197 $app->raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__); 198 $app->logMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__); 199 return false; 200 } 201 If (!copy($app->getParam('log_directory') . '/' . $old_file_name, $app->getParam('log_directory') . '/' . $new_file_name)) { 202 $app->raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__); 203 $app->logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__); 204 return false; 205 } 206 207 $app->raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__); 208 $app->logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__); 203 209 return true; 204 210 } … … 206 212 function printLog($log_file) 207 213 { 208 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 209 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); 210 App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 211 return false; 212 } 213 214 readfile(App::getParam('log_directory') . '/' . $log_file); 214 $app =& App::getInstance(); 215 216 if (!is_file($app->getParam('log_directory') . '/' . $log_file)) { 217 $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); 218 $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 219 return false; 220 } 221 222 readfile($app->getParam('log_directory') . '/' . $log_file); 215 223 } 216 224 217 225 function &getLog($log_file, $search_query='') 218 226 { 219 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 220 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); 221 App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 222 return false; 223 } 224 $log = file(App::getParam('log_directory') . '/' . $log_file); 227 $app =& App::getInstance(); 228 229 if (!is_file($app->getParam('log_directory') . '/' . $log_file)) { 230 $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); 231 $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__); 232 return false; 233 } 234 $log = file($app->getParam('log_directory') . '/' . $log_file); 225 235 226 236 if ('' != trim($search_query)) { … … 237 247 { 238 248 global $valid_file_extensions; 249 $app =& App::getInstance(); 239 250 240 251 // Get a list of all files in the log directory. 241 $dir_handle = opendir( App::getParam('log_directory'));252 $dir_handle = opendir($app->getParam('log_directory')); 242 253 $list = array(); 243 254 while ($dir_handle && ($file = readdir($dir_handle)) !== false) { 244 if (!preg_match('/^\./', $file) && is_file( App::getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {255 if (!preg_match('/^\./', $file) && is_file($app->getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) { 245 256 $list[] = array( 246 257 'filename' => $file, 247 'filesize' => filesize( App::getParam('log_directory') . '/' . $file),248 'modified' => filemtime( App::getParam('log_directory') . '/' . $file),258 'filesize' => filesize($app->getParam('log_directory') . '/' . $file), 259 'modified' => filemtime($app->getParam('log_directory') . '/' . $file), 249 260 ); 250 261 } -
branches/2.0singleton/services/password.php
r42 r129 27 27 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { 28 28 // We remember which page we came from so we can go back there. 29 App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');29 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password'); 30 30 } 31 App::sslOn();31 $app->sslOn(); 32 32 33 33 switch (getFormData('op')) { … … 50 50 if (!$fv->anyErrors() && false === $auth->authenticate($auth->getVal('username'), $frm['oldpassword'])) { 51 51 $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication.")); 52 App::logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);52 $app->logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__); 53 53 } 54 54 55 55 if (!$fv->anyErrors()) { 56 56 $auth->setPassword(null, $frm['newpassword']); 57 App::logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);58 App::raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);59 App::dieBoomerangURL('admin_password');57 $app->logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__); 58 $app->raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__); 59 $app->dieBoomerangURL('admin_password'); 60 60 } 61 61 break; -
branches/2.0singleton/services/versions.php
r42 r129 8 8 9 9 $auth->requireLogin(); 10 App::sslOn();10 $app->sslOn(); 11 11 12 12 require_once 'codebase/lib/RecordVersion.inc.php'; … … 20 20 21 21 // Query arguments to retain their values between page requests. 22 App::carryQuery('record_table');23 App::carryQuery('record_key');24 App::carryQuery('record_val');25 App::carryQuery('version_title');22 $app->carryQuery('record_table'); 23 $app->carryQuery('record_key'); 24 $app->carryQuery('record_val'); 25 $app->carryQuery('version_title'); 26 26 27 27 // Titles and navigation header. … … 39 39 40 40 if ('' == $version_id && ('' == $record_table || '' == $record_key || '' == $record_val)) { 41 App::raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__);42 App::logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__);43 App::dieBoomerangURL();41 $app->raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__); 42 $app->logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__); 43 $app->dieBoomerangURL(); 44 44 } 45 45 46 46 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) { 47 47 // We remember which page we came from so we can go back there. 48 App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');48 $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions'); 49 49 } 50 50 … … 53 53 54 54 case _("Cancel") : 55 App::dieBoomerangURL('versions', false);55 $app->dieBoomerangURL('versions', false); 56 56 break; 57 57 … … 68 68 $current = $version->getCurrent($record_table, $record_key, $record_val); 69 69 if (serialize($data) == serialize($current)) { 70 App::raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);70 $app->raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__); 71 71 } 72 72 $nav->addPage(sprintf(_("Difference between version %s (%s) and current record."), $version_id, $versionrecord['version_datetime'])); … … 86 86 // Create version of this restored record as the "current" version. 87 87 $version->create($record_table, $record_key, $record_val, $v['version_title']); 88 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__);89 App::dieBoomerangURL('versions', array('break_list_cache'=>'true', false));88 $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__); 89 $app->dieBoomerangURL('versions', array('break_list_cache'=>'true', false)); 90 90 } else { 91 App::raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__);92 App::dieURL($_SERVER['PHP_SELF']);91 $app->raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__); 92 $app->dieURL($_SERVER['PHP_SELF']); 93 93 } 94 94 break; … … 101 101 $main_template = 'versions_list.ihtml'; 102 102 } else { 103 App::raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__);104 App::dieBoomerangURL('versions');103 $app->raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__); 104 $app->dieBoomerangURL('versions'); 105 105 } 106 106 } -
branches/2.0singleton/tests/AppTest.php
r42 r129 79 79 { 80 80 $expected = 'My message'; 81 App::raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);81 $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__); 82 82 $msg = current($_SESSION[$this->App->app]['messages']); 83 83 $this->assertEquals($expected, $msg['message']); … … 87 87 { 88 88 ob_start(); 89 App::printraisedmessages();89 $app->printraisedmessages(); 90 90 $result = ob_get_clean(); 91 91 $this->assertContains('My message', $result, 'Raised message not found in output.'); … … 95 95 { 96 96 $file = $this->App->getParam('log_directory') . '/' . $this->App->getParam('log_filename'); 97 App::logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);97 $app->logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__); 98 98 if ($result = file($file)) { 99 99 $result = end($result); … … 107 107 { 108 108 $_GET['arg1'] = 'A'; 109 $result = App::ohref('/some/url.php', array('arg1'), true);109 $result = $app->ohref('/some/url.php', array('arg1'), true); 110 110 $this->assertContains(session_name(), $result, 'SSID not found in URL.'); 111 111 $this->assertContains('arg1=A', $result, 'Argument not passed through.'); … … 115 115 { 116 116 ob_start(); 117 App::printhiddensession();117 $app->printhiddensession(); 118 118 $result = ob_get_clean(); 119 119 $this->assertContains(session_name(), $result); … … 122 122 // function test_dieurl() 123 123 // { 124 // App::dieURL('/die/to/this/url.php');124 // $app->dieURL('/die/to/this/url.php'); 125 125 // } 126 126 //
Note: See TracChangeset
for help on using the changeset viewer.