From b9dbe75a8d7d022f32ed35fde566c9399f8f1aa9 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Tue, 20 Jan 2009 10:53:10 +0000
Subject: [PATCH] Fixed: When an SSL web site is created, configure Apache
 automatically to listen on port 443, if it is not already listening on that
 port.

---
 install/lib/install.lib.php        | 3 +++
 install/lib/installer_base.lib.php | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php
index bf93cad1f9..4af0d54dba 100644
--- a/install/lib/install.lib.php
+++ b/install/lib/install.lib.php
@@ -530,6 +530,9 @@ function replaceLine($filename,$search_pattern,$new_line,$strict = 0) {
 			}
 		}
 		if($found == 0) {
+			//* add \n if the last line does not end with \n or \r
+			if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
+			//* add the new line at the end of the file
 			$out .= $new_line."\n";
 		}
 		file_put_contents($filename,$out);
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index d05bf60333..ea4e382cc0 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -706,6 +706,11 @@ class installer_base {
 			replaceLine('/etc/apache2/sites-available/000-default','<VirtualHost *>','<VirtualHost *:80>',1);
 		}
 		
+		if(is_file('/etc/apache2/ports.conf')) {
+			// add a line "Listen 443" to ports conf if line does not exist
+			replaceLine('/etc/apache2/ports.conf','Listen 443','Listen 443',1);
+		}
+		
 		
 		//* Copy the ISPConfig configuration include
         $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
-- 
GitLab