customer-extras overviews

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-02-25 17:17:29 +01:00
parent 01798650fe
commit 8c6452bb05
11 changed files with 211 additions and 88 deletions

View File

@@ -50,36 +50,18 @@ if ($page == 'overview') {
'path' => $lng['panel']['path']
);
try {
// get total count
$json_result = DirProtections::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = DirProtections::getLocal($userinfo, $paging->getApiCommandParams())->listing();
$htpasswd_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htpasswd.php';
$list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\DirProtections::class, $userinfo))
->withPagination($htpasswd_list_data['htpasswd_list']['columns'])
->getList();
} catch (Exception $e) {
\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);
$count = 0;
$htpasswds = '';
foreach ($result['list'] as $row) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
}
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$htpasswds.=\"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds_htpasswd") . "\";");
$count ++;
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htpasswds") . "\";");
UI::twigBuffer('user/table.html.twig', [
'listing' => \Froxlor\UI\Listing::format($list, $htpasswd_list_data['htpasswd_list']),
]);
UI::twigOutputBuffer();
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = DirProtections::getLocal($userinfo, array(
@@ -181,51 +163,22 @@ if ($page == 'overview') {
if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras::htaccess");
$fields = array(
'path' => $lng['panel']['path'],
'options_indexes' => $lng['extras']['view_directory'],
'error404path' => $lng['extras']['error404path'],
'error403path' => $lng['extras']['error403path'],
'error500path' => $lng['extras']['error500path'],
'options_cgi' => $lng['extras']['execute_perl']
);
try {
// get total count
$json_result = DirOptions::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
// get list
$json_result = DirOptions::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\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);
$count = 0;
$htaccess = '';
$cperlenabled = \Froxlor\Customer\Customer::customerHasPerlEnabled($userinfo['customerid']);
foreach ($result['list'] as $row) {
if (strpos($row['path'], $userinfo['documentroot']) === 0) {
$row['path'] = str_replace($userinfo['documentroot'], "/", $row['path']);
}
$row['path'] = \Froxlor\FileDir::makeCorrectDir($row['path']);
$row['options_indexes'] = str_replace('1', $lng['panel']['yes'], $row['options_indexes']);
$row['options_indexes'] = str_replace('0', $lng['panel']['no'], $row['options_indexes']);
$row['options_cgi'] = str_replace('1', $lng['panel']['yes'], $row['options_cgi']);
$row['options_cgi'] = str_replace('0', $lng['panel']['no'], $row['options_cgi']);
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
eval("\$htaccess.=\"" . \Froxlor\UI\Template::getTemplate("extras/htaccess_htaccess") . "\";");
$count ++;
try {
$htaccess_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.htaccess.php';
$list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\DirOptions::class, $userinfo))
->withPagination($htaccess_list_data['htaccess_list']['columns'])
->getList();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/htaccess") . "\";");
UI::twigBuffer('user/table.html.twig', [
'listing' => \Froxlor\UI\Listing::format($list, $htaccess_list_data['htaccess_list']),
]);
UI::twigOutputBuffer();
} elseif ($action == 'delete' && $id != 0) {
try {
$json_result = DirOptions::getLocal($userinfo, array(
@@ -371,18 +324,19 @@ if ($page == 'overview') {
$row['backup_web'] = ($row['backup_web'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_mail'] = ($row['backup_mail'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
$row['backup_dbs'] = ($row['backup_dbs'] == '1') ? $lng['panel']['yes'] : $lng['panel']['no'];
}
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
$backup_form = \Froxlor\UI\HtmlForm::genHTMLForm($backup_data);
$title = $backup_data['backup']['title'];
$image = $backup_data['backup']['image'];
if (! empty($existing_backupJob)) {
// overwrite backup_form after we took everything from it we needed
eval("\$backup_form = \"" . \Froxlor\UI\Template::getTemplate("extras/backup_listexisting") . "\";");
}
eval("echo \"" . \Froxlor\UI\Template::getTemplate("extras/backup") . "\";");
$pathSelect = \Froxlor\FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']);
$backup_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.backup.php';
UI::twigBuffer('user/form.html.twig', [
'formaction' => $linker->getLink(array('section' => 'extras')),
'formdata' => $backup_data['backup']
]);
UI::twigOutputBuffer();
}
}
} else {

View File

@@ -17,7 +17,7 @@
return array(
'backup' => array(
'title' => $lng['extras']['backup'],
'image' => 'icons/backup_big.png',
'image' => 'fa-solid fa-server',
'sections' => array(
'section_a' => array(
'title' => $lng['extras']['backup'],
@@ -33,8 +33,9 @@ return array(
),
'path_protection_info' => array(
'label' => $lng['extras']['path_protection_label'],
'type' => 'label',
'value' => $lng['extras']['path_protection_info']
'type' => 'infotext',
'value' => $lng['extras']['path_protection_info'],
'classes' => 'fw-bold text-danger'
),
'backup_web' => array(
'label' => $lng['extras']['backup_web'],

View File

@@ -17,7 +17,7 @@
return array(
'htaccess_add' => array(
'title' => $lng['extras']['pathoptions_add'],
'image' => 'icons/htpasswd_add.png',
'image' => 'fa-solid fa-folder',
'sections' => array(
'section_a' => array(
'title' => $lng['extras']['pathoptions_add'],

View File

@@ -17,7 +17,7 @@
return array(
'htaccess_edit' => array(
'title' => $lng['extras']['pathoptions_edit'],
'image' => 'icons/htpasswd_edit.png',
'image' => 'fa-solid fa-folder',
'sections' => array(
'section_a' => array(
'title' => $lng['extras']['pathoptions_edit'],

View File

@@ -17,7 +17,7 @@
return array(
'htpasswd_add' => array(
'title' => $lng['extras']['directoryprotection_add'],
'image' => 'icons/htpasswd_add.png',
'image' => 'fa-solid fa-lock',
'sections' => array(
'section_a' => array(
'title' => $lng['extras']['directoryprotection_add'],

View File

@@ -17,7 +17,7 @@
return array(
'htpasswd_edit' => array(
'title' => $lng['extras']['directoryprotection_edit'],
'image' => 'icons/htpasswd_edit.png',
'image' => 'fa-solid fa-lock',
'sections' => array(
'section_a' => array(
'title' => $lng['extras']['directoryprotection_edit'],

View File

@@ -0,0 +1,87 @@
<?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-)
* @author Maurice Preuß <hello@envoyr.com>
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Tabellisting
*
*/
use Froxlor\UI\Callbacks\Ftp;
use Froxlor\UI\Callbacks\Text;
use Froxlor\UI\Listing;
return [
'htaccess_list' => [
'title' => $lng['menue']['extras']['pathoptions'],
'icon' => 'fa-solid fa-folder',
'columns' => [
'path' => [
'label' => $lng['panel']['path'],
'column' => 'path',
'format_callback' => [Ftp::class, 'pathRelative']
],
'option_indexes' => [
'label' => $lng['extras']['view_directory'],
'column' => 'option_indexes',
'format_callback' => [Text::class, 'boolean']
],
'error404path' => [
'label' => $lng['extras']['error404path'],
'column' => 'error404path'
],
'error403path' => [
'label' => $lng['extras']['error403path'],
'column' => 'error403path'
],
'error500path' => [
'label' => $lng['extras']['error500path'],
'column' => 'error500path'
],
'options_cgi' => [
'label' => $lng['extras']['execute_perl'],
'column' => 'options_cgi',
'format_callback' => [Text::class, 'boolean'],
'visible' => $cperlenabled
]
],
'visible_columns' => Listing::getVisibleColumnsForListing('htaccess_list', [
'path',
'option_indexes',
'error404path',
'error403path',
'error500path',
'options_cgi'
]),
'actions' => [
'edit' => [
'icon' => 'fa fa-edit',
'href' => [
'section' => 'extras',
'page' => 'htaccess',
'action' => 'edit',
'id' => ':id'
],
],
'delete' => [
'icon' => 'fa fa-trash',
'class' => 'text-danger',
'href' => [
'section' => 'extras',
'page' => 'htaccess',
'action' => 'delete',
'id' => ':id'
],
]
]
]
];

View File

@@ -0,0 +1,63 @@
<?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-)
* @author Maurice Preuß <hello@envoyr.com>
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Tabellisting
*
*/
use Froxlor\UI\Callbacks\Ftp;
use Froxlor\UI\Listing;
return [
'htpasswd_list' => [
'title' => $lng['menue']['extras']['directoryprotection'],
'icon' => 'fa-solid fa-lock',
'columns' => [
'username' => [
'label' => $lng['login']['username'],
'column' => 'username'
],
'path' => [
'label' => $lng['panel']['path'],
'column' => 'path',
'format_callback' => [Ftp::class, 'pathRelative']
]
],
'visible_columns' => Listing::getVisibleColumnsForListing('htpasswd_list', [
'username',
'path'
]),
'actions' => [
'edit' => [
'icon' => 'fa fa-edit',
'href' => [
'section' => 'extras',
'page' => 'htpasswds',
'action' => 'edit',
'id' => ':id'
],
],
'delete' => [
'icon' => 'fa fa-trash',
'class' => 'text-danger',
'href' => [
'section' => 'extras',
'page' => 'htpasswds',
'action' => 'delete',
'id' => ':id'
],
]
]
]
];

View File

@@ -1893,8 +1893,8 @@ $lng['crondesc']['cron_backup'] = 'Process backup jobs';
$lng['error']['backupfunctionnotenabled'] = 'The backup function is not enabled';
$lng['serversettings']['backupenabled']['title'] = "Enable backup for customers";
$lng['serversettings']['backupenabled']['description'] = "If activated, the customer will be able to schedule backup jobs (cron-backup) which generates an archive within his docroot (subdirectory chosable by customer)";
$lng['extras']['path_protection_label'] = '<strong class="red">Important</strong>';
$lng['extras']['path_protection_info'] = '<strong class="red">We strongly recommend protecting the given path, see "Extras" -> "Directory protection"</strong>';
$lng['extras']['path_protection_label'] = '<strong class="text-danger">Important</strong>';
$lng['extras']['path_protection_info'] = 'We strongly recommend protecting the given path, see "Extras" -> "Directory protection"';
$lng['tasks']['CREATE_CUSTOMER_BACKUP'] = 'Backup job for customer %loginname%';
$lng['error']['dns_domain_nodns'] = 'DNS is not enabled for this domain';

View File

@@ -1543,8 +1543,8 @@ $lng['crondesc']['cron_backup'] = 'Ausstehende Sicherungen erstellen';
$lng['error']['backupfunctionnotenabled'] = 'Die Sicherungs-Funktion is nicht aktiviert';
$lng['serversettings']['backupenabled']['title'] = "Backup für Kunden aktivieren";
$lng['serversettings']['backupenabled']['description'] = "Wenn dies aktiviert ist, kann der Kunde Sicherungen planen (cron-backup) welche ein Archiv in sein Heimatverzeichnis ablegt (Unterordner vom Kunden wählbar)";
$lng['extras']['path_protection_label'] = '<strong class="red">Wichtig</strong>';
$lng['extras']['path_protection_info'] = '<strong class="red">Wir raten dringend dazu den angegebenen Pfad zu schützen, siehe "Extras" -> "Verzeichnisschutz"</strong>';
$lng['extras']['path_protection_label'] = '<strong class="text-danger">Wichtig</strong>';
$lng['extras']['path_protection_info'] = 'Wir raten dringend dazu den angegebenen Pfad zu schützen, siehe "Extras" -> "Verzeichnisschutz"';
$lng['tasks']['CREATE_CUSTOMER_BACKUP'] = 'Datensicherung für Kunde %loginname%';
$lng['error']['dns_domain_nodns'] = 'DNS ist für diese Domain nicht aktiviert';

View File

@@ -6,7 +6,7 @@
{% if field.desc is defined and field.desc is not empty %}<br><small>{{ field.desc|raw }}</small>
{% endif %}
</label>
<div class="col-sm-8">
<div class="col-sm-8{% if field.type == 'infotext' %} d-flex align-items-center{% endif %}">
{% endif %}
{% if field.type == 'text' or field.type == 'password' or field.type == 'number' or field.type == 'file' or field.type == 'email' or field.type == 'hidden' %}
{{ _self.input(id, field) }}
@@ -24,6 +24,8 @@
{{ _self.link(id, field) }}
{% elseif field.type == 'itemlist' %}
{{ _self.itemlist(id, field) }}
{% elseif field.type == 'infotext' %}
{{ _self.infotext(id, field) }}
{% endif %}
{% if norow == false and field.type != 'hidden' %}
</div>
@@ -49,6 +51,22 @@
{% endif %}
{% endmacro %}
{% macro infotext(id, field) %}
{% if field.next_to is defined %}
<div class="input-group">
{% endif %}
<span {% if field.classes is defined %} class="{{ field.classes }}" {% endif %}>{{ field.value }}</span>
{% if field.next_to is defined %}
{% for nid, nfield in field.next_to %}
{% if nfield.next_to_prefix is defined %}
<span class="input-group-text">{{ nfield.next_to_prefix }}</span>
{% endif %}
{{ _self.fieldrow(nid, nfield, true) }}
{% endfor %}
</div>
{% endif %}
{% endmacro %}
{% macro plain(id, field) %}
{% if field.next_to is defined %}
<div class="input-group">