diff --git a/interface/lib/classes/validate_domain.inc.php b/interface/lib/classes/validate_domain.inc.php
new file mode 100644
index 0000000000000000000000000000000000000000..25f16af682e0587d1c03050190e68abf42c49304
--- /dev/null
+++ b/interface/lib/classes/validate_domain.inc.php
@@ -0,0 +1,115 @@
+tform->wordbook[$errmsg])) {
+ return $app->tform->wordbook[$errmsg]."
\r\n";
+ } else {
+ return $errmsg."
\r\n";
+ }
+ }
+
+ /* Validator function for domain (website) */
+ function web_domain($field_name, $field_value, $validator) {
+ if(empty($field_value)) return $this->get_error('domain_error_empty');
+
+ // do not allow wildcards on website domains
+ $result = $this->_regex_validate($field_value);
+ if(!$result) return $this->get_error('domain_error_regex');
+
+ $result = $this->_check_unique($field_value);
+ if(!$result) return $this->get_error('domain_error_unique');
+ }
+
+ /* Validator function for sub domain */
+ function sub_domain($field_name, $field_value, $validator) {
+ if(empty($field_value)) return $this->get_error('domain_error_empty');
+
+ $allow_wildcard = $this->_wildcard_limit();
+ if($allow_wildcard == false && substr($field_value, 0, 2) === '*.') return $this->get_error('domain_error_wildcard');
+
+ $result = $this->_regex_validate($field_value, $allow_wildcard);
+ if(!$result) return $this->get_error('domain_error_regex');
+
+ $result = $this->_check_unique($field_value);
+ if(!$result) return $this->get_error('domain_error_unique');
+ }
+
+ /* Validator function for alias domain */
+ function alias_domain($field_name, $field_value, $validator) {
+ if(empty($field_value)) return $this->get_error('domain_error_empty');
+
+ // do not allow wildcards on alias domains
+ $result = $this->_regex_validate($field_value);
+ if(!$result) return $this->get_error('domain_error_regex');
+
+ $result = $this->_check_unique($field_value);
+ if(!$result) return $this->get_error('domain_error_unique');
+ }
+
+ /* internal validator function to match regexp */
+ function _regex_validate($domain_name, $allow_wildcard = false) {
+ $pattern = '/^' . ($allow_wildcard == true ? '(\*\.)?' : '') . '[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/';
+ return preg_match($pattern, $domain_name);
+ }
+
+ /* check if the domain hostname is unique (keep in mind the auto subdomains!) */
+ function _check_unique($domain_name) {
+ global $app;
+
+ $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `domain` = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . intval($app->tform->primary_id));
+ if($check['cnt'] > 0) return false;
+
+ $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE CONCAT(`subdomain`, '.', `domain`) = '" . $app->db->quote($domain_name) . "' AND `domain_id` != " . intval($app->tform->primary_id));
+ if($check['cnt'] > 0) return false;
+
+ return true;
+ }
+
+ /* check if the client may add wildcard domains */
+ function _wildcard_limit() {
+ global $app;
+
+ if($_SESSION["s"]["user"]["typ"] != 'admin') {
+ // Get the limits of the client
+ $client_group_id = $_SESSION["s"]["user"]["default_group"];
+ $client = $app->db->queryOneRecord("SELECT limit_wildcard FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+
+ if($client["limit_wildcard"] == 'y') return true;
+ else return false;
+ }
+ return true; // admin may always add wildcard domain
+ }
+}
\ No newline at end of file
diff --git a/interface/web/sites/form/web_aliasdomain.tform.php b/interface/web/sites/form/web_aliasdomain.tform.php
index 9507aa0663123ceb535e5b4fe10914ba5d75a331..69cf83135c802906d098a60b32f946698f1c03ed 100644
--- a/interface/web/sites/form/web_aliasdomain.tform.php
+++ b/interface/web/sites/form/web_aliasdomain.tform.php
@@ -72,14 +72,11 @@ $form["tabs"]['domain'] = array (
'domain' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'domain_error_empty'),
- 1 => array ( 'type' => 'UNIQUE',
- 'errmsg'=> 'domain_error_unique'),
- 2 => array ( 'type' => 'REGEX',
- 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/',
- 'errmsg'=> 'domain_error_regex'),
- ),
+ 'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
+ 'class' => 'validate_domain',
+ 'function' => 'alias_domain',
+ 'errmsg'=> 'domain_error_regex'),
+ ),
'default' => '',
'value' => '',
'width' => '30',
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php
index 467376cab6824b00da7aec6d942231c0100da2ea..1deec48ad2d29f2b272b8f892bd0ff2ca58c2cec 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_domain.tform.php
@@ -119,14 +119,11 @@ $form["tabs"]['domain'] = array (
'domain' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'domain_error_empty'),
- 1 => array ( 'type' => 'UNIQUE',
- 'errmsg'=> 'domain_error_unique'),
- 2 => array ( 'type' => 'REGEX',
- 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/',
- 'errmsg'=> 'domain_error_regex'),
- ),
+ 'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
+ 'class' => 'validate_domain',
+ 'function' => 'web_domain',
+ 'errmsg'=> 'domain_error_regex'),
+ ),
'filters' => array ( 0 => array ( 'event' => 'SAVE',
'type' => 'TOLOWER'),
),
diff --git a/interface/web/sites/form/web_subdomain.tform.php b/interface/web/sites/form/web_subdomain.tform.php
index 9b2744b682826d8f60829633ebbf9b15891e5853..d8d6c2c523628b00bf31241ff140ad2568ddc2fe 100644
--- a/interface/web/sites/form/web_subdomain.tform.php
+++ b/interface/web/sites/form/web_subdomain.tform.php
@@ -72,14 +72,11 @@ $form["tabs"]['domain'] = array (
'domain' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'domain_error_empty'),
- 1 => array ( 'type' => 'UNIQUE',
- 'errmsg'=> 'domain_error_unique'),
- 2 => array ( 'type' => 'REGEX',
- 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/',
- 'errmsg'=> 'domain_error_regex'),
- ),
+ 'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
+ 'class' => 'validate_domain',
+ 'function' => 'sub_domain',
+ 'errmsg'=> 'domain_error_regex'),
+ ),
'default' => '',
'value' => '',
'width' => '30',
diff --git a/interface/web/sites/form/web_vhost_subdomain.tform.php b/interface/web/sites/form/web_vhost_subdomain.tform.php
index 1b257671208a40f5a9f54e5d96ba234a39b606eb..3440eba590655a6a46a46bcfde88ee324913d79f 100644
--- a/interface/web/sites/form/web_vhost_subdomain.tform.php
+++ b/interface/web/sites/form/web_vhost_subdomain.tform.php
@@ -111,14 +111,11 @@ $form["tabs"]['domain'] = array (
'domain' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'domain_error_empty'),
- 1 => array ( 'type' => 'UNIQUE',
- 'errmsg'=> 'domain_error_unique'),
- 2 => array ( 'type' => 'REGEX',
- 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/',
- 'errmsg'=> 'domain_error_regex'),
- ),
+ 'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
+ 'class' => 'validate_domain',
+ 'function' => 'sub_domain',
+ 'errmsg'=> 'domain_error_regex'),
+ ),
'default' => '',
'value' => '',
'width' => '30',
diff --git a/interface/web/sites/lib/lang/de_web_subdomain.lng b/interface/web/sites/lib/lang/de_web_subdomain.lng
index 9621a1f2a5a1b94b3413f333b7a37e039724b6ee..20565fd44dfd08a75ed9388c08b08d82c1644591 100644
--- a/interface/web/sites/lib/lang/de_web_subdomain.lng
+++ b/interface/web/sites/lib/lang/de_web_subdomain.lng
@@ -35,6 +35,7 @@ $wb['apache_directives_txt'] = 'Apache Direktiven';
$wb['domain_error_empty'] = 'Domain ist leer.';
$wb['domain_error_unique'] = 'Domain muss eindeutig sein.';
$wb['domain_error_regex'] = 'Domainname ist ungültig.';
+$wb['domain_error_wildcard'] = 'Wildcard Subdomains sind nicht erlaubt.';
$wb['host_txt'] = 'Host';
$wb['redirect_error_regex'] = 'Ungültiger redirect Pfad. Gültige Pfade sind beispielsweise: /test/ oder http://www.domain.tld/test/';
$wb['no_redirect_txt'] = 'Kein Redirect';
diff --git a/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng b/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
index d4d9660e8b4e505b95aff792c69d385acf332bf6..0b3315a60665cecd11234827acae3199ff526edd 100644
--- a/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
+++ b/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng
@@ -42,6 +42,7 @@ $wb['apache_directives_txt'] = 'Apache Direktiven';
$wb['domain_error_empty'] = 'Domain ist leer.';
$wb['domain_error_unique'] = 'Domain muss eindeutig sein';
$wb['domain_error_regex'] = 'Domainname ungültig.';
+$wb['domain_error_wildcard'] = 'Wildcard Subdomains sind nicht erlaubt.';
$wb['hd_quota_error_empty'] = 'Harddisk Quota ist leer.';
$wb['traffic_quota_error_empty'] = 'Traffic Quota ist leer.';
$wb['errordocs_txt'] = 'Eigene Fehlerseiten';
diff --git a/interface/web/sites/lib/lang/en_web_subdomain.lng b/interface/web/sites/lib/lang/en_web_subdomain.lng
index a26e03e20181d1868f14f11bd69ef72aaa25f7c3..a6c3103e69cc107f2fc46e85515640dc10d6293f 100644
--- a/interface/web/sites/lib/lang/en_web_subdomain.lng
+++ b/interface/web/sites/lib/lang/en_web_subdomain.lng
@@ -35,6 +35,7 @@ $wb["apache_directives_txt"] = 'Apache directives';
$wb["domain_error_empty"] = 'Domain is empty.';
$wb["domain_error_unique"] = 'There is already a website or sub / aliasdomain with this domain name.';
$wb["domain_error_regex"] = 'Domain name invalid.';
+$wb['domain_error_wildcard'] = 'Wildcard subdomains are not allowed.';
$wb["host_txt"] = 'Host';
$wb["redirect_error_regex"] = 'Invalid redirect path. Valid redirects are for example: /test/ or http://www.domain.tld/test/';
$wb['no_redirect_txt'] = 'No redirect';
diff --git a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
index 42c6e4fe536f9f204e8f2810f14fb5ad5e4739b1..d993af80b02809e3df554be966dff0b4e3d69026 100644
--- a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
+++ b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
@@ -48,6 +48,7 @@ $wb["apache_directives_txt"] = 'Apache Directives';
$wb["domain_error_empty"] = 'Domain is empty.';
$wb["domain_error_unique"] = 'There is already a website or sub / aliasdomain with this domain name.';
$wb["domain_error_regex"] = 'Domain name invalid.';
+$wb['domain_error_wildcard'] = 'Wildcard subdomains are not allowed.';
$wb["hd_quota_error_empty"] = 'Harddisk quota is 0 or empty.';
$wb["traffic_quota_error_empty"] = 'Traffic quota is empty.';
$wb["error_ssl_state_empty"] = 'SSL State is empty.';