Skip to content

Commit 06d72f1

Browse files
LaKingLaKing
authored andcommitted
Update on Sites, adding the logs tab to see error logs.
1 parent de115b4 commit 06d72f1

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

interface/web/sites/form/web_domain.tform.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,33 @@
395395
)
396396
);
397397

398+
399+
//* Logs
400+
$form["tabs"]['logs'] = array (
401+
'title' => "logs",
402+
'width' => 100,
403+
'template' => "templates/web_domain_logs.htm",
404+
'readonly' => true,
405+
'fields' => array (
406+
##################################
407+
# Begin Datatable fields
408+
##################################
409+
'logs' => array (
410+
'datatype' => 'TEXT',
411+
'formtype' => 'TEXTAREA',
412+
'default' => 'DEFAULT',
413+
'value' => 'VALUE',
414+
'cols' => '30',
415+
'rows' => '10'
416+
)
417+
##################################
418+
# ENDE Datatable fields
419+
##################################
420+
)
421+
);
422+
423+
424+
398425
if($_SESSION["s"]["user"]["typ"] == 'admin') {
399426

400427
//* Backup

interface/web/sites/web_domain_edit.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,32 @@ function onShowEnd() {
262262
$app->tpl->setVar("domain_option",$domain_select);
263263
}
264264

265+
// Code to display the error log for the site.
266+
267+
// Query the logfile name
268+
$tmp = $app->db->queryOneRecord("SELECT document_root FROM web_domain WHERE domain_id = ".$this->id);
269+
$logfile = $tmp["document_root"]."/log/error.log";
270+
271+
$lines = count(file($logfile));
272+
273+
// the "tail" function
274+
$handle = @fopen($logfile, "r");
275+
if ($handle) {
276+
while (($buffer = fgets($handle)) !== false) {
277+
$lines = $lines -1;
278+
// this constant defines how many lines to display
279+
if ($lines<60) $tail .= $buffer; // TODO: We need a newline here.
280+
}
281+
if (!feof($handle)) {
282+
$tail = "Error.";
283+
}
284+
fclose($handle);
285+
}
286+
287+
// store the tail so it can be displayed in the interface
288+
$app->db->query("UPDATE web_domain SET logs = '$tail' WHERE domain_id = ".$this->id);
289+
290+
265291
parent::onShowEnd();
266292
}
267293

@@ -605,4 +631,4 @@ function onAfterDelete() {
605631
$page = new page_action;
606632
$page->onLoad();
607633

608-
?>
634+
?>

0 commit comments

Comments
 (0)