From c3bf39efc438d869645049e17549c9644a5467c2 Mon Sep 17 00:00:00 2001 From: mcramer Date: Mon, 20 Aug 2012 13:34:47 +0000 Subject: [PATCH] Changes for subdomain vhosts: - Fixed missing templates and language entries - Previous subdomain mode can be used concurrently - Changed log path to a more convenient location --- .../web/admin/lib/lang/de_system_config.lng | 2 +- .../web/admin/lib/lang/en_system_config.lng | 2 +- interface/web/admin/system_config_edit.php | 8 +- .../sites/form/web_vhost_subdomain.tform.php | 10 +- .../sites/lib/lang/de_web_vhost_subdomain.lng | 1 + .../sites/lib/lang/en_web_vhost_subdomain.lng | 1 + interface/web/sites/lib/module.conf.php | 11 +- .../web_vhost_subdomain_advanced.htm | 146 ++++++++++++++++++ .../templates/web_vhost_subdomain_backup.htm | 32 ++++ .../web_vhost_subdomain_redirect.htm | 76 +++++++++ .../templates/web_vhost_subdomain_ssl.htm | 68 ++++++++ .../templates/web_vhost_subdomain_stats.htm | 37 +++++ interface/web/sites/web_domain_edit.php | 2 +- .../web/sites/web_vhost_subdomain_edit.php | 25 +-- .../plugins-available/apache2_plugin.inc.php | 8 +- server/plugins-available/nginx_plugin.inc.php | 8 +- 16 files changed, 408 insertions(+), 29 deletions(-) create mode 100644 interface/web/sites/templates/web_vhost_subdomain_advanced.htm create mode 100644 interface/web/sites/templates/web_vhost_subdomain_backup.htm create mode 100644 interface/web/sites/templates/web_vhost_subdomain_redirect.htm create mode 100644 interface/web/sites/templates/web_vhost_subdomain_ssl.htm create mode 100644 interface/web/sites/templates/web_vhost_subdomain_stats.htm diff --git a/interface/web/admin/lib/lang/de_system_config.lng b/interface/web/admin/lib/lang/de_system_config.lng index 79f80c2f8..5eaa996fe 100644 --- a/interface/web/admin/lib/lang/de_system_config.lng +++ b/interface/web/admin/lib/lang/de_system_config.lng @@ -6,7 +6,7 @@ $wb['dbuser_prefix_txt'] = 'Datenbankbenutzer Prefix'; $wb['shelluser_prefix_txt'] = 'Shellbenutzer Prefix'; $wb['ftpuser_prefix_txt'] = 'FTP Benutzer Prefix'; $wb['vhost_subdomains_txt'] = 'Subdomains als Website anlegen'; -$wb['vhost_subdomains_note_txt'] = 'Diese Einstellung kann nicht geändert werden, wenn Subdomains im System vorhanden sind!'; +$wb['vhost_subdomains_note_txt'] = 'Diese Einstellung kann nicht wieder deaktiviert werden, wenn Vhost Subdomains im System vorhanden sind!'; $wb['dbname_prefix_error_regex'] = 'Zeichen nicht erlaubt in Datenbanknamen Prefix.'; $wb['dbuser_prefix_error_regex'] = 'Zeichen nicht erlaubt in Datenbankbenutzer Prefix.'; $wb['ftpuser_prefix_error_regex'] = 'Zeichen nicht erlaubt in FTP Benutzer Prefix.'; diff --git a/interface/web/admin/lib/lang/en_system_config.lng b/interface/web/admin/lib/lang/en_system_config.lng index dc2f96e15..4fbaa579b 100644 --- a/interface/web/admin/lib/lang/en_system_config.lng +++ b/interface/web/admin/lib/lang/en_system_config.lng @@ -10,7 +10,7 @@ $wb["shelluser_prefix_txt"] = 'Shell user prefix'; $wb["webdavuser_prefix_txt"] = 'Webdav user prefix'; $wb["ftpuser_prefix_txt"] = 'FTP user prefix'; $wb['vhost_subdomains_txt'] = 'Create Subdomains as web site'; -$wb['vhost_subdomains_note_txt'] = 'You cannot change this as long as subdomains exist in the system!'; +$wb['vhost_subdomains_note_txt'] = 'You cannot disable this as long as vhost subdomains exist in the system!'; $wb["dbname_prefix_error_regex"] = 'Char not allowed in database name prefix.'; $wb["dbuser_prefix_error_regex"] = 'Char not allowed in database user prefix.'; $wb["ftpuser_prefix_error_regex"] = 'Char not allowed in ftp user prefix.'; diff --git a/interface/web/admin/system_config_edit.php b/interface/web/admin/system_config_edit.php index c78e91917..dc615a1f6 100644 --- a/interface/web/admin/system_config_edit.php +++ b/interface/web/admin/system_config_edit.php @@ -88,11 +88,11 @@ class page_action extends tform_actions { $server_config_array = $app->getconf->get_global_config(); $new_config = $app->tform->encode($this->dataRecord,$section); - if($section == 'sites' && $new_config['vhost_subdomains'] != $server_config_array['vhost_subdomains']) { - // check for existing subdomains - $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'subdomain' OR `type` = 'vhostsubdomain'"); + if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['vhost_subdomains'] == 'y') { + // check for existing vhost subdomains, if found the mode cannot be disabled + $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain'"); if($check['cnt'] > 0) { - $new_config['vhost_subdomains'] = $server_config_array['vhost_subdomains']; + $new_config['vhost_subdomains'] = 'y'; } } $server_config_array[$section] = $new_config; diff --git a/interface/web/sites/form/web_vhost_subdomain.tform.php b/interface/web/sites/form/web_vhost_subdomain.tform.php index 448e3ae33..1b2576712 100644 --- a/interface/web/sites/form/web_vhost_subdomain.tform.php +++ b/interface/web/sites/form/web_vhost_subdomain.tform.php @@ -277,7 +277,7 @@ $form["tabs"]['domain'] = array ( $form["tabs"]['redirect'] = array ( 'title' => "Redirect", 'width' => 100, - 'template' => "templates/web_domain_redirect.htm", + 'template' => "templates/web_vhost_subdomain_redirect.htm", 'readonly' => false, 'fields' => array ( ################################## @@ -317,7 +317,7 @@ if($ssl_available) { $form["tabs"]['ssl'] = array ( 'title' => "SSL", 'width' => 100, - 'template' => "templates/web_domain_ssl.htm", + 'template' => "templates/web_vhost_subdomain_ssl.htm", 'readonly' => false, 'fields' => array ( ################################## @@ -453,7 +453,7 @@ $form["tabs"]['ssl'] = array ( $form["tabs"]['stats'] = array ( 'title' => "Stats", 'width' => 100, - 'template' => "templates/web_domain_stats.htm", + 'template' => "templates/web_vhost_subdomain_stats.htm", 'readonly' => false, 'fields' => array ( ################################## @@ -486,7 +486,7 @@ $form["tabs"]['stats'] = array ( $form["tabs"]['backup'] = array ( 'title' => "Backup", 'width' => 100, - 'template' => "templates/web_domain_backup.htm", + 'template' => "templates/web_vhost_subdomain_backup.htm", 'readonly' => false, 'fields' => array ( ################################## @@ -524,7 +524,7 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') { $form["tabs"]['advanced'] = array ( 'title' => "Options", 'width' => 100, - 'template' => "templates/web_domain_advanced.htm", + 'template' => "templates/web_vhost_subdomain_advanced.htm", 'readonly' => false, 'fields' => array ( ################################## 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 92f55a981..d4d9660e8 100644 --- a/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng +++ b/interface/web/sites/lib/lang/de_web_vhost_subdomain.lng @@ -15,6 +15,7 @@ $wb['ssl_bundle_txt'] = 'SSL-Bundle'; $wb['ssl_action_txt'] = 'SSL-Aktion'; $wb['server_id_txt'] = 'Server'; $wb['domain_txt'] = 'Domain'; +$wb["host_txt"] = 'Host'; $wb['type_txt'] = 'Typ'; $wb['parent_domain_id_txt'] = 'Zugehörige Website'; $wb['web_folder_error_regex'] = 'Ungültige Ordnerangabe, bitte keinen / eingeben.'; 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 274a5b63c..42c6e4fe5 100644 --- a/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng +++ b/interface/web/sites/lib/lang/en_web_vhost_subdomain.lng @@ -18,6 +18,7 @@ $wb["ssl_action_txt"] = 'SSL Action'; $wb["ssl_domain_txt"] = 'SSL Domain'; $wb["server_id_txt"] = 'Server'; $wb["domain_txt"] = 'Domain'; +$wb["host_txt"] = 'Hostname'; $wb['web_folder_error_regex'] = 'Invalid folder entered. Please do not enter a slash.'; $wb["type_txt"] = 'Type'; $wb["parent_domain_id_txt"] = 'Parent Website'; diff --git a/interface/web/sites/lib/module.conf.php b/interface/web/sites/lib/module.conf.php index aa0cb67ef..1e11450f8 100644 --- a/interface/web/sites/lib/module.conf.php +++ b/interface/web/sites/lib/module.conf.php @@ -21,13 +21,20 @@ $items[] = array( 'title' => "Website", if($app->auth->get_client_limit($userid,'web_subdomain') != 0) { +$items[] = array( 'title' => "Subdomain", + 'target' => 'content', + 'link' => 'sites/web_subdomain_list.php', + 'html_id' => 'subdomain_list'); + // read web config $app->uses('getconf'); $sys_config = $app->getconf->get_global_config('sites'); -$items[] = array( 'title' => "Subdomain", + if($sys_config['vhost_subdomains'] == 'y') { +$items[] = array( 'title' => "Subdomain (Vhost)", 'target' => 'content', - 'link' => 'sites/' . ($sys_config['vhost_subdomains'] == 'y' ? 'web_vhost_subdomain_list.php' : 'web_subdomain_list.php'), + 'link' => 'sites/web_vhost_subdomain_list.php', 'html_id' => 'subdomain_list'); + } } if($app->auth->get_client_limit($userid,'web_aliasdomain') != 0) diff --git a/interface/web/sites/templates/web_vhost_subdomain_advanced.htm b/interface/web/sites/templates/web_vhost_subdomain_advanced.htm new file mode 100644 index 000000000..87107400a --- /dev/null +++ b/interface/web/sites/templates/web_vhost_subdomain_advanced.htm @@ -0,0 +1,146 @@ +

+

+ +
+ +
+
+ +
+ + + +
+
+ + + +
+
+ + +
+
+
+

{tmpl_var name='php_fpm_use_socket_txt'}

+
+ {tmpl_var name='php_fpm_use_socket'} +
+
+
+ + +
+
+ {tmpl_var name='pm_ondemand_hint_txt'} +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +  s +
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + +
+
+ +
+ \ No newline at end of file diff --git a/interface/web/sites/templates/web_vhost_subdomain_backup.htm b/interface/web/sites/templates/web_vhost_subdomain_backup.htm new file mode 100644 index 000000000..c46d4e2d4 --- /dev/null +++ b/interface/web/sites/templates/web_vhost_subdomain_backup.htm @@ -0,0 +1,32 @@ +

+

+ +
+ +
+
Backup +
+ + +
+
+ + +
+
+ + {tmpl_var name='backup_records'} + + + +
+ + +
+
+ +
\ No newline at end of file diff --git a/interface/web/sites/templates/web_vhost_subdomain_redirect.htm b/interface/web/sites/templates/web_vhost_subdomain_redirect.htm new file mode 100644 index 000000000..66a17034c --- /dev/null +++ b/interface/web/sites/templates/web_vhost_subdomain_redirect.htm @@ -0,0 +1,76 @@ +

+

+ +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + +
+
+ +
+ \ No newline at end of file diff --git a/interface/web/sites/templates/web_vhost_subdomain_ssl.htm b/interface/web/sites/templates/web_vhost_subdomain_ssl.htm new file mode 100644 index 000000000..4c27bb772 --- /dev/null +++ b/interface/web/sites/templates/web_vhost_subdomain_ssl.htm @@ -0,0 +1,68 @@ +

+

+ +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ + +
+
+ +
\ No newline at end of file diff --git a/interface/web/sites/templates/web_vhost_subdomain_stats.htm b/interface/web/sites/templates/web_vhost_subdomain_stats.htm new file mode 100644 index 000000000..26eee9477 --- /dev/null +++ b/interface/web/sites/templates/web_vhost_subdomain_stats.htm @@ -0,0 +1,37 @@ +

+

+ +
+ +
+
+
+

{tmpl_var name='stats_user_txt'}

admin

+
+
+ +  {tmpl_var name='generate_password_txt'} +
+
+ + +
+ + +
+ + +
+
+ + + +
+ + +
+
+ +
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index f972b0db1..97d7d5730 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -342,7 +342,7 @@ class page_action extends tform_actions { } $app->tpl->setVar("client_group_id",$client_select); - foreach($read_limits as $limit) $app->tpl->setVar($limit, 'y'); + foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y')); } $ssl_domain_select = ''; diff --git a/interface/web/sites/web_vhost_subdomain_edit.php b/interface/web/sites/web_vhost_subdomain_edit.php index a5866c879..e71841359 100644 --- a/interface/web/sites/web_vhost_subdomain_edit.php +++ b/interface/web/sites/web_vhost_subdomain_edit.php @@ -196,7 +196,7 @@ class page_action extends tform_actions { $app->tpl->setVar("fastcgi_php_version",$php_select); unset($php_records); - foreach($read_limits as $limit) $app->tpl->setVar($limit, 'y'); + foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y')); } $ssl_domain_select = ''; @@ -245,17 +245,20 @@ class page_action extends tform_actions { $this->parent_domain_record = $parent_domain; $read_limits = array('limit_cgi', 'limit_ssi', 'limit_perl', 'limit_ruby', 'limit_python', 'force_suexec', 'limit_hterror', 'limit_wildcard', 'limit_ssl'); - $this->dataRecord['web_folder'] = strtolower($this->dataRecord['web_folder']); - $forbidden_folders = array('', 'cgi-bin', 'web', 'log', 'private', 'ssl', 'tmp', 'webdav'); - if(in_array($this->dataRecord['web_folder'], $forbidden_folders) || preg_match('/^log_web\d+$/', $this->dataRecord['web_folder'])) { - $app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."
"; - } - // check for duplicate folder usage - $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "'"); - if($check && $check['cnt'] > 0) { - $app->tform->errorMessage .= $app->tform->lng("web_folder_unique_txt")."
"; + + if($app->tform->getCurrentTab() == 'domain') { + $this->dataRecord['web_folder'] = strtolower($this->dataRecord['web_folder']); + $forbidden_folders = array('', 'cgi-bin', 'web', 'log', 'private', 'ssl', 'tmp', 'webdav'); + if(in_array($this->dataRecord['web_folder'], $forbidden_folders)) { + $app->tform->errorMessage .= $app->tform->lng("web_folder_invalid_txt")."
"; + } + // check for duplicate folder usage + $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain' AND `parent_domain_id` = '" . intval($this->dataRecord['parent_domain_id']) . "' AND `web_folder` = '" . $app->db->quote($this->dataRecord['web_folder']) . "' AND `domain_id` != '" . intval($this->id) . "'"); + if($check && $check['cnt'] > 0) { + $app->tform->errorMessage .= $app->tform->lng("web_folder_unique_txt")."
"; + } } - + if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index a861265a9..bd1b1c10f 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -328,8 +328,12 @@ class apache2_plugin { $web_folder = 'web'; $log_folder = 'log'; if($data['new']['type'] == 'vhostsubdomain') { + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id'])); + $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']); + if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id']; $web_folder = $data['new']['web_folder']; - $log_folder .= '_web' . $data['new']['domain_id']; + $log_folder .= '/' . $subdomain_host; + unset($tmp); } // Create group and user, if not exist @@ -471,7 +475,7 @@ class apache2_plugin { if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']); if(!is_dir($data['new']['document_root'].'/'.$log_folder) || is_link($data['new']['document_root'].'/'.$log_folder)) { if(is_link($data['new']['document_root'].'/'.$log_folder)) unlink($data['new']['document_root'].'/'.$log_folder); - $app->system->mkdir($data['new']['document_root'].'/'.$log_folder); + $app->system->mkdirpath($data['new']['document_root'].'/'.$log_folder); $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root'); $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,'root'); $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755); diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 424d96fa8..255fca43b 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -322,8 +322,12 @@ class nginx_plugin { $web_folder = 'web'; $log_folder = 'log'; if($data['new']['type'] == 'vhostsubdomain') { + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id'])); + $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']); + if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id']; $web_folder = $data['new']['web_folder']; - $log_folder .= '_web' . $data['new']['domain_id']; + $log_folder .= '/' . $subdomain_host; + unset($tmp); } // Create group and user, if not exist @@ -459,7 +463,7 @@ class nginx_plugin { if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']); if(!is_dir($data['new']['document_root'].'/'.$log_folder) || is_link($data['new']['document_root'].'/'.$log_folder)) { if(is_link($data['new']['document_root'].'/'.$log_folder)) unlink($data['new']['document_root'].'/'.$log_folder); - $app->system->mkdir($data['new']['document_root'].'/'.$log_folder); + $app->system->mkdirpath($data['new']['document_root'].'/'.$log_folder); $app->system->chown($data['new']['document_root'].'/'.$log_folder,'root'); $app->system->chgrp($data['new']['document_root'].'/'.$log_folder,'root'); $app->system->chmod($data['new']['document_root'].'/'.$log_folder,0755); -- GitLab