From 1f751bd44e4e52ac4b46e8da6cf1ff84675577da Mon Sep 17 00:00:00 2001
From: laking <laking@ispconfig3>
Date: Sun, 03 Apr 2011 23:53:09 -0400
Subject: [PATCH] Implemented passwordless ssh-rsa authentication support.

---
 install/lib/update.lib.php |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php
index fc4f57b..8faff1a 100644
--- a/install/lib/update.lib.php
+++ b/install/lib/update.lib.php
@@ -58,8 +58,9 @@
 	// 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';
 	copy('existing_db.sql',$backup_db_name);
-	exec("chmod 700 $backup_db_name");
-	exec("chown root:root $backup_db_name");
+	chmod($backup_db_name, 0700);
+	chown($backup_db_name, 'root');
+	chgrp($backup_db_name, 'root');
 
 	if ($conf['powerdns']['installed']) {
 		//** export the current PowerDNS database data
@@ -72,8 +73,9 @@
 		// create a backup copy of the PowerDNS database in the root folder
 		$backup_db_name = '/root/ispconfig_powerdns_db_backup_'.@date('Y-m-d_h-i').'.sql';
 	        copy('existing_powerdns_db.sql',$backup_db_name);
-        	exec("chmod 700 $backup_db_name");
-	        exec("chown root:root $backup_db_name");
+		chmod($backup_db_name, 0700);
+	        chown($backup_db_name, 'root');
+	        chgrp($backup_db_name, 'root');
 	}
 }
 
@@ -149,6 +151,21 @@
 		} else {
 			system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' ".$conf['mysql']['database']." < existing_db.sql");
 		}
+		
+		//** Get the database version number based on the patchfile
+		$found = true;
+		while($found == true) {
+			$next_db_version = intval($current_db_version + 1);
+			$patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
+			if(is_file($patch_filename)) {
+				$current_db_version = $next_db_version;
+			} else {
+				$found = false;
+			}
+		}
+		
+		//* update the database version in server table
+		$inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']);
 
 		if ($conf['powerdns']['installed']) {
                                                  

--
Gitblit v1.9.1