From 73813a4bd2c3d3fcefecbd73416e8bb27273225f Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Fri, 24 Jan 2014 11:36:39 -0500
Subject: [PATCH] Merged domains, vhost subdomains and vhost aliasdomains into vhost domains
---
interface/web/sites/form/web_vhost_domain.tform.php | 120 +++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 87 insertions(+), 33 deletions(-)
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_vhost_domain.tform.php
similarity index 86%
rename from interface/web/sites/form/web_domain.tform.php
rename to interface/web/sites/form/web_vhost_domain.tform.php
index 84f8cd5..b529181 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_vhost_domain.tform.php
@@ -38,15 +38,31 @@
*/
-$form["title"] = "Web Domain";
+$vhostdomain_type = 'domain';
+$form_title = "Web Domain";
+$validator_function = 'web_domain';
+
+if(isset($_SESSION['s']['var']['vhostdomain_type'])) {
+ if($_SESSION['s']['var']['vhostdomain_type'] == 'subdomain') {
+ $vhostdomain_type = 'subdomain';
+ $form_title = "Subdomain";
+ $validator_function = 'sub_domain';
+ } elseif($_SESSION['s']['var']['vhostdomain_type'] == 'aliasdomain') {
+ $vhostdomain_type = 'aliasdomain';
+ $form_title = "Aliasdomain";
+ $validator_function = 'alias_domain';
+ }
+}
+
+$form["title"] = $form_title;
$form["description"] = "";
-$form["name"] = "web_domain";
-$form["action"] = "web_domain_edit.php";
+$form["name"] = "web_vhost_domain";
+$form["action"] = "web_vhost_domain_edit.php";
$form["db_table"] = "web_domain";
$form["db_table_idx"] = "domain_id";
$form["db_history"] = "yes";
$form["tab_default"] = "domain";
-$form["list_default"] = "web_domain_list.php";
+$form["list_default"] = "web_vhost_domain_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
@@ -55,14 +71,16 @@
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
+$web_domain_edit_readonly = false;
// Clients may not change the website basic settings if they are not resellers
if($app->auth->has_clients($_SESSION['s']['user']['userid']) || $app->auth->is_admin()) {
$web_domain_edit_readonly = false;
} else {
- $web_domain_edit_readonly = true;
+ if($vhostdomain_type == 'domain') $web_domain_edit_readonly = true;
}
$wildcard_available = true;
+if($vhostdomain_type != 'domain') $wildcard_available = false;
$ssl_available = true;
if(!$app->auth->is_admin()) {
$client_group_id = $_SESSION["s"]["user"]["default_group"];
@@ -78,7 +96,7 @@
$form["tabs"]['domain'] = array (
'title' => "Domain",
'width' => 100,
- 'template' => "templates/web_domain_edit.htm",
+ 'template' => "templates/web_vhost_domain_edit.htm",
'readonly' => $web_domain_edit_readonly,
'fields' => array (
//#################################
@@ -88,9 +106,6 @@
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'no_server_error'),
- ),
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND web_server = 1 AND {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
@@ -134,7 +149,7 @@
),
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
'class' => 'validate_domain',
- 'function' => 'web_domain',
+ 'function' => $validator_function,
'errmsg'=> 'domain_error_regex'),
),
'default' => '',
@@ -147,17 +162,12 @@
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'y',
- 'value' => array('vhost' => 'Site', 'alias' => 'Alias')
+ 'value' => array('vhost' => 'Site', 'alias' => 'Alias', 'vhostalias' => 'Alias', 'subdomain' => 'Subdomain', 'vhostsubdomain' => 'Subdomain')
),
'parent_domain_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
- 'datasource' => array ( 'type' => 'SQL',
- 'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'site' AND {AUTHSQL} ORDER BY domain",
- 'keyfield'=> 'domain_id',
- 'valuefield'=> 'domain'
- ),
'value' => ''
),
'vhost_type' => array (
@@ -169,13 +179,7 @@
'hd_quota' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
- 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
- 'errmsg'=> 'hd_quota_error_empty'),
- 1 => array ( 'type' => 'REGEX',
- 'regex' => '/^(\-1|[0-9]{1,10})$/',
- 'errmsg'=> 'hd_quota_error_regex'),
- ),
- 'default' => '-1',
+ 'default' => ($vhostdomain_type == 'domain' ? '-1' : '0'),
'value' => '',
'width' => '7',
'maxlength' => '7'
@@ -222,11 +226,6 @@
'datatype' => 'VARCHAR',
'formtype' => 'SELECT',
'default' => 'www',
- 'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
- 'class' => 'validate_domain',
- 'function' => 'web_domain_autosub',
- 'errmsg'=> 'domain_error_autosub'),
- ),
'value' => ($wildcard_available ? array('none' => 'none_txt', 'www' => 'www.', '*' => '*.') : array('none' => 'none_txt', 'www' => 'www.'))
),
'ssl' => array (
@@ -284,11 +283,66 @@
)
);
+// add type-specific field attributes
+if($vhostdomain_type == 'domain') {
+ $form['tabs']['domain']['fields']['server_id']['validators'] = array(
+ 0 => array (
+ 'type' => 'NOTEMPTY',
+ 'errmsg'=> 'no_server_error'
+ ),
+ );
+ $form['tabs']['domain']['fields']['parent_domain_id']['datasource'] = array (
+ 'type' => 'SQL',
+ 'querystring' => "SELECT web_domain.domain_id,web_domain.domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
+ 'keyfield'=> 'domain_id',
+ 'valuefield'=> 'domain'
+ );
+ $form['tabs']['domain']['fields']['hd_quota']['validators'] = array (
+ 0 => array (
+ 'type' => 'NOTEMPTY',
+ 'errmsg'=> 'hd_quota_error_empty'
+ ),
+ 1 => array (
+ 'type' => 'REGEX',
+ 'regex' => '/^(\-1|[0-9]{1,10})$/',
+ 'errmsg'=> 'hd_quota_error_regex'
+ ),
+ );
+ $form['tabs']['domain']['fields']['subdomain']['validators'] = array(
+ 0 => array (
+ 'type' => 'CUSTOM',
+ 'class' => 'validate_domain',
+ 'function' => 'web_domain_autosub',
+ 'errmsg'=> 'domain_error_autosub'
+ ),
+ );
+} else {
+ $form['tabs']['domain']['fields']['parent_domain_id']['datasource'] = array (
+ 'type' => 'SQL',
+ 'querystring' => "SELECT web_domain.domain_id, CONCAT(web_domain.domain, ' :: ', server.server_name) AS parent_domain FROM web_domain, server WHERE web_domain.type = 'vhost' AND web_domain.server_id = server.server_id AND {AUTHSQL::web_domain} ORDER BY web_domain.domain",
+ 'keyfield'=> 'domain_id',
+ 'valuefield'=> 'parent_domain'
+ );
+ $form['tabs']['domain']['fields']['web_folder'] = array (
+ 'datatype' => 'VARCHAR',
+ 'validators' => array ( 0 => array ( 'type' => 'REGEX',
+ 'regex' => '@^((?!.*\.\.)[\w/_\.\-]{1,100})$@',
+ 'errmsg'=> 'web_folder_error_regex'),
+ ),
+ 'formtype' => 'TEXT',
+ 'default' => '',
+ 'value' => '',
+ 'width' => '30',
+ 'maxlength' => '255'
+ );
+
+}
+
$form["tabs"]['redirect'] = array (
'title' => "Redirect",
'width' => 100,
- 'template' => "templates/web_domain_redirect.htm",
+ 'template' => "templates/web_vhost_domain_redirect.htm",
'readonly' => false,
'fields' => array (
//#################################
@@ -336,7 +390,7 @@
$form["tabs"]['ssl'] = array (
'title' => "SSL",
'width' => 100,
- 'template' => "templates/web_domain_ssl.htm",
+ 'template' => "templates/web_vhost_domain_ssl.htm",
'readonly' => false,
'fields' => array (
//#################################
@@ -472,7 +526,7 @@
$form["tabs"]['stats'] = array (
'title' => "Stats",
'width' => 100,
- 'template' => "templates/web_domain_stats.htm",
+ 'template' => "templates/web_vhost_domain_stats.htm",
'readonly' => false,
'fields' => array (
//#################################
@@ -505,7 +559,7 @@
$form["tabs"]['backup'] = array (
'title' => "Backup",
'width' => 100,
- 'template' => "templates/web_domain_backup.htm",
+ 'template' => "templates/web_vhost_domain_backup.htm",
'readonly' => false,
'fields' => array (
//#################################
@@ -556,7 +610,7 @@
$form["tabs"]['advanced'] = array (
'title' => "Options",
'width' => 100,
- 'template' => "templates/web_domain_advanced.htm",
+ 'template' => "templates/web_vhost_domain_advanced.htm",
'readonly' => false,
'fields' => array (
//#################################
--
Gitblit v1.9.1