Changeset 42 for trunk/services
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- Location:
- trunk/services
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/services/admins.php
r41 r42 1 1 <?php 2 2 /** 3 * admins.php 3 * admins.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 23 23 * CONFIG 24 24 *****************************************************************************/ 25 25 26 26 // Titles and navigation header. 27 27 $nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']); 28 28 29 29 // The object to validate form input. 30 30 $fv = new FormValidator(); … … 60 60 * MAIN 61 61 *****************************************************************************/ 62 62 63 63 // We may want to use the add/edit interface from another script, so this 64 64 // allows us to remember which page we came from so we can go back there. … … 208 208 $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank.")); 209 209 $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters.")); 210 210 211 211 $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank.")); 212 212 $fv->stringLength('userpass', 6, 36, _("<strong>Passwords</strong> must be between 6 and 36 characters long.")); 213 213 214 214 $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters.")); 215 215 216 216 $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters.")); 217 217 … … 219 219 $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters.")); 220 220 $fv->validateEmail('email'); 221 221 222 222 $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank.")); 223 223 $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection.")); … … 265 265 // Get the information for the form. 266 266 $qid = DB::query(" 267 SELECT * 267 SELECT * 268 268 FROM admin_tbl 269 269 WHERE admin_id = '" . addslashes($id) . "' … … 274 274 App::dieBoomerangURL(); 275 275 } 276 276 277 277 // Lock this record. 278 278 $lock->set('admin_tbl', 'admin_id', $id, $frm['username']); 279 279 280 280 // Set misc values for the form. 281 281 $frm = array_merge(array( … … 312 312 { 313 313 global $auth, $lock; 314 314 315 315 $lock->select('admin_tbl', 'admin_id', $id); 316 316 if ($lock->isLocked() && !$lock->isMine()) { … … 320 320 // Break the cache because we are changing the list data. 321 321 SessionCache::breakCache($_SERVER['PHP_SELF']); 322 322 323 323 // Get the information for this object. 324 324 $qid = DB::query(" … … 331 331 App::dieBoomerangURL(); 332 332 } 333 333 334 334 // Get the information for this object. 335 335 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); … … 357 357 { 358 358 global $auth; 359 359 360 360 // Break the cache because we are changing the list data. 361 361 SessionCache::breakCache($_SERVER['PHP_SELF']); 362 362 363 363 // Insert record data. 364 364 DB::query(" … … 382 382 "); 383 383 $last_insert_id = mysql_insert_id(DB::getDBH()); 384 384 385 385 // Set admin password. 386 386 $auth->setPassword($last_insert_id, $frm['userpass']); 387 387 388 388 // Create version. 389 389 $version = RecordVersion::getInstance($GLOBALS['auth']); 390 390 $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']); 391 391 392 392 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 393 393 394 394 return $last_insert_id; 395 395 } … … 398 398 { 399 399 global $auth, $lock; 400 400 401 401 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); 402 402 if ($lock->isLocked() && !$lock->isMine()) { … … 406 406 // Break the cache because we are changing the list data. 407 407 SessionCache::breakCache($_SERVER['PHP_SELF']); 408 408 409 409 // If the userpass is left blank or with the filler **** characters, we don't want to update it. 410 410 if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) { … … 412 412 $auth->setPassword($frm['admin_id'], $frm['userpass']); 413 413 } 414 414 415 415 // Update record data. 416 416 DB::query(" … … 440 440 global $page; 441 441 global $so; 442 442 443 443 $where_clause = ''; 444 444 445 445 // Build search query if available. 446 446 if (getFormData('search_query', false)) { … … 460 460 // Count the total number of records so we can do something about the page numbers. 461 461 $qid = DB::query(" 462 SELECT COUNT(*) 463 FROM admin_tbl 462 SELECT COUNT(*) 463 FROM admin_tbl 464 464 $where_clause 465 465 "); 466 466 list($num_results) = mysql_fetch_row($qid); 467 467 468 468 // Set page numbers now we know (needed for next step). 469 469 $page->setTotalItems($num_results); 470 470 $page->calculate(); 471 471 472 472 // Final SQL, with sort and page limiters. 473 473 $sql = " 474 SELECT 475 admin_tbl.*, 474 SELECT 475 admin_tbl.*, 476 476 a1.username AS added_admin_username, 477 477 a2.username AS modified_admin_username … … 483 483 " . $page->getLimitSQL() . " 484 484 "; 485 485 486 486 // A unique key for this query, with the total_items in case db records 487 487 // were added since the last cache. This identifies a unique set of … … 494 494 Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 495 495 } 496 496 497 497 if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) { 498 498 // Get the cached results. … … 505 505 $list[] = $row; 506 506 } 507 507 508 508 if (isset($list) && !empty($list)) { 509 509 // Cache the results. -
trunk/services/css.php
r41 r42 1 1 <?php 2 2 /** 3 * css.php 3 * css.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 * -
trunk/services/lock.php
r41 r42 1 1 <?php 2 2 /** 3 * lock.php 3 * lock.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ -
trunk/services/login.php
r41 r42 1 1 <?php 2 2 /** 3 * login.php 3 * login.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 24 24 } else { 25 25 App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__); 26 App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', $auth->getVal('auth_name'), $frm['username'], md5($frm['password'])), LOG_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 } -
trunk/services/logout.php
r41 r42 1 1 <?php 2 2 /** 3 * logout.php 3 * logout.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ -
trunk/services/logs.php
r41 r42 1 1 <?php 2 2 /** 3 * logs.php 3 * logs.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 48 48 * MAIN 49 49 *****************************************************************************/ 50 50 51 51 // Allow realtime file stats. 52 clearstatcache(); 52 clearstatcache(); 53 53 54 54 // What action to take. … … 65 65 App::dieURL($_SERVER['PHP_SELF']); 66 66 break; 67 67 68 68 case 'clear' : 69 69 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); … … 76 76 App::dieURL($_SERVER['PHP_SELF']); 77 77 break; 78 78 79 79 case 'archive' : 80 80 // $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET); … … 90 90 App::dieURL($_SERVER['PHP_SELF']); 91 91 break; 92 92 93 93 // case 'ouput' : 94 94 // $main_template = 'ouput'; 95 95 // break; 96 96 97 97 case 'download' : 98 98 header('Content-Type: application/octet-stream'); … … 101 101 die; 102 102 break; 103 103 104 104 default : 105 105 $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query')); … … 137 137 138 138 function deleteLog($log_file) 139 { 139 { 140 140 if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) { 141 141 App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 143 143 return false; 144 144 } 145 145 146 146 if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) { 147 147 App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 149 149 return false; 150 150 } 151 151 152 152 if (unlink(App::getParam('log_directory') . '/' . $log_file)) { 153 153 App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 162 162 163 163 function clearLog($log_file) 164 { 164 { 165 165 if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) { 166 166 App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__); … … 168 168 return false; 169 169 } 170 170 171 171 flock($fp, LOCK_EX); 172 172 $ftruncate_return = ftruncate($fp, 0); … … 185 185 186 186 function archiveLog($log_file) 187 { 187 { 188 188 $old_file_name = $log_file; 189 189 $new_file_name = $log_file . '__' . date('Y-m-d'); … … 198 198 return false; 199 199 } 200 200 201 201 App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__); 202 202 App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__); … … 205 205 206 206 function printLog($log_file) 207 { 207 { 208 208 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 209 209 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); … … 216 216 217 217 function &getLog($log_file, $search_query='') 218 { 218 { 219 219 if (!is_file(App::getParam('log_directory') . '/' . $log_file)) { 220 220 App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__); … … 223 223 } 224 224 $log = file(App::getParam('log_directory') . '/' . $log_file); 225 225 226 226 if ('' != trim($search_query)) { 227 227 if (getFormData('search_grep')) { … … 237 237 { 238 238 global $valid_file_extensions; 239 239 240 240 // Get a list of all files in the log directory. 241 241 $dir_handle = opendir(App::getParam('log_directory')); -
trunk/services/password.php
r41 r42 1 1 <?php 2 2 /** 3 * password.php 3 * password.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 14 14 * CODE CONFIG 15 15 *****************************************************************************/ 16 16 17 17 // Titles and navigation header. 18 18 $nav->addPage(_("Change password")); … … 47 47 } 48 48 } 49 49 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.")); -
trunk/services/templates/admin_list.ihtml
r41 r42 6 6 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span> 7 7 <br /> 8 8 9 9 <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" /> 10 10 <input type="submit" value="<?php echo _("Search"); ?>" /> -
trunk/services/templates/list_info.ihtml
r41 r42 4 4 <?php } ?> 5 5 <span class="nowrap commanditem commandtext"> 6 <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?> 6 <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?> 7 7 <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a> 8 8 <?php echo _("Per page"); ?>: <?php $page->printPerPageLinks() ?> -
trunk/services/templates/lock.ihtml
r41 r42 1 <?php 1 <?php 2 2 if (!is_a($lock, 'RecordLock')) { 3 3 return null; … … 9 9 10 10 <p><?php 11 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 12 $lock->getTitle(), 13 $lock->getEditor(), 11 printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 12 $lock->getTitle(), 13 $lock->getEditor(), 14 14 date('i', $lock->getSecondsElapsed() + 60) 15 15 ); -
trunk/services/templates/versions_diff.ihtml
r41 r42 1 <div id="commandbox"> 1 <div id="commandbox"> 2 2 <?php if (!getFormData('current', false)) { ?> 3 3 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span> -
trunk/services/templates/versions_list.ihtml
r41 r42 9 9 <th class="padleft"><?php echo _("By"); ?></th> 10 10 </tr> 11 <?php 11 <?php 12 12 $first = true; 13 13 foreach ($versions as $v) { ?> … … 25 25 <td class="padleft nowrap"><?php echo $v['editor']; ?></td> 26 26 </tr> 27 <?php 27 <?php 28 28 $first = false; 29 } 29 } 30 30 ?> 31 31 </table> -
trunk/services/templates/versions_view.ihtml
r41 r42 1 <div id="commandbox"> 1 <div id="commandbox"> 2 2 <?php if (!getFormData('current', false)) { ?> 3 3 <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span> … … 10 10 <table class="list" border="0" cellspacing="0" cellpadding="4"> 11 11 <?php 12 while ((list($k, $v_d) = each($data))) { 12 while ((list($k, $v_d) = each($data))) { 13 13 ?> 14 14 <tr> -
trunk/services/versions.php
r41 r42 1 1 <?php 2 2 /** 3 * versions.php 3 * versions.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 110 110 * TEMPLATE INITIALIZATION 111 111 *****************************************************************************/ 112 112 113 113 include 'header.ihtml'; 114 114 include 'codebase/services/templates/' . $main_template;
Note: See TracChangeset
for help on using the changeset viewer.