From 06d1cedc37158b528eeb1e786bf199784c0bc657 Mon Sep 17 00:00:00 2001
From: xaver <xaver@ispconfig3>
Date: Sun, 11 Mar 2012 16:44:00 -0400
Subject: [PATCH] moved css for sorting from combobox to content.css and added class selector

---
 install/lib/installer_base.lib.php |   76 +++++++++++++++++++++++++++++--------
 1 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 6b1f4ee..ae279ab 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -514,6 +514,10 @@
 			copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
 			copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
 		}
+		
+		//* help jailkit fo find its ini files
+		if(!is_link('/usr/jk_socketd.ini')) exec('ln -s /etc/jailkit/jk_socketd.ini /usr/jk_socketd.ini');
+		if(!is_link('/usr/jk_init.ini')) exec('ln -s /etc/jailkit/jk_init.ini /usr/jk_init.ini');
 
 	}
 	
@@ -625,6 +629,21 @@
 		$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
 		if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 
+		$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
+		$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
+		unset($server_ini_rec);
+
+		//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
+		$rbl_list = '';
+		if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') {
+			$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
+			foreach ($rbl_hosts as $key => $value) {
+				$rbl_list .= ", reject_rbl_client ". $value;
+			}
+		}
+		unset($rbl_hosts);
+		unset($server_ini_array);
+
 		$postconf_commands = array (
 				'myhostname = '.$conf['hostname'],
 				'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
@@ -641,7 +660,7 @@
 				'smtpd_sasl_auth_enable = yes',
 				'broken_sasl_auth_clients = yes',
 				'smtpd_sasl_authenticated_header = yes',
-				'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
+				'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination'. $rbl_list,
 				'smtpd_use_tls = yes',
 				'smtpd_tls_security_level = may',
 				'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
@@ -876,19 +895,32 @@
 			caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
 		}
 
-		//* copy dovecot.conf
+		//* backup dovecot.conf
 		$configfile = 'dovecot.conf';
 		if(is_file($config_dir.'/'.$configfile)) {
 			copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
 		}
-		copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
+		
+		//* Get the dovecot version
+		exec('dovecot --version',$tmp);
+		$parts = explode('.',trim($tmp[0]));
+		$dovecot_version = $parts[0];
+		unset($tmp);
+		unset($parts);
+		
+		//* Copy dovecot configuration file
+		if($dovecot_version == 2) {
+			copy('tpl/debian_dovecot2.conf.master',$config_dir.'/'.$configfile);
+		} else {
+			copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
+		}
 
 		//* dovecot-sql.conf
 		$configfile = 'dovecot-sql.conf';
 		if(is_file($config_dir.'/'.$configfile)) {
 			copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
 		}
-		chmod($config_dir.'/'.$configfile.'~', 0400);
+		if(is_file($config_dir.'/'.$configfile.'~')) chmod($config_dir.'/'.$configfile.'~', 0400);
 		$content = rf('tpl/debian_dovecot-sql.conf.master');
 		$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
 		$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
@@ -1485,6 +1517,7 @@
 			if(substr($socket_dir,-1) != '/') $socket_dir .= '/';
 			if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
 			$fpm_socket = $socket_dir.'apps.sock';
+			$cgi_socket = escapeshellcmd($conf['nginx']['cgi_socket']);
 
 			$content = str_replace('{apps_vhost_ip}', $apps_vhost_ip, $content);
 			$content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
@@ -1492,6 +1525,7 @@
 			$content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
 			//$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
 			$content = str_replace('{fpm_socket}', $fpm_socket, $content);
+			$content = str_replace('{cgi_socket}', $cgi_socket, $content);
 
 			wf($vhost_conf_dir.'/apps.vhost', $content);
 			
@@ -1587,6 +1621,7 @@
 		$content = str_replace('{server_id}', $conf['server_id'], $content);
 		$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
 		$content = str_replace('{language}', $conf['language'], $content);
+		$content = str_replace('{timezone}', $conf['timezone'], $content);
 
 		wf($install_dir.'/interface/lib/'.$configfile, $content);
 
@@ -1609,6 +1644,7 @@
 		$content = str_replace('{server_id}', $conf['server_id'], $content);
 		$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
 		$content = str_replace('{language}', $conf['language'], $content);
+		$content = str_replace('{timezone}', $conf['timezone'], $content);
 
 		wf($install_dir.'/server/lib/'.$configfile, $content);
 
@@ -1683,13 +1719,9 @@
 		$dns_server_enabled = ($conf['services']['dns'])?1:0;
 		$file_server_enabled = ($conf['services']['file'])?1:0;
 		$db_server_enabled = ($conf['services']['db'])?1:0;
-		$vserver_server_enabled = ($conf['services']['vserver'])?1:0;
+		$vserver_server_enabled = ($conf['openvz']['installed'])?1:0;
 		$proxy_server_enabled = ($conf['services']['proxy'])?1:0;
 		$firewall_server_enabled = ($conf['services']['firewall'])?1:0;
-
-
-
-
 
 		$sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled', proxy_server = '$proxy_server_enabled', firewall_server = '$firewall_server_enabled' WHERE server_id = ".intval($conf['server_id']);
 
@@ -1745,6 +1777,12 @@
 			chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
 			chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
 		}
+		
+		if(is_dir($install_dir.'/interface/invoices')) {
+			chmod($install_dir.'/interface/invoices', 0770);
+			chown($install_dir.'/interface/invoices', 'ispconfig');
+			chgrp($install_dir.'/interface/invoices', 'ispconfig');
+		}
 
 		// TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
 		// and must be fixed as this will allow the apache user to read the ispconfig files.
@@ -1752,14 +1790,18 @@
 		if($conf['apache']['installed'] == true){
 			$command = 'adduser '.$conf['apache']['user'].' ispconfig';
 			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
-			$command = 'adduser '.$conf['apache']['user'].' ispapps';
-			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			if(is_group('ispapps')){
+				$command = 'adduser '.$conf['apache']['user'].' ispapps';
+				caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			}
 		}
 		if($conf['nginx']['installed'] == true){
 			$command = 'adduser '.$conf['nginx']['user'].' ispconfig';
 			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
-			$command = 'adduser '.$conf['nginx']['user'].' ispapps';
-			caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			if(is_group('ispapps')){
+				$command = 'adduser '.$conf['nginx']['user'].' ispapps';
+				caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
+			}
 		}
 
 		//* Make the shell scripts executable
@@ -1818,11 +1860,11 @@
 			$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content);
 		
 			if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
-				$content = str_replace('{ssl_on}', ' ssl', $content);
+				$content = str_replace('{ssl_on}', 'on', $content);
 				$content = str_replace('{ssl_comment}', '', $content);
 				$content = str_replace('{fastcgi_ssl}', 'on', $content);
 			} else {
-				$content = str_replace('{ssl_on}', '', $content);
+				$content = str_replace('{ssl_on}', 'off', $content);
 				$content = str_replace('{ssl_comment}', '#', $content);
 				$content = str_replace('{fastcgi_ssl}', 'off', $content);
 			}
@@ -1935,7 +1977,7 @@
 		wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
 		chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
 		chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
-		chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
+		chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');		
 
 	}
 
@@ -2052,7 +2094,7 @@
 		if ( is_file($tConf) ) {
 			$stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
 			if ($res == 0) { // stat successfull
-				list($access, $user, $group) = split(" ", $stat);
+				list($access, $user, $group) = explode(" ", $stat);
 			}
 
 			if ( copy($tConf, $tConf.'~') ) {

--
Gitblit v1.9.1