From 06d72f1c2819f4a7f14682077a1b6fe48ec63004 Mon Sep 17 00:00:00 2001 From: LaKing Date: Mon, 2 May 2011 17:36:14 +0000 Subject: [PATCH] Update on Sites, adding the logs tab to see error logs. --- interface/web/sites/form/web_domain.tform.php | 27 ++++++++++++++++++ interface/web/sites/web_domain_edit.php | 28 ++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php index 5f690791d..1436967b5 100644 --- a/interface/web/sites/form/web_domain.tform.php +++ b/interface/web/sites/form/web_domain.tform.php @@ -395,6 +395,33 @@ $form["tabs"]['stats'] = array ( ) ); + +//* Logs +$form["tabs"]['logs'] = array ( + 'title' => "logs", + 'width' => 100, + 'template' => "templates/web_domain_logs.htm", + 'readonly' => true, + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'logs' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => 'DEFAULT', + 'value' => 'VALUE', + 'cols' => '30', + 'rows' => '10' + ) + ################################## + # ENDE Datatable fields + ################################## + ) +); + + + if($_SESSION["s"]["user"]["typ"] == 'admin') { //* Backup diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index bac49eb37..87b57a50c 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -262,6 +262,32 @@ class page_action extends tform_actions { $app->tpl->setVar("domain_option",$domain_select); } + // Code to display the error log for the site. + + // Query the logfile name + $tmp = $app->db->queryOneRecord("SELECT document_root FROM web_domain WHERE domain_id = ".$this->id); + $logfile = $tmp["document_root"]."/log/error.log"; + + $lines = count(file($logfile)); + + // the "tail" function + $handle = @fopen($logfile, "r"); + if ($handle) { + while (($buffer = fgets($handle)) !== false) { + $lines = $lines -1; + // this constant defines how many lines to display + if ($lines<60) $tail .= $buffer; // TODO: We need a newline here. + } + if (!feof($handle)) { + $tail = "Error."; + } + fclose($handle); + } + + // store the tail so it can be displayed in the interface + $app->db->query("UPDATE web_domain SET logs = '$tail' WHERE domain_id = ".$this->id); + + parent::onShowEnd(); } @@ -605,4 +631,4 @@ class page_action extends tform_actions { $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> -- GitLab