17 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
18 require_once SQ_FUDGE_PATH.
'/general/file_system.inc';
46 $this->static_screens = Array();
49 $this->static_screens[
'details'][
'name'] =translate(
'details');
50 $this->static_screens[
'details'][
'force_unlock'] = FALSE;
51 $this->static_screens[
'details'][
'lock_type'] =
'none';
68 $download_file = array_get_index($_POST, $prefix.
'_download_file',
'');
69 if ($download_file !==
'') {
73 $write_access = $lm->writeAccess();
76 $logs = $lm->getLogs();
78 echo
'<h2>'.translate(
'no_logs_found').
'</h2>';
83 <script type=
"text/javascript">
85 var prefix =
"<?php echo $prefix; ?>";
86 var communicator_url =
"<?php echo $lm->getCommunicatorUrl(); ?>";
87 var action_prefix = prefix +
"_action";
88 var action_value = prefix +
"_value";
89 var logname_index = prefix +
"_log";
90 var offset_index = prefix +
"_offset";
91 var num_lines_index = prefix +
"_num_lines";
93 var refresh_interval = 30000;
94 var last_offset = null;
97 var log_refresh =
true;
99 var current_log = null;
104 function monitorLog(logname)
106 if (logname == null) {
107 logname = current_log;
109 current_log = logname;
112 if (logname == null) {
116 document.getElementById(
'sq-log-monitor-initial-message').style.display =
'none';
117 document.getElementById(
'sq-log-monitor-containter').style.display =
'block';
118 setIdValue(
'sq-log-name', logname);
119 document.getElementById(
'sq-log-num-lines').defaultValue = num_lines;
122 if (log_refresh && null === refresher) {
140 function forceRefresh()
153 request_url = communicator_url+
'&'+action_prefix+
'=monitor&'+logname_index+
'='+current_log+
'&rand='+ Math.random()+
'&'+num_lines_index+
'='+num_lines;
154 if (null !== last_offset) {
155 request_url = request_url+
'&'+offset_index+
'='+last_offset;
158 document.getElementById(
'sq-log-monitor').src = request_url;
168 function setRefreshInterval(interval)
170 var value = parseInt(interval);
172 refresh_interval = value * 1000;
182 function setNumLines(new_num_lines)
184 var value = parseInt(new_num_lines);
201 function setLastRefreshInfo(date_string, num_rows, offset)
203 setIdValue(
'sq-log-last-refresh', date_string);
204 setIdValue(
'sq-log-total-rows', num_rows);
205 setLastOffset(offset);
210 function setIdValue(
id, value)
212 document.getElementById(
id).innerHTML = value;
226 function setLastOffset(value)
228 var value = parseInt(value);
243 function enableRefresh()
245 if (null !== refresher) {
246 clearTimeout(refresher);
248 refresher = setInterval(loadLog, refresh_interval);
250 setIdValue(
'sq-log-refresh-status',
'ON');
251 document.getElementById(
'sq-log-refresh-enabler').value=js_translate(
'disable');
263 function disableRefresh()
265 if (null !== refresher) {
266 clearInterval(refresher);
270 setIdValue(
'sq-log-refresh-status',
'OFF');
271 document.getElementById(
'sq-log-refresh-enabler').value=js_translate(
'enable');
281 function toggleLogRefreshStatus()
297 <table
class=
"sq-backend-table">
299 <th style=
"width: 10%"><?php echo translate(
'log_name'); ?></th>
300 <th style=
"width: 50%"><?php echo translate(
'info'); ?></th>
304 foreach ($logs as $logname => $rotation) {
305 $filepath = SQ_LOG_PATH.
'/'.$logname.SQ_CONF_LOG_EXTENSION;
306 if (!file_exists($filepath))
continue;
308 $last_modified = date(
'G:i:s - M d', filemtime($filepath));
310 $last_rotated = array_get_index(array_get_index($rotation,
'rotation'),
'last_timestamp');
311 if (empty($last_rotated)) {
312 $last_rotated = translate(
'never');
314 $last_rotated = date(
'G:i:s - M d', $last_rotated);
319 <td><strong><?php echo $logname; ?></strong></td>
321 <?php echo translate(
'modified'); ?>: <strong><?php echo $last_modified; ?></strong>
323 <?php echo translate(
'core_log_manager_current_logfile_size'); ?>: <strong><?php echo easy_filesize(filesize($filepath)); ?></strong>
325 <?php echo translate(
'rotated'); ?>: <strong><?php echo $last_rotated; ?></strong>
328 <input type=
"button" onclick=
"monitorLog('<?php echo $logname; ?>');" value=
"<?php echo translate('monitor'); ?>" />
329 <?php normal_button($prefix.
'_export_to_csv', translate(
'download_file'),
'this.form.'.$prefix.
'_download_file.value = \''.$logname.
'\';
this.form.submit(); SQ_FORM_SUBMITTED =
false; this.form.
'.$prefix.'_download_file.value = 0;
return true;
');
336 hidden_field($prefix.'_download_file
', 0);
341 $o->openSection(translate('log_monitor
'));
344 <div id="sq-log-monitor-initial-message">
345 <?php echo translate('moniter_logs_instructions
'); ?>
347 <div id="sq-log-monitor-containter" style="display: none;">
348 <table class="sq-backend-table">
351 <?php echo translate('log
'); ?>: <strong id="sq-log-name"></strong>
353 <?php echo translate('loaded
'); ?>: <strong id="sq-log-last-refresh"></strong>
355 <?php echo translate('rows_displayed
'); ?>: <strong id="sq-log-total-rows"></strong>
358 <td style="text-align: right">
359 <?php echo translate('max_rows
'); ?>:
360 <select id="sq-log-num-lines" onchange="setNumLines(this.value)">
361 <option value="10">10</option>
362 <option value="50" selected="selected">50</option>
363 <option value="100">100</option>
364 <option value="500">500</option>
365 <option value="1000">1000</option>
368 <?php echo translate('auto-refresh
'); ?>: <strong id="sq-log-refresh-status"> </strong>
369 <input type="button" onclick="toggleLogRefreshStatus();" id="sq-log-refresh-enabler" value="" />
371 <?php echo translate('refresh_interval
'); ?>:
372 <select name="sq-log-refresh-interval" id="sq-log-refresh-interval" onchange="setRefreshInterval(this.value)">
373 <option value="15">15 <?php echo translate('sec
'); ?></option>
374 <option value="30" selected="selected">30 <?php echo translate('sec
'); ?></option>
375 <option value="60">1 <?php echo translate('min
'); ?></option>
376 <option value="300">5 <?php echo translate('min
'); ?></option>
379 <input type="button" onclick="forceRefresh();" id="sq-log-refresh-force" value="<?php echo translate('refresh_now
'); ?>" />
384 <iframe id="sq-log-monitor" src="" style="width: 100%; height: 400px; border: 1px solid #C3C3C3;"></iframe>
392 }//end paintLogList()
404 public function processDownloadLogFile(Log_Manager $asset, Backend_Outputter $o, $prefix)
406 if ($asset->writeAccess() === FALSE) {
410 $download_file = array_get_index($_POST, $prefix.'_download_file
', '');
412 if ($download_file !== '') {
413 // Get all the valid log files in that directory, and see whether our
414 // file is one of them
415 $log_file = SQ_DATA_PATH.'/
private/logs/
'.$download_file.SQ_CONF_LOG_EXTENSION;
416 $valid_log_files = glob(SQ_DATA_PATH.'/
private/logs