From 15b96b9cb8bd335d37df57bf794bfa2cd1fefa6d Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Sat, 15 Feb 2014 15:10:49 +0100
Subject: [PATCH] Fixed: FS#3131 - Wrong Apache setting for Subdomain (vhost)
 without hostname

---
 interface/web/sites/lib/lang/en_web_vhost_subdomain.lng | 1 +
 interface/web/sites/web_vhost_subdomain_edit.php        | 5 +++++
 2 files changed, 6 insertions(+)

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 3c9009ee15..1322801700 100644
--- a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
+++ b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng
@@ -124,4 +124,5 @@ $wb['variables_txt'] = 'Variables';
 $wb['backup_excludes_txt'] = 'Excluded Directories';
 $wb['backup_excludes_note_txt'] = '(Separate multiple directories with commas. Example: web/cache/*,web/backup)';
 $wb['backup_excludes_error_regex'] = 'The excluded directories contain invalid characters.';
+$wb['subdomain_error_empty'] = 'The subdommain field is empty or contains invalid characters.';
 ?>
\ No newline at end of file
diff --git a/interface/web/sites/web_vhost_subdomain_edit.php b/interface/web/sites/web_vhost_subdomain_edit.php
index 560079d040..1e27593687 100644
--- a/interface/web/sites/web_vhost_subdomain_edit.php
+++ b/interface/web/sites/web_vhost_subdomain_edit.php
@@ -348,6 +348,11 @@ class page_action extends tform_actions {
 
 		if($app->tform->getCurrentTab() == 'domain') {
 
+			// Check that domain (the subdomain part) is not empty
+			if(!preg_match('/^[a-zA-Z0-9].+/',$this->dataRecord['domain'])) {
+				$app->tform->errorMessage .= $app->tform->lng("subdomain_error_empty")."<br />";
+			}
+			
 			/* check if the domain module is used - and check if the selected domain can be used! */
 			$app->uses('ini_parser,getconf');
 			$settings = $app->getconf->get_global_config('domains');
-- 
GitLab