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;
 }
 /**
  * We compose the virtualhost entries for the domains
  */
 public function createVirtualHosts()
 {
     $domains = WebserverBase::getVhostsToCreate();
     foreach ($domains as $domain) {
         fwrite($this->debugHandler, '  apache::createVirtualHosts: creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname'] . "\n");
         $this->logger->logAction(CRON_ACTION, LOG_INFO, 'creating vhost container for domain ' . $domain['id'] . ', customer ' . $domain['loginname']);
         $vhosts_filename = $this->getVhostFilename($domain);
         // Apply header
         $this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: '******'loginname'] . "\n";
         if ($domain['deactivated'] != '1' || Settings::Get('system.deactivateddocroot') != '') {
             // Create vhost without ssl
             $this->virtualhosts_data[$vhosts_filename] .= $this->getVhostContent($domain, false);
             if ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1') {
                 // Adding ssl stuff if enabled
                 $vhosts_filename_ssl = $this->getVhostFilename($domain, true);
                 $this->virtualhosts_data[$vhosts_filename_ssl] = '# Domain ID: ' . $domain['id'] . ' (SSL) - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: '******'loginname'] . "\n";
                 $this->virtualhosts_data[$vhosts_filename_ssl] .= $this->getVhostContent($domain, true);
             }
         } else {
             $this->virtualhosts_data[$vhosts_filename] .= '# Customer deactivated and a docroot for deactivated users hasn\'t been set.' . "\n";
         }
     }
 }
 /**
  * create vhosts
  */
 protected function createNginxHosts()
 {
     $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'))));
         }
         $vhost_filename = $this->getVhostFilename($domain);
         if (!isset($this->nginx_data[$vhost_filename])) {
             $this->nginx_data[$vhost_filename] = '';
         }
         if (empty($this->nginx_data[$vhost_filename]) && !is_dir(Settings::Get('system.apacheconf_vhost')) || is_dir(Settings::Get('system.apacheconf_vhost'))) {
             // Create non-ssl host
             $this->nginx_data[$vhost_filename] .= $this->getVhostContent($domain, false);
             if ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1') {
                 $vhost_filename_ssl = $this->getVhostFilename($domain, true);
                 if (!isset($this->nginx_data[$vhost_filename_ssl])) {
                     $this->nginx_data[$vhost_filename_ssl] = '';
                 }
                 // Now enable ssl stuff
                 $this->nginx_data[$vhost_filename_ssl] .= $this->getVhostContent($domain, true);
             }
         }
     }
 }