add default-ssl-ip setting

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-02-21 11:50:34 +01:00
parent 26b9c030b5
commit 5480fcbf5d
14 changed files with 106 additions and 10 deletions

View File

@@ -60,6 +60,16 @@ return array(
'default' => '',
'save_method' => 'storeSettingDefaultIp',
),
'system_defaultsslip' => array(
'label' => $lng['serversettings']['defaultsslip'],
'settinggroup' => 'system',
'varname' => 'defaultsslip',
'type' => 'option',
'option_mode' => 'multiple',
'option_options_method' => 'getSslIpPortCombinations',
'default' => '',
'save_method' => 'storeSettingDefaultSslIp',
),
'system_hostname' => array(
'label' => $lng['serversettings']['hostname'],
'settinggroup' => 'system',

View File

@@ -540,6 +540,7 @@ opcache.interned_strings_buffer'),
('system', 'mysql_access_host', 'localhost'),
('system', 'lastcronrun', ''),
('system', 'defaultip', '1'),
('system', 'defaultsslip', ''),
('system', 'phpappendopenbasedir', '/tmp/'),
('system', 'deactivateddocroot', ''),
('system', 'mailpwcleartext', '1'),
@@ -689,7 +690,7 @@ opcache.interned_strings_buffer'),
('panel', 'password_special_char', '!?<>§$%+#=@'),
('panel', 'customer_hide_options', ''),
('panel', 'version', '0.10.0'),
('panel', 'db_version', '201802150');
('panel', 'db_version', '201802210');
DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -14,7 +14,7 @@
* @package Install
*
*/
if (!defined('_CRON_UPDATE')) {
if (! defined('_CRON_UPDATE')) {
if (! defined('AREA') || (defined('AREA') && AREA != 'admin') || ! isset($userinfo['loginname']) || (isset($userinfo['loginname']) && $userinfo['loginname'] == '')) {
header('Location: ../../../../index.php');
exit();
@@ -26,3 +26,12 @@ if (isFroxlorVersion('0.9.39.5')) {
showUpdateStep("Updating from 0.9.39.5 to 0.10.0", false);
updateToVersion('0.10.0');
}
if (isDatabaseVersion('201802150')) {
showUpdateStep("Adding new default-ssl-ip setting");
Settings::AddNew('system.defaultsslip', '');
lastStepStatus(0);
updateToDbVersion('201802210');
}

View File

@@ -184,6 +184,20 @@ abstract class ApiCommand
return $this->cmd_params[$param];
}
/**
* get specific parameter which also has and unlimited-field
*
* @param string $param
* parameter to get out of the request-parameter list
* @param string $ul_field
* parameter to get out of the request-parameter list
* @param bool $optional
* default: false
* @param mixed $default
* value which is returned if optional=true and param is not set
*
* @return mixed
*/
protected function getUlParam($param = null, $ul_field = null, $optional = false, $default = 0)
{
$param_value = intval_ressource($this->getParam($param, $optional, $default));

View File

@@ -751,8 +751,7 @@ class Customers extends ApiCommand implements ResourceEntity
'adminid' => $this->getUserDetail('adminid'),
'docroot' => $result['documentroot'],
'phpenabled' => $phpenabled,
'openbasedir' => '1',
'ipandport' => explode(',', Settings::Get('system.defaultip'))
'openbasedir' => '1'
);
$domainid = - 1;
try {

View File

@@ -124,7 +124,7 @@ class Domains extends ApiCommand implements ResourceEntity
$mod_fcgid_maxrequests = $this->getParam('mod_fcgid_maxrequests', true, - 1);
$ssl_redirect = $this->getParam('ssl_redirect', true, 0);
$letsencrypt = $this->getParam('letsencrypt', true, 0);
$p_ssl_ipandports = $this->getParam('ssl_ipandport', true, array());
$p_ssl_ipandports = $this->getParam('ssl_ipandport', true, explode(',', Settings::Get('system.defaultsslip')));
$http2 = $this->getParam('http2', true, 0);
$hsts_maxage = $this->getParam('hsts_maxage', true, 0);
$hsts_sub = $this->getParam('hsts_sub', true, 0);
@@ -312,7 +312,7 @@ class Domains extends ApiCommand implements ResourceEntity
}
if (empty($p_ipandports)) {
throw new Exception("No IPs given, unable to add domain (no default IPs set?", 406);
throw new Exception("No IPs given, unable to add domain (no default IPs set?)", 406);
}
$ipandports = array();

View File

@@ -370,7 +370,7 @@ class IpsAndPorts extends ApiCommand implements ResourceEntity
), true, true);
if ($result_checkdomain['id'] == '') {
if (! in_array($result['id'], explode(',', Settings::Get('system.defaultip')))) {
if (! in_array($result['id'], explode(',', Settings::Get('system.defaultip'))) && ! in_array($result['id'], explode(',', Settings::Get('system.defaultsslip')))) {
$result_sameipotherport_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`

View File

@@ -126,10 +126,12 @@ class IntegrityCheck {
// Cache all IPs the admins have assigned
$adm_stmt = Database::prepare("SELECT `adminid`, `ip` FROM `" . TABLE_PANEL_ADMINS . "` ORDER BY `adminid` ASC");
Database::pexecute($adm_stmt);
$default_ips = explode(',', Settings::Get('system.defaultip'));
$default_ssl_ips = explode(',', Settings::Get('system.defaultsslip'));
while ($row = $adm_stmt->fetch(PDO::FETCH_ASSOC)) {
if ($row['ip'] < 0 || is_null($row['ip']) || empty($row['ip'])) {
// Admin uses default-IP
$admips[$row['adminid']] = explode(',', Settings::Get('system.defaultip'));
$admips[$row['adminid']] = array_merge($default_ips, $default_ssl_ips);
} else {
$admips[$row['adminid']] = array($row['ip']);
}

View File

@@ -48,6 +48,7 @@ class SImExporter
'system.mysql_access_host',
'system.lastcronrun',
'system.defaultip',
'system.defaultsslip'.
'system.last_tasks_run',
'system.last_archive_run',
'system.leprivatekey',

View File

@@ -62,3 +62,7 @@ function getIpPortCombinations($ssl = false) {
return $system_ipaddress_array;
}
function getSslIpPortCombinations() {
return getIpPortCombinations(true);
}

View File

@@ -67,3 +67,55 @@ function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
return $returnvalue;
}
function storeSettingDefaultSslIp($fieldname, $fielddata, $newfieldvalue) {
$defaultips_old = Settings::Get('system.defaultsslip');
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if ($returnvalue !== false
&& is_array($fielddata)
&& isset($fielddata['settinggroup'])
&& $fielddata['settinggroup'] == 'system'
&& isset($fielddata['varname'])
&& $fielddata['varname'] == 'defaultsslip'
) {
$customerstddomains_result_stmt = Database::prepare("
SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'
");
Database::pexecute($customerstddomains_result_stmt);
$ids = array();
while ($customerstddomains_row = $customerstddomains_result_stmt->fetch(PDO::FETCH_ASSOC)) {
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
}
if (count($ids) > 0) {
$defaultips_new = explode(',', $newfieldvalue);
// Delete the existing mappings linking to default IPs
$del_stmt = Database::prepare("
DELETE FROM `" . TABLE_DOMAINTOIP . "`
WHERE `id_domain` IN (" . implode(', ', $ids) . ")
AND `id_ipandports` IN (" . $defaultips_old . ", " . $newfieldvalue . ")
");
Database::pexecute($del_stmt);
// Insert the new mappings
$ins_stmt = Database::prepare("
INSERT INTO `" . TABLE_DOMAINTOIP . "`
SET `id_domain` = :domainid, `id_ipandports` = :ipandportid
");
foreach ($ids as $id) {
foreach ($defaultips_new as $defaultip_new) {
Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new));
}
}
}
}
return $returnvalue;
}

View File

@@ -19,7 +19,7 @@
$version = '0.10.0';
// Database version (YYYYMMDDC where C is a daily counter)
$dbversion = '201802150';
$dbversion = '201802210';
// Distribution branding-tag (used for Debian etc.)
$branding = '';

View File

@@ -436,6 +436,8 @@ $lng['error']['webftpiswrong'] = 'The WebFTP-link is not a valid link.';
$lng['domains']['hasaliasdomains'] = 'Has alias domain(s)';
$lng['serversettings']['defaultip']['title'] = 'Default IP/Port';
$lng['serversettings']['defaultip']['description'] = 'Select all IP-addresses you want to use as default for new domains';
$lng['serversettings']['defaultsslip']['title'] = 'Default SSL IP/Port';
$lng['serversettings']['defaultsslip']['description'] = 'Select all ssl-enabled IP-addresses you want to use as default for new domains';
$lng['domains']['statstics'] = 'Usage Statistics';
$lng['panel']['ascending'] = 'ascending';
$lng['panel']['descending'] = 'descending';

View File

@@ -429,8 +429,10 @@ $lng['error']['phpmyadminiswrong'] = 'Die "phpMyAdmin-URL" ist keine gültige UR
$lng['error']['webmailiswrong'] = 'Die "Webmail-URL" ist keine gültige URL.';
$lng['error']['webftpiswrong'] = 'Die "WebFTP-URL" ist keine gültige URL.';
$lng['domains']['hasaliasdomains'] = 'Hat Aliasdomain(s)';
$lng['serversettings']['defaultip']['title'] = 'Standard-IP/Port';
$lng['serversettings']['defaultip']['title'] = 'Standard IP/Port';
$lng['serversettings']['defaultip']['description'] = 'Welche IP/Port-Kombination sollen standardmäßig verwendet werden?';
$lng['serversettings']['defaultsslip']['title'] = 'Standard SSL IP/Port';
$lng['serversettings']['defaultsslip']['description'] = 'Welche ssl-fähigen IP/Port-Kombination sollen standardmäßig verwendet werden?';
$lng['domains']['statstics'] = 'Statistiken';
$lng['panel']['ascending'] = 'aufsteigend';
$lng['panel']['descending'] = 'absteigend';