From 6a2e36ec27a4c06741e72fd1f9275d3b767f390c Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Tue, 09 Dec 2008 15:33:49 -0500
Subject: [PATCH] It is now possible to have customized html-pages in /usr/local/ispconfig/server/conf-custom (with or without language-informations)

---
 server/plugins-available/apache2_plugin.inc.php |   53 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 632fda5..7ebeedb 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -186,9 +186,21 @@
 		if($this->action != 'insert') $this->action = 'update';
 		
 		if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
+			
+			$old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
+			$new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
+			
+			// If the parent_domain_id has been chenged, we will have to update the old site as well.
+			if($data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
+				$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
+				$data["new"] = $tmp;
+				$data["old"] = $tmp;
+				$this->action = 'update';
+				$this->update($event_name,$data);
+			}
+			
 			// This is not a vhost, so we need to update the parent record instead.
-			$parent_domain_id = intval($data["new"]["parent_domain_id"]);
-			$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id." AND active = 'y'");
+			$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
 			$data["new"] = $tmp;
 			$data["old"] = $tmp;
 			$this->action = 'update';
@@ -288,14 +300,34 @@
 		
 		if($this->action == 'insert' && $data["new"]["type"] == 'vhost') {
 			// Copy the error pages
-      if($data["new"]["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);
-      }
-      		
+			if($data["new"]["errordocs"]){
+				$error_page_path = escapeshellcmd($data["new"]["document_root"])."/web/error/";
+				if (file_exists("/usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2))){
+					exec("cp /usr/local/ispconfig/server/conf-custom/error/".substr(escapeshellcmd($conf["language"]),0,2)."/* ".$error_page_path);
+				}
+				else {
+					if (file_exists("/usr/local/ispconfig/server/conf-custom/error/fileNotFound.html")){
+						exec("cp /usr/local/ispconfig/server/conf-custom/error/*.html ".$error_page_path);
+					}
+					else {
+						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");
+			if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2))){
+				exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html_".substr(escapeshellcmd($conf["language"]),0,2)." ".escapeshellcmd($data["new"]["document_root"])."/web/index.html");
+			}
+			else {
+				if (file_exists("/usr/local/ispconfig/server/conf-custom/index/standard_index.html")){
+					exec("cp /usr/local/ispconfig/server/conf-custom/index/standard_index.html ".escapeshellcmd($data["new"]["document_root"])."/web/index.html");
+				}
+				else {
+					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");
 		}
 		
@@ -331,6 +363,9 @@
 		// Chown and chmod the directories
 		exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"]));
 		
+		// make temp direcory writable for the apache user and the website user
+		exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
+		
 		
 		// Create the vhost config file
 		$app->load('tpl');

--
Gitblit v1.9.1