Marius Cramer
2014-02-10 5f29df751d026642fdf49adb2c160e8fbca73e77
interface/web/sites/web_vhost_subdomain_edit.php
@@ -91,7 +91,7 @@
      if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT client.limit_web_subdomain, client.default_webserver, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
         //* Get global web config
@@ -102,10 +102,10 @@
         if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
         if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
         if($this->dataRecord['php'] == 'php-fpm'){
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
         }
         if($this->dataRecord['php'] == 'fast-cgi'){
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
         }
         $php_select = "<option value=''>Default</option>";
         if(is_array($php_records) && !empty($php_records)) {
@@ -130,7 +130,7 @@
      } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT client.client_id, client.limit_web_subdomain, client.default_webserver, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
         //* Get global web config
@@ -141,10 +141,10 @@
         if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
         if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
         if($this->dataRecord['php'] == 'php-fpm'){
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
         }
         if($this->dataRecord['php'] == 'fast-cgi') {
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$parent_domain['server_id']." AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")");
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = ".$app->functions->intval($parent_domain['server_id'])." AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")");
         }
         $php_select = "<option value=''>Default</option>";
         if(is_array($php_records) && !empty($php_records)) {
@@ -176,10 +176,10 @@
         if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
         if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
         if($this->dataRecord['php'] == 'php-fpm'){
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $parent_domain['server_id']);
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = " . $app->functions->intval($parent_domain['server_id']));
         }
         if($this->dataRecord['php'] == 'fast-cgi') {
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $parent_domain['server_id']);
            $php_records = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fastcgi_binary != '' AND php_fastcgi_ini_dir != '' AND server_id = " . $app->functions->intval($parent_domain['server_id']));
         }
         $php_select = "<option value=''>Default</option>";
         if(is_array($php_records) && !empty($php_records)) {
@@ -203,7 +203,7 @@
         $php_directive_snippets_txt = '';
         if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
            foreach($php_directive_snippets as $php_directive_snippet){
               $php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$php_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$php_directive_snippet['snippet'].'</pre></a> ';
               $php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$php_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($php_directive_snippet['snippet']).'</pre></a> ';
            }
         }
         if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------';
@@ -214,7 +214,7 @@
            $apache_directive_snippets_txt = '';
            if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
               foreach($apache_directive_snippets as $apache_directive_snippet){
                  $apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$apache_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$apache_directive_snippet['snippet'].'</pre></a> ';
                  $apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$apache_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($apache_directive_snippet['snippet']).'</pre></a> ';
               }
            }
            if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------';
@@ -226,7 +226,7 @@
            $nginx_directive_snippets_txt = '';
            if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
               foreach($nginx_directive_snippets as $nginx_directive_snippet){
                  $nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$nginx_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$nginx_directive_snippet['snippet'].'</pre></a> ';
                  $nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$nginx_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($nginx_directive_snippet['snippet']).'</pre></a> ';
               }
            }
            if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------';
@@ -237,7 +237,7 @@
         $proxy_directive_snippets_txt = '';
         if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
            foreach($proxy_directive_snippets as $proxy_directive_snippet){
               $proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.$proxy_directive_snippet['snippet'].'</pre></a> ';
               $proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$proxy_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($proxy_directive_snippet['snippet']).'</pre></a> ';
            }
         }
         if($proxy_directive_snippets_txt == '') $proxy_directive_snippets_txt = '------';
@@ -246,13 +246,17 @@
      $ssl_domain_select = '';
      $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ".$this->id);
      $ssl_domains = array($tmp["domain"], 'www.'.$tmp["domain"]);
      $ssl_domains = array($tmp["domain"], 'www.'.$tmp["domain"], '*.'.$tmp["domain"]);
      if(is_array($ssl_domains)) {
         foreach( $ssl_domains as $ssl_domain) {
            $selected = ($ssl_domain == $this->dataRecord['ssl_domain'])?'SELECTED':'';
            $ssl_domain_select .= "<option value='$ssl_domain' $selected>$ssl_domain</option>\r\n";
         }
      }
      $app->tpl->setVar("ssl_domain", $ssl_domain_select);
      unset($ssl_domain_select);
      unset($ssl_domains);
      unset($ssl_domain);
      if($this->id > 0) {
         $app->tpl->setVar('fixed_folder', 'y');
@@ -261,11 +265,6 @@
         $app->tpl->setVar('fixed_folder', 'n');
         $app->tpl->setVar('server_id_value', $parent_domain['server_id']);
      }
      $app->tpl->setVar("ssl_domain", $ssl_domain_select);
      unset($ssl_domain_select);
      unset($ssl_domains);
      unset($ssl_domain);
      $tmp_txt = ($this->dataRecord['traffic_quota_lock'] == 'y')?'<b>('.$app->tform->lng('traffic_quota_exceeded_txt').')</b>':'';
      $app->tpl->setVar("traffic_quota_exceeded_txt", $tmp_txt);
@@ -307,6 +306,17 @@
         $this->dataRecord["domain"] = str_replace('.'.$parent_domain["domain"], '', $this->dataRecord["domain"]);
      }
      $app->tpl->setVar("domain", $this->dataRecord["domain"]);
      // check for configuration errors in sys_datalog
      if($this->id > 0) {
         $datalog = $app->db->queryOneRecord("SELECT sys_datalog.error, sys_log.tstamp FROM sys_datalog, sys_log WHERE sys_datalog.dbtable = 'web_domain' AND sys_datalog.dbidx = 'domain_id:".$app->functions->intval($this->id)."' AND sys_datalog.datalog_id = sys_log.datalog_id AND sys_log.message = CONCAT('Processed datalog_id ',sys_log.datalog_id) ORDER BY sys_datalog.tstamp DESC");
         if(is_array($datalog) && !empty($datalog)){
            if(trim($datalog['error']) != ''){
               $app->tpl->setVar("config_error_msg", nl2br(htmlentities($datalog['error'])));
               $app->tpl->setVar("config_error_tstamp", date($app->lng('conf_format_datetime'), $datalog['tstamp']));
            }
         }
      }
      parent::onShowEnd();
   }
@@ -381,7 +391,7 @@
      if($_SESSION["s"]["user"]["typ"] != 'admin') {
         // Get the limits of the client
         $client_group_id = $_SESSION["s"]["user"]["default_group"];
         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
         $client = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, default_webserver, parent_client_id, limit_web_quota, client." . implode(", client.", $read_limits) . " FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
         if($client['limit_cgi'] != 'y') $this->dataRecord['cgi'] = '-';
@@ -389,7 +399,7 @@
         if($client['limit_perl'] != 'y') $this->dataRecord['perl'] = '-';
         if($client['limit_ruby'] != 'y') $this->dataRecord['ruby'] = '-';
         if($client['limit_python'] != 'y') $this->dataRecord['python'] = '-';
         if($client['force_suexec'] != 'n') $this->dataRecord['suexec'] = 'y';
         if($client['force_suexec'] == 'y') $this->dataRecord['suexec'] = 'y';
         if($client['limit_hterror'] != 'y') $this->dataRecord['errordocs'] = '-';
         if($client['limit_wildcard'] != 'y' && $this->dataRecord['subdomain'] == '*') $this->dataRecord['subdomain'] = '-';
         if($client['limit_ssl'] != 'y') $this->dataRecord['ssl'] = '-';
@@ -398,7 +408,7 @@
         if($this->id > 0) {
            $old_web_values = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($this->id));
         } else {
            $old_web_values = $_POST;
            $old_web_values = array();
         }
         //* Check the traffic quota of the client
@@ -419,7 +429,7 @@
         if($client['parent_client_id'] > 0) {
            // Get the limits of the reseller
            $reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, default_webserver, limit_web_quota FROM client WHERE client_id = ".$client['parent_client_id']);
            $reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota, limit_web_subdomain, default_webserver, limit_web_quota FROM client WHERE client_id = ".$app->functions->intval($client['parent_client_id']));
            //* Check the traffic quota of the client
            if(isset($_POST["traffic_quota"]) && $reseller["limit_traffic_quota"] > 0 && $_POST["traffic_quota"] != $old_web_values["traffic_quota"]) {