Changeset 42 for trunk/services/logs.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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'));
Note: See TracChangeset
for help on using the changeset viewer.