fix setting of default IP/Port (which still used panel_domain's ipandport-field), don't show ssl-enabled IP/Ports for default-ip (wrong default parameter of function getIpPortCombinations()), smaller fixes in bind- and lighttpdcronjob
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -1098,23 +1098,24 @@ if($page == 'domains'
|
|||||||
'id' => 0
|
'id' => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
if($aliasdomain != 0)
|
if ($aliasdomain != 0) {
|
||||||
{
|
// Overwrite given ipandports with these of the "main" domain
|
||||||
// Overwrite given ipandports with these of the "main" domain
|
$ipandports = array();
|
||||||
$ipandports = array();
|
$origipresult = $db->query("SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP ."` WHERE `id_domain` = '" . (int)$aliasdomain . "'");
|
||||||
$origipresult = $db->query("SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP ."` WHERE `id_domain` = '" . (int)$aliasdomain . "'");
|
while ($origip = $db->fetch_array($origipresult)) {
|
||||||
while($origip = $db->fetch_array($origipresult))
|
$ipandports[] = $origip['id_ipandports'];
|
||||||
{
|
}
|
||||||
$ipandports[] = $origip['id_ipandports'];
|
$aliasdomain_check = $db->query_first("SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d`, `" . TABLE_PANEL_CUSTOMERS . "` `c`
|
||||||
}
|
WHERE `d`.`customerid`='" . (int)$customerid . "'
|
||||||
|
AND `d`.`aliasdomain` IS NULL AND
|
||||||
|
`d`.`id` <> `c`.`standardsubdomain`
|
||||||
|
AND `c`.`customerid`='" . (int)$customerid . "'
|
||||||
|
AND `d`.`id`='" . (int)$aliasdomain . "'");
|
||||||
|
}
|
||||||
|
|
||||||
$aliasdomain_check = $db->query_first('SELECT `d`.`id` FROM `' . TABLE_PANEL_DOMAINS . '` `d`,`' . TABLE_PANEL_CUSTOMERS . '` `c` WHERE `d`.`customerid`=\'' . (int)$customerid . '\' AND `d`.`aliasdomain` IS NULL AND `d`.`id`<>`c`.`standardsubdomain` AND `c`.`customerid`=\'' . (int)$customerid . '\' AND `d`.`id`=\'' . (int)$aliasdomain . '\'');
|
if (count($ipandports) == 0) {
|
||||||
}
|
standard_error('noipportgiven');
|
||||||
|
}
|
||||||
if(count($ipandports) == 0)
|
|
||||||
{
|
|
||||||
standard_error('noipportgiven');
|
|
||||||
}
|
|
||||||
|
|
||||||
if($aliasdomain_check['id'] != $aliasdomain)
|
if($aliasdomain_check['id'] != $aliasdomain)
|
||||||
{
|
{
|
||||||
@@ -1282,6 +1283,10 @@ if($page == 'domains'
|
|||||||
WHERE `parentdomainid`='" . (int)$id . "'
|
WHERE `parentdomainid`='" . (int)$id . "'
|
||||||
");
|
");
|
||||||
|
|
||||||
|
// FIXME check how many we got and if the amount of assigned IP's
|
||||||
|
// has changed so we can insert a config-rebuild task if only
|
||||||
|
// the ip's of this domain were changed
|
||||||
|
|
||||||
// Cleanup domain <-> ip mapping
|
// Cleanup domain <-> ip mapping
|
||||||
$db->query("DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = '" . (int)$id . "'");
|
$db->query("DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` = '" . (int)$id . "'");
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getIpPortCombinations($ssl = null)
|
function getIpPortCombinations($ssl = false)
|
||||||
{
|
{
|
||||||
global $db, $theme;
|
global $db, $theme;
|
||||||
|
|
||||||
|
|||||||
@@ -16,30 +16,34 @@
|
|||||||
* @package Functions
|
* @package Functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue) {
|
||||||
|
|
||||||
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
|
|
||||||
{
|
|
||||||
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
|
||||||
|
|
||||||
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip')
|
if ($returnvalue !== false
|
||||||
{
|
&& is_array($fielddata)
|
||||||
|
&& isset($fielddata['settinggroup'])
|
||||||
|
&& $fielddata['settinggroup'] == 'system'
|
||||||
|
&& isset($fielddata['varname'])
|
||||||
|
&& $fielddata['varname'] == 'defaultip'
|
||||||
|
) {
|
||||||
global $db, $theme;
|
global $db, $theme;
|
||||||
|
|
||||||
$customerstddomains_result = $db->query('SELECT `standardsubdomain` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `standardsubdomain` <> \'0\'');
|
$customerstddomains_result = $db->query("SELECT `standardsubdomain` FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `standardsubdomain` <> '0'");
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
while($customerstddomains_row = $db->fetch_array($customerstddomains_result))
|
while($customerstddomains_row = $db->fetch_array($customerstddomains_result)) {
|
||||||
{
|
|
||||||
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
|
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($ids) > 0)
|
if(count($ids) > 0) {
|
||||||
{
|
$db->query("UPDATE `" . TABLE_DOMAINTOIP . "` SET
|
||||||
$db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `ipandport`=\'' . (int)$newfieldvalue . '\' WHERE `id` IN (\'' . implode('\',\'', $ids) . '\') AND `ipandport` = \'' . $db->escape(getSetting('system', 'defaultip')) . '\'');
|
`id_ipandports`='" . (int)$newfieldvalue . "'
|
||||||
|
WHERE `id_domain` IN ('" . implode(', ', $ids) . "')
|
||||||
|
AND `id_ipandports` = '" . $db->escape(getSetting('system', 'defaultip')) . "'"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $returnvalue;
|
return $returnvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* This script creates the php.ini's used by mod_suPHP+php-cgi
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(@php_sapi_name() != 'cli'
|
if(@php_sapi_name() != 'cli'
|
||||||
&& @php_sapi_name() != 'cgi'
|
&& @php_sapi_name() != 'cgi'
|
||||||
@@ -179,23 +176,24 @@ class bind
|
|||||||
|
|
||||||
protected function generateZone($domain)
|
protected function generateZone($domain)
|
||||||
{
|
{
|
||||||
/** Array to save all ips needed in the records (already including IN A/AAAA */
|
// Array to save all ips needed in the records (already including IN A/AAAA)
|
||||||
$ip_a_records = array();
|
$ip_a_records = array();
|
||||||
/** Array to save DNS records */
|
// Array to save DNS records
|
||||||
$records = array();
|
$records = array();
|
||||||
|
|
||||||
$result_ip = $this->db->query("SELECT `p`.`ip` AS `ip` FROM `".TABLE_PANEL_IPSANDPORTS."` `p`, `".TABLE_DOMAINTOIP."` `di` WHERE `di`.`id_domain` = '$domain[id]' AND `p`.`id` = `di`.`id_ipandports` GROUP BY `p`.`ip`;");
|
$result_ip = $this->db->query("SELECT `p`.`ip` AS `ip` FROM `".TABLE_PANEL_IPSANDPORTS."` `p`, `".TABLE_DOMAINTOIP."` `di` WHERE `di`.`id_domain` = '$domain[id]' AND `p`.`id` = `di`.`id_ipandports` GROUP BY `p`.`ip`;");
|
||||||
|
|
||||||
while ($ip = $this->db->fetch_array($result_ip)) {
|
while ($ip = $this->db->fetch_array($result_ip)) {
|
||||||
|
|
||||||
if(filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
|
if (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||||
$ip_a_records[] = "A $ip[ip]";
|
$ip_a_records[] = "A $ip[ip]";
|
||||||
|
}
|
||||||
elseif(filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
elseif (filter_var($ip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
||||||
$ip_a_records[] = "AAAA $ip[ip]";
|
$ip_a_records[] = "AAAA $ip[ip]";
|
||||||
|
}
|
||||||
else
|
else {
|
||||||
return ";Error in at least one IP Adress ($ip[ip]), could not create zonefile!";
|
return ";Error in at least one IP Adress (".$ip['ip']."), could not create zonefile!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$date = date('Ymd');
|
$date = date('Ymd');
|
||||||
@@ -214,17 +212,20 @@ class bind
|
|||||||
|
|
||||||
$zonefile.= ' ' . $bindserial . ' ; serial' . "\n" . ' 8H ; refresh' . "\n" . ' 2H ; retry' . "\n" . ' 1W ; expiry' . "\n" . ' 11h) ; minimum' . "\n";
|
$zonefile.= ' ' . $bindserial . ' ; serial' . "\n" . ' 8H ; refresh' . "\n" . ' 2H ; retry' . "\n" . ' 1W ; expiry' . "\n" . ' 11h) ; minimum' . "\n";
|
||||||
|
|
||||||
|
// FIXME What is this? there is no $ip_a_record at this stage
|
||||||
|
/*
|
||||||
if(count($this->nameservers) == 0)
|
if(count($this->nameservers) == 0)
|
||||||
{
|
{
|
||||||
$zonefile.= '@ IN NS ns' . "\n" . 'ns IN ' . $ip_a_record . "\n";
|
$zonefile.= '@ IN NS ns' . "\n" . 'ns IN ' . $ip_a_record . "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
*/
|
||||||
foreach($this->nameservers as $nameserver)
|
foreach($this->nameservers as $nameserver)
|
||||||
{
|
{
|
||||||
$zonefile.= '@ IN NS ' . trim($nameserver['hostname']) . "\n";
|
$zonefile.= '@ IN NS ' . trim($nameserver['hostname']) . "\n";
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(count($this->mxservers) == 0)
|
if(count($this->mxservers) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class lighttpd
|
|||||||
* if $this->settings['system']['apacheconf_vhost'] is a folder
|
* if $this->settings['system']['apacheconf_vhost'] is a folder
|
||||||
* refs #70
|
* refs #70
|
||||||
*/
|
*/
|
||||||
$vhosts = $this->createLighttpdHosts($row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'], $vhost_filename);
|
$vhosts = $this->createLighttpdHosts($row_ipsandports['id'], $row_ipsandports['ssl'], $vhost_filename);
|
||||||
if ($vhosts !== null && is_array($vhosts) && isset($vhosts[0])) {
|
if ($vhosts !== null && is_array($vhosts) && isset($vhosts[0])) {
|
||||||
// sort vhosts by number (subdomains first!)
|
// sort vhosts by number (subdomains first!)
|
||||||
sort($vhosts);
|
sort($vhosts);
|
||||||
@@ -300,19 +300,35 @@ class lighttpd
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createLighttpdHosts($ip, $port, $ssl, $vhost_filename)
|
protected function createLighttpdHosts($ipid, $ssl, $vhost_filename)
|
||||||
{
|
{
|
||||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip`='" . $ip . "' AND `port`='" . $port . "'";
|
$query = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`,
|
||||||
$ipandport = $this->db->query_first($query);
|
`d`.`phpsettingid`, `c`.`adminid`, `c`.`guid`, `c`.`email`,
|
||||||
|
`c`.`documentroot` AS `customerroot`, `c`.`deactivated`,
|
||||||
|
`c`.`phpenabled` AS `phpenabled`, `d`.`mod_fcgid_starter`,
|
||||||
|
`d`.`mod_fcgid_maxrequests`, `p`.`ssl` AS `ssl`,
|
||||||
|
`p`.`ssl_cert_file`, `p`.`ssl_key_file`, `p`.`ssl_ca_file`, `p`.`ssl_cert_chainfile`
|
||||||
|
FROM `".TABLE_PANEL_DOMAINS."` `d`
|
||||||
|
|
||||||
if ($ssl == '0') {
|
LEFT JOIN `".TABLE_PANEL_CUSTOMERS."` `c` USING(`customerid`)
|
||||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
LEFT JOIN `".TABLE_PANEL_DOMAINS."` `pd` ON (`pd`.`id` = `d`.`parentdomainid`)
|
||||||
} else {
|
|
||||||
$query2 = "SELECT `d`.*, `pd`.`domain` AS `parentdomain`, `c`.`loginname`, `c`.`guid`, `c`.`email`, `c`.`documentroot` AS `customerroot`, `c`.`deactivated`, `c`.`phpenabled` AS `phpenabled` FROM `" . TABLE_PANEL_DOMAINS . "` `d` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING(`customerid`) LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON (`pd`.`id` = `d`.`parentdomainid`) WHERE `d`.`ssl_ipandport`='" . $ipandport['id'] . "' AND `d`.`aliasdomain` IS NULL AND `d`.`email_only` <> 1 ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC";
|
INNER JOIN (
|
||||||
}
|
SELECT * FROM (
|
||||||
|
SELECT `di`.`id_domain` , `p`.`ssl`, `p`.`ssl_cert_file`, `p`.`ssl_key_file`, `p`.`ssl_ca_file`, `p`.`ssl_cert_chainfile`
|
||||||
|
FROM `".TABLE_DOMAINTOIP."` `di` , `".TABLE_PANEL_IPSANDPORTS."` `p`
|
||||||
|
WHERE `p`.`id` = `di`.`id_ipandports`
|
||||||
|
AND `p`.`id` = '".(int)$ipid."'
|
||||||
|
ORDER BY `p`.`ssl` DESC
|
||||||
|
) AS my_table_tmp
|
||||||
|
GROUP BY `id_domain`
|
||||||
|
) AS p ON p.`id_domain` = `d`.`id`
|
||||||
|
|
||||||
|
WHERE `d`.`aliasdomain` IS NULL
|
||||||
|
ORDER BY `d`.`parentdomainid` DESC, `d`.`iswildcarddomain`, `d`.`domain` ASC;";
|
||||||
|
|
||||||
$included_vhosts = array();
|
$included_vhosts = array();
|
||||||
$result_domains = $this->db->query($query2);
|
$result_domains = $this->db->query($query);
|
||||||
while ($domain = $this->db->fetch_array($result_domains)) {
|
while ($domain = $this->db->fetch_array($result_domains)) {
|
||||||
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
if (is_dir($this->settings['system']['apacheconf_vhost'])) {
|
||||||
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/')));
|
safe_exec('mkdir -p '.escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'].'/vhosts/')));
|
||||||
@@ -368,39 +384,25 @@ class lighttpd
|
|||||||
$ips_and_ports_index = 'ipandport';
|
$ips_and_ports_index = 'ipandport';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lighttpd_data[$vhost_filename].= $this->getVhostContent($domain, $ssl_vhost);
|
// FIXME we get duplicate entries of a vhost if it has assigned more than one IP
|
||||||
$this->lighttpd_data[$vhost_filename].= isset($this->needed_htpasswds[$domain[$ips_and_ports_index]]) ? $this->needed_htpasswds[$domain[$ips_and_ports_index]] . "\n" : '';
|
// checking if the lightt_data for that filename is empty *might* be correct
|
||||||
|
if ($this->lighttpd_data[$vhost_filename] == '') {
|
||||||
|
$this->lighttpd_data[$vhost_filename] .= $this->getVhostContent($domain, $ssl_vhost, $ipid);
|
||||||
|
}
|
||||||
|
// FIXME did this ever work?
|
||||||
|
//$this->lighttpd_data[$vhost_filename].= isset($this->needed_htpasswds[$domain[$ips_and_ports_index]]) ? $this->needed_htpasswds[$domain[$ips_and_ports_index]] . "\n" : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $included_vhosts;
|
return $included_vhosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getVhostContent($domain, $ssl_vhost = false)
|
protected function getVhostContent($domain, $ssl_vhost = false, $ipid)
|
||||||
{
|
{
|
||||||
if($ssl_vhost === true
|
if($ssl_vhost === true
|
||||||
&& $domain['ssl'] != '1')
|
&& $domain['ssl'] != '1'
|
||||||
{
|
&& $domain['ssl_redirect'] != '1'
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ssl_vhost === true
|
|
||||||
&& $domain['ssl'] == '1'
|
|
||||||
) {
|
) {
|
||||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ssl_ipandport'] . "'";
|
return '';
|
||||||
} else {
|
|
||||||
$query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `id`='" . $domain['ipandport'] . "'";
|
|
||||||
}
|
|
||||||
|
|
||||||
$ipandport = $this->db->query_first($query);
|
|
||||||
$domain['ip'] = $ipandport['ip'];
|
|
||||||
$domain['port'] = $ipandport['port'];
|
|
||||||
$domain['ssl_cert_file'] = $ipandport['ssl_cert_file'];
|
|
||||||
$domain['ssl_ca_file'] = $ipandport['ssl_ca_file'];
|
|
||||||
|
|
||||||
if (filter_var($domain['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
|
||||||
$ipport = '[' . $domain['ip'] . ']:' . $domain['port'];
|
|
||||||
} else {
|
|
||||||
$ipport = $domain['ip'] . ':' . $domain['port'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$vhost_content = '';
|
$vhost_content = '';
|
||||||
@@ -440,6 +442,8 @@ class lighttpd
|
|||||||
$vhost_content.= $domain['specialsettings'] . "\n";
|
$vhost_content.= $domain['specialsettings'] . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query = "SELECT `default_vhostconf_domain` FROM `".TABLE_PANEL_IPSANDPORTS."` WHERE `id`='".$ipid."';";
|
||||||
|
$ipandport = $this->db->query_first($query);
|
||||||
if ($ipandport['default_vhostconf_domain'] != '') {
|
if ($ipandport['default_vhostconf_domain'] != '') {
|
||||||
$vhost_content.= $ipandport['default_vhostconf_domain'] . "\n";
|
$vhost_content.= $ipandport['default_vhostconf_domain'] . "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user