customer ftp/mysql listing
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -38,44 +38,19 @@ if ($page == 'overview') {
|
|||||||
} elseif ($page == 'accounts') {
|
} elseif ($page == 'accounts') {
|
||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
|
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts");
|
||||||
$fields = array(
|
|
||||||
'username' => $lng['login']['username'],
|
|
||||||
'homedir' => $lng['panel']['path'],
|
|
||||||
'description' => $lng['panel']['ftpdesc']
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
// get total count
|
$ftp_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.ftps.php';
|
||||||
$json_result = Ftps::getLocal($userinfo)->listingCount();
|
$list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Ftps::class, $userinfo))
|
||||||
$result = json_decode($json_result, true)['data'];
|
->withPagination($ftp_list_data['ftp_list']['columns'])
|
||||||
// initialize pagination and filtering
|
->getList();
|
||||||
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
||||||
// get list
|
|
||||||
$json_result = Ftps::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'];
|
|
||||||
$ftps_count = $paging->getEntries();
|
|
||||||
$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;
|
|
||||||
$accounts = '';
|
|
||||||
|
|
||||||
foreach ($result['list'] as $row) {
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
if (strpos($row['homedir'], $userinfo['documentroot']) === 0) {
|
'listing' => \Froxlor\UI\Listing::format($list, $ftp_list_data['ftp_list']),
|
||||||
$row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']);
|
]);
|
||||||
} else {
|
UI::twigOutputBuffer();
|
||||||
$row['documentroot'] = $row['homedir'];
|
|
||||||
}
|
|
||||||
$row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']);
|
|
||||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
|
||||||
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";");
|
|
||||||
$count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";");
|
|
||||||
} elseif ($action == 'delete' && $id != 0) {
|
} elseif ($action == 'delete' && $id != 0) {
|
||||||
try {
|
try {
|
||||||
$json_result = Ftps::getLocal($userinfo, array(
|
$json_result = Ftps::getLocal($userinfo, array(
|
||||||
|
|||||||
@@ -47,56 +47,24 @@ if ($page == 'overview') {
|
|||||||
} elseif ($page == 'mysqls') {
|
} elseif ($page == 'mysqls') {
|
||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
|
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
|
||||||
$fields = array(
|
|
||||||
'databasename' => $lng['mysql']['databasename'],
|
|
||||||
'description' => $lng['mysql']['databasedescription']
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
// get total count
|
|
||||||
$json_result = Mysqls::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 = Mysqls::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
||||||
} catch (Exception $e) {
|
|
||||||
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
||||||
}
|
|
||||||
$result = json_decode($json_result, true)['data'];
|
|
||||||
|
|
||||||
$mysqls_count = $paging->getEntries();
|
|
||||||
$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;
|
|
||||||
$mysqls = '';
|
|
||||||
|
|
||||||
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`");
|
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`");
|
||||||
$dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
|
$dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$count_mysqlservers = $dbserver['numservers'];
|
$count_mysqlservers = $dbserver['numservers'];
|
||||||
|
|
||||||
// Begin root-session
|
try {
|
||||||
Database::needRoot(true);
|
$mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php';
|
||||||
foreach ($result['list'] as $row) {
|
$list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Mysqls::class, $userinfo))
|
||||||
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
->withPagination($mysql_list_data['mysql_list']['columns'])
|
||||||
$mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES
|
->getList();
|
||||||
WHERE table_schema = :table_schema
|
} catch (Exception $e) {
|
||||||
GROUP BY table_schema");
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
||||||
$mbdata = Database::pexecute_first($mbdata_stmt, array(
|
|
||||||
"table_schema" => $row['databasename']
|
|
||||||
));
|
|
||||||
if (!$mbdata) {
|
|
||||||
$mbdata = array('MB' => 0);
|
|
||||||
}
|
|
||||||
$row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
|
||||||
eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";");
|
|
||||||
$count++;
|
|
||||||
}
|
}
|
||||||
Database::needRoot(false);
|
|
||||||
// End root-session
|
|
||||||
|
|
||||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls') . "\";");
|
UI::twigBuffer('user/table.html.twig', [
|
||||||
|
'listing' => \Froxlor\UI\Listing::format($list, $mysql_list_data['mysql_list']),
|
||||||
|
]);
|
||||||
|
UI::twigOutputBuffer();
|
||||||
} elseif ($action == 'delete' && $id != 0) {
|
} elseif ($action == 'delete' && $id != 0) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
33
lib/Froxlor/UI/Callbacks/Ftp.php
Normal file
33
lib/Froxlor/UI/Callbacks/Ftp.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Froxlor\UI\Callbacks;
|
||||||
|
|
||||||
|
use Froxlor\UI\Panel\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-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Listing
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Ftp
|
||||||
|
{
|
||||||
|
public static function pathRelative(string $data, array $attributes): string
|
||||||
|
{
|
||||||
|
if (strpos($data, UI::getCurrentUser()['documentroot']) === 0) {
|
||||||
|
$data = str_replace(UI::getCurrentUser()['documentroot'], "/", $data);
|
||||||
|
}
|
||||||
|
$data = \Froxlor\FileDir::makeCorrectDir($data);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
lib/Froxlor/UI/Callbacks/Mysql.php
Normal file
34
lib/Froxlor/UI/Callbacks/Mysql.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Froxlor\UI\Callbacks;
|
||||||
|
|
||||||
|
use Froxlor\Database\Database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 Listing
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Mysql
|
||||||
|
{
|
||||||
|
public static function dbserver(string $data, array $attributes): string
|
||||||
|
{
|
||||||
|
// get sql-root access data
|
||||||
|
Database::needRoot(true, (int) $data);
|
||||||
|
Database::needSqlData();
|
||||||
|
$sql_root = Database::getSqlData();
|
||||||
|
Database::needRoot(false);
|
||||||
|
|
||||||
|
return $sql_root['caption'] . '<br><small>' . $sql_root['host'] . '</small>';
|
||||||
|
}
|
||||||
|
}
|
||||||
74
lib/tablelisting/customer/tablelisting.ftps.php
Normal file
74
lib/tablelisting/customer/tablelisting.ftps.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?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 [
|
||||||
|
'ftp_list' => [
|
||||||
|
'title' => $lng['menue']['ftp']['accounts'],
|
||||||
|
'icon' => 'fa-solid fa-users',
|
||||||
|
'columns' => [
|
||||||
|
'username' => [
|
||||||
|
'label' => $lng['login']['username'],
|
||||||
|
'column' => 'username',
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'label' => $lng['panel']['ftpdesc'],
|
||||||
|
'column' => 'description'
|
||||||
|
],
|
||||||
|
'homedir' => [
|
||||||
|
'label' => $lng['panel']['path'],
|
||||||
|
'column' => 'homedir',
|
||||||
|
'format_callback' => [Ftp::class, 'pathRelative']
|
||||||
|
],
|
||||||
|
'shell' => [
|
||||||
|
'label' => $lng['panel']['shell'],
|
||||||
|
'column' => 'shell',
|
||||||
|
'visible' => \Froxlor\Settings::Get('system.allow_customer_shell') == '1'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'visible_columns' => Listing::getVisibleColumnsForListing('ftp_list', [
|
||||||
|
'username',
|
||||||
|
'description',
|
||||||
|
'homedir',
|
||||||
|
'shell'
|
||||||
|
]),
|
||||||
|
'actions' => [
|
||||||
|
'edit' => [
|
||||||
|
'icon' => 'fa fa-edit',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'ftp',
|
||||||
|
'page' => 'ftps',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'delete' => [
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'class' => 'text-danger',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'ftp',
|
||||||
|
'page' => 'ftps',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
76
lib/tablelisting/customer/tablelisting.mysqls.php
Normal file
76
lib/tablelisting/customer/tablelisting.mysqls.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?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\Mysql;
|
||||||
|
use Froxlor\UI\Callbacks\Text;
|
||||||
|
use Froxlor\UI\Listing;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'mysql_list' => [
|
||||||
|
'title' => $lng['menue']['mysql']['databases'],
|
||||||
|
'icon' => 'fa-solid fa-database',
|
||||||
|
'columns' => [
|
||||||
|
'databasename' => [
|
||||||
|
'label' => $lng['mysql']['databasename'],
|
||||||
|
'column' => 'databasename',
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'label' => $lng['mysql']['databasedescription'],
|
||||||
|
'column' => 'description'
|
||||||
|
],
|
||||||
|
'size' => [
|
||||||
|
'label' => $lng['mysql']['size'],
|
||||||
|
'column' => 'size',
|
||||||
|
'format_callback' => [Text::class, 'size']
|
||||||
|
],
|
||||||
|
'dbserver' => [
|
||||||
|
'label' => $lng['mysql']['mysql_server'],
|
||||||
|
'column' => 'dbserver',
|
||||||
|
'format_callback' => [Mysql::class, 'dbserver'],
|
||||||
|
'visible' => $count_mysqlservers > 1
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'visible_columns' => Listing::getVisibleColumnsForListing('mysql_list', [
|
||||||
|
'databasename',
|
||||||
|
'description',
|
||||||
|
'size',
|
||||||
|
'dbserver'
|
||||||
|
]),
|
||||||
|
'actions' => [
|
||||||
|
'edit' => [
|
||||||
|
'icon' => 'fa fa-edit',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'mysql',
|
||||||
|
'page' => 'mysqls',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'delete' => [
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'class' => 'text-danger',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'mysql',
|
||||||
|
'page' => 'mysqls',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user