admin_cronjobs form and admin/customer logger overview
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -66,30 +66,14 @@ if ($page == 'cronjobs' || $page == 'overview') {
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// interval
|
|
||||||
$interval_nfo = explode(' ', $result['interval']);
|
|
||||||
$interval_value = $interval_nfo[0];
|
|
||||||
|
|
||||||
$interval_interval = '';
|
|
||||||
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['minutes'], 'MINUTE', $interval_nfo[1]);
|
|
||||||
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['hours'], 'HOUR', $interval_nfo[1]);
|
|
||||||
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['days'], 'DAY', $interval_nfo[1]);
|
|
||||||
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['weeks'], 'WEEK', $interval_nfo[1]);
|
|
||||||
$interval_interval .= \Froxlor\UI\HTML::makeoption($lng['cronmgmt']['months'], 'MONTH', $interval_nfo[1]);
|
|
||||||
// end of interval
|
|
||||||
|
|
||||||
$change_cronfile = false;
|
|
||||||
if (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor') {
|
|
||||||
$change_cronfile = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
|
$cronjobs_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/cronjobs/formfield.cronjobs_edit.php';
|
||||||
$cronjobs_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($cronjobs_edit_data);
|
|
||||||
|
|
||||||
$title = $cronjobs_edit_data['cronjobs_edit']['title'];
|
UI::twigBuffer('user/form.html.twig', [
|
||||||
$image = $cronjobs_edit_data['cronjobs_edit']['image'];
|
'formaction' => $linker->getLink(array('section' => 'cronjobs', 'id' => $id)),
|
||||||
|
'formdata' => $cronjobs_edit_data['cronjobs_edit'],
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('cronjobs/cronjob_edit') . "\";");
|
'editid' => $id
|
||||||
|
]);
|
||||||
|
UI::twigOutputBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'delete' && $id != 0) {
|
} elseif ($action == 'delete' && $id != 0) {
|
||||||
|
|||||||
@@ -21,94 +21,29 @@ const AREA = 'admin';
|
|||||||
require __DIR__ . '/lib/init.php';
|
require __DIR__ . '/lib/init.php';
|
||||||
|
|
||||||
use Froxlor\Api\Commands\SysLog;
|
use Froxlor\Api\Commands\SysLog;
|
||||||
|
use Froxlor\UI\Panel\UI;
|
||||||
|
|
||||||
if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
if ($page == 'log' && $userinfo['change_serversettings'] == '1') {
|
||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$fields = array(
|
|
||||||
'date' => $lng['logger']['date'],
|
|
||||||
'type' => $lng['logger']['type'],
|
|
||||||
'user' => $lng['logger']['user'],
|
|
||||||
'text' => $lng['logger']['action']
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
// get total count
|
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php';
|
||||||
$json_result = SysLog::getLocal($userinfo)->listingCount();
|
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\SysLog::class, $userinfo))
|
||||||
$result = json_decode($json_result, true)['data'];
|
->addParam(['sql_orderby' => ['date' => 'DESC']])
|
||||||
// initialize pagination and filtering
|
->withPagination($syslog_list_data['syslog_list']['columns']);
|
||||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
||||||
// get list
|
|
||||||
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
}
|
}
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
$sortcode = $paging->getHtmlSortCode($lng);
|
|
||||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
||||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
||||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
||||||
$clog = array();
|
|
||||||
|
|
||||||
foreach ($result['list'] as $row) {
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
|
'listing' => \Froxlor\UI\Listing::format($collection, $syslog_list_data['syslog_list']),
|
||||||
$clog[$row['action']] = array();
|
'actions_links' => [[
|
||||||
}
|
'href' => $linker->getLink(['section' => 'logger', 'page' => 'log', 'action' => 'truncate']),
|
||||||
$clog[$row['action']][$row['logid']] = $row;
|
'label' => $lng['logger']['truncate'],
|
||||||
}
|
'icon' => 'fa-solid fa-recycle',
|
||||||
|
'class' => 'btn-warning'
|
||||||
if ($paging->sortfield == 'date' && $paging->sortorder == 'desc') {
|
]]
|
||||||
krsort($clog);
|
]);
|
||||||
} else {
|
UI::twigOutputBuffer();
|
||||||
ksort($clog);
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = 0;
|
|
||||||
$log_count = 0;
|
|
||||||
$log = '';
|
|
||||||
foreach ($clog as $action => $logrows) {
|
|
||||||
$_action = 0;
|
|
||||||
foreach ($logrows as $row) {
|
|
||||||
// if ($paging->checkDisplay($i)) {
|
|
||||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
|
||||||
$row['date'] = date("d.m.y H:i:s", $row['date']);
|
|
||||||
|
|
||||||
if ($_action != $action) {
|
|
||||||
switch ($action) {
|
|
||||||
case \Froxlor\FroxlorLogger::USR_ACTION:
|
|
||||||
$_action = $lng['admin']['customer'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::RES_ACTION:
|
|
||||||
$_action = $lng['logger']['reseller'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::ADM_ACTION:
|
|
||||||
$_action = $lng['logger']['admin'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::CRON_ACTION:
|
|
||||||
$_action = $lng['logger']['cron'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::LOGIN_ACTION:
|
|
||||||
$_action = $lng['logger']['login'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::LOG_ERROR:
|
|
||||||
$_action = $lng['logger']['intern'];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$_action = $lng['logger']['unknown'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$row['action'] = $_action;
|
|
||||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";");
|
|
||||||
}
|
|
||||||
|
|
||||||
$log_count ++;
|
|
||||||
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']);
|
|
||||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
|
|
||||||
$count ++;
|
|
||||||
$_action = $action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
|
|
||||||
} elseif ($action == 'truncate') {
|
} elseif ($action == 'truncate') {
|
||||||
|
|
||||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
const AREA = 'customer';
|
const AREA = 'customer';
|
||||||
require __DIR__ . '/lib/init.php';
|
require __DIR__ . '/lib/init.php';
|
||||||
|
|
||||||
use Froxlor\Api\Commands\SysLog;
|
|
||||||
use Froxlor\Database\Database;
|
|
||||||
use Froxlor\Settings;
|
use Froxlor\Settings;
|
||||||
use Froxlor\UI\Panel\UI;
|
use Froxlor\UI\Panel\UI;
|
||||||
|
|
||||||
@@ -31,91 +29,17 @@ if (Settings::IsInList('panel.customer_hide_options', 'extras.logger')) {
|
|||||||
|
|
||||||
if ($page == 'log') {
|
if ($page == 'log') {
|
||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$fields = array(
|
|
||||||
'date' => $lng['logger']['date'],
|
|
||||||
'type' => $lng['logger']['type'],
|
|
||||||
'user' => $lng['logger']['user'],
|
|
||||||
'text' => $lng['logger']['action']
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
// get total count
|
$syslog_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/tablelisting.syslog.php';
|
||||||
$json_result = SysLog::getLocal($userinfo)->listingCount();
|
$collection = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\SysLog::class, $userinfo))
|
||||||
$result = json_decode($json_result, true)['data'];
|
->addParam(['sql_orderby' => ['date' => 'DESC']])
|
||||||
// initialize pagination and filtering
|
->withPagination($syslog_list_data['syslog_list']['columns']);
|
||||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
||||||
// get list
|
|
||||||
$json_result = SysLog::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
}
|
}
|
||||||
$result = json_decode($json_result, true)['data'];
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
$sortcode = $paging->getHtmlSortCode($lng);
|
'listing' => \Froxlor\UI\Listing::format($collection, $syslog_list_data['syslog_list'])
|
||||||
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
]);
|
||||||
$searchcode = $paging->getHtmlSearchCode($lng);
|
UI::twigOutputBuffer();
|
||||||
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
||||||
$clog = array();
|
|
||||||
|
|
||||||
foreach ($result['list'] as $row) {
|
|
||||||
|
|
||||||
if (! isset($clog[$row['action']]) || ! is_array($clog[$row['action']])) {
|
|
||||||
$clog[$row['action']] = array();
|
|
||||||
}
|
|
||||||
$clog[$row['action']][$row['logid']] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($paging->sortfield == 'date' && $paging->sortorder == 'desc') {
|
|
||||||
krsort($clog);
|
|
||||||
} else {
|
|
||||||
ksort($clog);
|
|
||||||
}
|
|
||||||
|
|
||||||
$count = 0;
|
|
||||||
$log_count = 0;
|
|
||||||
$log = '';
|
|
||||||
foreach ($clog as $action => $logrows) {
|
|
||||||
$_action = 0;
|
|
||||||
foreach ($logrows as $row) {
|
|
||||||
// if ($paging->checkDisplay($i)) {
|
|
||||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
|
||||||
$row['date'] = date("d.m.y H:i:s", $row['date']);
|
|
||||||
|
|
||||||
if ($_action != $action) {
|
|
||||||
switch ($action) {
|
|
||||||
case \Froxlor\FroxlorLogger::USR_ACTION:
|
|
||||||
$_action = $lng['admin']['customer'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::RES_ACTION:
|
|
||||||
$_action = $lng['logger']['reseller'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::ADM_ACTION:
|
|
||||||
$_action = $lng['logger']['admin'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::CRON_ACTION:
|
|
||||||
$_action = $lng['logger']['cron'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::LOGIN_ACTION:
|
|
||||||
$_action = $lng['logger']['login'];
|
|
||||||
break;
|
|
||||||
case \Froxlor\FroxlorLogger::LOG_ERROR:
|
|
||||||
$_action = $lng['logger']['intern'];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$_action = $lng['logger']['unknown'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$row['action'] = $_action;
|
|
||||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_action') . "\";");
|
|
||||||
}
|
|
||||||
|
|
||||||
$log_count ++;
|
|
||||||
$row['type'] = \Froxlor\FroxlorLogger::getInstanceOf()->getLogLevelDesc($row['type']);
|
|
||||||
eval("\$log.=\"" . \Froxlor\UI\Template::getTemplate('logger/logger_log') . "\";");
|
|
||||||
$count ++;
|
|
||||||
$_action = $action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('logger/logger') . "\";");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
lib/Froxlor/UI/Callbacks/SysLog.php
Normal file
28
lib/Froxlor/UI/Callbacks/SysLog.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Froxlor\UI\Callbacks;
|
||||||
|
|
||||||
|
use Froxlor\FroxlorLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Froxlor\UI\Callbacks
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SysLog
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function typeDescription(array $attributes): string
|
||||||
|
{
|
||||||
|
return FroxlorLogger::getInstanceOf()->getLogLevelDesc($attributes['data']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
return array(
|
return array(
|
||||||
'cronjobs_edit' => array(
|
'cronjobs_edit' => array(
|
||||||
'title' => $lng['admin']['cronjob_edit'],
|
'title' => $lng['admin']['cronjob_edit'],
|
||||||
'image' => 'icons/clock_edit.png',
|
'image' => 'fa-solid fa-clock-rotate-left',
|
||||||
'sections' => array(
|
'sections' => array(
|
||||||
'section_a' => array(
|
'section_a' => array(
|
||||||
'title' => $lng['cronjob']['cronjobsettings'],
|
'title' => $lng['cronjob']['cronjobsettings'],
|
||||||
@@ -25,31 +25,31 @@ return array(
|
|||||||
'fields' => array(
|
'fields' => array(
|
||||||
'cronfile' => array(
|
'cronfile' => array(
|
||||||
'label' => 'Cronjob',
|
'label' => 'Cronjob',
|
||||||
'type' => ($change_cronfile == 1 ? 'text' : 'label'),
|
'type' => (substr($result['module'], 0, strpos($result['module'], '/')) != 'froxlor' ? 'text' : 'label'),
|
||||||
'value' => $result['cronfile']
|
'value' => $result['cronfile']
|
||||||
),
|
),
|
||||||
'isactive' => array(
|
'isactive' => array(
|
||||||
'label' => $lng['admin']['activated'],
|
'label' => $lng['admin']['activated'],
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'values' => array(
|
'value' => '1',
|
||||||
array(
|
'checked' => $result['isactive']
|
||||||
'label' => $lng['panel']['yes'],
|
|
||||||
'value' => '1'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'value' => array(
|
|
||||||
$result['isactive']
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
'interval_value' => array(
|
'interval_value' => array(
|
||||||
'label' => $lng['cronjob']['cronjobintervalv'],
|
'label' => $lng['cronjob']['cronjobintervalv'],
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'value' => $interval_value
|
'value' => explode(' ', $result['interval'] ?? "5 MINUTE")[0] ?? ""
|
||||||
),
|
),
|
||||||
'interval_interval' => array(
|
'interval_interval' => array(
|
||||||
'label' => $lng['cronjob']['cronjobinterval'],
|
'label' => $lng['cronjob']['cronjobinterval'],
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'select_var' => $interval_interval
|
'select_var' => [
|
||||||
|
'MINUTE' => $lng['cronmgmt']['minutes'],
|
||||||
|
'HOUR' => $lng['cronmgmt']['hours'],
|
||||||
|
'DAY' => $lng['cronmgmt']['days'],
|
||||||
|
'WEEK' => $lng['cronmgmt']['weeks'],
|
||||||
|
'MONTH' => $lng['cronmgmt']['months']
|
||||||
|
],
|
||||||
|
'selected' => explode(' ', $result['interval'] ?? "5 MINUTE")[1] ?? null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
53
lib/tablelisting/tablelisting.syslog.php
Normal file
53
lib/tablelisting/tablelisting.syslog.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Tabellisting
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Froxlor\UI\Callbacks\Text;
|
||||||
|
use Froxlor\UI\Callbacks\SysLog;
|
||||||
|
use Froxlor\UI\Listing;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'syslog_list' => [
|
||||||
|
'title' => $lng['menue']['logger']['logger'],
|
||||||
|
'icon' => 'fa-solid fa-file-lines',
|
||||||
|
'columns' => [
|
||||||
|
'date' => [
|
||||||
|
'label' => $lng['logger']['date'],
|
||||||
|
'field' => 'date',
|
||||||
|
'callback' => [Text::class, 'timestamp'],
|
||||||
|
],
|
||||||
|
'type' => [
|
||||||
|
'label' => $lng['logger']['type'],
|
||||||
|
'field' => 'type',
|
||||||
|
'callback' => [SysLog::class, 'typeDescription'],
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'label' => $lng['logger']['user'],
|
||||||
|
'field' => 'user',
|
||||||
|
],
|
||||||
|
'text' => [
|
||||||
|
'label' => $lng['logger']['action'],
|
||||||
|
'field' => 'text',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'visible_columns' => Listing::getVisibleColumnsForListing('syslog_list', [
|
||||||
|
'date',
|
||||||
|
'type',
|
||||||
|
'user',
|
||||||
|
'text'
|
||||||
|
])
|
||||||
|
]
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user