/** * Get the filename for the virtualhost */ protected function getVhostFilename($domain, $ssl_vhost = false) { if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '35'; } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '30'; } else { // number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth $vhost_no = (string) (30 - substr_count($domain['domain'], ".") + 1); } if ($ssl_vhost === true) { $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_ssl_vhost_' . $domain['domain'] . '.conf'); } else { $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_normal_vhost_' . $domain['domain'] . '.conf'); } return $vhost_filename; }
/** * Get the filename for the virtualhost */ protected function getVhostFilename($domain, $ssl_vhost = false) { if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '22'; } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '21'; } else { $vhost_no = '20'; } if ($ssl_vhost === true) { $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_ssl_vhost_' . $domain['domain'] . '.conf'); } else { $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/' . $vhost_no . '_froxlor_normal_vhost_' . $domain['domain'] . '.conf'); } return $vhost_filename; }
protected function createLighttpdHosts($ipid, $ssl, $vhost_filename) { $domains = WebserverBase::getVhostsToCreate(); foreach ($domains as $domain) { if (is_dir(Settings::Get('system.apacheconf_vhost'))) { safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost') . '/vhosts/'))); // determine correct include-path: // e.g. '/etc/lighttpd/conf-enabled/vhosts/ has to become' // 'conf-enabled/vhosts/' (damn debian, but luckily works too on other distros) $_tmp_path = substr(makeCorrectDir(Settings::Get('system.apacheconf_vhost')), 0, -1); $_pos = strrpos($_tmp_path, '/'); $_inc_path = substr($_tmp_path, $_pos + 1); // maindomain if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '50'; } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '51'; } else { // number of dots in a domain specifies it's position (and depth of subdomain) starting at 89 going downwards on higher depth $vhost_no = (string) (90 - substr_count($domain['domain'], ".") + 1); } if ($ssl == '1') { $vhost_no = (int) ($vhost_no += 10); } $vhost_filename = makeCorrectFile(Settings::Get('system.apacheconf_vhost') . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf'); $included_vhosts[] = $_inc_path . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf'; } if (!isset($this->lighttpd_data[$vhost_filename])) { $this->lighttpd_data[$vhost_filename] = ''; } if (!empty($this->lighttpd_data[$vhost_filename]) && !is_dir(Settings::Get('system.apacheconf_vhost')) || is_dir(Settings::Get('system.apacheconf_vhost'))) { if ($ssl == '1') { $ssl_vhost = true; $ips_and_ports_index = 'ssl_ipandport'; } else { $ssl_vhost = false; $ips_and_ports_index = 'ipandport'; } // FIXME we get duplicate entries of a vhost if it has assigned more than one IP // 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); } } } return $included_vhosts; }
protected function createLighttpdHosts($ip, $port, $ssl, $vhost_filename) { $query = "SELECT * FROM " . TABLE_PANEL_IPSANDPORTS . " WHERE `ip`='" . $ip . "' AND `port`='" . $port . "'"; $ipandport = $this->db->query_first($query); if ($ssl == '0') { $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"; } 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"; } $included_vhosts = array(); $result_domains = $this->db->query($query2); while ($domain = $this->db->fetch_array($result_domains)) { if (is_dir($this->settings['system']['apacheconf_vhost'])) { safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir($this->settings['system']['apacheconf_vhost'] . '/vhosts/'))); // determine correct include-path: // e.g. '/etc/lighttpd/conf-enabled/vhosts/ has to become' // 'conf-enabled/vhosts/' (damn debian, but luckily works too on other distros) $_tmp_path = substr(makeCorrectDir($this->settings['system']['apacheconf_vhost']), 0, -1); $_pos = strrpos($_tmp_path, '/'); $_inc_path = substr($_tmp_path, $_pos + 1); if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) { $vhost_no = '52'; if ($ssl == '1') { $vhost_no = '62'; } } elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) { $vhost_no = '51'; if ($ssl == '1') { $vhost_no = '61'; } } else { $vhost_no = '50'; if ($ssl == '1') { $vhost_no = '60'; } } $vhost_filename = makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf'); $included_vhosts[] = $_inc_path . '/vhosts/' . $vhost_no . '_' . $domain['domain'] . '.conf'; } if (!isset($this->lighttpd_data[$vhost_filename])) { $this->lighttpd_data[$vhost_filename] = ''; } if (!empty($this->lighttpd_data[$vhost_filename]) && !is_dir($this->settings['system']['apacheconf_vhost']) || is_dir($this->settings['system']['apacheconf_vhost'])) { if ($ssl == '1') { $ssl_vhost = true; $ips_and_ports_index = 'ssl_ipandport'; } else { $ssl_vhost = false; $ips_and_ports_index = 'ipandport'; } $this->lighttpd_data[$vhost_filename] .= $this->getVhostContent($domain, $ssl_vhost); $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; }