Marius Cramer
2014-02-28 1aece9b8d53b51f3ce02241d96d7a1b2f38455db
interface/web/sites/web_vhost_domain_edit.php
@@ -188,7 +188,7 @@
         //* Fill the IPv4 select field with the IP addresses that are allowed for this client
         $sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
         $ip_select = ($web_config[$server_id]['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
         //if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
         //$ip_select = "";
         if(is_array($ips)) {
@@ -218,7 +218,7 @@
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
         if(!empty($web_config[$server_id]['server_type'])) $server_type = $web_config[$server_id]['server_type'];
         if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
         if($this->_vhostdomain_type == 'domain') {
@@ -319,7 +319,7 @@
         //* Fill the IPv4 select field with the IP addresses that are allowed for this client
         $sql = "SELECT ip_address FROM server_ip WHERE server_id IN (" . $client['web_servers'] . ") AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
         $ips = $app->db->queryAllRecords($sql);
         $ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
         $ip_select = ($web_config[$server_id]['enable_ip_wildcard'] == 'y')?"<option value='*'>*</option>":"";
         //if(!in_array($this->dataRecord["ip_address"], $ips)) $ip_select .= "<option value='".$this->dataRecord["ip_address"]."' SELECTED>".$this->dataRecord["ip_address"]."</option>\r\n";
         //$ip_select = "";
         if(is_array($ips)) {
@@ -349,7 +349,7 @@
         //PHP Version Selection (FastCGI)
         $server_type = 'apache';
         if(!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
         if(!empty($web_config[$server_id]['server_type'])) $server_type = $web_config[$server_id]['server_type'];
         if($server_type == 'nginx' && $this->dataRecord['php'] == 'fast-cgi') $this->dataRecord['php'] = 'php-fpm';
         $selected_client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ".$app->functions->intval($selected_client_group_id));
         //$sql_where = " AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id']." OR client_id = ".intval($selected_client['client_id']).")";
@@ -1003,6 +1003,35 @@
            $app->tform->errorMessage .= $app->tform->lng("invalid_rewrite_rules_txt").'<br>';
         }
      }
      // check custom php.ini settings
      if(isset($this->dataRecord['custom_php_ini']) && trim($this->dataRecord['custom_php_ini']) != '') {
         $custom_php_ini_settings = trim($this->dataRecord['custom_php_ini']);
         $custom_php_ini_settings_are_valid = true;
         // Make sure we only have Unix linebreaks
         $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
         $custom_php_ini_settings = str_replace("\r", "\n", $custom_php_ini_settings);
         $custom_php_ini_settings_lines = explode("\n", $custom_php_ini_settings);
         if(is_array($custom_php_ini_settings_lines) && !empty($custom_php_ini_settings_lines)){
            foreach($custom_php_ini_settings_lines as $custom_php_ini_settings_line){
               if(trim($custom_php_ini_settings_line) == '') continue;
               if(substr(trim($custom_php_ini_settings_line),0,1) == ';') continue;
               // empty value
               if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
               // value inside ""
               if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*".*"\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
               // value inside ''
               if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*\'.*\'\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
               // everything else
               if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*[-a-zA-Z0-9~&=_\@/,.#\s]*\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
               $custom_php_ini_settings_are_valid = false;
               break;
            }
         }
         if(!$custom_php_ini_settings_are_valid){
            $app->tform->errorMessage .= $app->tform->lng("invalid_custom_php_ini_settings_txt").'<br>';
         }
      }
      parent::onSubmit();
   }