Marius Burkard
2016-05-04 c3189ce6c7301c3ec17878fd3918f31d0d3cb18a
interface/web/sites/web_vhost_domain_edit.php
@@ -757,6 +757,7 @@
       * Now we have to check, if we should use the domain-module to select the domain
       * or not
       */
      $settings = $app->getconf->get_global_config('domains');
      if ($settings['use_domain_module'] == 'y') {
         /*
          * The domain-module is in use.
@@ -1304,6 +1305,32 @@
         $this->dataRecord['folder_directive_snippets'] = trim($this->dataRecord['folder_directive_snippets']);
      }
      
      // Check custom PHP version
      if(isset($this->dataRecord['fastcgi_php_version']) && $this->dataRecord['fastcgi_php_version'] != '') {
         // Check php-fpm mode
         if($this->dataRecord['php'] == 'php-fpm'){
            $tmp = $app->db->queryOneRecord("SELECT * FROM server_php WHERE CONCAT(name,':',php_fpm_init_script,':',php_fpm_ini_dir,':',php_fpm_pool_dir) = '".$app->db->quote($this->dataRecord['fastcgi_php_version'])."'");
            if(is_array($tmp)) {
               $this->dataRecord['fastcgi_php_version'] = $tmp['name'].':'.$tmp['php_fpm_init_script'].':'.$tmp['php_fpm_ini_dir'].':'.$tmp['php_fpm_pool_dir'];
            } else {
               $this->dataRecord['fastcgi_php_version'] = '';
            }
            unset($tmp);
         // Check fast-cgi mode
         } elseif($this->dataRecord['php'] == 'fast-cgi') {
            $tmp = $app->db->queryOneRecord("SELECT * FROM server_php WHERE CONCAT(name,':',php_fastcgi_binary,':',php_fastcgi_ini_dir) = '".$app->db->quote($this->dataRecord['fastcgi_php_version'])."'");
            if(is_array($tmp)) {
               $this->dataRecord['fastcgi_php_version'] = $tmp['name'].':'.$tmp['php_fastcgi_binary'].':'.$tmp['php_fastcgi_ini_dir'];
            } else {
               $this->dataRecord['fastcgi_php_version'] = '';
            }
            unset($tmp);
         } else {
            // Other PHP modes do not have custom versions, so we force the value to be empty
            $this->dataRecord['fastcgi_php_version'] = '';
         }
      }
      parent::onSubmit();
   }
@@ -1356,11 +1383,10 @@
         $php_open_basedir = str_replace("[website_path]", $document_root, $web_config["php_open_basedir"]);
         $php_open_basedir = str_replace("[website_domain]", $web_rec['domain'], $php_open_basedir);
         $htaccess_allow_override = $web_config["htaccess_allow_override"];
         $added_date = date($app->lng('conf_format_dateshort'));
         $added_by = $_SESSION['s']['user']['username'];
         $sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ?, added_date = ?, added_by = ?  WHERE domain_id = ?";
         $app->db->query($sql, $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_date, $added_by, $this->id);
         $sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ?, added_date = CURDATE(), added_by = ?  WHERE domain_id = ?";
         $app->db->query($sql, $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_by, $this->id);
      } else  {
         // Set the values for document_root, system_user and system_group
         $system_user = $this->parent_domain_record['system_user'];
@@ -1371,11 +1397,10 @@
         $php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir);
         $php_open_basedir = str_replace("[website_domain]", $web_rec['domain'], $php_open_basedir);
         $htaccess_allow_override = $this->parent_domain_record['allow_override'];
         $added_date = date($app->lng('conf_format_dateshort'));
         $added_by = $_SESSION['s']['user']['username'];
         
         $sql = "UPDATE web_domain SET sys_groupid = ?, system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ?, added_date = ?, added_by = ?  WHERE domain_id = ?";
         $app->db->query($sql, $this->parent_domain_record['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_date, $added_by, $this->id);
         $sql = "UPDATE web_domain SET sys_groupid = ?, system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ?, added_date = CURDATE(), added_by = ?  WHERE domain_id = ?";
         $app->db->query($sql, $this->parent_domain_record['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_by, $this->id);
      }
      if(isset($this->dataRecord['folder_directive_snippets'])) $app->db->query("UPDATE web_domain SET folder_directive_snippets = ? WHERE domain_id = ?", $this->dataRecord['folder_directive_snippets'], $this->id);
   }
@@ -1400,7 +1425,7 @@
         } else {
            //* We do not allow users to change a domain which has been created by the admin
            $rec = $app->db->queryOneRecord("SELECT sys_perm_group, domain, ip_address, ipv6_address from web_domain WHERE domain_id = ?", $this->id);
            if(isset($this->dataRecord["domain"]) && $rec['domain'] != $this->dataRecord["domain"] && $app->tform->checkPerm($this->id, 'u')) {
            if(isset($this->dataRecord["domain"]) && $rec['domain'] != $this->dataRecord["domain"] && !$app->tform->checkPerm($this->id, 'u')) {
               //* Add a error message and switch back to old server
               $app->tform->errorMessage .= $app->lng('The Domain can not be changed. Please ask your Administrator if you want to change the domain name.');
               $this->dataRecord["domain"] = $rec['domain'];