update templates introduce request helper

This commit is contained in:
envoyr
2022-02-20 18:00:44 +01:00
parent e0540ceb7c
commit e057314795
41 changed files with 41521 additions and 275 deletions

View File

@@ -16,101 +16,42 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'admins' && $userinfo['change_serversettings'] == '1') {
if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_admins");
$fields = array(
'loginname' => $lng['login']['username'],
'name' => $lng['customer']['name'],
'diskspace' => $lng['customer']['diskspace'],
'diskspace_used' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
'traffic' => $lng['customer']['traffic'],
'traffic_used' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')',
'deactivated' => $lng['admin']['deactivated']
);
try {
$admin_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/admin/tablelisting.admin.php';
try {
// get total count
$json_result = Admins::getLocal($userinfo)->listingCount();
$result = json_decode($json_result, true)['data'];
// initialize pagination and filtering
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
$paging = new \Froxlor\UI\Pagination($userinfo, $admin_list_data['admin_list']['columns'], $result);
// get list
$json_result = Admins::getLocal($userinfo, $paging->getApiCommandParams())->listing();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
$admins = '';
$sortcode = $paging->getHtmlSortCode($lng, true);
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
$searchcode = $paging->getHtmlSearchCode($lng);
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
$count = 0;
$dec_places = Settings::Get('panel.decimal_places');
foreach ($result['list'] as $row) {
$row['traffic_used'] = round($row['traffic_used'] / (1024 * 1024), $dec_places);
$row['traffic'] = round($row['traffic'] / (1024 * 1024), $dec_places);
$row['diskspace_used'] = round($row['diskspace_used'] / 1024, $dec_places);
$row['diskspace'] = round($row['diskspace'] / 1024, $dec_places);
// percent-values for progressbar
// For Disk usage
if ($row['diskspace'] > 0) {
$disk_percent = round(($row['diskspace_used'] * 100) / $row['diskspace'], 0);
$disk_doublepercent = round($disk_percent * 2, 2);
} else {
$disk_percent = 0;
$disk_doublepercent = 0;
}
// For Traffic usage
if ($row['traffic'] > 0) {
$traffic_percent = round(($row['traffic_used'] * 100) / $row['traffic'], 0);
$traffic_doublepercent = round($traffic_percent * 2, 2);
} else {
$traffic_percent = 0;
$traffic_doublepercent = 0;
}
// fix progress-bars if value is >100%
if ($disk_percent > 100) {
$disk_percent = 100;
}
if ($traffic_percent > 100) {
$traffic_percent = 100;
}
$row = \Froxlor\PhpHelper::strReplaceArray('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains');
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$admins.=\"" . \Froxlor\UI\Template::getTemplate("admins/admins_admin") . "\";");
$count++;
}
$admincount = $result['count'] . " / " . $paging->getEntries();
eval("echo \"" . \Froxlor\UI\Template::getTemplate("admins/admins") . "\";");
} elseif ($action == 'su') {
UI::twigBuffer('user/table.html.twig', [
'api_response' => json_decode($json_result, true)['data'],
'table_options' => $admin_list_data['admin_list'],
]);
UI::twigOutputBuffer();
} elseif ($action == 'su') {
try {
$json_result = Admins::getLocal($userinfo, array(

View File

@@ -25,8 +25,9 @@
* Implemented into Froxlor: Janos Muzsi <muzsij@hypernics.hu>
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
$horizontal_bar_size = 950; // 1280px window width

View File

@@ -17,8 +17,9 @@
* @since 0.9.35
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Http\HttpClient;

View File

@@ -15,8 +15,9 @@
*
* @since 0.9.34
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Settings;

View File

@@ -14,16 +14,14 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Cronjobs;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'cronjobs' || $page == 'overview') {
if ($action == '') {

View File

@@ -16,25 +16,20 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'customers' && $userinfo['customers'] != '0') {
if ($action == '') {
// clear request data
unset($_SESSION['requestData']);
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
$fields = array(

View File

@@ -16,19 +16,17 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Customers as Customers;
use Froxlor\Api\Commands\Domains as Domains;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'domains' || $page == 'overview') {
// Let's see how many customers we have

View File

@@ -16,14 +16,18 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Froxlor as Froxlor;
use Froxlor\Api\Commands\Admins as Admins;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
$id = (int) Request::get('id');
if ($action == 'logout') {
@@ -49,12 +53,6 @@ if ($action == 'logout') {
\Froxlor\UI\Response::redirectTo('index.php');
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_index");

View File

@@ -16,18 +16,16 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Settings;
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\IpsAndPorts;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'ipsandports' || $page == 'overview') {
// Do not display attributes that are not used by the current webserver

View File

@@ -16,8 +16,9 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog;

View File

@@ -16,16 +16,14 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'message') {
if ($action == '') {

View File

@@ -17,8 +17,9 @@
* Based on https://github.com/amnuts/opcache-gui
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
if ($action == 'reset' && function_exists('opcache_reset') && $userinfo['change_serversettings'] == '1') {
opcache_reset();

View File

@@ -16,18 +16,16 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Api\Commands\PhpSettings as PhpSettings;
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\FpmDaemons as FpmDaemons;
use Froxlor\Api\Commands\PhpSettings as PhpSettings;
use Froxlor\Database\Database;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'overview') {

View File

@@ -14,18 +14,16 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\HostingPlans;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == '' || $page == 'overview') {

View File

@@ -20,8 +20,8 @@ use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Froxlor;
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
// get sql-root access data
Database::needRoot(true);

View File

@@ -16,25 +16,17 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Request;
if (isset($_POST['subjectid'])) {
$subjectid = intval($_POST['subjectid']);
$mailbodyid = intval($_POST['mailbodyid']);
} elseif (isset($_GET['subjectid'])) {
$subjectid = intval($_GET['subjectid']);
$mailbodyid = intval($_GET['mailbodyid']);
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
$subjectid = intval(Request::get('subjectid'));
$mailbodyid = intval(Request::get('mailbodyid'));
$available_templates = array(
'createcustomer',

View File

@@ -15,17 +15,15 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Request;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
$months = array(
'0' => 'empty',

View File

@@ -14,8 +14,9 @@
* @package Panel
*
*/
define('AREA', 'admin');
require './lib/init.php';
const AREA = 'admin';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;

View File

@@ -21,13 +21,14 @@ if (! defined('AREA')) {
*/
use Froxlor\Database\Database;
use Froxlor\UI\Request;
// This file is being included in admin_index and customer_index
// and therefore does not need to require lib/init.php
$del_stmt = Database::prepare("DELETE FROM `" . TABLE_API_KEYS . "` WHERE id = :id");
$success_message = "";
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$id = (int) Request::get('id');
$area = AREA;
// do the delete and then just show a success-message and the apikeys list again

View File

@@ -16,24 +16,21 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Certificates as Certificates;
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Api\Commands\Certificates as Certificates;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'domains')) {
\Froxlor\UI\Response::redirectTo('customer_index.php');
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains");

View File

@@ -16,26 +16,23 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Emails as Emails;
use Froxlor\Api\Commands\EmailAccounts as EmailAccounts;
use Froxlor\Api\Commands\EmailForwarders as EmailForwarders;
use Froxlor\Api\Commands\Emails as Emails;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'email')) {
\Froxlor\UI\Response::redirectTo('customer_index.php');
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email");
@@ -213,10 +210,10 @@ if ($page == 'overview') {
if (Settings::Get('catchall.catchall_enabled') != '1') {
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
}
UI::TwigBuffer('user/form.html.twig', [
UI::twigBuffer('user/form.html.twig', [
'formdata' => $email_add_data['emails_add']
]);
UI::TwigOutputBuffer();
UI::twigOutputBuffer();
}
} else {
\Froxlor\UI\Response::standard_error('allresourcesused');
@@ -262,10 +259,10 @@ if ($page == 'overview') {
unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']);
}
UI::TwigBuffer('user/form.html.twig', [
UI::twigBuffer('user/form.html.twig', [
'formdata' => $email_edit_data['emails_edit']
]);
UI::TwigOutputBuffer();
UI::twigOutputBuffer();
}
} elseif ($action == 'togglecatchall' && $id != 0) {
try {
@@ -330,10 +327,10 @@ if ($page == 'overview') {
$account_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addaccount.php';
UI::TwigBuffer('user/form.html.twig', [
UI::twigBuffer('user/form.html.twig', [
'formdata' => $account_add_data['emails_addaccount']
]);
UI::TwigOutputBuffer();
UI::twigOutputBuffer();
}
} else {
\Froxlor\UI\Response::standard_error(array(
@@ -476,10 +473,10 @@ if ($page == 'overview') {
$forwarder_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addforwarder.php';
UI::TwigBuffer('user/form.html.twig', [
UI::twigBuffer('user/form.html.twig', [
'formdata' => $forwarder_add_data['emails_addforwarder']
]);
UI::TwigOutputBuffer();
UI::twigOutputBuffer();
}
}
} else {

View File

@@ -16,24 +16,21 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Settings;
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
use Froxlor\Api\Commands\DirOptions as DirOptions;
use Froxlor\Api\Commands\DirProtections as DirProtections;
use Froxlor\Api\Commands\CustomerBackups as CustomerBackups;
use Froxlor\Settings;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'extras')) {
\Froxlor\UI\Response::redirectTo('customer_index.php');
}
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_extras");

View File

@@ -16,24 +16,20 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Ftps as Ftps;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Ftps as Ftps;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'ftp')) {
\Froxlor\UI\Response::redirectTo('customer_index.php');
}
$id = 0;
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id', 0);
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp");

View File

@@ -16,8 +16,8 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;

View File

@@ -16,8 +16,8 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\SysLog;
use Froxlor\Database\Database;

View File

@@ -16,12 +16,13 @@
* @package Panel
*
*/
define('AREA', 'customer');
require './lib/init.php';
const AREA = 'customer';
require __DIR__ . '/lib/init.php';
use Froxlor\Api\Commands\Mysqls as Mysqls;
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\Api\Commands\Mysqls as Mysqls;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'mysql')) {
@@ -34,11 +35,7 @@ Database::needSqlData();
$sql_root = Database::getSqlData();
Database::needRoot(false);
if (isset($_POST['id'])) {
$id = intval($_POST['id']);
} elseif (isset($_GET['id'])) {
$id = intval($_GET['id']);
}
$id = (int) Request::get('id');
if ($page == 'overview') {
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql");

View File

@@ -16,12 +16,13 @@
* @package Panel
*
*/
define('AREA', 'customer');
const AREA = 'customer';
$intrafficpage = 1;
require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use Froxlor\UI\Request;
// redirect if this customer page is hidden via settings
if (Settings::IsInList('panel.customer_hide_options', 'traffic')) {
@@ -32,14 +33,10 @@ $traffic = '';
$month = null;
$year = null;
if (isset($_POST['month']) && isset($_POST['year'])) {
$month = intval($_POST['month']);
$year = intval($_POST['year']);
} elseif (isset($_GET['month']) && isset($_GET['year'])) {
$month = intval($_GET['month']);
$year = intval($_GET['year']);
} // BAM! $_GET???
elseif (isset($_GET['page']) && $_GET['page'] == 'current') {
if (Request::exist('month') && Request::exist('year')) {
$month = (int) Request::get('month');
$year = (int) Request::get('year');
} elseif (isset($_GET['page']) && $_GET['page'] == 'current') {
if (date('d') != '01') {
$month = date('m');
$year = date('Y');

View File

@@ -20,11 +20,12 @@ if (! defined('AREA')) {
*/
use Froxlor\Api\Commands\DomainZones as DomainZones;
use Froxlor\UI\Request;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
$domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
$domain_id = (int) Request::get(['domain_id']);
$record = isset($_POST['record']['record']) ? trim($_POST['record']['record']) : null;
$type = isset($_POST['record']['type']) ? $_POST['record']['type'] : 'A';

View File

@@ -17,7 +17,7 @@
*
*/
define('AREA', 'login');
require './lib/init.php';
require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database;
use Froxlor\Settings;

View File

@@ -0,0 +1,43 @@
<?php
namespace Froxlor\UI;
/**
* 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 API
*
*/
class Request
{
/**
* Get key from current request.
*
* @param $key
* @param string|null $default
* @return mixed|string|null
*/
public static function get($key, string $default = null)
{
return $_GET[$key] ?? $_POST[$key] ?? $default;
}
/**
* Check if key is existing in current request.
*
* @param $key
* @return bool|mixed
*/
public static function exist($key)
{
return (bool) $_GET[$key] ?? $_POST[$key] ?? false;
}
}

View File

@@ -52,10 +52,11 @@ if (!file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
require dirname(__DIR__) . '/vendor/autoload.php';
use Froxlor\Database\Database;
use Froxlor\Settings;
use voku\helper\AntiXSS;
use Froxlor\PhpHelper;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use voku\helper\AntiXSS;
// include MySQL-tabledefinitions
require \Froxlor\Froxlor::getInstallDir() . '/lib/tables.inc.php';
@@ -476,28 +477,12 @@ if (!empty($panel_privacy_url) && strtolower(substr($panel_privacy_url, 0, 4)) !
}
*/
if (isset($_POST['action'])) {
$action = trim(strip_tags($_POST['action']));
} elseif (isset($_GET['action'])) {
$action = trim(strip_tags($_GET['action']));
} else {
$action = '';
// clear request data
if (isset($_SESSION)) {
unset($_SESSION['requestData']);
}
}
$action = Request::get('action');
$page = Request::get('page', 'overview');
if (isset($_POST['page'])) {
$page = trim(strip_tags($_POST['page']));
} elseif (isset($_GET['page'])) {
$page = trim(strip_tags($_GET['page']));
} else {
$page = '';
}
if ($page == '') {
$page = 'overview';
// clear request data
if (!$action && isset($_SESSION)) {
unset($_SESSION['requestData']);
}
UI::twig()->addGlobal('action', $action);

View File

@@ -0,0 +1,77 @@
<?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
*
*/
return [
'admin_list' => [
'title' => $lng['admin']['admin'],
'icon' => 'fa-solid fa-user-plus',
'columns' => [
'adminid' => [
'title' => '#',
'sortable' => true,
],
'loginname' => [
'title' => $lng['login']['username'],
'sortable' => true,
],
'name' => [
'title' => $lng['customer']['name'],
],
'diskspace' => [
'title' => $lng['customer']['diskspace'],
],
'diskspace_used' => [
'title' => $lng['customer']['diskspace'] . ' (' . $lng['panel']['used'] . ')',
],
'traffic' => [
'title' => $lng['customer']['traffic']
],
'traffic_used' => [
'title' => $lng['customer']['traffic'] . ' (' . $lng['panel']['used'] . ')'
],
'deactivated' => [
'title' => $lng['admin']['deactivated']
],
],
'visible_columns' => getVisibleColumnsForListing('admin_list', [
'loginname',
'name',
'diskspace',
]),
'actions' => [
'delete' => [
'icon' => 'fa fa-trash',
'href' => '#',
],
'show' => [
'title' => 'Show',
'href' => '#',
]
]
]
];
// Das müsste dann irgendwie als Klasse ausgelagert werden
function getVisibleColumnsForListing($listing, $default_columns)
{
// Hier käme dann die Logik, die das aus der DB zieht ...
// alternativ nimmt er die $default_columns, wenn kein Eintrag
// in der DB definiert ist
return $default_columns;
}

View File

@@ -19,15 +19,17 @@ if (! defined('AREA')) {
*
*/
use Froxlor\Settings;
use Froxlor\Api\Commands\SubDomains as SubDomains;
use Froxlor\Settings;
use Froxlor\UI\Request;
// This file is being included in admin_domains and customer_domains
// and therefore does not need to require lib/init.php
// TODO get domain related settings for logfile (speciallogfile)
$domain_id = isset($_GET['domain_id']) ? (int) $_GET['domain_id'] : null;
$last_n = isset($_GET['number_of_lines']) ? (int) $_GET['number_of_lines'] : 100;
$domain_id = (int) Request::get('domain_id');
$last_n = (int) Request::get('number_of_lines', 100);
// user's with logviewenabled = false
if (AREA != 'admin' && $userinfo['logviewenabled'] != '1') {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
/*!
* Bootstrap v5.1.3 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2021-02-16
*/
/*!
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2021-03-02T17:08Z
*/

View File

@@ -0,0 +1,52 @@
{% macro table(table_options, api_response, action, title = "") %}
<form action="{{ action|default("") }}" method="post" enctype="application/x-www-form-urlencoded" class="form">
{% if title is not empty %}
<h3 class="page-header">
{% if table_options.icon is not empty %}
<i class="{{ table_options.icon }}"></i>
{% endif %}
{{ title }}
</h3>
{% endif %}
<div class="card">
<table class="table table-borderless table-striped mb-0">
<thead>
<tr>
{% for column in table_options.visible_columns %}
<th class="p-3">{{ table_options.columns[column].title }}</th>
{% endfor %}
{% if table_options.actions %}
<th class="p-3 text-end">Actions</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for item in api_response.list %}
<tr>
{% for column in table_options.visible_columns %}
<td class="p-3">{{ item[column] }}</td>
{% endfor %}
{% if table_options.actions %}
<th class="p-3 text-end">
{% for action in table_options.actions %}
{% if action.href is not empty %}
<a href="{{ action.href }}">{% if action.icon is not empty %}<i class="{{ action.icon }}"></i>{% endif %}{{ action.title }}</a>
{% else %}
{% if action.icon is not empty %}<i class="{{ action.icon }}"></i>{% endif %}{{ action.title }}
{% endif %}
{% endfor %}
</th>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<div class="card-footer">
Pagination...
</div>
</div>
</form>
{% endmacro %}

View File

@@ -0,0 +1,9 @@
{% extends "Froxlor/userarea.html.twig" %}
{% block content %}
{% import "Froxlor/table/table.html.twig" as table %}
{{ table.table(table_options, api_response, '#', table_options.title) }}
{% endblock %}