Marius Cramer
2014-04-23 9b3069a1eacd3cbda0bfe565925e80f667f6c96d
server/plugins-available/nginx_plugin.inc.php
@@ -102,7 +102,7 @@
         $app->log("CA path error, file does not exist:".$web_config['CA_path'].'/openssl.cnf', LOGLEVEL_ERROR);
      //* Only vhosts can have a ssl cert
      if($data["new"]["type"] != "vhost" && $data["new"]["type"] != "vhostsubdomain") return;
      if($data["new"]["type"] != "vhost" && $data["new"]["type"] != "vhostsubdomain" && $data["new"]["type"] != "vhostalias") return;
      // if(!is_dir($data['new']['document_root'].'/ssl')) exec('mkdir -p '.$data['new']['document_root'].'/ssl');
      if(!is_dir($data['new']['document_root'].'/ssl')) $app->system->mkdirpath($data['new']['document_root'].'/ssl');
@@ -314,7 +314,7 @@
      if($this->action != 'insert') $this->action = 'update';
      if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['parent_domain_id'] > 0) {
      if($data['new']['type'] != 'vhost' && $data['new']['type'] != 'vhostsubdomain' && $data['new']['type'] != 'vhostalias' && $data['new']['parent_domain_id'] > 0) {
         $old_parent_domain_id = intval($data['old']['parent_domain_id']);
         $new_parent_domain_id = intval($data['new']['parent_domain_id']);
@@ -348,7 +348,7 @@
      }
      if($data['new']['document_root'] == '') {
         if($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain') $app->log('document_root not set', LOGLEVEL_WARN);
         if($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') $app->log('document_root not set', LOGLEVEL_WARN);
         return 0;
      }
      if($data['new']['system_user'] == 'root' or $data['new']['system_group'] == 'root') {
@@ -362,13 +362,26 @@
      $web_folder = 'web';
      $log_folder = 'log';
      if($data['new']['type'] == 'vhostsubdomain') {
      $old_web_folder = 'web';
      $old_log_folder = 'log';
      if($data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') {
         // new one
         $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id']));
         $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']);
         if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id'];
         $web_folder = $data['new']['web_folder'];
         $log_folder .= '/' . $subdomain_host;
         unset($tmp);
         if(isset($data['old']['parent_domain_id'])) {
            // old one
            $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id']));
            $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']);
            if($subdomain_host == '') $subdomain_host = 'web'.$data['old']['domain_id'];
            $old_web_folder = $data['old']['web_folder'];
            $old_log_folder .= '/' . $subdomain_host;
            unset($tmp);
         }
      }
      // Create group and user, if not exist
@@ -436,7 +449,7 @@
            }
         }
         if($data["new"]["type"] != "vhostsubdomain") {
         if($data["new"]["type"] != "vhostsubdomain" && $data["new"]["type"] != "vhostalias") {
            //* Move the site data
            $tmp_docroot = explode('/', $data['new']['document_root']);
            unset($tmp_docroot[count($tmp_docroot)-1]);
@@ -477,9 +490,11 @@
         if($nginx_chrooted) $this->_exec('chroot '.escapeshellcmd($web_config['website_basedir']).' '.$command);
         //* Change the log mount
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$log_folder.'    none    bind';
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.'    none    bind';
         $app->system->removeLine('/etc/fstab', $fstab_line);
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind,nobootwait    0 0';
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.'    none    bind,nobootwait';
         $app->system->removeLine('/etc/fstab', $fstab_line);
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind,nobootwait,_netdev    0 0';
         $app->system->replaceLine('/etc/fstab', $fstab_line, $fstab_line, 1, 1);
      }
@@ -509,14 +524,14 @@
      // Remove the symlink for the site, if site is renamed
      if($this->action == 'update' && $data['old']['domain'] != '' && $data['new']['domain'] != $data['old']['domain']) {
         if(is_dir('/var/log/ispconfig/httpd/'.$data['old']['domain'])) exec('rm -rf /var/log/ispconfig/httpd/'.$data['old']['domain']);
         if(is_link($data['old']['document_root'].'/'.$log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$log_folder);
         if(is_link($data['old']['document_root'].'/'.$old_log_folder)) $app->system->unlink($data['old']['document_root'].'/'.$old_log_folder);
         //* remove old log mount
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$log_folder.'    none    bind';
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['old']['domain'].' '.$data['old']['document_root'].'/'.$old_log_folder.'    none    bind';
         $app->system->removeLine('/etc/fstab', $fstab_line);
         //* Unmount log directory
         exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder));
         exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$old_log_folder));
      }
      //* Create the log dir if nescessary and mount it
@@ -529,7 +544,7 @@
         $app->system->chmod($data['new']['document_root'].'/'.$log_folder, 0755);
         exec('mount --bind '.escapeshellarg('/var/log/ispconfig/httpd/'.$data['new']['domain']).' '.escapeshellarg($data['new']['document_root'].'/'.$log_folder));
         //* add mountpoint to fstab
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind,nobootwait    0 0';
         $fstab_line = '/var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/'.$log_folder.'    none    bind,nobootwait,_netdev    0 0';
         $app->system->replaceLine('/etc/fstab', $fstab_line, $fstab_line, 1, 1);
      }
@@ -592,7 +607,7 @@
      // setting a local var here
      // normally $conf['templates'] = "/usr/local/ispconfig/server/conf";
      if($this->action == 'insert' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
      if($this->action == 'insert' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias')) {
         // Copy the error pages
         if($data['new']['errordocs']) {
@@ -638,7 +653,7 @@
         exec('chmod -R a+r '.escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/');
         //** Copy the error documents on update when the error document checkbox has been activated and was deactivated before
      } elseif ($this->action == 'update' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain') && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
      } elseif ($this->action == 'update' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') && $data['old']['errordocs'] == 0 && $data['new']['errordocs'] == 1) {
         $error_page_path = escapeshellcmd($data['new']['document_root']).'/' . $web_folder . '/error/';
         if (file_exists($conf['rootpath'] . '/conf-custom/error/'.substr(escapeshellcmd($conf['language']), 0, 2))) {
@@ -656,7 +671,7 @@
         exec('chown -R '.$data['new']['system_user'].':'.$data['new']['system_group'].' '.$error_page_path);
      }  // end copy error docs
      // Set the quota for the user, but only for vhosts, not vhostsubdomains
      // Set the quota for the user, but only for vhosts, not vhostsubdomains or vhostalias
      if($username != '' && $app->system->is_user($username) && $data['new']['type'] == 'vhost') {
         if($data['new']['hd_quota'] > 0) {
            $blocks_soft = $data['new']['hd_quota'] * 1024;
@@ -693,7 +708,7 @@
         if($web_config['security_level'] == 20) {
            $app->system->chmod($data['new']['document_root'], 0755);
            $app->system->chmod($data['new']['document_root'].'/web', 0710);
            $app->system->chmod($data['new']['document_root'].'/web', 0711);
            //$app->system->chmod($data['new']['document_root'].'/webdav',0710);
            $app->system->chmod($data['new']['document_root'].'/private', 0710);
            $app->system->chmod($data['new']['document_root'].'/ssl', 0755);
@@ -788,7 +803,9 @@
            //$app->system->chown($data['new']['document_root'].'/webdav',$username);
            //$app->system->chgrp($data['new']['document_root'].'/webdav',$groupname);
         }
      } elseif(($this->action == 'insert' && $data['new']['type'] == 'vhostsubdomain') or ($web_config['set_folder_permissions_on_update'] == 'y' && $data['new']['type'] == 'vhostsubdomain')) {
      } elseif((($data['new']['type'] == 'vhostsubdomain') || ($data['new']['type'] == 'vhostalias')) &&
             (($this->action == 'insert') || ($web_config['set_folder_permissions_on_update'] == 'y'))) {
         if($web_config['security_level'] == 20) {
            $app->system->chmod($data['new']['document_root'].'/' . $web_folder, 0710);
            $app->system->chown($data['new']['document_root'].'/' . $web_folder, $username);
@@ -984,6 +1001,18 @@
                  $final_rewrite_rules[] = array('rewrite_rule' => $custom_rewrite_rule_line);
                  continue;
               }
               if(preg_match('@^\s*rewrite\s+(^/)?(\'[^\']+\'|"[^"]+")+(\$)?\s+(\'[^\']+\'|"[^"]+")+(\s+(last|break|redirect|permanent|))?\s*;\s*$@', $custom_rewrite_rule_line)){
                  $final_rewrite_rules[] = array('rewrite_rule' => $custom_rewrite_rule_line);
                  continue;
               }
               if(preg_match('@^\s*rewrite\s+(^/)?(\'[^\']+\'|"[^"]+")+(\$)?\s+\S+(\s+(last|break|redirect|permanent|))?\s*;\s*$@', $custom_rewrite_rule_line)){
                  $final_rewrite_rules[] = array('rewrite_rule' => $custom_rewrite_rule_line);
                  continue;
               }
               if(preg_match('@^\s*rewrite\s+(^/)?\S+(\$)?\s+(\'[^\']+\'|"[^"]+")+(\s+(last|break|redirect|permanent|))?\s*;\s*$@', $custom_rewrite_rule_line)){
                  $final_rewrite_rules[] = array('rewrite_rule' => $custom_rewrite_rule_line);
                  continue;
               }
               // if
               if(preg_match('@^\s*if\s+\(\s*\$\S+(\s+(\!?(=|~|~\*))\s+(\S+|\".+\"))?\s*\)\s*\{\s*$@', $custom_rewrite_rule_line)){
                  $final_rewrite_rules[] = array('rewrite_rule' => $custom_rewrite_rule_line);
@@ -1041,8 +1070,9 @@
      $nginx_directives = str_replace("\r", "\n", $nginx_directives);
      $nginx_directive_lines = explode("\n", $nginx_directives);
      if(is_array($nginx_directive_lines) && !empty($nginx_directive_lines)){
         $trans = array('{DOCROOT}' => $vhost_data['web_document_root_www'], '{FASTCGIPASS}' => 'fastcgi_pass '.($data['new']['php_fpm_use_socket'] == 'y'? 'unix:'.$fpm_socket : '127.0.0.1:'.$vhost_data['fpm_port']).';');
         foreach($nginx_directive_lines as $nginx_directive_line){
            $final_nginx_directives[] = array('nginx_directive' => $nginx_directive_line);
            $final_nginx_directives[] = array('nginx_directive' => strtr($nginx_directive_line, $trans));
         }
      }
      $tpl->setLoop('nginx_directives', $final_nginx_directives);
@@ -1292,7 +1322,7 @@
      }
      // get alias domains (co-domains and subdomains)
      $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND type != 'vhostsubdomain'");
      $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND (type != 'vhostsubdomain' AND type != 'vhostalias')");
      $alias_seo_redirects = array();
      if(is_array($aliases)) {
         foreach($aliases as $alias) {
@@ -1609,7 +1639,7 @@
      }
      //* Create awstats configuration
      if($data['new']['stats_type'] == 'awstats' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain')) {
      if($data['new']['stats_type'] == 'awstats' && ($data['new']['type'] == 'vhost' || $data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias')) {
         $this->awstats_update($data, $web_config);
      }
@@ -1727,7 +1757,7 @@
      $app->uses('system');
      $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
      if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain') $app->system->web_folder_protection($data['old']['document_root'], false);
      if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') $app->system->web_folder_protection($data['old']['document_root'], false);
      //* Check if this is a chrooted setup
      if($web_config['website_basedir'] != '' && @is_file($web_config['website_basedir'].'/etc/passwd')) {
@@ -1739,7 +1769,7 @@
      //* Remove the mounts
      $log_folder = 'log';
      $web_folder = '';
      if($data['old']['type'] == 'vhostsubdomain') {
      if($data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') {
         $tmp = $app->db->queryOneRecord('SELECT `domain`,`document_root` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id']));
         if($tmp['domain'] != ''){
            $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']);
@@ -1785,7 +1815,7 @@
         unset($subdomain_hosts);
      }
      if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain'){
      if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias'){
         if(is_array($log_folders) && !empty($log_folders)){
            foreach($log_folders as $log_folder){
               //if($app->system->is_mounted($data['old']['document_root'].'/'.$log_folder)) exec('umount '.escapeshellarg($data['old']['document_root'].'/'.$log_folder));
@@ -1809,7 +1839,7 @@
      }
      unset($log_folders);
      if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['parent_domain_id'] > 0) {
      if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['type'] != 'vhostalias' && $data['old']['parent_domain_id'] > 0) {
         //* This is a alias domain or subdomain, so we have to update the website instead
         $parent_domain_id = intval($data['old']['parent_domain_id']);
         $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'");
@@ -1843,7 +1873,7 @@
         $app->system->unlink($vhost_file);
         $app->log('Removing vhost file: '.$vhost_file, LOGLEVEL_DEBUG);
         if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain') {
         if($data['old']['type'] == 'vhost' || $data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') {
            $docroot = escapeshellcmd($data['old']['document_root']);
            if($docroot != '' && !stristr($docroot, '..')) {
               if($data['old']['type'] == 'vhost') {
@@ -1866,7 +1896,7 @@
                  } else {
                     // read all vhost subdomains with same parent domain
                     $used_paths = array();
                     $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE type = 'vhostsubdomain' AND parent_domain_id = ".intval($data['old']['parent_domain_id'])." AND domain_id != ".intval($data['old']['domain_id']));
                     $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ".intval($data['old']['parent_domain_id'])." AND domain_id != ".intval($data['old']['domain_id']));
                     foreach($tmp as $tmprec) {
                        // we normalize the folder entries because we need to compare them
                        $tmp_folder = preg_replace('/[\/]{2,}/', '/', $tmprec['web_folder']); // replace / occuring multiple times
@@ -2022,7 +2052,7 @@
      }
      $web_folder = 'web';
      if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
      if($website['type'] == 'vhostsubdomain' || $website['type'] == 'vhostalias') $web_folder = $website['web_folder'];
      //* Get the folder path.
      if(substr($folder['path'], 0, 1) == '/') $folder['path'] = substr($folder['path'], 1);
@@ -2038,9 +2068,7 @@
      //* Create the folder path, if it does not exist
      if(!is_dir($folder_path)) {
         $app->system->mkdirpath($folder_path);
         $app->system->chown($folder_path, $website['system_user']);
         $app->system->chgrp($folder_path, $website['system_group']);
         $app->system->mkdirpath($folder_path, 0755, $website['system_user'], $website['system_group']);
      }
      //* Create empty .htpasswd file, if it does not exist
@@ -2101,7 +2129,7 @@
      }
      $web_folder = 'web';
      if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
      if($website['type'] == 'vhostsubdomain' || $website['type'] == 'vhostalias') $web_folder = $website['web_folder'];
      //* Get the folder path.
      if(substr($folder['path'], 0, 1) == '/') $folder['path'] = substr($folder['path'], 1);
@@ -2138,7 +2166,7 @@
      }
      $web_folder = 'web';
      if($website['type'] == 'vhostsubdomain') $web_folder = $website['web_folder'];
      if($website['type'] == 'vhostsubdomain' || $website['type'] == 'vhostalias') $web_folder = $website['web_folder'];
      //* Get the folder path.
      if(substr($data['old']['path'], 0, 1) == '/') $data['old']['path'] = substr($data['old']['path'], 1);
@@ -2209,7 +2237,7 @@
               $website_auth_location['path'] .= '/';
            }
            $basic_auth_locations[] = array('htpasswd_location' => '/'.$website_auth_location['path'],
               'htpasswd_path' => $website['document_root'].'/' . ($website['type'] == 'vhostsubdomain' ? $website['web_folder'] : 'web') . '/'.$website_auth_location['path']);
               'htpasswd_path' => $website['document_root'].'/' . (($website['type'] == 'vhostsubdomain' || $website['type'] == 'vhostalias') ? $website['web_folder'] : 'web') . '/'.$website_auth_location['path']);
         }
      }
      return $basic_auth_locations;
@@ -2235,13 +2263,22 @@
         }
         $content = '';
         $content .= "Include \"".$awstats_conf_dir."/awstats.conf\"\n";
         if (is_file($awstats_conf_dir."/awstats.conf")) {
            $include_file = $awstats_conf_dir."/awstats.conf";
         } elseif (is_file($awstats_conf_dir."/awstats.model.conf")) {
            $include_file = $awstats_conf_dir."/awstats.model.conf";
         }
         $content .= "Include \"".$include_file."\"\n";
         $content .= "LogFile=\"/var/log/ispconfig/httpd/".$data['new']['domain']."/access.log\"\n";
         $content .= "SiteDomain=\"".$data['new']['domain']."\"\n";
         $content .= "HostAliases=\"www.".$data['new']['domain']."  localhost 127.0.0.1\"\n";
         $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
         $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
         if (isset($include_file)) {
            $app->system->file_put_contents($awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', $content);
            $app->log('Created AWStats config file: '.$awstats_conf_dir.'/awstats.'.$data['new']['domain'].'.conf', LOGLEVEL_DEBUG);
         } else {
            $app->log("No awstats base config found. Either awstats.conf or awstats.model.conf must exist in ".$awstats_conf_dir.".", LOGLEVEL_WARN);
         }
      }
      if(is_file($data['new']['document_root']."/" . $web_folder . "/stats/index.html")) $app->system->unlink($data['new']['document_root']."/" . $web_folder . "/stats/index.html");
@@ -2329,6 +2366,7 @@
      $fpm_socket = $socket_dir.$pool_name.'.sock';
      $tpl->setVar('fpm_socket', $fpm_socket);
      $tpl->setVar('fpm_listen_mode', '0660');
      $tpl->setVar('fpm_pool', $pool_name);
      $tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id'] - 1);
@@ -2343,6 +2381,7 @@
      $tpl->setVar('pm_max_requests', $data['new']['pm_max_requests']);
      $tpl->setVar('document_root', $data['new']['document_root']);
      $tpl->setVar('security_level', $web_config['security_level']);
      $tpl->setVar('domain', $data['new']['domain']);
      $php_open_basedir = ($data['new']['php_open_basedir'] == '')?escapeshellcmd($data['new']['document_root']):escapeshellcmd($data['new']['php_open_basedir']);
      $tpl->setVar('php_open_basedir', $php_open_basedir);
      if($php_open_basedir != ''){
@@ -2365,9 +2404,9 @@
               if(substr($ini_setting, 0, 1) == ';') continue;
               if(substr($ini_setting, 0, 1) == '#') continue;
               if(substr($ini_setting, 0, 2) == '//') continue;
               list($key, $value) = explode('=', $ini_setting);
               if($value){
                  $value = trim($value);
               list($key, $value) = explode('=', $ini_setting, 2);
               $value = trim($value);
               if($value != ''){
                  $key = trim($key);
                  switch (strtolower($value)) {
                  case '0':
@@ -2712,7 +2751,7 @@
            // web domain doesn't match hostname
            if(substr($hostname, -strlen($web['domain'])) != $web['domain']) continue;
            // own vhost and therefore server {} container of its own
            //if($web['type'] == 'vhostsubdomain') continue;
            //if($web['type'] == 'vhostsubdomain' || $web['type'] == 'vhostalias') continue;
            // alias domains/subdomains using rewrites and therefore a server {} container of their own
            //if(($web['type'] == 'alias' || $web['type'] == 'subdomain') && $web['redirect_type'] != '' && $web['redirect_path'] != '') continue;
@@ -2723,7 +2762,7 @@
               if($web['domain'] == $hostname){
                  if($web['domain_id'] == $domain_id || $web['parent_domain_id'] == $domain_id){
                     // own vhost and therefore server {} container of its own
                     if($web['type'] == 'vhostsubdomain') return false;
                     if($web['type'] == 'vhostsubdomain' || $web['type'] == 'vhostalias') return false;
                     // alias domains/subdomains using rewrites and therefore a server {} container of their own
                     if(($web['type'] == 'alias' || $web['type'] == 'subdomain') && $web['redirect_type'] != '' && $web['redirect_path'] != '') return false;
                     return true;
@@ -2737,7 +2776,7 @@
               if($web['domain'] == $hostname || $web['subdomain'].'.'.$web['domain'] == $hostname){
                  if($web['domain_id'] == $domain_id || $web['parent_domain_id'] == $domain_id){
                     // own vhost and therefore server {} container of its own
                     if($web['type'] == 'vhostsubdomain') return false;
                     if($web['type'] == 'vhostsubdomain' || $web['type'] == 'vhostalias') return false;
                     // alias domains/subdomains using rewrites and therefore a server {} container of their own
                     if(($web['type'] == 'alias' || $web['type'] == 'subdomain') && $web['redirect_type'] != '' && $web['redirect_path'] != '') return false;
                     return true;
@@ -2750,7 +2789,7 @@
            if(preg_match($pattern, $hostname)){
               if($web['domain_id'] == $domain_id || $web['parent_domain_id'] == $domain_id){
                  // own vhost and therefore server {} container of its own
                  if($web['type'] == 'vhostsubdomain') return false;
                  if($web['type'] == 'vhostsubdomain' || $web['type'] == 'vhostalias') return false;
                  // alias domains/subdomains using rewrites and therefore a server {} container of their own
                  if(($web['type'] == 'alias' || $web['type'] == 'subdomain') && $web['redirect_type'] != '' && $web['redirect_path'] != '') return false;
                  return true;