diff --git a/src/library/Server/Manager/Hestia.php b/src/library/Server/Manager/Hestia.php index c0ae31f79..d757136b6 100644 --- a/src/library/Server/Manager/Hestia.php +++ b/src/library/Server/Manager/Hestia.php @@ -27,11 +27,7 @@ class Server_Manager_Hestia extends Server_Manager public function _getPort() { - if ($this->_config['port']) { - return $this->_config['port']; - } else { - return '8083'; - } + return is_numeric($this->_config['port']) ? $this->_config['port'] : '8083'; } /** @@ -42,7 +38,27 @@ class Server_Manager_Hestia extends Server_Manager public static function getForm() { return [ - 'label' => 'Hestia', + 'label' => 'Hestia Control Panel', + 'form' => [ + 'credentials' => [ + 'fields' => [ + [ + 'name' => 'username', + 'type' => 'text', + 'label' => 'Username', + 'placeholder' => 'Username to connect to the server', + 'required' => true, + ], + [ + 'name' => 'accesshash', + 'type' => 'text', + 'label' => 'Access hash', + 'placeholder' => 'Access hash to connect to the server', + 'required' => true, + ], + ], + ], + ] ]; } @@ -53,9 +69,7 @@ class Server_Manager_Hestia extends Server_Manager */ public function getLoginUrl() { - $host = 'https://'.$this->_config['host'].':'.$this->_getPort().'/'; - - return $host; + return 'https://'.$this->_config['host'].':'.$this->_getPort().'/'; } /** @@ -65,7 +79,7 @@ class Server_Manager_Hestia extends Server_Manager */ public function getResellerLoginUrl() { - return 'https://hestiacp.com'; + return $this->getLoginUrl(); } private function _makeRequest($params) @@ -361,4 +375,4 @@ class Server_Manager_Hestia extends Server_Manager { throw new Server_Exception('Server Manager Hestia CP Error: Not Supported'); } -} +} \ No newline at end of file diff --git a/src/library/Server/Manager/Plesk.php b/src/library/Server/Manager/Plesk.php index 03197bae2..3dbdf9659 100644 --- a/src/library/Server/Manager/Plesk.php +++ b/src/library/Server/Manager/Plesk.php @@ -22,9 +22,9 @@ class Server_Manager_Plesk extends Server_Manager public static function getForm() { - return array( + return [ 'label' => 'Plesk', - ); + ]; } public function getLoginUrl() @@ -516,4 +516,4 @@ class Server_Manager_Plesk extends Server_Manager return $props; } -} +} \ No newline at end of file diff --git a/src/library/Server/Manager/Vesta.php b/src/library/Server/Manager/Vesta.php index 499993109..2cc18fdcd 100644 --- a/src/library/Server/Manager/Vesta.php +++ b/src/library/Server/Manager/Vesta.php @@ -27,11 +27,7 @@ class Server_Manager_Vesta extends Server_Manager public function _getPort() { - if (is_numeric($this->_config['port'])) { - return $this->_config['port']; - } else { - return '8083'; - } + return is_numeric($this->_config['port']) ? $this->_config['port'] : '8083'; } /** @@ -53,9 +49,7 @@ class Server_Manager_Vesta extends Server_Manager */ public function getLoginUrl() { - $host = 'https://'.$this->_config['host'].':'.$this->_getPort().'/'; - - return $host; + return 'https://'.$this->_config['host'].':'.$this->_getPort().'/'; } /** @@ -65,7 +59,7 @@ class Server_Manager_Vesta extends Server_Manager */ public function getResellerLoginUrl() { - return 'https://vestacp.com'; + return $this->getLoginUrl(); } private function _makeRequest($params) @@ -369,4 +363,4 @@ class Server_Manager_Vesta extends Server_Manager { throw new Server_Exception('Server Manager Vesta CP Error: Not Supported'); } -} +} \ No newline at end of file diff --git a/src/library/Server/Manager/Whm.php b/src/library/Server/Manager/Whm.php index 02da9d5e7..ef106830f 100644 --- a/src/library/Server/Manager/Whm.php +++ b/src/library/Server/Manager/Whm.php @@ -77,7 +77,27 @@ class Server_Manager_Whm extends Server_Manager public static function getForm() { return array( - 'label' => 'cPanel WHM', + 'label' => 'WHM (cPanel)', + 'form' => [ + 'credentials' => [ + 'fields' => [ + [ + 'name' => 'username', + 'type' => 'text', + 'label' => 'Username', + 'placeholder' => 'Username to connect to the server', + 'required' => true, + ], + [ + 'name' => 'accesshash', + 'type' => 'text', + 'label' => 'Access hash', + 'placeholder' => 'Access hash to connect to the server', + 'required' => true, + ], + ], + ], + ] ); } @@ -2683,7 +2703,5 @@ class xmlapi { $values['display'] = substr($args, 0, -1); } return $this->api2_query($username, 'StatsBar', 'stat', $values); - } - - + } } \ No newline at end of file diff --git a/src/modules/Servicehosting/html_admin/mod_servicehosting_index.html.twig b/src/modules/Servicehosting/html_admin/mod_servicehosting_index.html.twig index f68f0504d..4d6db8cce 100644 --- a/src/modules/Servicehosting/html_admin/mod_servicehosting_index.html.twig +++ b/src/modules/Servicehosting/html_admin/mod_servicehosting_index.html.twig @@ -205,31 +205,14 @@
- {% for code, manager in admin.servicehosting_manager_get_pairs %} {% endfor %}
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+
@@ -287,5 +270,72 @@ function onAfterHostingPlanCreate(id) { bb.redirect("{{ 'servicehosting/plan'|alink }}/" + id); } + + function handleManagerChange (select) { + var pairs = {{ admin.servicehosting_manager_get_pairs|json_encode|raw }} // PHP array returned by the server manager converted to a JavaScript object + var defaults = { + form: { + credentials: { + fields: [ + { + name: 'username', + label: 'Username', + type: 'text', + placeholder: 'Username to connect to the server', + required: true + }, + { + name: 'password', + label: 'Password', + type: 'password', + placeholder: 'Password to connect to the server', + required: true + } + ], + }, + }, + } // Default form fields. If server manager does not provide any, use these. + + var credentials = document.getElementById('credentials'); // HTML element where the form fields will be inserted. + var manager = select.value; // Selected server manager code. + + credentials.innerHTML = ''; // Clear the form fields. + + if (pairs[manager].form && pairs[manager].form.credentials && pairs[manager].form.credentials.fields) { + var data = pairs[manager].form.credentials.fields; + } else { + var data = defaults.form.credentials.fields; + } + + for (var i = 0; i < data.length; i++) { + // Create a new form field and append it to the credentials element. + var field = data[i]; + var div = document.createElement('div'); + div.className = 'mb-3 row'; + + var label = document.createElement('label'); + label.className = 'form-label col-3 col-form-label'; + label.innerHTML = field.label + ':'; + div.appendChild(label); + + var input = document.createElement('input'); + input.className = 'form-control'; + input.type = field.type; + input.name = field.name; + input.placeholder = field.placeholder; + input.required = field.required; + + var col = document.createElement('div'); + col.className = 'col'; + col.appendChild(input); + div.appendChild(col); + + credentials.appendChild(div); + } + } + + window.onload = function () { + handleManagerChange(document.querySelector('select[name="manager"]')); + }; -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/src/modules/Servicehosting/html_admin/mod_servicehosting_manage.html.twig b/src/modules/Servicehosting/html_admin/mod_servicehosting_manage.html.twig index b2e8877da..67fa6a73b 100644 --- a/src/modules/Servicehosting/html_admin/mod_servicehosting_manage.html.twig +++ b/src/modules/Servicehosting/html_admin/mod_servicehosting_manage.html.twig @@ -1,184 +1,226 @@ -{% import 'macro_functions.html.twig' as mf %} +{% extends 'layout_default.html.twig' %} -{% set server = service.server %} -{% set hp = service.hosting_plan %} +{% block meta_title %}{{ 'Hosting management'|trans }}{% endblock %} -
-

{{ 'Details'|trans }}

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {% if server.ns3 %} - - - - - {% endif %} - {% if server.ns4 %} - - - - - {% endif %} - - - - - - - - - -
{{ 'Status'|trans }}:{{ mf.status_name(order.status) }}
{{ 'Domain'|trans }}: - {{ service.domain }} -
{{ 'Server Name'|trans }}:{{ server.name }}
{{ 'Hosting plan'|trans }}:{{ hp.name }}
{{ 'Server IP'|trans }}:{{ server.ip }}
{{ 'Account IP'|trans }}:{{ service.ip }}
{{ 'Username'|trans }}:{{ service.username }}
{{ 'Nameserver 1'|trans }}:{{ server.ns1 }}
{{ 'Nameserver 2'|trans }}:{{ server.ns2 }}
{{ 'Nameserver 3'|trans }}:{{ server.ns3 }}
{{ 'Nameserver 4'|trans }}:{{ server.ns4 }}
{{ 'Bandwidth'|trans }}:{{ hp.bandwidth }} MB / {{ 'per month'|trans }}
{{ 'Disk quota'|trans }}:{{ hp.quota }} MB
+{% set active_menu = 'system' %} - +{% block content %} +
+
+

{{ 'Server management'|trans }}

-
-

{{ 'Change hosting plan'|trans }}

- -
- -
- -
- {{ mf.selectbox('plan_id', admin.servicehosting_hp_get_pairs, hp.id, 1) }} -
-
- - - -
-
- -

{{ 'Change account password'|trans }}

-
- -
- -
- -
-
-
- -
- -
-
- - - -
-
- -

{{ 'Change IP'|trans }}

-
- -
- -
- -
-
- - - -
-
- -

{{ 'Change username'|trans }}

-
- -
- -
- -
-
- - - -
-
- -

{{ 'Change domain'|trans }}

-
- -
- -
-
- - + + +
+ +
+
-
+
+ +
+ +
+
+
+ +
+ +
+
+ {#
+ +
+ +
+
#} +
+ +
+
+ + +
+
+ + +
+
+
+
- - - +
{{ 'Server manager'|trans }}
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+
+
+ +
+
+ + +
+
+ + +
+
+
+ + + +
{{ 'Nameservers'|trans }}
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + + + +
+{% endblock %} + +{% block js%} + +{% endblock %} \ No newline at end of file