logfiles view to twig

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-11 16:20:16 +01:00
parent 9c60cf006f
commit e4144d8c6a
3 changed files with 48 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
<?php
if (! defined('AREA')) {
if (!defined('AREA')) {
header("Location: index.php");
exit();
}
@@ -22,6 +22,7 @@ if (! defined('AREA')) {
use Froxlor\Api\Commands\SubDomains;
use Froxlor\Settings;
use Froxlor\UI\Request;
use Froxlor\UI\Panel\UI;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
@@ -65,7 +66,7 @@ if (function_exists('exec')) {
// error log
if (file_exists($error_log)) {
$result = \Froxlor\FileDir::safe_exec('tail -n ' . $last_n . ' ' . escapeshellarg($error_log));
$error_log_content = implode("\n", $result) . "</textarea>";
$error_log_content = implode("\n", $result);
} else {
$error_log_content = "Error-Log" . (AREA == 'admin' ? " '" . $error_log . "'" : "") . " does not seem to exist";
}
@@ -78,7 +79,22 @@ if (function_exists('exec')) {
$access_log_content = "Access-Log" . (AREA == 'admin' ? " '" . $access_log . "'" : "") . " does not seem to exist";
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("logfiles_viewer/index", true) . "\";");
UI::twigBuffer('user/logfiles.html.twig', [
'error_log_content' => $error_log_content,
'access_log_content' => $access_log_content,
'actions_links' => [[
'class' => 'btn-secondary',
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'edit', 'id' => $domain_id]),
'label' => $lng['panel']['edit'],
'icon' => 'fa fa-pen'
], [
'class' => 'btn-secondary',
'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains']),
'label' => $lng['menue']['domains']['domains'],
'icon' => 'fa fa-globe'
]]
]);
UI::twigOutputBuffer();
} else {
if (AREA == 'admin') {
\Froxlor\UI\Response::dynamic_error('You need to allow the exec() function in the froxlor-vhost php-config');

View File

@@ -57,3 +57,7 @@
footer {
@extend .text-muted;
}
.logcontent {
width: 100%;
}

View File

@@ -0,0 +1,25 @@
{% extends "Froxlor/userarea.html.twig" %}
{% block content %}
<h3 class="page-header">
<i class="fa-solid fa-magnifying-glass me-1"></i>
{{ lng('panel.viewlogs') }}
</h3>
<div class="row">
<div class="col-12 col-md-10 order-2 order-md-1">
<h4>Error-Log</h4>
<textarea rows="16" class="logcontent" readonly>{{ error_log_content }}</textarea>
<h4>Access-Log</h4>
<textarea rows="16" class="logcontent" readonly>{{ access_log_content }}</textarea>
</div>
<div class="col-12 col-md-2 order-1 order-md-2">
{% if actions_links is iterable %}
{% for link in actions_links %}
<a class="btn {{ link.class|default('btn-success') }} d-block mb-2" href="{{ link.href|raw }}">
<i class="{{ link.icon|default('fa-solid fa-plus-circle') }} me-1"></i>
{{ link.label }}</a>
{% endfor %}
{% endif %}
</div>
</div>
{% endblock %}