add frontend for new MysqlServer API command
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
144
admin_mysqlserver.php
Normal file
144
admin_mysqlserver.php
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you can also view it online at
|
||||||
|
* https://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org>
|
||||||
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||||
|
*/
|
||||||
|
|
||||||
|
const AREA = 'admin';
|
||||||
|
require __DIR__ . '/lib/init.php';
|
||||||
|
|
||||||
|
use Froxlor\Api\Commands\MysqlServer;
|
||||||
|
use Froxlor\FroxlorLogger;
|
||||||
|
use Froxlor\PhpHelper;
|
||||||
|
use Froxlor\UI\Collection;
|
||||||
|
use Froxlor\UI\HTML;
|
||||||
|
use Froxlor\UI\Listing;
|
||||||
|
use Froxlor\UI\Panel\UI;
|
||||||
|
use Froxlor\UI\Request;
|
||||||
|
use Froxlor\UI\Response;
|
||||||
|
|
||||||
|
$id = (int)Request::get('id');
|
||||||
|
|
||||||
|
if ($page == 'mysqlserver' || $page == 'overview') {
|
||||||
|
if ($action == '') {
|
||||||
|
$log->logAction(FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_mysqlserver");
|
||||||
|
|
||||||
|
try {
|
||||||
|
$mysqlserver_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.mysqlserver.php';
|
||||||
|
$collection = (new Collection(MysqlServer::class, $userinfo))
|
||||||
|
->withPagination($mysqlserver_list_data['mysqlserver_list']['columns']);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
UI::view('user/table.html.twig', [
|
||||||
|
'listing' => Listing::format($collection, $mysqlserver_list_data, 'mysqlserver_list'),
|
||||||
|
'actions_links' => [
|
||||||
|
[
|
||||||
|
'href' => $linker->getLink(['section' => 'mysqlserver', 'page' => $page, 'action' => 'add']),
|
||||||
|
'label' => lng('admin.mysqlserver.add')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
} elseif ($action == 'delete' && $id != 0) {
|
||||||
|
try {
|
||||||
|
$json_result = MysqlServer::getLocal($userinfo, [
|
||||||
|
'id' => $id
|
||||||
|
])->get();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
|
if (isset($result['id']) && $result['id'] == $id) {
|
||||||
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
|
try {
|
||||||
|
MysqlServer::getLocal($userinfo, [
|
||||||
|
'id' => $id
|
||||||
|
])->delete();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
Response::redirectTo($filename, [
|
||||||
|
'page' => $page
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
HTML::askYesNo('admin_mysqlserver_reallydelete', $filename, [
|
||||||
|
'id' => $id,
|
||||||
|
'page' => $page,
|
||||||
|
'action' => $action
|
||||||
|
], $result['caption'] . ' (' . $result['host'] . ')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($action == 'add') {
|
||||||
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
|
try {
|
||||||
|
MysqlServer::getLocal($userinfo, $_POST)->add();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
Response::redirectTo($filename, [
|
||||||
|
'page' => $page
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$mysqlserver_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/mysqlserver/formfield.mysqlserver_add.php';
|
||||||
|
|
||||||
|
UI::view('user/form.html.twig', [
|
||||||
|
'formaction' => $linker->getLink(['section' => 'mysqlserver']),
|
||||||
|
'formdata' => $mysqlserver_add_data['mysqlserver_add']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} elseif ($action == 'edit' && $id >= 0) {
|
||||||
|
try {
|
||||||
|
$json_result = MysqlServer::getLocal($userinfo, [
|
||||||
|
'id' => $id
|
||||||
|
])->get();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
|
if (isset($result['id']) && $result['id'] == $id) {
|
||||||
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||||
|
try {
|
||||||
|
MysqlServer::getLocal($userinfo, $_POST)->update();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Response::dynamicError($e->getMessage());
|
||||||
|
}
|
||||||
|
Response::redirectTo($filename, [
|
||||||
|
'page' => $page
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$result = PhpHelper::htmlentitiesArray($result);
|
||||||
|
|
||||||
|
$mysqlserver_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/mysqlserver/formfield.mysqlserver_edit.php';
|
||||||
|
|
||||||
|
UI::view('user/form.html.twig', [
|
||||||
|
'formaction' => $linker->getLink(['section' => 'mysqlserver', 'id' => $id]),
|
||||||
|
'formdata' => $mysqlserver_edit_data['mysqlserver_edit'],
|
||||||
|
'editid' => $id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,9 +55,7 @@ if ($page == 'overview' || $page == 'mysqls') {
|
|||||||
if ($action == '') {
|
if ($action == '') {
|
||||||
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
|
$log->logAction(FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls");
|
||||||
|
|
||||||
$dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`");
|
$multiple_mysqlservers = count(json_decode($userinfo['allowed_mysqlserver'] ?? '[]', true)) > 1;
|
||||||
$dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$count_mysqlservers = $dbserver['numservers'];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php';
|
$mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php';
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
$test_connection = $this->getParam('test_connection', true, 1);
|
$test_connection = $this->getParam('test_connection', true, 1);
|
||||||
|
|
||||||
// validation
|
// validation
|
||||||
$mysql_host = Validate::validate_ip2($mysql_host, true, 'invalidip', true, true, false);
|
$mysql_host_chk = Validate::validate_ip2($mysql_host, true, 'invalidip', true, true, false);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
$mysql_host = Validate::validateLocalHostname($mysql_host);
|
$mysql_host_chk = Validate::validateLocalHostname($mysql_host);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
$mysql_host = Validate::validateDomain($mysql_host);
|
$mysql_host_chk = Validate::validateDomain($mysql_host);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
throw new Exception("Invalid mysql server ip/hostname", 406);
|
throw new Exception("Invalid mysql server ip/hostname", 406);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,8 +170,10 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
/**
|
/**
|
||||||
* remove a mysql-server
|
* remove a mysql-server
|
||||||
*
|
*
|
||||||
|
* @param int $id
|
||||||
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
* @param int $dbserver
|
* @param int $dbserver
|
||||||
* the number of the mysql-server
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
*
|
*
|
||||||
* @access admin
|
* @access admin
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -181,7 +183,10 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
{
|
{
|
||||||
$this->validateAccess();
|
$this->validateAccess();
|
||||||
|
|
||||||
$dbserver = (int) $this->getParam('dbserver');
|
$id = (int) $this->getParam('id', true, -1);
|
||||||
|
$dn_optional = $id >= 0;
|
||||||
|
$dbserver = (int) $this->getParam('dbserver', $dn_optional, -1);
|
||||||
|
$dbserver = $id >= 0 ? $id : $dbserver;
|
||||||
|
|
||||||
if ($dbserver == 0) {
|
if ($dbserver == 0) {
|
||||||
throw new Exception('Cannot delete first/default mysql-server', 406);
|
throw new Exception('Cannot delete first/default mysql-server', 406);
|
||||||
@@ -197,7 +202,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
// check whether the server is in use by any customer
|
// check whether the server is in use by any customer
|
||||||
$result_ms = $this->databasesOnServer(true, $dbserver);
|
$result_ms = $this->databasesOnServer(true, $dbserver);
|
||||||
if ($result_ms > 0) {
|
if ($result_ms > 0) {
|
||||||
Response::standardError('mysqlserverstillhasdbs', '', true);
|
throw new Exception(lng('error.mysqlserverstillhasdbs'), 406);
|
||||||
}
|
}
|
||||||
|
|
||||||
// when removing, remove from list of allowed_mysqlservers from any customers
|
// when removing, remove from list of allowed_mysqlservers from any customers
|
||||||
@@ -239,6 +244,7 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
// passwords will not be returned in any case for security reasons
|
// passwords will not be returned in any case for security reasons
|
||||||
unset($sqlrootdata['password']);
|
unset($sqlrootdata['password']);
|
||||||
|
$sqlrootdata['id'] = $index;
|
||||||
$result[$index] = $sqlrootdata;
|
$result[$index] = $sqlrootdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,8 +274,10 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
/**
|
/**
|
||||||
* Return info about a specific mysql-server
|
* Return info about a specific mysql-server
|
||||||
*
|
*
|
||||||
|
* @param int $id
|
||||||
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
* @param int $dbserver
|
* @param int $dbserver
|
||||||
* the number of the mysql-server
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
*
|
*
|
||||||
* @access admin, customer
|
* @access admin, customer
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@@ -277,7 +285,10 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
*/
|
*/
|
||||||
public function get()
|
public function get()
|
||||||
{
|
{
|
||||||
$dbserver = (int) $this->getParam('dbserver');
|
$id = (int) $this->getParam('id', true, -1);
|
||||||
|
$dn_optional = $id >= 0;
|
||||||
|
$dbserver = (int) $this->getParam('dbserver', $dn_optional, -1);
|
||||||
|
$dbserver = $id >= 0 ? $id : $dbserver;
|
||||||
|
|
||||||
// get all data from lib/userdata
|
// get all data from lib/userdata
|
||||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||||
@@ -297,14 +308,17 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
unset($sql_root[$dbserver]['password']);
|
unset($sql_root[$dbserver]['password']);
|
||||||
|
$sql_root[$dbserver]['id'] = $dbserver;
|
||||||
return $this->response($sql_root[$dbserver]);
|
return $this->response($sql_root[$dbserver]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update given mysql-server
|
* update given mysql-server
|
||||||
*
|
*
|
||||||
|
* @param int $id
|
||||||
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
* @param int $dbserver
|
* @param int $dbserver
|
||||||
* the number of the mysql server
|
* optional the number of the mysql server (either id or dbserver must be set)
|
||||||
* @param string $mysql_host
|
* @param string $mysql_host
|
||||||
* ip/hostname of mysql-server
|
* ip/hostname of mysql-server
|
||||||
* @param string $mysql_port
|
* @param string $mysql_port
|
||||||
@@ -332,7 +346,10 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
{
|
{
|
||||||
$this->validateAccess();
|
$this->validateAccess();
|
||||||
|
|
||||||
$dbserver = (int) $this->getParam('dbserver');
|
$id = (int) $this->getParam('id', true, -1);
|
||||||
|
$dn_optional = $id >= 0;
|
||||||
|
$dbserver = (int) $this->getParam('dbserver', $dn_optional, -1);
|
||||||
|
$dbserver = $id >= 0 ? $id : $dbserver;
|
||||||
|
|
||||||
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
require Froxlor::getInstallDir() . "/lib/userdata.inc.php";
|
||||||
|
|
||||||
@@ -342,7 +359,11 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
|
|
||||||
$result = $sql_root[$dbserver];
|
$result = $sql_root[$dbserver];
|
||||||
|
|
||||||
$mysql_host = $this->getParam('mysql_host', true, $result['host']);
|
if ($dbserver == 0) {
|
||||||
|
$mysql_host = $result['host'];
|
||||||
|
} else {
|
||||||
|
$mysql_host = $this->getParam('mysql_host', true, $result['host']);
|
||||||
|
}
|
||||||
$mysql_port = $this->getParam('mysql_port', true, $result['port'] ?? 3306);
|
$mysql_port = $this->getParam('mysql_port', true, $result['port'] ?? 3306);
|
||||||
$mysql_ca = $this->getParam('mysql_ca', true, $result['ssl']['caFile'] ?? '');
|
$mysql_ca = $this->getParam('mysql_ca', true, $result['ssl']['caFile'] ?? '');
|
||||||
$mysql_verifycert = $this->getBoolParam('mysql_verifycert', true, $result['ssl']['verifyServerCertificate'] ?? 0);
|
$mysql_verifycert = $this->getBoolParam('mysql_verifycert', true, $result['ssl']['verifyServerCertificate'] ?? 0);
|
||||||
@@ -353,12 +374,12 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
$test_connection = $this->getParam('test_connection', true, 1);
|
$test_connection = $this->getParam('test_connection', true, 1);
|
||||||
|
|
||||||
// validation
|
// validation
|
||||||
$mysql_host = Validate::validate_ip2($mysql_host, true, 'invalidip', true, true, false);
|
$mysql_host_chk = Validate::validate_ip2($mysql_host, true, 'invalidip', true, true, false);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
$mysql_host = Validate::validateLocalHostname($mysql_host);
|
$mysql_host_chk = Validate::validateLocalHostname($mysql_host);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
$mysql_host = Validate::validateDomain($mysql_host);
|
$mysql_host_chk = Validate::validateDomain($mysql_host);
|
||||||
if ($mysql_host === false) {
|
if ($mysql_host_chk === false) {
|
||||||
throw new Exception("Invalid mysql server ip/hostname", 406);
|
throw new Exception("Invalid mysql server ip/hostname", 406);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -367,6 +388,14 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
$privileged_password = Validate::validate($privileged_password, 'password', '', '', [], true);
|
$privileged_password = Validate::validate($privileged_password, 'password', '', '', [], true);
|
||||||
$description = Validate::validate(trim($description), 'description', Validate::REGEX_DESC_TEXT, '', [], true);
|
$description = Validate::validate(trim($description), 'description', Validate::REGEX_DESC_TEXT, '', [], true);
|
||||||
|
|
||||||
|
if ($mysql_host != $result['host']) {
|
||||||
|
// check whether the server is in use by any customer
|
||||||
|
$result_ms = $this->databasesOnServer(true, $dbserver);
|
||||||
|
if ($result_ms > 0) {
|
||||||
|
throw new Exception("Unable to update mysql-host as there are still databases on it", 406);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// testing connection with given credentials
|
// testing connection with given credentials
|
||||||
if ($test_connection) {
|
if ($test_connection) {
|
||||||
$options = array(
|
$options = array(
|
||||||
@@ -491,6 +520,12 @@ class MysqlServer extends ApiCommand implements ResourceEntity
|
|||||||
['sql' => $sql, 'sql_root' => $sql_root],
|
['sql' => $sql, 'sql_root' => $sql_root],
|
||||||
'automatically generated userdata.inc.php for froxlor'
|
'automatically generated userdata.inc.php for froxlor'
|
||||||
);
|
);
|
||||||
|
chmod(Froxlor::getInstallDir() . "/lib/userdata.inc.php", 0700);
|
||||||
file_put_contents(Froxlor::getInstallDir() . "/lib/userdata.inc.php", $content);
|
file_put_contents(Froxlor::getInstallDir() . "/lib/userdata.inc.php", $content);
|
||||||
|
chmod(Froxlor::getInstallDir() . "/lib/userdata.inc.php", 0400);
|
||||||
|
clearstatcache();
|
||||||
|
if (function_exists('opcache_invalidate')) {
|
||||||
|
@opcache_invalidate(Froxlor::getInstallDir() . "/lib/userdata.inc.php", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ return [
|
|||||||
'label' => lng('customer.mysqlserver'),
|
'label' => lng('customer.mysqlserver'),
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
'values' => $mysql_servers,
|
'values' => $mysql_servers,
|
||||||
'value' => isset($result['allowed_mysqlserver']) && !empty($result['allowed_mysqlserver']) ? json_decode($result['allowed_phpconfigs'], JSON_OBJECT_AS_ARRAY) : [],
|
'value' => isset($result['allowed_mysqlserver']) && !empty($result['allowed_mysqlserver']) ? json_decode($result['allowed_mysqlserver'], JSON_OBJECT_AS_ARRAY) : [],
|
||||||
'is_array' => 1
|
'is_array' => 1
|
||||||
],
|
],
|
||||||
'phpenabled' => [
|
'phpenabled' => [
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you can also view it online at
|
||||||
|
* https://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org>
|
||||||
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Froxlor\Settings;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'mysqlserver_add' => [
|
||||||
|
'title' => lng('admin.mysqlserver.add'),
|
||||||
|
'image' => 'fa-solid fa-plus',
|
||||||
|
'self_overview' => ['section' => 'mysqlserver', 'page' => 'mysqlserver'],
|
||||||
|
'sections' => [
|
||||||
|
'section_a' => [
|
||||||
|
'title' => lng('admin.mysqlserver.mysqlserver'),
|
||||||
|
'fields' => [
|
||||||
|
'mysql_host' => [
|
||||||
|
'label' => lng('admin.mysqlserver.host'),
|
||||||
|
'type' => 'text',
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'mysql_port' => [
|
||||||
|
'label' => lng('admin.mysqlserver.port'),
|
||||||
|
'type' => 'number',
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 65535,
|
||||||
|
'value' => 3306,
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'label' => lng('admin.mysqlserver.caption'),
|
||||||
|
'type' => 'text',
|
||||||
|
],
|
||||||
|
'privileged_user' => [
|
||||||
|
'label' => lng('admin.mysqlserver.user'),
|
||||||
|
'type' => 'text',
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'privileged_password' => [
|
||||||
|
'label' => lng('admin.mysqlserver.password'),
|
||||||
|
'type' => 'password',
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'allow_all_customers' => [
|
||||||
|
'label' => lng('admin.mysqlserver.allowall'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => false
|
||||||
|
],
|
||||||
|
'test_connection' => [
|
||||||
|
'label' => lng('admin.mysqlserver.testconn'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => true
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'section_b' => [
|
||||||
|
'title' => lng('admin.mysqlserver.ssl'),
|
||||||
|
'fields' => [
|
||||||
|
'mysql_ca' => [
|
||||||
|
'label' => lng('admin.mysqlserver.ssl_cert_file'),
|
||||||
|
'type' => 'text'
|
||||||
|
],
|
||||||
|
'mysql_verifycert' => [
|
||||||
|
'label' => lng('admin.mysqlserver.verify_ca'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => false
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you can also view it online at
|
||||||
|
* https://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org>
|
||||||
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
'mysqlserver_edit' => [
|
||||||
|
'title' => lng('admin.mysqlserver.edit'),
|
||||||
|
'image' => 'fa-solid fa-pen',
|
||||||
|
'self_overview' => ['section' => 'mysqlserver', 'page' => 'mysqlserver'],
|
||||||
|
'sections' => [
|
||||||
|
'section_a' => [
|
||||||
|
'title' => lng('admin.mysqlserver.mysqlserver'),
|
||||||
|
'fields' => [
|
||||||
|
'mysql_host' => [
|
||||||
|
'label' => lng('admin.mysqlserver.host'),
|
||||||
|
'type' => empty($result['id']) ? 'label' : 'text',
|
||||||
|
'value' => $result['host'],
|
||||||
|
'mandatory' => true,
|
||||||
|
],
|
||||||
|
'mysql_port' => [
|
||||||
|
'label' => lng('admin.mysqlserver.port'),
|
||||||
|
'type' => 'number',
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 65535,
|
||||||
|
'value' => $result['port'],
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'label' => lng('admin.mysqlserver.caption'),
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $result['caption'],
|
||||||
|
],
|
||||||
|
'privileged_user' => [
|
||||||
|
'label' => lng('admin.mysqlserver.user'),
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $result['user'],
|
||||||
|
'mandatory' => true
|
||||||
|
],
|
||||||
|
'privileged_password' => [
|
||||||
|
'label' => lng('admin.mysqlserver.password_emptynochange'),
|
||||||
|
'type' => 'password'
|
||||||
|
],
|
||||||
|
'allow_all_customers' => [
|
||||||
|
'label' => lng('admin.mysqlserver.allowall'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => false
|
||||||
|
],
|
||||||
|
'test_connection' => [
|
||||||
|
'label' => lng('admin.mysqlserver.testconn'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => true
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'section_b' => [
|
||||||
|
'title' => lng('admin.mysqlserver.ssl'),
|
||||||
|
'fields' => [
|
||||||
|
'mysql_ca' => [
|
||||||
|
'label' => lng('admin.mysqlserver.ssl_cert_file'),
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => $result['ssl']['caFile'] ?? "",
|
||||||
|
],
|
||||||
|
'mysql_verifycert' => [
|
||||||
|
'label' => lng('admin.mysqlserver.verify_ca'),
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'value' => '1',
|
||||||
|
'checked' => $result['ssl']['verifyServerCertificate'] ?? false,
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
0
lib/formfields/admin/mysqlserver/index.html
Normal file
0
lib/formfields/admin/mysqlserver/index.html
Normal file
@@ -182,6 +182,10 @@ return [
|
|||||||
'label' => lng('admin.ipsandports.ipsandports'),
|
'label' => lng('admin.ipsandports.ipsandports'),
|
||||||
'required_resources' => 'change_serversettings'
|
'required_resources' => 'change_serversettings'
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'url' => 'admin_mysqlserver.php?page=mysqlserver',
|
||||||
|
'label' => lng('admin.mysqlserver.mysqlserver'),
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'url' => 'admin_plans.php?page=overview',
|
'url' => 'admin_plans.php?page=overview',
|
||||||
'label' => lng('admin.plans.plans'),
|
'label' => lng('admin.plans.plans'),
|
||||||
|
|||||||
89
lib/tablelisting/admin/tablelisting.mysqlserver.php
Normal file
89
lib/tablelisting/admin/tablelisting.mysqlserver.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you can also view it online at
|
||||||
|
* https://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org>
|
||||||
|
* @license https://files.froxlor.org/misc/COPYING.txt GPLv2
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Froxlor\UI\Callbacks\Admin;
|
||||||
|
use Froxlor\UI\Listing;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'mysqlserver_list' => [
|
||||||
|
'title' => lng('admin.mysqlserver.mysqlserver'),
|
||||||
|
'icon' => 'fa-solid fa-server',
|
||||||
|
'self_overview' => ['section' => 'mysqlserver', 'page' => 'mysqlserver'],
|
||||||
|
'columns' => [
|
||||||
|
'id' => [
|
||||||
|
'label' => lng('admin.mysqlserver.dbserver'),
|
||||||
|
'field' => 'id',
|
||||||
|
],
|
||||||
|
'caption' => [
|
||||||
|
'label' => lng('admin.mysqlserver.caption'),
|
||||||
|
'field' => 'caption',
|
||||||
|
],
|
||||||
|
'host' => [
|
||||||
|
'label' => lng('admin.mysqlserver.host'),
|
||||||
|
'field' => 'host',
|
||||||
|
],
|
||||||
|
'port' => [
|
||||||
|
'label' => lng('admin.mysqlserver.port'),
|
||||||
|
'field' => 'port',
|
||||||
|
'class' => 'text-center',
|
||||||
|
],
|
||||||
|
'user' => [
|
||||||
|
'label' => lng('admin.mysqlserver.user'),
|
||||||
|
'field' => 'user',
|
||||||
|
'visible' => [Admin::class, 'canChangeServerSettings']
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'visible_columns' => Listing::getVisibleColumnsForListing('mysqlserver_list', [
|
||||||
|
'caption',
|
||||||
|
'host',
|
||||||
|
'port',
|
||||||
|
]),
|
||||||
|
'actions' => [
|
||||||
|
'edit' => [
|
||||||
|
'icon' => 'fa fa-edit',
|
||||||
|
'title' => lng('panel.edit'),
|
||||||
|
'href' => [
|
||||||
|
'section' => 'mysqlserver',
|
||||||
|
'page' => 'mysqlserver',
|
||||||
|
'action' => 'edit',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
'visible' => [Admin::class, 'canChangeServerSettings']
|
||||||
|
],
|
||||||
|
'delete' => [
|
||||||
|
'icon' => 'fa fa-trash',
|
||||||
|
'title' => lng('panel.delete'),
|
||||||
|
'class' => 'btn-danger',
|
||||||
|
'href' => [
|
||||||
|
'section' => 'mysqlserver',
|
||||||
|
'page' => 'mysqlserver',
|
||||||
|
'action' => 'delete',
|
||||||
|
'id' => ':id'
|
||||||
|
],
|
||||||
|
'visible' => [Admin::class, 'canChangeServerSettings']
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
@@ -50,7 +50,7 @@ return [
|
|||||||
'label' => lng('mysql.mysql_server'),
|
'label' => lng('mysql.mysql_server'),
|
||||||
'field' => 'dbserver',
|
'field' => 'dbserver',
|
||||||
'callback' => [Mysql::class, 'dbserver'],
|
'callback' => [Mysql::class, 'dbserver'],
|
||||||
'visible' => $count_mysqlservers > 1
|
'visible' => $multiple_mysqlservers
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'visible_columns' => Listing::getVisibleColumnsForListing('mysql_list', [
|
'visible_columns' => Listing::getVisibleColumnsForListing('mysql_list', [
|
||||||
|
|||||||
@@ -458,6 +458,22 @@ return [
|
|||||||
'smtpsettings' => 'SMTP Einstellungen',
|
'smtpsettings' => 'SMTP Einstellungen',
|
||||||
'smtptestaddr' => 'Test-Email senden an',
|
'smtptestaddr' => 'Test-Email senden an',
|
||||||
'smtptestnote' => 'Bitte beachten: Die untenstehenden Werte reflektieren die aktuellen Einstellungen und können auch nur dort angepasst werden (siehe Link in der oberen rechten Ecke)',
|
'smtptestnote' => 'Bitte beachten: Die untenstehenden Werte reflektieren die aktuellen Einstellungen und können auch nur dort angepasst werden (siehe Link in der oberen rechten Ecke)',
|
||||||
|
'mysqlserver' => [
|
||||||
|
'caption' => 'Beschreibung',
|
||||||
|
'user' => 'Privilegierter Benutzer',
|
||||||
|
'add' => 'MySQL Server hinzufügen',
|
||||||
|
'edit' => 'MySQL Server bearbeiten',
|
||||||
|
'password' => 'Passwort privilegierter Benutzer',
|
||||||
|
'password_emptynochange' => 'Neues Passwort, leer für keine Änderung',
|
||||||
|
'allowall' => [
|
||||||
|
'title' => 'Nutzung für aktuelle Kunden automatisch erlauben',
|
||||||
|
'description' => 'Ist diese Einstellung aktiv, wird die Verwendung dieses Datenbank-Servers automatisch allen aktuell existierenden Kunden-Accounts erlaubt. Diese Einstellung ist nicht permanent, kann aber mehrfach / nach Bedarf ausgeführt werden.',
|
||||||
|
],
|
||||||
|
'testconn' => 'Teste Verbindung beim Speichern',
|
||||||
|
'ssl' => 'Verwende SSL für die Verbindung zum Datenbank-Server',
|
||||||
|
'ssl_cert_file' => 'Dateipfad zur SSL certificate authority',
|
||||||
|
'verify_ca' => 'Aktiviere SSL Zertifikats-Verifikation',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'apikeys' => [
|
'apikeys' => [
|
||||||
'no_api_keys' => 'Keine API Keys gefunden',
|
'no_api_keys' => 'Keine API Keys gefunden',
|
||||||
|
|||||||
@@ -465,6 +465,26 @@ return [
|
|||||||
'smtpsettings' => 'SMTP settings',
|
'smtpsettings' => 'SMTP settings',
|
||||||
'smtptestaddr' => 'Send test-mail to',
|
'smtptestaddr' => 'Send test-mail to',
|
||||||
'smtptestnote' => 'Note that the values below reflect your current settings and can only be adjusted there (see link in top right corner)',
|
'smtptestnote' => 'Note that the values below reflect your current settings and can only be adjusted there (see link in top right corner)',
|
||||||
|
'mysqlserver' => [
|
||||||
|
'mysqlserver' => 'MySQL Server',
|
||||||
|
'dbserver' => 'Server #',
|
||||||
|
'caption' => 'Description',
|
||||||
|
'host' => 'Hostname / IP',
|
||||||
|
'port' => 'Port',
|
||||||
|
'user' => 'Privileged user',
|
||||||
|
'add' => 'Add new MySQL server',
|
||||||
|
'edit' => 'Edit MySQL server',
|
||||||
|
'password' => 'Privileged user password',
|
||||||
|
'password_emptynochange' => 'New password, leave empty for no change',
|
||||||
|
'allowall' => [
|
||||||
|
'title' => 'Allow use of this server to all currently existing customers',
|
||||||
|
'description' => 'Set this to "true" if you want to allow use of this database-server to all currently existing customers so they can add databases on it. This setting is not permanent but can be run multiple times.',
|
||||||
|
],
|
||||||
|
'testconn' => 'Test connection when saving',
|
||||||
|
'ssl' => 'Use SSL for connection to database-server',
|
||||||
|
'ssl_cert_file' => 'The file path to the SSL certificate authority',
|
||||||
|
'verify_ca' => 'Enable verification of the server SSL certificate',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'apcuinfo' => [
|
'apcuinfo' => [
|
||||||
'clearcache' => 'Clear APCu cache',
|
'clearcache' => 'Clear APCu cache',
|
||||||
|
|||||||
Reference in New Issue
Block a user