From 0ff3f159b5bcbd2bfed44731e38ab40296a402ee Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sat, 25 Sep 2010 12:54:18 -0400
Subject: [PATCH] Fixed: FS#1305 - Webdav user information is not written to domains vhost file.

---
 server/plugins-available/apache2_plugin.inc.php |   55 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index a404060..b2ddf9d 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -415,9 +415,9 @@
 				}
 				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("cp /usr/local/ispconfig/server/conf/index/favicon.ico ".escapeshellcmd($data["new"]["document_root"])."/web/");
-					exec("cp /usr/local/ispconfig/server/conf/index/robots.txt ".escapeshellcmd($data["new"]["document_root"])."/web/");
-					exec("cp /usr/local/ispconfig/server/conf/index/.htaccess ".escapeshellcmd($data["new"]["document_root"])."/web/");
+					if(is_file('/usr/local/ispconfig/server/conf/index/favicon.ico')) exec("cp /usr/local/ispconfig/server/conf/index/favicon.ico ".escapeshellcmd($data["new"]["document_root"])."/web/");
+					if(is_file('/usr/local/ispconfig/server/conf/index/robots.txt')) exec("cp /usr/local/ispconfig/server/conf/index/robots.txt ".escapeshellcmd($data["new"]["document_root"])."/web/");
+					if(is_file('/usr/local/ispconfig/server/conf/index/.htaccess')) exec("cp /usr/local/ispconfig/server/conf/index/.htaccess ".escapeshellcmd($data["new"]["document_root"])."/web/");
 				}
 			}
 			exec("chmod -R a+r ".escapeshellcmd($data["new"]["document_root"])."/web/");
@@ -489,7 +489,7 @@
 			$this->_exec("chmod 751 ".escapeshellcmd($data["new"]["document_root"])."/*");
 			$this->_exec("chmod 710 ".escapeshellcmd($data["new"]["document_root"]."/web"));
 
-			// make temp direcory writable for the apache user and the website user
+			// make temp directory writable for the apache and website users
 			$this->_exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
 
 			$command = 'usermod';
@@ -534,7 +534,7 @@
 			$this->_exec("chmod 755 ".escapeshellcmd($data["new"]["document_root"]."/*"));
 			$this->_exec("chown root:root ".escapeshellcmd($data["new"]["document_root"]."/"));
 
-			// make temp direcory writable for the apache user and the website user
+			// make temp directory writable for the apache and website users
 			$this->_exec("chmod 777 ".escapeshellcmd($data["new"]["document_root"]."/tmp"));
 		}
 
@@ -1155,26 +1155,29 @@
 	 */
 	private function _writeHtDigestFile($filename, $username, $authname, $pwdhash ) {
 		$changed = false;
-		$in = fopen($filename, 'r');
-		$output = '';
-		/*
-		 * read line by line and search for the username and authname
-		*/
-		while (preg_match("/:/", $line = fgets($in))) {
-			$line = rtrim($line);
-			$tmp = explode(':', $line);
-			if ($tmp[0] == $username && $tmp[1] == $authname) {
-				/*
-				 * found the user. delete or change it?
-				*/
-				if ($pwdhash != '') {
-					$output .= $tmp[0] . ':' . $tmp[1] . ':' . $pwdhash . "\n";
-					}
-				$changed = true;
+		if(is_file($filename)) {
+			$in = fopen($filename, 'r');
+			$output = '';
+			/*
+			* read line by line and search for the username and authname
+			*/
+			while (preg_match("/:/", $line = fgets($in))) {
+				$line = rtrim($line);
+				$tmp = explode(':', $line);
+				if ($tmp[0] == $username && $tmp[1] == $authname) {
+					/*
+					* found the user. delete or change it?
+					*/
+					if ($pwdhash != '') {
+						$output .= $tmp[0] . ':' . $tmp[1] . ':' . $pwdhash . "\n";
+						}
+					$changed = true;
+				}
+				else {
+					$output .= $line . "\n";
+				}
 			}
-			else {
-				$output .= $line . "\n";
-			}
+			fclose($in);
 		}
 		/*
 		 * if we didn't change anything, we have to add the new user at the end of the file
@@ -1182,7 +1185,7 @@
 		if (!$changed) {
 			$output .= $username . ':' . $authname . ':' . $pwdhash . "\n";
 		}
-		fclose($in);
+		
 
 		/*
 		 * Now lets write the new file
@@ -1325,4 +1328,4 @@
 
 } // end class
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1