From 1c6b268465d01655553553d01c03d4944138a4b0 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Wed, 04 Jan 2012 10:55:45 -0500
Subject: [PATCH] Added: FS#1954 - Add a config file backup option in the ispconfig updater - FS#1898 Added username after client name in IP address list

---
 interface/web/admin/form/server_ip.tform.php |    4 ++--
 install/lib/update.lib.php                   |    6 +++++-
 install/update.php                           |   21 +++++++++++++++++++++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index c794d39..5a3c9bb 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -56,7 +56,11 @@
 	//if(filesize('existing_db.sql') < 30000) die('Possible problem with dumping the database. We will stop here. Please check the file existing_db.sql');
 
 	// create a backup copy of the ispconfig database in the root folder
-	$backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_h-i').'.sql';
+	if(isset($conf['backup_path'])) {
+		$backup_db_name = $conf['backup_path'].'/ispconfig_db_backup.sql';
+	} else {
+		$backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_H-i').'.sql';
+	}
 	copy('existing_db.sql',$backup_db_name);
 	chmod($backup_db_name, 0700);
 	chown($backup_db_name, 'root');
diff --git a/install/update.php b/install/update.php
index 4da9fce..223613a 100644
--- a/install/update.php
+++ b/install/update.php
@@ -123,6 +123,27 @@
 
 echo "This application will update ISPConfig 3 on your server.\n";
 
+//* Make a backup before we start the update
+$do_backup = $inst->simple_query('Shall the script create a ISPConfig backup in /var/backup/ now?', array('yes','no'),'yes');
+if($do_backup == 'yes') {
+	
+	//* Create the backup directory
+	$backup_path = '/var/backup/backup/ispconfig_'.date('Y-m-d_H-i');
+	$conf['backup_path'] = $backup_path;
+	exec("mkdir -p $backup_path");
+	exec("chown root:root $backup_path");
+	exec("chmod 700 $backup_path");
+	
+	//* Do the backup
+	swriteln('Creating backup of /usr/local/ispconfig directory...');
+	exec("tar pcfz $backup_path/ispconfig_software.tar.gz /usr/local/ispconfig");
+	swriteln('Creating backup of /etc directory...');
+	exec("tar pcfz $backup_path/etc.tar.gz /etc");
+	exec("chown root:root $backup_path/*.tar.gz");
+	exec("chmod 700 $backup_path/*.tar.gz");
+}
+
+
 //** Initialize the MySQL server connection
 include_once('lib/mysql.lib.php');
 
diff --git a/interface/web/admin/form/server_ip.tform.php b/interface/web/admin/form/server_ip.tform.php
index a6d9bcf..9cab997 100644
--- a/interface/web/admin/form/server_ip.tform.php
+++ b/interface/web/admin/form/server_ip.tform.php
@@ -100,9 +100,9 @@
 			'formtype'	=> 'SELECT',
 			'default'	=> '',
 			'datasource'	=> array ( 	'type'	=> 'SQL',
-										'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
+										'querystring' => 'SELECT client_id,CONCAT(company_name,' :: ',username) as name FROM client WHERE {AUTHSQL} ORDER BY contact_name',
 										'keyfield'=> 'client_id',
-										'valuefield'=> 'contact_name'
+										'valuefield'=> 'name'
 									 ),
 			'value'		=> array(0 => ' ')
 		),

--
Gitblit v1.9.1