From 0f7d3e2306acbdf618ed2a2d48d1c8cf3457fd87 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 30 Jun 2010 06:06:16 -0400
Subject: [PATCH] Fixed regex for email filed to allow _ in email addresses.

---
 install/lib/installer_base.lib.php |   48 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 78423e9..350ae05 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -282,9 +282,11 @@
 			
 			$hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
 			$hosts[$from_host]['db'] = $conf['mysql']['master_database'];
+			$hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
 
 			$hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
 			$hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
+			$hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
 		} else{
 			/*
 			 * it is NOT a master-slave - Setup so we have to find out all clients and their
@@ -298,17 +300,27 @@
 			foreach ($data as $item){
 				$hosts[$item['Host']]['user'] = $item['User'];
 				$hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
+				$hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
 			}
 		}
-
+		
+		if(is_array($hosts)) {
 		foreach($hosts as $host => $value) {
 			/*
-			 *  Delete ISPConfig user in the master database, in case that it exists
+			 * If a pwd exists, this means, we have to add the new user (and his pwd).
+			 * if not, the user already exists and we do not need the pwd
+			 */
+			if ($value['pwd'] != ''){
+				$query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
+				$this->dbmaster->query($query); // ignore the error
+			}
+
+			/*
+			 *  Try to delete all rights of the user in case that it exists.
+			 *  In Case that it will not exist, do nothing (ignore the error!)
 			 */
 			$query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
-			if(!$this->dbmaster->query($query)) {
-				$this->error('Unable to remove rights of user in master database: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
-			}
+			$this->dbmaster->query($query); // ignore the error
 
 			//* Create the ISPConfig database user in the remote database
 			$query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
@@ -371,6 +383,7 @@
 		 * It is all done. Relod the rights...
 		 */
 		$this->dbmaster->query('FLUSH PRIVILEGES;');
+		}
 
 	}
 
@@ -531,7 +544,7 @@
 
 		//** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
 		$command = 'chmod 755  /var/run/courier/authdaemon/';
-		caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
+		if(is_file('/var/run/courier/authdaemon/')) caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
 
 		//* Changing maildrop lines in posfix master.cf
 		if(is_file($config_dir.'/master.cf')) {
@@ -839,6 +852,7 @@
 		//exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
 		exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
 		exec('echo "yes" > '.$config_dir.'/conf/BrokenClientsCompatibility');
+		exec('echo "yes" > '.$config_dir.'/conf/DisplayDotFiles');
 
 		if(is_file('/etc/default/pure-ftpd-common')) {
 			replaceLine('/etc/default/pure-ftpd-common','STANDALONE_OR_INETD=inetd','STANDALONE_OR_INETD=standalone',1,0);
@@ -1228,9 +1242,15 @@
 						$module_name = substr($file,0,-8);
 						$tmp = new $module_name;
 						if($tmp->onInstall()) {
-							if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+							if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
+								@symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+								// @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
+							}
 							if (strpos($file, '_core_module') !== false) {
-								if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
+								if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
+									@symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
+									// @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
+								}
 							}
 						}
 						unset($tmp);
@@ -1249,9 +1269,15 @@
 						$plugin_name = substr($file,0,-8);
 						$tmp = new $plugin_name;
 						if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
-							if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+							if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
+								@symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+								//@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-enabled/'.$file);
+							}
 							if (strpos($file, '_core_plugin') !== false) {
-								if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
+								if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
+									@symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
+									//@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-core/'.$file);
+								}
 							}
 						}
 						unset($tmp);
@@ -1400,7 +1426,7 @@
 
 		//* Add Log-Rotation
 		if (is_dir('/etc/logrotate.d')) {
-			unlink('/etc/logrotate.d/logispc3');
+			@unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
 			$fh = fopen('/etc/logrotate.d/logispc3', 'w');
 			fwrite($fh,
 					"/var/log/ispconfig/ispconfig.log { \n" .

--
Gitblit v1.9.1