diff --git a/setup/upgrade/index.php b/setup/upgrade/index.php index 30b902d..5048495 100644 --- a/setup/upgrade/index.php +++ b/setup/upgrade/index.php @@ -1,6 +1,6 @@ temp_variables = array("step_name"=>"backup", "silent"=>$this->silent); @@ -65,7 +62,7 @@ class upgradeBackup extends Step { $this->util = new UpgradeUtil(); } - function doStep() { + public function doStep() { parent::doStep(); if(!$this->inStep("backup")) { $this->doRun(); @@ -92,17 +89,21 @@ class upgradeBackup extends Step { else if($this->previous()) { return 'previous'; } + else if ($this->upgrade()) { + header('Location: index.php?step_name=database'); + exit; + } $this->doRun(); return 'landing'; } - function backupNow() + private function backupNow() { return isset($_POST['BackupNow']); } - function doRun($action = null) { + private function doRun($action = null) { $this->temp_variables['action'] = $action; if (is_null($action) || ($action == 'confirm')) { @@ -127,29 +128,7 @@ class upgradeBackup extends Step { private function storeSilent() { } - /* - // these belong in a shared lib - function set_state($value) -{ - $_SESSION['state'] = $value; -} -function check_state($value, $state='Home') -{ - if ($_SESSION['state'] != $value) - { - ?> - - check_state(1); -// $this->set_state(2); $targetfile = $_SESSION['backupFile']; $stmt = $this->create_backup_stmt($targetfile); $dir = $stmt['dir']; @@ -163,7 +142,7 @@ function check_state($value, $state='Home') $read = fread($handle, 10240); pclose($handle); $_SESSION['backupOutput']=$read; - $dir = $this->resolveTempDir(); + $dir = $this->util->resolveTempDir(); $_SESSION['backupFile'] = $stmt['target']; if (OS_UNIX) { @@ -177,21 +156,9 @@ function check_state($value, $state='Home') $_SESSION['backupStatus'] = false; } } - else - { - ?> -

- The mysqldump utility was not found in the subdirectory. - -        - check_state(2); -// $this->set_state(3); -// title('Backup Status'); $status = $_SESSION['backupStatus']; $filename = $_SESSION['backupFile']; @@ -200,7 +167,7 @@ function check_state($value, $state='Home') if ($status) { $stmt = $this->util->create_restore_stmt($filename); - $this->temp_variables['display'] = 'The backup file "" has been created. + $this->temp_variables['display'] = 'The backup file "' . $filename . '" has been created.

It appears as though the backup has been successful.

'; if ($stmt['dir'] != '') @@ -230,136 +197,78 @@ function check_state($value, $state='Home') else { $this->temp_variables['display'] .= 'It appears as though the backup process has failed.

Unfortunately, it is difficult to diagnose these problems automatically - and would recommend that you try to do the backup process manually. -

- We appologise for the inconvenience. -

- - -
' . $_SESSION['backupOutput'] . '
'; + and would recommend that you try to do the backup process manually. +

+ We appologise for the inconvenience. +

+ + +
' . $_SESSION['backupOutput'] . '
'; } -} - -function create_backup_stmt($targetfile=null) -{ - $oKTConfig =& KTConfig::getSingleton(); - - $adminUser = $oKTConfig->get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - - $dbPort = trim($oKTConfig->get('db/dbPort')); - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $date=date('Y-m-d-H-i-s'); - - $dir=$this->resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else - { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir=$this->resolveTempDir(); - - if (is_null($targetfile)) - { - $targetfile="$tmpdir/kt-backup-$date.sql"; - } - - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; - $info['display']=$stmt; - $info['target']=$targetfile; - - - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function resolveMysqlDir() -{ - // possibly detect existing installations: - - if (OS_UNIX) - { - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); - $mysqlname ='mysql'; - } - else - { - $dirs = explode(';', $_SERVER['PATH']); - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; - $dirs[] = 'c:/program files/ktdms/mysql/bin'; - $mysqlname ='mysql.exe'; - } - - $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) - { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); } - foreach($dirs as $dir) + private function create_backup_stmt($targetfile=null) { - if (is_file($dir . '/' . $mysqlname)) + $oKTConfig =& KTConfig::getSingleton(); + + $adminUser = $oKTConfig->get('db/dbAdminUser'); + $adminPwd = $oKTConfig->get('db/dbAdminPass'); + $dbHost = $oKTConfig->get('db/dbHost'); + $dbName = $oKTConfig->get('db/dbName'); + + $dbPort = trim($oKTConfig->get('db/dbPort')); + if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); + if (empty($dbPort)) $dbPort='3306'; + $dbSocket = trim($oKTConfig->get('db/dbSocket')); + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; + + $date=date('Y-m-d-H-i-s'); + + $dir=$this->util->resolveMysqlDir(); + + $info['dir']=$dir; + + $prefix=''; + if (OS_UNIX) { - return $dir; + $prefix .= "./"; } + + if (@stat($dbSocket) !== false) + { + $mechanism="--socket=\"$dbSocket\""; + } + else + { + $mechanism="--port=\"$dbPort\""; + } + + $tmpdir=$this->util->resolveTempDir(); + + if (is_null($targetfile)) + { + $targetfile="$tmpdir/kt-backup-$date.sql"; + } + + $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; + $info['display']=$stmt; + $info['target']=$targetfile; + + + $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; + $info['cmd']=$stmt; + return $info; } - return ''; -} - -function resolveTempDir() -{ - if (OS_UNIX) { - $dir='/tmp/kt-db-backup'; - } - else { - $dir='c:/kt-db-backup'; - } - $oKTConfig =& KTConfig::getSingleton(); - $dir = $oKTConfig->get('backup/backupDirectory',$dir); - - if (!is_dir($dir)) { - mkdir($dir); + private function backupConfirm() + { + $stmt = $this->create_backup_stmt(); + $_SESSION['backupFile'] = $stmt['target']; + + $dir = $stmt['dir']; + $this->temp_variables['dir'] = $dir; + $this->temp_variables['display'] = $stmt['display']; } - return $dir; -} - - -function backupConfirm() -{ - $stmt = $this->create_backup_stmt(); - $_SESSION['backupFile'] = $stmt['target']; - - $dir = $stmt['dir']; - $this->temp_variables['dir'] = $dir; - $this->temp_variables['display'] = $stmt['display']; -} - - - } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeComplete.php b/setup/upgrade/steps/upgradeComplete.php index 9a8e1e4..0896c1a 100644 --- a/setup/upgrade/steps/upgradeComplete.php +++ b/setup/upgrade/steps/upgradeComplete.php @@ -44,20 +44,20 @@ require '../../config/dmsDefaults.php'; class upgradeComplete extends Step { - protected $silent = true; - protected $util = null; + protected $silent = false; + protected $temp_variables = array(); public function __construct() { $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); } - function doStep() { + public function doStep() { $this->doRun(); return 'landing'; } - function doRun() { + private function doRun() { $this->storeSilent();// Set silent mode variables } diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index 5a414ca..390a834 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -1,6 +1,6 @@ initErrors(); - $this->setDetails(); // Set any posted variables -// if(!$this->inStep("database")) { -// $this->doRun(); -// return 'landing'; -// } + if(!$this->inStep("database")) { + $this->doRun(); + return 'landing'; + } if($this->next()) { + $this->doRun('preview'); return 'next'; } else if($this->previous()) { return 'previous'; @@ -297,15 +164,15 @@ class upgradeDatabase extends Step return 'landing'; } - function confirmUpgrade() { + private function confirmUpgrade() { return isset($_POST['ConfirmUpgrade']); } - function upgrading() { + private function upgrading() { return isset($_POST['RunUpgrade']); } - function doRun($action = null) { + private function doRun($action = null) { $this->readConfig(KTConfig::getConfigFilename()); if($this->dbSettings['dbPort'] == '') { @@ -327,8 +194,7 @@ class upgradeDatabase extends Step } else if ($action == 'runUpgrade') { $this->temp_variables['title'] = 'Upgrade In Progress'; - if (!$this->upgrade()) { -// $this->temp_variables['upgradeTable'] = '';//$this->upgradeErrors(); + if (!$this->upgradeDatabase()) { return false; } } @@ -336,7 +202,7 @@ class upgradeDatabase extends Step return true; } - public function generateUpgradeTable() { + private function generateUpgradeTable() { global $default; $this->temp_variables['systemVersion'] = $default->systemVersion; @@ -367,42 +233,6 @@ class upgradeDatabase extends Step } /** - * Store options - * - * @author KnowledgeTree Team - * @params object SimpleXmlObject - * @access private - * @return void - */ - private function setDetails() { - // create lock file to indicate Upgrade mode - $this->createUpgradeFile(); - } - - /** - * Creates miUpgradeock file so that system knows it is supposed to run an upgrade installation - * - * @author KnowledgeTree Team - * @access private - * @return void - */ - private function createUpgradeFile() { - @touch($this->wizardLocation . DIRECTORY_SEPARATOR . "upgrade.lock"); - } - - /** - * Safer way to return post data - * - * @author KnowledgeTree Team - * @params SimpleXmlObject $simplexml - * @access public - * @return void - */ - public function getPostSafe($key) { - return isset($_POST[$key]) ? $_POST[$key] : ""; - } - - /** * Stores varibles used by template * * @author KnowledgeTree Team @@ -455,7 +285,7 @@ class upgradeDatabase extends Step $this->temp_variables['dbSettings'] = $this->dbSettings; } - function upgradeConfirm() + private function upgradeConfirm() { if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) { $this->temp_variables['backupStatus'] = false; @@ -465,158 +295,141 @@ class upgradeDatabase extends Step } } - -function upgrade() -{ - global $default; + private function upgradeDatabase() + { + global $default; + + $this->temp_variables['detail'] = '

The table below describes the upgrades that have occurred to + upgrade your KnowledgeTree installation to ' . $default->systemVersion . ''; + + $pre_res = $this->performPreUpgradeActions(); + if (PEAR::isError($pre_res)) { + $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions failed.'; + } + else { + $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions succeeded.'; - $this->temp_variables['detail'] = '

The table below describes the upgrades that have occurred to - upgrade your KnowledgeTree installation to ' . $default->systemVersion . ''; -?> -

- -performPreUpgradeActions(); - if (PEAR::isError($pre_res)) { - $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions failed.'; - } - else { - $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions succeeded.'; - + } + + $res = $this->performAllUpgrades(); + if (PEAR::isError($res) || PEAR::isError($pres)) { + $this->temp_variables['upgradeStatus'] = 'Upgrade failed.'; + } + else { + $this->temp_variables['upgradeStatus'] = 'Upgrade succeeded.'; + } + + $post_pres = $this->performPostUpgradeActions(); + if (PEAR::isError($post_res)) { + $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.'; + } + else { + $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions succeeded.'; + } } - ?> -
-

- -

-performAllUpgrades(); - if (PEAR::isError($res) || PEAR::isError($pres)) { - $this->temp_variables['upgradeStatus'] = 'Upgrade failed.'; - } - else { - $this->temp_variables['upgradeStatus'] = 'Upgrade succeeded.'; - } -?> -

- -

- performPostUpgradeActions(); - if (PEAR::isError($post_res)) { - $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.'; - } - else { - $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions succeeded.'; + private function performPreUpgradeActions() { + + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. + // It should idealy work the same as the upgrades. + + global $default; + + // Lock the scheduler + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + touch($lockFile); + return true; + } -} - -function performPreUpgradeActions() { - - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. - // It should idealy work the same as the upgrades. - - global $default; - - // Lock the scheduler - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; - touch($lockFile); - return true; - -} - -function performPostUpgradeActions() { - - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. - // It should idealy work the same as the upgrades. - - global $default; - - // Ensure all plugins are re-registered. - $sql = "TRUNCATE plugin_helper"; - $res = DBUtil::runQuery($sql); - - // Clear out all caches and proxies - they need to be regenerated with the new code - $proxyDir = $default->proxyCacheDirectory; - KTUtil::deleteDirectory($proxyDir); - - $oKTCache = new KTCache(); - $oKTCache->deleteAllCaches(); - - // Clear the configuration cache, it'll regenerate on next load - $oKTConfig = new KTConfig(); - $oKTConfig->clearCache(); - - // Unlock the scheduler - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; - if(file_exists($lockFile)){ - @unlink($lockFile); + + private function performPostUpgradeActions() { + + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. + // It should idealy work the same as the upgrades. + + global $default; + + // Ensure all plugins are re-registered. + $sql = "TRUNCATE plugin_helper"; + $res = DBUtil::runQuery($sql); + + // Clear out all caches and proxies - they need to be regenerated with the new code + $proxyDir = $default->proxyCacheDirectory; + KTUtil::deleteDirectory($proxyDir); + + $oKTCache = new KTCache(); + $oKTCache->deleteAllCaches(); + + // Clear the configuration cache, it'll regenerate on next load + $oKTConfig = new KTConfig(); + $oKTConfig->clearCache(); + + // Unlock the scheduler + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + if(file_exists($lockFile)){ + @unlink($lockFile); + } + + return true; + } - return true; - -} - -function performAllUpgrades () { - global $default; - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); - $lastVersion = DBUtil::getOneResultKey($query, 'value'); - $currentVersion = $default->systemVersion; - - $upgrades = describeUpgrade($lastVersion, $currentVersion); + private function performAllUpgrades () { + global $default; + + $row = 1; + + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); + $lastVersion = DBUtil::getOneResultKey($query, 'value'); + $currentVersion = $default->systemVersion; - $this->temp_variables['upgradeTable'] = ''; - - foreach ($upgrades as $upgrade) { - if (($GLOBALS['row'] % 2) == 1) { - $class = "odd"; - } else { - $class = "even"; + $upgrades = describeUpgrade($lastVersion, $currentVersion); + + $this->temp_variables['upgradeTable'] = ''; + + foreach ($upgrades as $upgrade) { + if (($row % 2) == 1) { + $class = "odd"; + } else { + $class = "even"; + } + $this->temp_variables['upgradeTable'] .= sprintf('

%s
' . "\n", $class, htmlspecialchars($upgrade->getDescription())); + ++$row; + $res = $upgrade->performUpgrade(); + $this->temp_variables['upgradeTable'] .= sprintf('
%s
', $this->showResult($res)); + $this->temp_variables['upgradeTable'] .= '
' . "\n"; + $this->temp_variables['upgradeTable'] .= "
\n"; + if (PEAR::isError($res)) { + if (!is_a($res, 'Upgrade_Already_Applied')) { + break; + } else { + $res = true; + } + } + if ($res === false) { + $res = PEAR::raiseError("Upgrade returned false"); + break; + } } - $this->temp_variables['upgradeTable'] .= sprintf('
%s
' . "\n", $class, htmlspecialchars($upgrade->getDescription())); - $GLOBALS['row']++; - ob_flush(); - flush(); - $res = $upgrade->performUpgrade(); - $this->temp_variables['upgradeTable'] .= sprintf('
%s
', $this->showResult($res)); - $this->temp_variables['upgradeTable'] .= '
' . "\n"; - ob_flush(); - flush(); - $this->temp_variables['upgradeTable'] .= "
\n"; + + return $res; + } + + private function showResult($res) { if (PEAR::isError($res)) { - if (!is_a($res, 'Upgrade_Already_Applied')) { - break; - } else { - $res = true; + if (is_a($res, 'Upgrade_Already_Applied')) { + return 'Already applied'; } + return sprintf('%s', htmlspecialchars($res->toString())); } - if ($res === false) { - $res = PEAR::raiseError("Upgrade returned false"); - break; + if ($res === true) { + return 'Success'; } - } - - return $res; -} - -function showResult($res) { - if (PEAR::isError($res)) { - if (is_a($res, 'Upgrade_Already_Applied')) { - return 'Already applied'; + if ($res === false) { + return 'Failure'; } - return sprintf('%s', htmlspecialchars($res->toString())); + return $res; } - if ($res === true) { - return 'Success'; - } - if ($res === false) { - return 'Failure'; - } - return $res; -} } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeInstallation.php b/setup/upgrade/steps/upgradeInstallation.php index bc7d0fc..2354f5a 100644 --- a/setup/upgrade/steps/upgradeInstallation.php +++ b/setup/upgrade/steps/upgradeInstallation.php @@ -1,6 +1,6 @@ temp_variables = array("step_name"=>"installation"); } - function doStep() { + public function doStep() { parent::doStep(); if($this->next()) { return 'next'; @@ -72,13 +73,5 @@ class UpgradeInstallation extends step return 'landing'; } - function backup() { - return isset($_POST['Backup']); - } - - function restore() { - return isset($_POST['Restore']); - } - } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php index 331e8dc..5b26336 100644 --- a/setup/upgrade/steps/upgradeRestore.php +++ b/setup/upgrade/steps/upgradeRestore.php @@ -1,6 +1,6 @@ util = new UpgradeUtil(); } - function doStep() { + public function doStep() { parent::doStep(); + $this->temp_variables['restore'] = false; + if(!$this->inStep("restore")) { $this->doRun(); return 'landing'; @@ -78,24 +78,40 @@ class upgradeRestore extends Step { } else if($this->previous()) { return 'previous'; } + else if ($this->restoreNow()) { + $this->temp_variables['restoreSuccessful'] = false; + $this->doRun(true); + return 'next'; + } $this->doRun(); return 'landing'; } - function doRun() { - $this->temp_variables['selected'] = false; - if ($this->select()) { - $this->restoreSelected(); - $this->temp_variables['selected'] = true; + private function restoreNow() { + return isset($_POST['RunRestore']); + } + + private function doRun($restore = false) { + if (!$restore) { + $this->temp_variables['selected'] = false; + if ($this->select()) { + $this->restoreSelected(); + $this->temp_variables['selected'] = true; + $this->temp_variables['availableBackups'] = true; + } + $this->restoreConfirm(); + } // end not running a restore, just setting up + else { + $this->restoreDatabase(); } - $this->restoreConfirm(); + $this->storeSilent();// Set silent mode variables return true; } - function select() { + private function select() { return isset($_POST['RestoreSelect']); } @@ -105,183 +121,126 @@ class upgradeRestore extends Step { */ private function storeSilent() { } - /* - // these belong in a shared lib - function set_state($value) -{ - $_SESSION['state'] = $value; -} -function check_state($value, $state='Home') -{ - if ($_SESSION['state'] != $value) - { - ?> - - util->create_restore_stmt($filename); - $dir = $stmt['dir']; - if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) + private function restoreDatabase() { - -?> - The restore is now underway. Please wait till it completes. -temp_variables['restore'] = true; + $status = $_SESSION['backupStatus']; + $filename = $_SESSION['backupFile']; + $stmt = $this->util->create_restore_stmt($filename); + $dir = $stmt['dir']; + + if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) { - - $handle = popen($stmt, 'r'); - if ($handle=='false') + $curdir=getcwd(); + chdir($dir); + + $ok=true; + $stmts=explode("\n",$stmt['cmd']); + foreach($stmts as $stmt) { - $ok=false; - break; + + $handle = popen($stmt, 'r'); + if ($handle=='false') + { + $ok=false; + break; + } + $read = fread($handle, 10240); + pclose($handle); + $_SESSION['restoreOutput']=$read; } - $read = fread($handle, 10240); - pclose($handle); - $_SESSION['restoreOutput']=$read; - } - + $_SESSION['restoreStatus'] = $ok; - - } - else - { -?> -

- The mysql utility was not found in the subdirectory. - -       -restoreDone(); + } } -} - - -function restoreDone() -{ -// check_state(5); -// set_state(6); -// title('Restore Status'); - $status = $_SESSION['restoreStatus']; - $filename = $_SESSION['backupFile']; - - if ($status) - { - -?> - The restore of "" has been completed. -

- It appears as though the restore has been successful. -

- - - - -It appears as though the restore process has failed.

-Unfortunately, it is difficult to diagnose these problems automatically -and would recommend that you try to do the backup process manually. -

-We appologise for the inconvenience. -

- - -
- -
-temp_variables['display'] = 'The restore of "' . $filename . '" has been completed. +

+ It appears as though the restore has been successful. +

'; + + $this->temp_variables['title'] = 'Restore Complete'; + $this->temp_variables['restoreSuccessful'] = true; + } + else + { + $this->temp_variables['display'] = 'It appears as though the restore process has failed.

+ Unfortunately, it is difficult to diagnose these problems automatically + and would recommend that you try to do the backup process manually. +

+ We appologise for the inconvenience. +

+ + +
' . $_SESSION['restoreOutput'] . ' +
'; + $this->temp_variables['title'] = 'Restore Failed'; + $this->temp_variables['restoreSuccessful'] = false; + } } -?> - -
- -       - -temp_variables['availableBackups'] = false; -// title('Select Backup to Restore'); - $dir = $this->util->resolveTempDir(); - - $files = array(); - if ($dh = opendir($dir)) + + private function restoreSelect() { - while (($file = readdir($dh)) !== false) + $this->temp_variables['availableBackups'] = false; + $dir = $this->util->resolveTempDir(); + + $files = array(); + if ($dh = opendir($dir)) { - if (!preg_match('/kt-backup.+\.sql/',$file)) { - continue; + while (($file = readdir($dh)) !== false) + { + if (!preg_match('/kt-backup.+\.sql/',$file)) { + continue; + } + $files[] = $file; } - $files[] = $file; + closedir($dh); + } + + $this->temp_variables['title'] = 'Select Backup to Restore'; + $this->temp_variables['dir'] = $dir; + if (count($files) != 0) { + $this->temp_variables['availableBackups'] = true; + $this->temp_variables['files'] = $files; } - closedir($dh); } - $this->temp_variables['dir'] = $dir; - if (count($files) != 0) { - $this->temp_variables['availableBackups'] = true; - $this->temp_variables['files'] = $files; + private function restoreSelected() + { + $file=$_REQUEST['file']; + + $dir = $this->util->resolveTempDir(); + $_SESSION['backupFile'] = $dir . '/' . $file; } -} - -function restoreSelected() -{ - $file=$_REQUEST['file']; - - $dir = $this->util->resolveTempDir(); - $_SESSION['backupFile'] = $dir . '/' . $file; -?> -restoreSelect(); - return; + if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0) + { + $this->restoreSelect(); + return; + } + + $status = $_SESSION['backupStatus']; + $filename = $_SESSION['backupFile']; + $stmt = $this->util->create_restore_stmt($filename); + + $this->temp_variables['title'] = 'Confirm Restore'; + $this->temp_variables['dir'] = $stmt['dir']; + $this->temp_variables['display'] = $stmt['display']; + $this->temp_variables['availableBackups'] = true; + $this->temp_variables['selected'] = true; } - $status = $_SESSION['backupStatus']; - $filename = $_SESSION['backupFile']; - $stmt = $this->util->create_restore_stmt($filename); - - $this->temp_variables['dir'] = $stmt['dir']; - $this->temp_variables['display'] = $stmt['display']; -} - - - - } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php index b311bcd..2450584 100644 --- a/setup/upgrade/steps/upgradeWelcome.php +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -40,14 +40,13 @@ * @version Version 0.1 */ -global $default; -// include defaults include '../../config/dmsDefaults.php'; require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; class upgradeWelcome extends step { - protected $silent = true; + protected $silent = false; + protected $temp_variables = array(); public function __construct() { $this->temp_variables = array("step_name"=>"welcome"); @@ -76,7 +75,6 @@ class upgradeWelcome extends step { if (!$authenticated) { session_unset(); -// loginFailed(_kt('Could not authenticate administrative user')); return false; } diff --git a/setup/upgrade/templates/backup.tpl b/setup/upgrade/templates/backup.tpl index 605eb77..28bc28e 100644 --- a/setup/upgrade/templates/backup.tpl +++ b/setup/upgrade/templates/backup.tpl @@ -44,18 +44,17 @@ You can continue to do the backup manually using the following process: ?>

- - - - + + - \ No newline at end of file diff --git a/setup/upgrade/templates/installation.tpl b/setup/upgrade/templates/installation.tpl index e33d25f..b51f7a1 100644 --- a/setup/upgrade/templates/installation.tpl +++ b/setup/upgrade/templates/installation.tpl @@ -2,7 +2,6 @@

Current Installation

-

If you have just updated your KnowledgeTree code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version.

diff --git a/setup/upgrade/templates/restore.tpl b/setup/upgrade/templates/restore.tpl index 3aaf583..e13f8e0 100644 --- a/setup/upgrade/templates/restore.tpl +++ b/setup/upgrade/templates/restore.tpl @@ -1,5 +1,5 @@

-

Confirm Restore

+


There don't seem to be any backups to restore from the "" directory.There don't seem to be any backups to restore from the "" directory. +

+ Select a backup to restore from the list below: +

+ + + + + +
Filename + File Size + Action + +
+ + + +
+ +

+

- Select a backup to restore from the list below:

-

- - - - -
Filename - File Size - Action - -
- - - -
- -
+ Manually, you would do the following to restore the backup: +

+ + +
+ cd "" +
-

-

-Manually, you would do the following to restore the backup: -

- - -
-cd "" -
- - The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. -

-You can continue to do the restore manually using the following command(s): -

- - -
+ The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. +

+ You can continue to do the restore manually using the following command(s): +

+ + + @@ -89,11 +91,12 @@ Press Next to attempt the command(s) above. } ?> - - + + + - \ No newline at end of file diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php index c1cb32a..5cd0634 100644 --- a/setup/upgrade/upgradeUtil.php +++ b/setup/upgrade/upgradeUtil.php @@ -666,115 +666,106 @@ class UpgradeUtil { return join(" ", $aSafeArgs); } - function create_restore_stmt($targetfile) -{ - $oKTConfig =& KTConfig::getSingleton(); - - $adminUser = $oKTConfig->get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - $dbPort = trim($oKTConfig->get('db/dbPort')); - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $dir = $this->resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else + public function create_restore_stmt($targetfile) { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir = $this->resolveTempDir(); - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; - - - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; - $info['display']=$stmt; - - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; - - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function resolveMysqlDir() -{ - // possibly detect existing installations: - - if (OS_UNIX) - { - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); - $mysqlname ='mysql'; - } - else - { - $dirs = explode(';', $_SERVER['PATH']); - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; - $dirs[] = 'c:/program files/ktdms/mysql/bin'; - $mysqlname ='mysql.exe'; - } - - $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) - { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); + $oKTConfig =& KTConfig::getSingleton(); + + $adminUser = $oKTConfig->get('db/dbAdminUser'); + $adminPwd = $oKTConfig->get('db/dbAdminPass'); + $dbHost = $oKTConfig->get('db/dbHost'); + $dbName = $oKTConfig->get('db/dbName'); + $dbPort = trim($oKTConfig->get('db/dbPort')); + if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); + if (empty($dbPort)) $dbPort='3306'; + $dbSocket = trim($oKTConfig->get('db/dbSocket')); + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; + + $dir = $this->resolveMysqlDir(); + + $info['dir']=$dir; + + $prefix=''; + if (OS_UNIX) { + $prefix .= "./"; + } + + if (@stat($dbSocket) !== false) { + $mechanism="--socket=\"$dbSocket\""; + } + else { + $mechanism="--port=\"$dbPort\""; + } + + $tmpdir = $this->resolveTempDir(); + + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; + + + $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; + $info['display']=$stmt; + + + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; + + $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; + $info['cmd']=$stmt; + return $info; } - - foreach($dirs as $dir) + + public function resolveMysqlDir() { - if (is_file($dir . '/' . $mysqlname)) + // possibly detect existing installations: + + if (OS_UNIX) { + $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); + $mysqlname ='mysql'; + } + else { - return $dir; + $dirs = explode(';', $_SERVER['PATH']); + $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; + $dirs[] = 'c:/program files/ktdms/mysql/bin'; + $mysqlname ='mysql.exe'; } + + $oKTConfig =& KTConfig::getSingleton(); + $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); + $dirs[] = $mysqldir; + + if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { + $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); + } + + foreach($dirs as $dir) + { + if (is_file($dir . '/' . $mysqlname)) + { + return $dir; + } + } + + return ''; } - - return ''; -} - -function resolveTempDir() -{ - - if (OS_UNIX) - { - $dir='/tmp/kt-db-backup'; - } - else - { - $dir='c:/kt-db-backup'; - } - $oKTConfig =& KTConfig::getSingleton(); - $dir = $oKTConfig->get('backup/backupDirectory',$dir); - - if (!is_dir($dir)) + + public function resolveTempDir() { - mkdir($dir); + if (OS_UNIX) { + $dir='/tmp/kt-db-backup'; + } + else { + $dir='c:/kt-db-backup'; + } + $oKTConfig =& KTConfig::getSingleton(); + $dir = $oKTConfig->get('backup/backupDirectory',$dir); + + if (!is_dir($dir)) { + mkdir($dir); + } + return $dir; } - return $dir; -} } ?> \ No newline at end of file