From 85f2863bdd781b6b3922fc4ff359a528b6ad0fa1 Mon Sep 17 00:00:00 2001 From: Tom Homer Date: Tue, 27 Mar 2018 10:55:20 -0400 Subject: [PATCH] Removed rest of hard coded HTML from log viewer --- public_html/admin/logviewer.php | 41 ++++++++----------- .../layout/denim/admin/logviewer.thtml | 21 ++++++++++ .../layout/denim_three/admin/logviewer.thtml | 21 ++++++++++ .../layout/modern_curve/admin/logviewer.thtml | 21 ++++++++++ 4 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 public_html/layout/denim/admin/logviewer.thtml create mode 100644 public_html/layout/denim_three/admin/logviewer.thtml create mode 100644 public_html/layout/modern_curve/admin/logviewer.thtml diff --git a/public_html/admin/logviewer.php b/public_html/admin/logviewer.php index 64fff8848..b69d00272 100644 --- a/public_html/admin/logviewer.php +++ b/public_html/admin/logviewer.php @@ -67,34 +67,24 @@ $LANG_LOGVIEW['info'], $_CONF['layout_url'] . '/images/icons/log_viewer.' . $_IMAGE_TYPE ); + + +$T = new Template($_CONF['path_layout'] . 'admin'); +$T->set_file('page','logviewer.thtml'); -$display .= '
' - . $LANG_LOGVIEW['logs'] . ': ' . PHP_EOL; -$tcc = COM_newTemplate($_CONF['path_layout'] . 'controls'); -$tcc->set_file('common', 'common.thtml'); -$tcc->set_block('common', 'type-select'); -$tcc->set_var('name', 'log'); +$T->set_var('lang_logs', $LANG_LOGVIEW['logs']); + $items = ''; foreach (glob($_CONF['path_log'] . '*.log') as $file) { $file = basename($file); $items .= '' . PHP_EOL; } -$tcc->set_var('select_items', $items); -$display .= $tcc->finish($tcc->parse('common', 'type-select')); +$T->set_var('log_items', $items); -$tcc->set_block('common', 'type-submit'); -$tcc->set_var('name', 'viewlog'); -$tcc->set_var('value', $LANG_LOGVIEW['view']); -$tcc->set_var('lang_button', $LANG_LOGVIEW['view']); -$display .= $tcc->finish($tcc->parse('common', 'type-submit')); - -$tcc->set_var('name', 'clearlog'); -$tcc->set_var('value', $LANG_LOGVIEW['clear']); -$tcc->set_var('lang_button', $LANG_LOGVIEW['clear']); -$tcc->set_var('onclick', 'return confirm(\'' . $MESSAGE[76] . '\');'); -$display .= $tcc->finish($tcc->parse('common', 'type-submit')); -$display .= '
'; +$T->set_var('lang_log_view', $LANG_LOGVIEW['view']); +$T->set_var('lang_log_clear', $LANG_LOGVIEW['clear']); +$T->set_var('lang_confirm_del_message', $MESSAGE[76]); if (isset($_POST['clearlog'])) { if (@unlink($_CONF['path_log'] . $log)) { @@ -104,14 +94,15 @@ } } if (isset($_POST['viewlog'])) { - $display .= '

' . $LANG_LOGVIEW['log_file'] . ': ' . $log . '

' - . '
' - . '
'
-        . htmlentities(file_get_contents($_CONF['path_log'] . $log), ENT_NOQUOTES, COM_getEncodingt())
-        . '
'; + $T->set_var('lang_log_file', $LANG_LOGVIEW['log_file']); + $T->set_var('log_filename', $log); + $T->set_var('log_contents', htmlentities(file_get_contents($_CONF['path_log'] . $log), ENT_NOQUOTES, COM_getEncodingt())); } +$T->parse('output', 'page'); +$display .= $T->finish($T->get_var('output')); $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); + $output = COM_createHTMLDocument($display, array('pagetitle' => $LANG_LOGVIEW['log_viewer'])); header('Content-Type: text/html; charset=' . COM_getEncodingt()); header('X-XSS-Protection: 1; mode=block'); diff --git a/public_html/layout/denim/admin/logviewer.thtml b/public_html/layout/denim/admin/logviewer.thtml new file mode 100644 index 000000000..fa33bf324 --- /dev/null +++ b/public_html/layout/denim/admin/logviewer.thtml @@ -0,0 +1,21 @@ +{# begin {templatelocation} #} + +
+
+ {lang_logs}: + + + + {!if log_contents} +

{lang_log_file}: {log_filename}

+ +
+ +
+            {log_contents}
+        
+ {!endif} +
+
+ +{# end {templatelocation} #} \ No newline at end of file diff --git a/public_html/layout/denim_three/admin/logviewer.thtml b/public_html/layout/denim_three/admin/logviewer.thtml new file mode 100644 index 000000000..51ee1969e --- /dev/null +++ b/public_html/layout/denim_three/admin/logviewer.thtml @@ -0,0 +1,21 @@ +{# begin {templatelocation} #} + +
+
+ {lang_logs}: + + + + {!if log_contents} +

{lang_log_file}: {log_filename}

+ +
+ +
+            {log_contents}
+        
+ {!endif} +
+
+ +{# end {templatelocation} #} \ No newline at end of file diff --git a/public_html/layout/modern_curve/admin/logviewer.thtml b/public_html/layout/modern_curve/admin/logviewer.thtml new file mode 100644 index 000000000..7fe89723b --- /dev/null +++ b/public_html/layout/modern_curve/admin/logviewer.thtml @@ -0,0 +1,21 @@ +{# begin {templatelocation} #} + +
+
+ {lang_logs}: + + + + {!if log_contents} +

{lang_log_file}: {log_filename}

+ +
+ +
+            {log_contents}
+        
+ {!endif} +
+
+ +{# end {templatelocation} #} \ No newline at end of file