From 7e14e9edd778d5cd78c3d375c7a34b47d7fcb7b3 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 13 May 2022 11:22:14 +0200 Subject: [PATCH] minor ui/lang adjustments; add security question for backup-abort action Signed-off-by: Michael Kaufmann --- customer_extras.php | 33 +++++++++++-------- customer_traffic.php | 10 +++--- lib/Froxlor/UI/HTML.php | 8 ++++- lib/navigation/00.froxlor.main.php | 4 +++ .../customer/tablelisting.domains.php | 2 +- lng/de.lng.php | 5 +-- lng/en.lng.php | 5 +-- .../Froxlor/form/yesnoquestion.html.twig | 2 +- 8 files changed, 45 insertions(+), 24 deletions(-) diff --git a/customer_extras.php b/customer_extras.php index 58fd2d71..dda10bb7 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -289,20 +289,27 @@ if ($page == 'overview' || $page == 'htpasswds') { } if (Settings::Get('system.backupenabled') == 1) { - if ($action == 'abort' && isset($_POST['send']) && $_POST['send'] == 'send') { - $log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); - try { - CustomerBackups::getLocal($userinfo, $_POST)->delete(); - } catch (Exception $e) { - Response::dynamicError($e->getMessage()); + if ($action == 'abort') { + if (isset($_POST['send']) && $_POST['send'] == 'send') { + $log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "customer_extras::backup - aborted scheduled backupjob"); + try { + CustomerBackups::getLocal($userinfo, $_POST)->delete(); + } catch (Exception $e) { + Response::dynamicError($e->getMessage()); + } + Response::redirectTo($filename, [ + 'page' => $page, + 'action' => '' + ]); + } else { + HTML::askYesNo('extras_reallydelete_backup', $filename, [ + 'backup_job_entry' => $id, + 'section' => 'extras', + 'page' => $page, + 'action' => $action + ]); } - Response::standardSuccess('backupaborted'); - Response::redirectTo($filename, [ - 'page' => $page, - 'action' => '' - ]); - } - if ($action == '') { + } elseif ($action == '') { $log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::backup"); // check whether there is a backup-job for this customer diff --git a/customer_traffic.php b/customer_traffic.php index 67f08ba7..a5c01d34 100644 --- a/customer_traffic.php +++ b/customer_traffic.php @@ -106,16 +106,18 @@ if (!is_null($month) && !is_null($year)) { 'mail_data' => $traf['mail_data'], ]); } else { + // default to the last 36 months + $from_date = (new DateTime)->modify("last day of last months")->setTime(23, 59, 59)->sub(new \DateInterval('P3Y'))->format('U'); $result_stmt = Database::prepare(" SELECT `month`, `year`, SUM(`http`) AS http, SUM(`ftp_up`) AS ftp_up, SUM(`ftp_down`) AS ftp_down, SUM(`mail`) AS mail FROM `" . TABLE_PANEL_TRAFFIC . "` - WHERE `customerid` = :customerid + WHERE `customerid` = :customerid AND `stamp` = :fromdate GROUP BY `year`, `month` - ORDER BY `year` DESC, `month` DESC - LIMIT 12 + ORDER BY `year` ASC, `month` ASC "); Database::pexecute($result_stmt, [ - "customerid" => $userinfo['customerid'] + "customerid" => $userinfo['customerid'], + "fromdate" => $from_date ]); $traffic_complete['http'] = 0; $traffic_complete['ftp'] = 0; diff --git a/lib/Froxlor/UI/HTML.php b/lib/Froxlor/UI/HTML.php index 6c6ae243..37f49956 100644 --- a/lib/Froxlor/UI/HTML.php +++ b/lib/Froxlor/UI/HTML.php @@ -53,6 +53,9 @@ class HTML if ((!isset($box['show_element']) || $box['show_element'] === true) && (!isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int)$userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) { $navigation_links = []; $box_active = false; + if (isset($box['url']) && $box['url'] == basename($_SERVER["SCRIPT_FILENAME"])) { + $box_active = true; + } foreach ($box['elements'] as $element) { if ((!isset($element['show_element']) || $element['show_element'] === true) && (!isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int)$userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) { $target = ''; @@ -63,7 +66,10 @@ class HTML $target = ' target="_blank"'; } - if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0) { + if ( + ((empty($_GET['page']) && substr_count($element['url'], "page=") == 0) || (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0)) + && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 + ) { $active = true; $box_active = true; } diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index 3521eeaa..49f4ea86 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -143,6 +143,10 @@ return [ [ 'url' => 'customer_traffic.php?page=current', 'label' => lng('menue.traffic.current') + ], + [ + 'url' => 'customer_traffic.php', + 'label' => lng('menue.traffic.overview') ] ] ] diff --git a/lib/tablelisting/customer/tablelisting.domains.php b/lib/tablelisting/customer/tablelisting.domains.php index 83efd417..7f701812 100644 --- a/lib/tablelisting/customer/tablelisting.domains.php +++ b/lib/tablelisting/customer/tablelisting.domains.php @@ -111,7 +111,7 @@ return [ 'visible' => [Domain::class, 'canEditAlias'] ], 'isassigned' => [ - 'icon' => 'fa-check-to-slot', + 'icon' => 'fa fa-check-to-slot', 'title' => lng('domains.isassigneddomain'), 'visible' => [Domain::class, 'isAssigned'] ], diff --git a/lng/de.lng.php b/lng/de.lng.php index f99fc7e8..12b5b59d 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -1035,7 +1035,7 @@ Vielen Dank, Ihr Administrator', ], 'domains' => [ 'domains' => 'Domains', - 'settings' => 'Einstellungen', + 'settings' => 'Übersicht Domains', ], 'ftp' => [ 'ftp' => 'FTP', @@ -1051,7 +1051,7 @@ Vielen Dank, Ihr Administrator', 'traffic' => [ 'traffic' => 'Traffic', 'current' => 'Aktueller Monat', - 'table' => 'Übersicht', + 'overview' => 'Übersicht', ], 'phpsettings' => [ 'maintitle' => 'PHP-Konfigurationen', @@ -1198,6 +1198,7 @@ Vielen Dank, Ihr Administrator', 'email_reallydelete_forwarder' => 'Wollen Sie die Weiterleitung "%s" wirklich löschen?', 'extras_reallydelete' => 'Wollen Sie den Verzeichnisschutz für "%s" wirklich löschen?', 'extras_reallydelete_pathoptions' => 'Wollen Sie die Optionen für den Pfad "%s" wirklich löschen?', + 'extras_reallydelete_backup' => 'Wollen Sie die geplante Sicherung wirklich löschen?', 'ftp_reallydelete' => 'Wollen Sie das FTP-Benutzerkonto "%s" wirklich löschen?', 'mysql_reallydelete' => 'Wollen Sie die Datenbank "%s" wirklich löschen?
ACHTUNG! Alle Daten gehen unwiderruflich verloren!', 'admin_configs_reallyrebuild' => 'Wollen Sie wirklich alle Konfigurationsdateien neu erstellen lassen?', diff --git a/lng/en.lng.php b/lng/en.lng.php index 3fd3e136..98c513de 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -1332,7 +1332,7 @@ Yours sincerely, your administrator', ], 'domains' => [ 'domains' => 'Domains', - 'settings' => 'Settings', + 'settings' => 'Domains overview', ], 'ftp' => [ 'ftp' => 'FTP', @@ -1348,7 +1348,7 @@ Yours sincerely, your administrator', 'traffic' => [ 'traffic' => 'Traffic', 'current' => 'Current Month', - 'table' => 'Traffic', + 'overview' => 'Total traffic', ], 'phpsettings' => [ 'maintitle' => 'PHP Configurations', @@ -1543,6 +1543,7 @@ Yours sincerely, your administrator', 'email_reallydelete_forwarder' => 'Do you really want to delete the forwarder %s?', 'extras_reallydelete' => 'Do you really want to delete the directory protection for %s?', 'extras_reallydelete_pathoptions' => 'Do you really want to delete the path options for %s?', + 'extras_reallydelete_backup' => 'Do you really want to abort the planned backup job?', 'ftp_reallydelete' => 'Do you really want to delete the FTP-account %s?', 'mysql_reallydelete' => 'Do you really want to delete the database %s? This cannot be undone!', 'admin_configs_reallyrebuild' => 'Do you really want to rebuild all config files?', diff --git a/templates/Froxlor/form/yesnoquestion.html.twig b/templates/Froxlor/form/yesnoquestion.html.twig index 73dfec30..326f3735 100644 --- a/templates/Froxlor/form/yesnoquestion.html.twig +++ b/templates/Froxlor/form/yesnoquestion.html.twig @@ -23,7 +23,7 @@ {% endfor %}   - {% if back_link is defined and back_link is iterable %} + {% if back_link is defined and back_link is iterable and back_link|length > 0 %} {{ lng('panel.no') }} {% else %} {{ lng('panel.no') }}