From ef49b7e5ae53355012e8e570132d0514a61a6a81 Mon Sep 17 00:00:00 2001
From: redray <redray@ispconfig3>
Date: Wed, 12 Nov 2008 17:38:41 -0500
Subject: [PATCH] changed var-names for ownerrordocs option added www.-Subdomain option

---
 server/conf/vhost.conf.master                     |   12 +++---
 install/sql/ispconfig3.sql                        |    3 +
 server/plugins-available/apache2_plugin.inc.php   |   21 +++++++---
 interface/web/sites/lib/lang/en_web_domain.lng    |    3 +
 interface/web/sites/form/web_domain.tform.php     |   14 +++++--
 interface/web/sites/templates/web_domain_edit.htm |    8 +++-
 6 files changed, 40 insertions(+), 21 deletions(-)

diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 62fe5f6..ed0c552 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -1000,7 +1000,8 @@
   `cgi` char(1) NOT NULL default 'y',
   `ssi` char(1) NOT NULL default 'y',
   `suexec` char(1) NOT NULL default 'y',
-  `errordocs` char(1) NOT NULL default 'y',
+  `is_errordocs` tinyint(1) NOT NULL default '1',
+  `is_subdomainwww` tinyint(1) NOT NULL default '1',
   `php` varchar(255) NOT NULL default 'y',
   `redirect_type` varchar(255) default NULL,
   `redirect_path` varchar(255) default NULL,
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php
index 79d85f8..c31977b 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_domain.tform.php
@@ -168,11 +168,17 @@
 			'default'	=> 'n',
 			'value'		=> array(0 => 'n',1 => 'y')
 		),
-		'errordocs' => array (
-			'datatype'	=> 'VARCHAR',
+		'is_errordocs' => array (
+			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'CHECKBOX',
-			'default'	=> 'y',
-			'value'		=> array(0 => 'n',1 => 'y')
+			'default'	=> '1',
+			'value'		=> array(0 => '0',1 => '1')
+		),
+		'is_subdomainwww' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'CHECKBOX',
+			'default'	=> '1',
+			'value'		=> array(0 => '0',1 => '1')
 		),
 		'ssl' => array (
 			'datatype'	=> 'VARCHAR',
diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng
index fc37b59..34f18aa 100644
--- a/interface/web/sites/lib/lang/en_web_domain.lng
+++ b/interface/web/sites/lib/lang/en_web_domain.lng
@@ -26,7 +26,8 @@
 $wb["traffic_quota_txt"] = 'Traffic Quota';
 $wb["cgi_txt"] = 'CGI';
 $wb["ssi_txt"] = 'SSI';
-$wb["errordocs_txt"] = 'Own Error-Documents';
+$wb["is_errordocs_txt"] = 'Own Error-Documents';
+$wb["is_subdomainwww_txt"] = 'www. Subdomain';
 $wb["ssl_txt"] = 'SSL';
 $wb["suexec_txt"] = 'SuEXEC';
 $wb["php_txt"] = 'PHP';
diff --git a/interface/web/sites/templates/web_domain_edit.htm b/interface/web/sites/templates/web_domain_edit.htm
index 09666f3..8752563 100644
--- a/interface/web/sites/templates/web_domain_edit.htm
+++ b/interface/web/sites/templates/web_domain_edit.htm
@@ -63,8 +63,12 @@
         <span class="">{tmpl_var name='suexec'}</span>
       </span>
       <span class="wf_oneField">
-        <label for="errordocs" class="wf_preField">{tmpl_var name='errordocs_txt'}</label>                    
-        <span class="">{tmpl_var name='errordocs'}</span>
+        <label for="is_errordocs" class="wf_preField">{tmpl_var name='is_errordocs_txt'}</label>                    
+        <span class="">{tmpl_var name='is_errordocs'}</span>
+      </span>
+      <span class="wf_oneField">
+        <label for="is_subdomainwww" class="wf_preField">{tmpl_var name='is_subdomainwww_txt'}</label>                    
+        <span class="">{tmpl_var name='is_subdomainwww'}</span>
       </span>
       <span class="wf_oneField">
         <label for="ssl" class="wf_preField">{tmpl_var name='ssl_txt'}</label>                    
diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index e1f6d53..e7e1e90 100644
--- a/server/conf/vhost.conf.master
+++ b/server/conf/vhost.conf.master
@@ -13,7 +13,7 @@
   ServerAdmin webmaster@<tmpl_var name='domain'>
 
   ErrorLog <tmpl_var name='document_root'>/log/error.log
-<tmpl_if name='errordocs' op='==' value='y'>
+<tmpl_if name='is_errordocs'>
 
 	ErrorDocument 400 /error/invalidSyntax.html
 	ErrorDocument 401 /error/authorizationRequired.html
@@ -87,9 +87,9 @@
 <tmpl_if name='php' op='!=' value=''>
 
   php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>"	
+  php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
+  php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
   #php_admin_value open_basedir <tmpl_var name='document_root'>:/usr/share/php5
-  #php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
-  #php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
 </tmpl_if>
 <tmpl_var name='apache_directives'>
 </VirtualHost>
@@ -112,7 +112,7 @@
   
   ErrorLog <tmpl_var name='document_root'>/log/error.log
 
-<tmpl_if name='errordocs' op='==' value='y'>
+<tmpl_if name='is_errordocs'>
 	ErrorDocument 400 /error/invalidSyntax.html
 	ErrorDocument 401 /error/authorizationRequired.html
 	ErrorDocument 403 /error/forbidden.html
@@ -172,9 +172,9 @@
 <tmpl_if name='php' op='!=' value=''>
 
   php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>"	
+  php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
+  php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
   #php_admin_value open_basedir <tmpl_var name='document_root'>:/usr/share/php5
-  #php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
-  #php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
 </tmpl_if>
 
 <tmpl_var name='apache_directives'>
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 8c20234..1dae20f 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -212,10 +212,11 @@
 		
 		// Check if the directories are there and create them if nescessary.
 		if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
-		if(!is_dir($data["new"]["document_root"]."/web/error")) exec("mkdir -p ".$data["new"]["document_root"]."/web/error");
+		if(!is_dir($data["new"]["document_root"]."/web/error") and $data["new"]["is_errordocs"]) exec("mkdir -p ".$data["new"]["document_root"]."/web/error");
 		//if(!is_dir($data["new"]["document_root"]."/log")) exec("mkdir -p ".$data["new"]["document_root"]."/log");
 		if(!is_dir($data["new"]["document_root"]."/ssl")) exec("mkdir -p ".$data["new"]["document_root"]."/ssl");
 		if(!is_dir($data["new"]["document_root"]."/cgi-bin")) exec("mkdir -p ".$data["new"]["document_root"]."/cgi-bin");
+		if(!is_dir($data["new"]["document_root"]."/tmp")) exec("mkdir -p ".$data["new"]["document_root"]."/tmp");
 		
 		// Remove the symlink for the site, if site is renamed
 		if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) {
@@ -287,10 +288,12 @@
 		
 		if($this->action == 'insert' && $data["new"]["type"] == 'vhost') {
 			// Copy the error pages
-			$error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/";
-			exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
-			exec("chmod -R +r ".$error_page_path);
-		
+      if($data["new"]["is_errordocs"]){
+  			$error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/";
+  			exec("cp /usr/local/ispconfig/server/conf/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
+  			exec("chmod -R +r ".$error_page_path);
+      }
+      		
 			// copy the standard index page
 			exec("cp /usr/local/ispconfig/server/conf/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html");
 			exec("chmod +r ".escapeshellcmd($data["new"]["document_root"])."/web/index.html");
@@ -369,10 +372,14 @@
 		
 		// get alias domains (co-domains and subdomains)
 		$aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'");
-		$server_alias = '';
+    if($data["new"]["is_subdomainwww"]){
+  	  $server_alias .= 'www.'.$data["new"]["domain"].' ';
+    } else {
+  		$server_alias = '';
+    }
 		if(is_array($aliases)) {
 			foreach($aliases as $alias) {
-				$server_alias .= $alias["domain"].' ';
+			  $server_alias .= $alias["domain"].' ';
 				$app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG);
 				// Rewriting
 				if($alias["redirect_type"] != '') {

--
Gitblit v1.9.1