From 6c54b1ddc757c429ecd740a7f6f1c56165cc58b4 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 09 Jan 2012 15:10:19 -0500
Subject: [PATCH] - Fixed FS#1959.

---
 server/plugins-available/nginx_plugin.inc.php |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index b04cfbb..1c1733b 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -198,7 +198,17 @@
 			if(trim($data["new"]["ssl_request"]) != '') file_put_contents($csr_file,$data["new"]["ssl_request"]);
 			if(trim($data["new"]["ssl_cert"]) != '') file_put_contents($crt_file,$data["new"]["ssl_cert"]);
 			// for nginx, bundle files have to be appended to the certificate file
-			if(trim($data["new"]["ssl_bundle"]) != '') file_put_contents($crt_file,$data["new"]["ssl_bundle"], FILE_APPEND);
+			if(trim($data["new"]["ssl_bundle"]) != ''){
+				if(file_exists($crt_file)){
+					$crt_file_contents = trim(file_get_contents($crt_file));
+				} else {
+					$crt_file_contents = '';
+				}
+				if($crt_file_contents != '') $crt_file_contents .= "\n";
+				$crt_file_contents .= $data["new"]["ssl_bundle"];
+				file_put_contents($crt_file,$crt_file_contents);
+				unset($crt_file_contents);
+			}
 			/* Update the DB of the (local) Server */
 			$app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'");
 			/* Update also the master-DB of the Server-Farm */

--
Gitblit v1.9.1