From f12e3d4f7e9b1810bc35584465c36f849d848630 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Oct 2009 09:04:39 +0200 Subject: [PATCH] preliminary commit from home of new database upgrade wizard (incomplete) --- config/dmsDefaults.php | 4 +++- setup/upgrade/config/config.xml | 19 +++++++++++++++++++ setup/upgrade/config/databases.xml | 22 ++++++++++++++++++++++ setup/upgrade/index.php | 44 ++++++++++++++++++++++++++++++++++++++++++-- setup/upgrade/path.php | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/resources/form.js | 13 +++++++++++++ setup/upgrade/resources/graphics/active.png | Bin 0 -> 1275 bytes setup/upgrade/resources/graphics/background.gif | Bin 0 -> 914 bytes setup/upgrade/resources/graphics/big-ok.png | Bin 0 -> 3217 bytes setup/upgrade/resources/graphics/cross.png | Bin 0 -> 846 bytes setup/upgrade/resources/graphics/cross_orange.png | Bin 0 -> 1465 bytes setup/upgrade/resources/graphics/dame/dot.png | Bin 0 -> 3302 bytes setup/upgrade/resources/graphics/dame/finish.png | Bin 0 -> 7393 bytes setup/upgrade/resources/graphics/dame/gradiant.gif | Bin 0 -> 2162 bytes setup/upgrade/resources/graphics/dame/kt_gradient.jpg | Bin 0 -> 13542 bytes setup/upgrade/resources/graphics/dame/loginbg.png | Bin 0 -> 769 bytes setup/upgrade/resources/graphics/dame/navbar.png | Bin 0 -> 1609 bytes setup/upgrade/resources/graphics/dame/powered-by-kt.png | Bin 0 -> 7515 bytes setup/upgrade/resources/graphics/dame/tick1.png | Bin 0 -> 3513 bytes setup/upgrade/resources/graphics/dame/tick2.png | Bin 0 -> 3487 bytes setup/upgrade/resources/graphics/dame/upgrader-header_logo.png | Bin 0 -> 2916 bytes setup/upgrade/resources/graphics/dame/upgrader_head.png | Bin 0 -> 2849 bytes setup/upgrade/resources/graphics/dropbox.png | Bin 0 -> 186054 bytes setup/upgrade/resources/graphics/dropbox_old.png | Bin 0 -> 13891 bytes setup/upgrade/resources/graphics/footer.png | Bin 0 -> 1065 bytes setup/upgrade/resources/graphics/gradient.png | Bin 0 -> 1859 bytes setup/upgrade/resources/graphics/inactive.png | Bin 0 -> 1226 bytes setup/upgrade/resources/graphics/indicator.png | Bin 0 -> 1247 bytes setup/upgrade/resources/graphics/kt_browse.png | Bin 0 -> 34912 bytes setup/upgrade/resources/graphics/left.png | Bin 0 -> 1111 bytes setup/upgrade/resources/graphics/logo.png | Bin 0 -> 1389 bytes setup/upgrade/resources/graphics/powered-by-kt.png | Bin 0 -> 8469 bytes setup/upgrade/resources/graphics/question.gif | Bin 0 -> 1051 bytes setup/upgrade/resources/graphics/tick.png | Bin 0 -> 917 bytes setup/upgrade/resources/graphics/tree.jpg | Bin 0 -> 2250 bytes setup/upgrade/resources/jquery.blockUI.js | 463 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/resources/jquery.form.js | 13 +++++++++++++ setup/upgrade/resources/jquery.js | 4376 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/resources/wizard.css | 539 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/resources/wizard.js | 284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/step.php | 425 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/stepAction.php | 517 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeBackup.php | 370 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeComplete.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeDatabase.php | 564 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeErrors.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeInstallation.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeRestore.php | 434 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/steps/upgradeWelcome.php | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/template.php | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/templates/backup.tpl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/templates/complete.tpl | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/templates/database.tpl | 34 ++++++++++++++++++++++++++++++++++ setup/upgrade/templates/error.tpl | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/templates/errors.tpl | 14 ++++++++++++++ setup/upgrade/templates/installation.tpl | 25 +++++++++++++++++++++++++ setup/upgrade/templates/restore.tpl | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/templates/welcome.tpl | 18 ++++++++++++++++++ setup/upgrade/templates/wizard.tpl | 41 +++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgrade | 0 setup/upgrade/upgradeIni.php | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgradeSession.php | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgradeUtil.php | 642 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgradeWizard.php | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgradedbUtil.php | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup/upgrade/upgrader.php | 680 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 66 files changed, 11290 insertions(+), 3 deletions(-) create mode 100644 setup/upgrade/config/config.xml create mode 100644 setup/upgrade/config/databases.xml create mode 100644 setup/upgrade/path.php create mode 100644 setup/upgrade/resources/form.js create mode 100644 setup/upgrade/resources/graphics/active.png create mode 100644 setup/upgrade/resources/graphics/background.gif create mode 100644 setup/upgrade/resources/graphics/big-ok.png create mode 100644 setup/upgrade/resources/graphics/cross.png create mode 100644 setup/upgrade/resources/graphics/cross_orange.png create mode 100644 setup/upgrade/resources/graphics/dame/dot.png create mode 100644 setup/upgrade/resources/graphics/dame/finish.png create mode 100644 setup/upgrade/resources/graphics/dame/gradiant.gif create mode 100644 setup/upgrade/resources/graphics/dame/kt_gradient.jpg create mode 100644 setup/upgrade/resources/graphics/dame/loginbg.png create mode 100644 setup/upgrade/resources/graphics/dame/navbar.png create mode 100644 setup/upgrade/resources/graphics/dame/powered-by-kt.png create mode 100644 setup/upgrade/resources/graphics/dame/tick1.png create mode 100644 setup/upgrade/resources/graphics/dame/tick2.png create mode 100644 setup/upgrade/resources/graphics/dame/upgrader-header_logo.png create mode 100644 setup/upgrade/resources/graphics/dame/upgrader_head.png create mode 100644 setup/upgrade/resources/graphics/dropbox.png create mode 100644 setup/upgrade/resources/graphics/dropbox_old.png create mode 100644 setup/upgrade/resources/graphics/footer.png create mode 100644 setup/upgrade/resources/graphics/gradient.png create mode 100644 setup/upgrade/resources/graphics/inactive.png create mode 100644 setup/upgrade/resources/graphics/indicator.png create mode 100644 setup/upgrade/resources/graphics/kt_browse.png create mode 100644 setup/upgrade/resources/graphics/left.png create mode 100644 setup/upgrade/resources/graphics/logo.png create mode 100644 setup/upgrade/resources/graphics/powered-by-kt.png create mode 100644 setup/upgrade/resources/graphics/question.gif create mode 100644 setup/upgrade/resources/graphics/tick.png create mode 100644 setup/upgrade/resources/graphics/tree.jpg create mode 100644 setup/upgrade/resources/jquery.blockUI.js create mode 100644 setup/upgrade/resources/jquery.form.js create mode 100644 setup/upgrade/resources/jquery.js create mode 100644 setup/upgrade/resources/wizard.css create mode 100644 setup/upgrade/resources/wizard.js create mode 100644 setup/upgrade/step.php create mode 100644 setup/upgrade/stepAction.php create mode 100644 setup/upgrade/steps/upgradeBackup.php create mode 100644 setup/upgrade/steps/upgradeComplete.php create mode 100644 setup/upgrade/steps/upgradeDatabase.php create mode 100644 setup/upgrade/steps/upgradeErrors.php create mode 100644 setup/upgrade/steps/upgradeInstallation.php create mode 100644 setup/upgrade/steps/upgradeRestore.php create mode 100644 setup/upgrade/steps/upgradeWelcome.php create mode 100644 setup/upgrade/template.php create mode 100644 setup/upgrade/templates/backup.tpl create mode 100644 setup/upgrade/templates/complete.tpl create mode 100644 setup/upgrade/templates/database.tpl create mode 100644 setup/upgrade/templates/error.tpl create mode 100644 setup/upgrade/templates/errors.tpl create mode 100644 setup/upgrade/templates/installation.tpl create mode 100644 setup/upgrade/templates/restore.tpl create mode 100644 setup/upgrade/templates/welcome.tpl create mode 100644 setup/upgrade/templates/wizard.tpl create mode 100644 setup/upgrade/upgrade create mode 100644 setup/upgrade/upgradeIni.php create mode 100644 setup/upgrade/upgradeSession.php create mode 100644 setup/upgrade/upgradeUtil.php create mode 100644 setup/upgrade/upgradeWizard.php create mode 100644 setup/upgrade/upgradedbUtil.php create mode 100644 setup/upgrade/upgrader.php diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index e70e890..e55fd56 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -38,6 +38,9 @@ * */ +// stuff in the new installer section database upgrade fails without this +global $default; + if (defined('DMS_DEFAULTS_INCLUDED')) { return; @@ -662,5 +665,4 @@ if (!extension_loaded('mbstring')) require_once(KT_LIB_DIR . '/templating/kt3template.inc.php'); $GLOBALS['main'] =new KTPage(); - ?> diff --git a/setup/upgrade/config/config.xml b/setup/upgrade/config/config.xml new file mode 100644 index 0000000..aa11286 --- /dev/null +++ b/setup/upgrade/config/config.xml @@ -0,0 +1,19 @@ + + + + + + + welcome + installation + backup + restore + database + complete + + \ No newline at end of file diff --git a/setup/upgrade/config/databases.xml b/setup/upgrade/config/databases.xml new file mode 100644 index 0000000..eae3c9f --- /dev/null +++ b/setup/upgrade/config/databases.xml @@ -0,0 +1,22 @@ + + + + + + + mysql + + localhost + 3306 + dms + root + dmsadminuser + js9281djw + dmsuser + djw9281js + diff --git a/setup/upgrade/index.php b/setup/upgrade/index.php index a02f362..30b902d 100644 --- a/setup/upgrade/index.php +++ b/setup/upgrade/index.php @@ -1,3 +1,43 @@ -. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +require_once("upgradeWizard.php"); ?> \ No newline at end of file diff --git a/setup/upgrade/path.php b/setup/upgrade/path.php new file mode 100644 index 0000000..5a81e2b --- /dev/null +++ b/setup/upgrade/path.php @@ -0,0 +1,134 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + // Define installer environment + define('DEBUG', 0); + define('AJAX', 0); + // Define upgrader environment + if (substr(php_uname(), 0, 7) == "Windows"){ + define('WINDOWS_OS', true); + define('UNIX_OS', false); + define('OS', 'windows'); + } else { + define('WINDOWS_OS', false); + define('UNIX_OS', true); + define('OS', 'unix'); + } + if(WINDOWS_OS) { + define('DS', '\\'); + } else { + define('DS', '/'); + } + // Define environment root + $wizard = realpath(dirname(__FILE__)); + $xdir = explode(DS, $wizard); + array_pop($xdir); + array_pop($xdir); + $sys = ''; + foreach ($xdir as $k=>$v) { + $sys .= $v.DS; + } + // Define paths to wizard + define('UPGRADE_DIR', $wizard.DS); + define('WIZARD_LIB', UPGRADE_DIR."lib".DS); + define('SQL_DIR', UPGRADE_DIR."sql".DS); + define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS); + define('CONF_DIR', UPGRADE_DIR."config".DS); + define('RES_DIR', UPGRADE_DIR."resources".DS); + define('STEP_DIR', UPGRADE_DIR."steps".DS); + define('TEMP_DIR', UPGRADE_DIR."templates".DS); + define('SHELL_DIR', UPGRADE_DIR."shells".DS); + define('OUTPUT_DIR', UPGRADE_DIR."output".DS); + // Define paths to system webroot + define('SYSTEM_DIR', $sys); + define('SYS_VAR_DIR', SYSTEM_DIR."var".DS); + define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); + define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS); + define('SYS_OUT_DIR', SYS_VAR_DIR); + define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS); + // Define paths to system + array_pop($xdir); + $asys = ''; + foreach ($xdir as $k=>$v) { + $asys .= $v.DS; + } + define('SYSTEM_ROOT', $asys); + // Upgrade Type + preg_match('/Zend/', $sys, $matches); // TODO: Dirty + if($matches) { + $sysdir = explode(DS, $sys); + array_pop($sysdir); + array_pop($sysdir); + array_pop($sysdir); + array_pop($sysdir); + $zendsys = ''; + foreach ($sysdir as $k=>$v) { + $zendsys .= $v.DS; + } + define('INSTALL_TYPE', 'Zend'); + define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS); + } else { + $modules = get_loaded_extensions(); + // TODO: Dirty + if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) { + define('INSTALL_TYPE', 'Zend'); + define('PHP_DIR', ''); + } else { + define('INSTALL_TYPE', ''); + define('PHP_DIR', ''); + } + } + // Other + date_default_timezone_set('Africa/Johannesburg'); + if(WINDOWS_OS) { // Mysql bin [Windows] + $serverPaths = explode(';',$_SERVER['PATH']); + foreach ($serverPaths as $apath) { + preg_match('/mysql/i', $apath, $matches); + if($matches) { + define('MYSQL_BIN', $apath.DS); + break; + } + } + } else { + define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line + } + +?> diff --git a/setup/upgrade/resources/form.js b/setup/upgrade/resources/form.js new file mode 100644 index 0000000..7e1815b --- /dev/null +++ b/setup/upgrade/resources/form.js @@ -0,0 +1,13 @@ +$(document).ready(function() { + var options = {target: '#content_container', beforeSubmit: w.showRequest, success: w.showResponse}; + $.blockUI.defaults.css = {}; + var override = $('form').attr('onsubmit'); + if(override == undefined) { + $('form').ajaxForm(options); + w.adjustMenu($('form').attr('id')); + } else { + var options = {target: '#content_container', beforeSubmit: w.validateRegistration, success: w.adjustMenu($('form').attr('id'))}; + $('form').ajaxForm(options); + } +}); + diff --git a/setup/upgrade/resources/graphics/active.png b/setup/upgrade/resources/graphics/active.png new file mode 100644 index 0000000..62b232c Binary files /dev/null and b/setup/upgrade/resources/graphics/active.png differ diff --git a/setup/upgrade/resources/graphics/background.gif b/setup/upgrade/resources/graphics/background.gif new file mode 100644 index 0000000..d8039fb Binary files /dev/null and b/setup/upgrade/resources/graphics/background.gif differ diff --git a/setup/upgrade/resources/graphics/big-ok.png b/setup/upgrade/resources/graphics/big-ok.png new file mode 100644 index 0000000..62c9046 Binary files /dev/null and b/setup/upgrade/resources/graphics/big-ok.png differ diff --git a/setup/upgrade/resources/graphics/cross.png b/setup/upgrade/resources/graphics/cross.png new file mode 100644 index 0000000..3ba9615 Binary files /dev/null and b/setup/upgrade/resources/graphics/cross.png differ diff --git a/setup/upgrade/resources/graphics/cross_orange.png b/setup/upgrade/resources/graphics/cross_orange.png new file mode 100644 index 0000000..cb02cd5 Binary files /dev/null and b/setup/upgrade/resources/graphics/cross_orange.png differ diff --git a/setup/upgrade/resources/graphics/dame/dot.png b/setup/upgrade/resources/graphics/dame/dot.png new file mode 100644 index 0000000..0365307 Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/dot.png differ diff --git a/setup/upgrade/resources/graphics/dame/finish.png b/setup/upgrade/resources/graphics/dame/finish.png new file mode 100644 index 0000000..6176f6e Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/finish.png differ diff --git a/setup/upgrade/resources/graphics/dame/gradiant.gif b/setup/upgrade/resources/graphics/dame/gradiant.gif new file mode 100644 index 0000000..019998d Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/gradiant.gif differ diff --git a/setup/upgrade/resources/graphics/dame/kt_gradient.jpg b/setup/upgrade/resources/graphics/dame/kt_gradient.jpg new file mode 100644 index 0000000..e5c3b5b Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/kt_gradient.jpg differ diff --git a/setup/upgrade/resources/graphics/dame/loginbg.png b/setup/upgrade/resources/graphics/dame/loginbg.png new file mode 100644 index 0000000..02c3ad7 Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/loginbg.png differ diff --git a/setup/upgrade/resources/graphics/dame/navbar.png b/setup/upgrade/resources/graphics/dame/navbar.png new file mode 100644 index 0000000..c29b192 Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/navbar.png differ diff --git a/setup/upgrade/resources/graphics/dame/powered-by-kt.png b/setup/upgrade/resources/graphics/dame/powered-by-kt.png new file mode 100644 index 0000000..0526fd8 Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/powered-by-kt.png differ diff --git a/setup/upgrade/resources/graphics/dame/tick1.png b/setup/upgrade/resources/graphics/dame/tick1.png new file mode 100644 index 0000000..2df208f Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/tick1.png differ diff --git a/setup/upgrade/resources/graphics/dame/tick2.png b/setup/upgrade/resources/graphics/dame/tick2.png new file mode 100644 index 0000000..979f834 Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/tick2.png differ diff --git a/setup/upgrade/resources/graphics/dame/upgrader-header_logo.png b/setup/upgrade/resources/graphics/dame/upgrader-header_logo.png new file mode 100644 index 0000000..c5d8e7d Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/upgrader-header_logo.png differ diff --git a/setup/upgrade/resources/graphics/dame/upgrader_head.png b/setup/upgrade/resources/graphics/dame/upgrader_head.png new file mode 100644 index 0000000..dcd92ac Binary files /dev/null and b/setup/upgrade/resources/graphics/dame/upgrader_head.png differ diff --git a/setup/upgrade/resources/graphics/dropbox.png b/setup/upgrade/resources/graphics/dropbox.png new file mode 100644 index 0000000..af538e5 Binary files /dev/null and b/setup/upgrade/resources/graphics/dropbox.png differ diff --git a/setup/upgrade/resources/graphics/dropbox_old.png b/setup/upgrade/resources/graphics/dropbox_old.png new file mode 100644 index 0000000..6958c3c Binary files /dev/null and b/setup/upgrade/resources/graphics/dropbox_old.png differ diff --git a/setup/upgrade/resources/graphics/footer.png b/setup/upgrade/resources/graphics/footer.png new file mode 100644 index 0000000..6486da9 Binary files /dev/null and b/setup/upgrade/resources/graphics/footer.png differ diff --git a/setup/upgrade/resources/graphics/gradient.png b/setup/upgrade/resources/graphics/gradient.png new file mode 100644 index 0000000..6074bca Binary files /dev/null and b/setup/upgrade/resources/graphics/gradient.png differ diff --git a/setup/upgrade/resources/graphics/inactive.png b/setup/upgrade/resources/graphics/inactive.png new file mode 100644 index 0000000..dfe29a2 Binary files /dev/null and b/setup/upgrade/resources/graphics/inactive.png differ diff --git a/setup/upgrade/resources/graphics/indicator.png b/setup/upgrade/resources/graphics/indicator.png new file mode 100644 index 0000000..89dbff0 Binary files /dev/null and b/setup/upgrade/resources/graphics/indicator.png differ diff --git a/setup/upgrade/resources/graphics/kt_browse.png b/setup/upgrade/resources/graphics/kt_browse.png new file mode 100644 index 0000000..048cd6c Binary files /dev/null and b/setup/upgrade/resources/graphics/kt_browse.png differ diff --git a/setup/upgrade/resources/graphics/left.png b/setup/upgrade/resources/graphics/left.png new file mode 100644 index 0000000..b74fcf7 Binary files /dev/null and b/setup/upgrade/resources/graphics/left.png differ diff --git a/setup/upgrade/resources/graphics/logo.png b/setup/upgrade/resources/graphics/logo.png new file mode 100644 index 0000000..bfeefd8 Binary files /dev/null and b/setup/upgrade/resources/graphics/logo.png differ diff --git a/setup/upgrade/resources/graphics/powered-by-kt.png b/setup/upgrade/resources/graphics/powered-by-kt.png new file mode 100644 index 0000000..2bc078b Binary files /dev/null and b/setup/upgrade/resources/graphics/powered-by-kt.png differ diff --git a/setup/upgrade/resources/graphics/question.gif b/setup/upgrade/resources/graphics/question.gif new file mode 100644 index 0000000..390a7fc Binary files /dev/null and b/setup/upgrade/resources/graphics/question.gif differ diff --git a/setup/upgrade/resources/graphics/tick.png b/setup/upgrade/resources/graphics/tick.png new file mode 100644 index 0000000..a24d605 Binary files /dev/null and b/setup/upgrade/resources/graphics/tick.png differ diff --git a/setup/upgrade/resources/graphics/tree.jpg b/setup/upgrade/resources/graphics/tree.jpg new file mode 100644 index 0000000..d9e11f6 Binary files /dev/null and b/setup/upgrade/resources/graphics/tree.jpg differ diff --git a/setup/upgrade/resources/jquery.blockUI.js b/setup/upgrade/resources/jquery.blockUI.js new file mode 100644 index 0000000..3a50783 --- /dev/null +++ b/setup/upgrade/resources/jquery.blockUI.js @@ -0,0 +1,463 @@ +/*! + * jQuery blockUI plugin + * Version 2.26 (09-SEP-2009) + * @requires jQuery v1.2.3 or later + * + * Examples at: http://malsup.com/jquery/block/ + * Copyright (c) 2007-2008 M. Alsup + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Thanks to Amir-Hossein Sobhi for some excellent contributions! + */ + +;(function($) { + +if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) { + alert('blockUI requires jQuery v1.2.3 or later! You are using v' + $.fn.jquery); + return; +} + +$.fn._fadeIn = $.fn.fadeIn; + +// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle +// retarded userAgent strings on Vista) +var mode = document.documentMode || 0; +var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8); +var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode; + +// global $ methods for blocking/unblocking the entire page +$.blockUI = function(opts) { install(window, opts); }; +$.unblockUI = function(opts) { remove(window, opts); }; + +// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl) +$.growlUI = function(title, message, timeout, onClose) { + var $m = $('
'); + if (title) $m.append('

'+title+'

'); + if (message) $m.append('

'+message+'

'); + if (timeout == undefined) timeout = 3000; + $.blockUI({ + message: $m, fadeIn: 700, fadeOut: 1000, centerY: false, + timeout: timeout, showOverlay: false, + onUnblock: onClose, + css: $.blockUI.defaults.growlCSS + }); +}; + +// plugin method for blocking element content +$.fn.block = function(opts) { + return this.unblock({ fadeOut: 0 }).each(function() { + if ($.css(this,'position') == 'static') + this.style.position = 'relative'; + if ($.browser.msie) + this.style.zoom = 1; // force 'hasLayout' + install(this, opts); + }); +}; + +// plugin method for unblocking element content +$.fn.unblock = function(opts) { + return this.each(function() { + remove(this, opts); + }); +}; + +$.blockUI.version = 2.26; // 2nd generation blocking at no extra cost! + +// override these in your code to change the default behavior and style +$.blockUI.defaults = { + // message displayed when blocking (use null for no message) + message: '

Please wait...

', + + title: null, // title string; only used when theme == true + draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded) + + theme: false, // set to true to use with jQuery UI themes + + // styles for the message when blocking; if you wish to disable + // these and use an external stylesheet then do this in your code: + // $.blockUI.defaults.css = {}; + css: { + padding: 0, + margin: 0, + width: '30%', + top: '40%', + left: '35%', + textAlign: 'center', + color: '#000', + border: '3px solid #aaa', + backgroundColor:'#fff', + cursor: 'wait' + }, + + // minimal style set used when themes are used + themedCSS: { + width: '30%', + top: '40%', + left: '35%' + }, + + // styles for the overlay + overlayCSS: { + backgroundColor: '#000', + opacity: 0.6, + cursor: 'wait' + }, + + // styles applied when using $.growlUI + growlCSS: { + width: '350px', + top: '10px', + left: '', + right: '10px', + border: 'none', + padding: '5px', + opacity: 0.6, + cursor: 'default', + color: '#fff', + backgroundColor: '#000', + '-webkit-border-radius': '10px', + '-moz-border-radius': '10px' + }, + + // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w + // (hat tip to Jorge H. N. de Vasconcelos) + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank', + + // force usage of iframe in non-IE browsers (handy for blocking applets) + forceIframe: false, + + // z-index for the blocking overlay + baseZ: 1000, + + // set these to true to have the message automatically centered + centerX: true, // <-- only effects element blocking (page block controlled via css above) + centerY: true, + + // allow body element to be stetched in ie6; this makes blocking look better + // on "short" pages. disable if you wish to prevent changes to the body height + allowBodyStretch: true, + + // enable if you want key and mouse events to be disabled for content that is blocked + bindEvents: true, + + // be default blockUI will supress tab navigation from leaving blocking content + // (if bindEvents is true) + constrainTabKey: true, + + // fadeIn time in millis; set to 0 to disable fadeIn on block + fadeIn: 200, + + // fadeOut time in millis; set to 0 to disable fadeOut on unblock + fadeOut: 400, + + // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock + timeout: 0, + + // disable if you don't want to show the overlay + showOverlay: true, + + // if true, focus will be placed in the first available input field when + // page blocking + focusInput: true, + + // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity) + applyPlatformOpacityRules: true, + + // callback method invoked when unblocking has completed; the callback is + // passed the element that has been unblocked (which is the window object for page + // blocks) and the options that were passed to the unblock call: + // onUnblock(element, options) + onUnblock: null, + + // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493 + quirksmodeOffsetHack: 4 +}; + +// private data and functions follow... + +var pageBlock = null; +var pageBlockEls = []; + +function install(el, opts) { + var full = (el == window); + var msg = opts && opts.message !== undefined ? opts.message : undefined; + opts = $.extend({}, $.blockUI.defaults, opts || {}); + opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {}); + var css = $.extend({}, $.blockUI.defaults.css, opts.css || {}); + var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {}); + msg = msg === undefined ? opts.message : msg; + + // remove the current block (if there is one) + if (full && pageBlock) + remove(window, {fadeOut:0}); + + // if an existing element is being used as the blocking content then we capture + // its current place in the DOM (and current display style) so we can restore + // it when we unblock + if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) { + var node = msg.jquery ? msg[0] : msg; + var data = {}; + $(el).data('blockUI.history', data); + data.el = node; + data.parent = node.parentNode; + data.display = node.style.display; + data.position = node.style.position; + if (data.parent) + data.parent.removeChild(node); + } + + var z = opts.baseZ; + + // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform; + // layer1 is the iframe layer which is used to supress bleed through of underlying content + // layer2 is the overlay layer which has opacity and a wait cursor (by default) + // layer3 is the message content that is displayed while blocking + + var lyr1 = ($.browser.msie || opts.forceIframe) + ? $('') + : $(''); + var lyr2 = $(''); + + var lyr3; + if (opts.theme && full) { + var s = ''; + lyr3 = $(s); + } + else { + lyr3 = full ? $('') + : $(''); + } + + // if we have a message, style it + if (msg) { + if (opts.theme) { + lyr3.css(themedCSS); + lyr3.addClass('ui-widget-content'); + } + else + lyr3.css(css); + } + + // style the overlay + if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform))) + lyr2.css(opts.overlayCSS); + lyr2.css('position', full ? 'fixed' : 'absolute'); + + // make iframe layer transparent in IE + if ($.browser.msie || opts.forceIframe) + lyr1.css('opacity',0.0); + + $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el); + + if (opts.theme && opts.draggable && $.fn.draggable) { + lyr3.draggable({ + handle: '.ui-dialog-titlebar', + cancel: 'li' + }); + } + + // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling) + var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0); + if (ie6 || expr) { + // give body 100% height + if (full && opts.allowBodyStretch && $.boxModel) + $('html,body').css('height','100%'); + + // fix ie6 issue when blocked element has a border width + if ((ie6 || !$.boxModel) && !full) { + var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth'); + var fixT = t ? '(0 - '+t+')' : 0; + var fixL = l ? '(0 - '+l+')' : 0; + } + + // simulate fixed position + $.each([lyr1,lyr2,lyr3], function(i,o) { + var s = o[0].style; + s.position = 'absolute'; + if (i < 2) { + full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"') + : s.setExpression('height','this.parentNode.offsetHeight + "px"'); + full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"') + : s.setExpression('width','this.parentNode.offsetWidth + "px"'); + if (fixL) s.setExpression('left', fixL); + if (fixT) s.setExpression('top', fixT); + } + else if (opts.centerY) { + if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"'); + s.marginTop = 0; + } + else if (!opts.centerY && full) { + var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0; + var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"'; + s.setExpression('top',expression); + } + }); + } + + // show the message + if (msg) { + if (opts.theme) + lyr3.find('.ui-widget-content').append(msg); + else + lyr3.append(msg); + if (msg.jquery || msg.nodeType) + $(msg).show(); + } + + if (($.browser.msie || opts.forceIframe) && opts.showOverlay) + lyr1.show(); // opacity is zero + if (opts.fadeIn) { + if (opts.showOverlay) + lyr2._fadeIn(opts.fadeIn); + if (msg) + lyr3.fadeIn(opts.fadeIn); + } + else { + if (opts.showOverlay) + lyr2.show(); + if (msg) + lyr3.show(); + } + + // bind key and mouse events + bind(1, el, opts); + + if (full) { + pageBlock = lyr3[0]; + pageBlockEls = $(':input:enabled:visible',pageBlock); + if (opts.focusInput) + setTimeout(focus, 20); + } + else + center(lyr3[0], opts.centerX, opts.centerY); + + if (opts.timeout) { + // auto-unblock + var to = setTimeout(function() { + full ? $.unblockUI(opts) : $(el).unblock(opts); + }, opts.timeout); + $(el).data('blockUI.timeout', to); + } +}; + +// remove the block +function remove(el, opts) { + var full = (el == window); + var $el = $(el); + var data = $el.data('blockUI.history'); + var to = $el.data('blockUI.timeout'); + if (to) { + clearTimeout(to); + $el.removeData('blockUI.timeout'); + } + opts = $.extend({}, $.blockUI.defaults, opts || {}); + bind(0, el, opts); // unbind events + + var els; + if (full) // crazy selector to handle odd field errors in ie6/7 + els = $('body').children().filter('.blockUI').add('body > .blockUI'); + else + els = $('.blockUI', el); + + if (full) + pageBlock = pageBlockEls = null; + + if (opts.fadeOut) { + els.fadeOut(opts.fadeOut); + setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut); + } + else + reset(els, data, opts, el); +}; + +// move blocking element back into the DOM where it started +function reset(els,data,opts,el) { + els.each(function(i,o) { + // remove via DOM calls so we don't lose event handlers + if (this.parentNode) + this.parentNode.removeChild(this); + }); + + if (data && data.el) { + data.el.style.display = data.display; + data.el.style.position = data.position; + if (data.parent) + data.parent.appendChild(data.el); + $(data.el).removeData('blockUI.history'); + } + + if (typeof opts.onUnblock == 'function') + opts.onUnblock(el,opts); +}; + +// bind/unbind the handler +function bind(b, el, opts) { + var full = el == window, $el = $(el); + + // don't bother unbinding if there is nothing to unbind + if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked'))) + return; + if (!full) + $el.data('blockUI.isBlocked', b); + + // don't bind events when overlay is not in use or if bindEvents is false + if (!opts.bindEvents || (b && !opts.showOverlay)) + return; + + // bind anchors and inputs for mouse and key events + var events = 'mousedown mouseup keydown keypress'; + b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler); + +// former impl... +// var $e = $('a,:input'); +// b ? $e.bind(events, opts, handler) : $e.unbind(events, handler); +}; + +// event handler to suppress keyboard/mouse events when blocking +function handler(e) { + // allow tab navigation (conditionally) + if (e.keyCode && e.keyCode == 9) { + if (pageBlock && e.data.constrainTabKey) { + var els = pageBlockEls; + var fwd = !e.shiftKey && e.target == els[els.length-1]; + var back = e.shiftKey && e.target == els[0]; + if (fwd || back) { + setTimeout(function(){focus(back)},10); + return false; + } + } + } + // allow events within the message content + if ($(e.target).parents('div.blockMsg').length > 0) + return true; + + // allow events for content that is not being blocked + return $(e.target).parents().children().filter('div.blockUI').length == 0; +}; + +function focus(back) { + if (!pageBlockEls) + return; + var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0]; + if (e) + e.focus(); +}; + +function center(el, x, y) { + var p = el.parentNode, s = el.style; + var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); + var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); + if (x) s.left = l > 0 ? (l+'px') : '0'; + if (y) s.top = t > 0 ? (t+'px') : '0'; +}; + +function sz(el, p) { + return parseInt($.css(el,p))||0; +}; + +})(jQuery); diff --git a/setup/upgrade/resources/jquery.form.js b/setup/upgrade/resources/jquery.form.js new file mode 100644 index 0000000..51225ea --- /dev/null +++ b/setup/upgrade/resources/jquery.form.js @@ -0,0 +1,13 @@ +// $Id: jquery.form.js,v 1.2 2007/11/19 10:05:48 goba Exp $ + +/* + * jQuery Form Plugin + * version: 2.01 (10/31/2007) + * @requires jQuery v1.1 or later + * + * Examples at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.7.1j=5(o){2(P o==\'5\')o={L:o};o=$.2h({1h:4.X(\'2i\')||1E.2u.3D(),I:4.X(\'2g\')||\'29\'},o||{});3 p={};$.M.N(\'R.2P.2L\',[4,o,p]);2(p.1Q)6 4;3 a=4.1z(o.2r);2(o.V){H(3 n 3u o.V)a.C({z:n,A:o.V[n]})}2(o.28&&o.28(a,4,o)===E)6 4;$.M.N(\'R.K.36\',[a,4,o,p]);2(p.1Q)6 4;3 q=$.1x(a);2(o.I.31()==\'29\'){o.1h+=(o.1h.2Z(\'?\')>=0?\'&\':\'?\')+q;o.V=B}8 o.V=q;3 r=4,U=[];2(o.1r)U.C(5(){r.1r()});2(o.1o)U.C(5(){r.1o()});2(!o.18&&o.14){3 u=o.L||5(){};U.C(5(a){2(4.1N)$(o.14).X("1M",a).1N().D(u,1L);8 $(o.14).2t(a).D(u,1L)})}8 2(o.L)U.C(o.L);o.L=5(a,b){H(3 i=0,F=U.G;i\');3 j=i[0];3 k=$.1i.20&&1E.20.30()<9;2($.1i.1X||k)j.2Y=\'2W:E;1w.2U("");\';i.2S({2R:\'2Q\',23:\'-24\',1R:\'-24\'});3 l={Z:B,1b:B,2K:0,2J:\'n/a\',2H:5(){},2F:5(){},2E:5(){}};3 g=f.2B;2(g&&!$.1O++)$.M.N("2x");2(g)$.M.N("2w",[l,f]);3 m=0;3 n=0;1f(5(){i.2v(\'1n\');j.1K?j.1K(\'1J\',12):j.2s(\'1I\',12,E);3 a=d.1H?\'1H\':\'2q\';3 t=r.X(\'14\');r.X({14:h,2g:\'3C\',2i:f.1h});d[a]=\'3B/R-V\';2(f.1G)1f(5(){n=T;12()},f.1G);d.K();r.X(\'14\',t)},10);5 12(){2(m++)6;j.2o?j.2o(\'1J\',12):j.3A(\'1I\',12,E);3 a=T;3z{2(n)3x\'1G\';3 b,O;O=j.2n?j.2n.1w:j.2l?j.2l:j.1w;l.Z=O.1n?O.1n.1M:B;l.1b=O.2k?O.2k:O;2(f.18==\'2j\'||f.18==\'3s\'){3 c=O.1D(\'1C\')[0];b=c?c.A:l.Z;2(f.18==\'2j\')3r("V = "+b);8 $.3q(b)}8 2(f.18==\'2m\'){b=l.1b;2(!b&&l.Z!=B)b=2d(l.Z)}8{b=l.Z}}3p(e){a=E;$.3n(f,l,\'2b\',e)}2(a){f.L(b,\'L\');2(g)$.M.N("3m",[l,f])}2(g)$.M.N("3k",[l,f]);2(g&&!--$.1O)$.M.N("3j");2(f.27)f.27(l,a?\'L\':\'2b\');1f(5(){i.3i();l.1b=B},3g)};5 2d(s,a){2(1E.26){a=25 26(\'3d.3c\');a.3b=\'E\';a.3a(s)}8 a=(25 38()).37(s,\'1A/2m\');6(a&&a.22&&a.22.1e!=\'34\')?a:B}}};$.7.1j.1a=0;$.7.W=5(a){6 4.21().K(1m).D(5(){4.1u=$.7.W.1a++;$.7.W.1t[4.1u]=a;$(":K,19:Y",4).1Z(1s)})};$.7.W.1a=1;$.7.W.1t={};5 1s(e){3 a=4.R;a.Q=4;2(4.I==\'Y\'){2(e.1Y!=S){a.11=e.1Y;a.16=e.2X}8 2(P $.7.1U==\'5\'){3 b=$(4).1U();a.11=e.1V-b.1R;a.16=e.1W-b.23}8{a.11=e.1V-4.2V;a.16=e.1W-4.32}}1f(5(){a.Q=a.11=a.16=B},10)};5 1m(){3 a=4.1u;3 b=$.7.W.1t[a];$(4).1j(b);6 E};$.7.21=5(){4.1T(\'K\',1m);6 4.D(5(){$(":K,19:Y",4).1T(\'1Z\',1s)})};$.7.1z=5(b){3 a=[];2(4.G==0)6 a;3 c=4[0];3 d=b?c.1D(\'*\'):c.2T;2(!d)6 a;H(3 i=0,F=d.G;i)[^>]*$|^#([\w-]+)$/, + // Is it a simple selector + isSimple = /^.[^:#\[\.,]*$/; + +jQuery.fn = jQuery.prototype = { + init: function( selector, context ) { + // Make sure that a selection was provided + selector = selector || document; + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this[0] = selector; + this.length = 1; + this.context = selector; + return this; + } + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + var match = quickExpr.exec( selector ); + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) + selector = jQuery.clean( [ match[1] ], context ); + + // HANDLE: $("#id") + else { + var elem = document.getElementById( match[3] ); + + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem && elem.id != match[3] ) + return jQuery().find( selector ); + + // Otherwise, we inject the element directly into the jQuery object + var ret = jQuery( elem || [] ); + ret.context = document; + ret.selector = selector; + return ret; + } + + // HANDLE: $(expr, [context]) + // (which is just equivalent to: $(content).find(expr) + } else + return jQuery( context ).find( selector ); + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) + return jQuery( document ).ready( selector ); + + // Make sure that old selector state is passed along + if ( selector.selector && selector.context ) { + this.selector = selector.selector; + this.context = selector.context; + } + + return this.setArray(jQuery.isArray( selector ) ? + selector : + jQuery.makeArray(selector)); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.3.2", + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num === undefined ? + + // Return a 'clean' array + Array.prototype.slice.call( this ) : + + // Return just the object + this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = jQuery( elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) + ret.selector = this.selector + (this.selector ? " " : "") + selector; + else if ( name ) + ret.selector = this.selector + "." + name + "(" + selector + ")"; + + // Return the newly-formed element set + return ret; + }, + + // Force the current matched set of elements to become + // the specified array of elements (destroying the stack in the process) + // You should use pushStack() in order to do this, but maintain the stack + setArray: function( elems ) { + // Resetting the length to 0, then using the native Array push + // is a super-fast way to populate an object with array-like properties + this.length = 0; + Array.prototype.push.apply( this, elems ); + + return this; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem && elem.jquery ? elem[0] : elem + , this ); + }, + + attr: function( name, value, type ) { + var options = name; + + // Look for the case where we're accessing a style value + if ( typeof name === "string" ) + if ( value === undefined ) + return this[0] && jQuery[ type || "attr" ]( this[0], name ); + + else { + options = {}; + options[ name ] = value; + } + + // Check to see if we're setting style values + return this.each(function(i){ + // Set all the styles + for ( name in options ) + jQuery.attr( + type ? + this.style : + this, + name, jQuery.prop( this, options[ name ], type, i, name ) + ); + }); + }, + + css: function( key, value ) { + // ignore negative width and height values + if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) + value = undefined; + return this.attr( key, value, "curCSS" ); + }, + + text: function( text ) { + if ( typeof text !== "object" && text != null ) + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); + + var ret = ""; + + jQuery.each( text || this, function(){ + jQuery.each( this.childNodes, function(){ + if ( this.nodeType != 8 ) + ret += this.nodeType != 1 ? + this.nodeValue : + jQuery.fn.text( [ this ] ); + }); + }); + + return ret; + }, + + wrapAll: function( html ) { + if ( this[0] ) { + // The elements to wrap the target around + var wrap = jQuery( html, this[0].ownerDocument ).clone(); + + if ( this[0].parentNode ) + wrap.insertBefore( this[0] ); + + wrap.map(function(){ + var elem = this; + + while ( elem.firstChild ) + elem = elem.firstChild; + + return elem; + }).append(this); + } + + return this; + }, + + wrapInner: function( html ) { + return this.each(function(){ + jQuery( this ).contents().wrapAll( html ); + }); + }, + + wrap: function( html ) { + return this.each(function(){ + jQuery( this ).wrapAll( html ); + }); + }, + + append: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.appendChild( elem ); + }); + }, + + prepend: function() { + return this.domManip(arguments, true, function(elem){ + if (this.nodeType == 1) + this.insertBefore( elem, this.firstChild ); + }); + }, + + before: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this ); + }); + }, + + after: function() { + return this.domManip(arguments, false, function(elem){ + this.parentNode.insertBefore( elem, this.nextSibling ); + }); + }, + + end: function() { + return this.prevObject || jQuery( [] ); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: [].push, + sort: [].sort, + splice: [].splice, + + find: function( selector ) { + if ( this.length === 1 ) { + var ret = this.pushStack( [], "find", selector ); + ret.length = 0; + jQuery.find( selector, this[0], ret ); + return ret; + } else { + return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ + return jQuery.find( selector, elem ); + })), "find", selector ); + } + }, + + clone: function( events ) { + // Do the clone + var ret = this.map(function(){ + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { + // IE copies events bound via attachEvent when + // using cloneNode. Calling detachEvent on the + // clone will also remove the events from the orignal + // In order to get around this, we use innerHTML. + // Unfortunately, this means some modifications to + // attributes in IE that are actually only stored + // as properties will not be copied (such as the + // the name attribute on an input). + var html = this.outerHTML; + if ( !html ) { + var div = this.ownerDocument.createElement("div"); + div.appendChild( this.cloneNode(true) ); + html = div.innerHTML; + } + + return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; + } else + return this.cloneNode(true); + }); + + // Copy the events from the original to the clone + if ( events === true ) { + var orig = this.find("*").andSelf(), i = 0; + + ret.find("*").andSelf().each(function(){ + if ( this.nodeName !== orig[i].nodeName ) + return; + + var events = jQuery.data( orig[i], "events" ); + + for ( var type in events ) { + for ( var handler in events[ type ] ) { + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); + } + } + + i++; + }); + } + + // Return the cloned set + return ret; + }, + + filter: function( selector ) { + return this.pushStack( + jQuery.isFunction( selector ) && + jQuery.grep(this, function(elem, i){ + return selector.call( elem, i ); + }) || + + jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ + return elem.nodeType === 1; + }) ), "filter", selector ); + }, + + closest: function( selector ) { + var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, + closer = 0; + + return this.map(function(){ + var cur = this; + while ( cur && cur.ownerDocument ) { + if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { + jQuery.data(cur, "closest", closer); + return cur; + } + cur = cur.parentNode; + closer++; + } + }); + }, + + not: function( selector ) { + if ( typeof selector === "string" ) + // test special case where just one selector is passed in + if ( isSimple.test( selector ) ) + return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); + else + selector = jQuery.multiFilter( selector, this ); + + var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; + return this.filter(function() { + return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; + }); + }, + + add: function( selector ) { + return this.pushStack( jQuery.unique( jQuery.merge( + this.get(), + typeof selector === "string" ? + jQuery( selector ) : + jQuery.makeArray( selector ) + ))); + }, + + is: function( selector ) { + return !!selector && jQuery.multiFilter( selector, this ).length > 0; + }, + + hasClass: function( selector ) { + return !!selector && this.is( "." + selector ); + }, + + val: function( value ) { + if ( value === undefined ) { + var elem = this[0]; + + if ( elem ) { + if( jQuery.nodeName( elem, 'option' ) ) + return (elem.attributes.value || {}).specified ? elem.value : elem.text; + + // We need to handle select boxes special + if ( jQuery.nodeName( elem, "select" ) ) { + var index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type == "select-one"; + + // Nothing was selected + if ( index < 0 ) + return null; + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + if ( option.selected ) { + // Get the specifc value for the option + value = jQuery(option).val(); + + // We don't need an array for one selects + if ( one ) + return value; + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + } + + // Everything else, we just grab the value + return (elem.value || "").replace(/\r/g, ""); + + } + + return undefined; + } + + if ( typeof value === "number" ) + value += ''; + + return this.each(function(){ + if ( this.nodeType != 1 ) + return; + + if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) + this.checked = (jQuery.inArray(this.value, value) >= 0 || + jQuery.inArray(this.name, value) >= 0); + + else if ( jQuery.nodeName( this, "select" ) ) { + var values = jQuery.makeArray(value); + + jQuery( "option", this ).each(function(){ + this.selected = (jQuery.inArray( this.value, values ) >= 0 || + jQuery.inArray( this.text, values ) >= 0); + }); + + if ( !values.length ) + this.selectedIndex = -1; + + } else + this.value = value; + }); + }, + + html: function( value ) { + return value === undefined ? + (this[0] ? + this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : + null) : + this.empty().append( value ); + }, + + replaceWith: function( value ) { + return this.after( value ).remove(); + }, + + eq: function( i ) { + return this.slice( i, +i + 1 ); + }, + + slice: function() { + return this.pushStack( Array.prototype.slice.apply( this, arguments ), + "slice", Array.prototype.slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function(elem, i){ + return callback.call( elem, i, elem ); + })); + }, + + andSelf: function() { + return this.add( this.prevObject ); + }, + + domManip: function( args, table, callback ) { + if ( this[0] ) { + var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), + scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), + first = fragment.firstChild; + + if ( first ) + for ( var i = 0, l = this.length; i < l; i++ ) + callback.call( root(this[i], first), this.length > 1 || i > 0 ? + fragment.cloneNode(true) : fragment ); + + if ( scripts ) + jQuery.each( scripts, evalScript ); + } + + return this; + + function root( elem, cur ) { + return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? + (elem.getElementsByTagName("tbody")[0] || + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : + elem; + } + } +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +function evalScript( i, elem ) { + if ( elem.src ) + jQuery.ajax({ + url: elem.src, + async: false, + dataType: "script" + }); + + else + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); + + if ( elem.parentNode ) + elem.parentNode.removeChild( elem ); +} + +function now(){ + return +new Date; +} + +jQuery.extend = jQuery.fn.extend = function() { + // copy reference to target object + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) + target = {}; + + // extend jQuery itself if only one argument is passed + if ( length == i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) + // Extend the base object + for ( var name in options ) { + var src = target[ name ], copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) + continue; + + // Recurse if we're merging object values + if ( deep && copy && typeof copy === "object" && !copy.nodeType ) + target[ name ] = jQuery.extend( deep, + // Never move original objects, clone them + src || ( copy.length != null ? [ ] : { } ) + , copy ); + + // Don't bring in undefined values + else if ( copy !== undefined ) + target[ name ] = copy; + + } + + // Return the modified object + return target; +}; + +// exclude the following css properties to add px +var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, + // cache defaultView + defaultView = document.defaultView || {}, + toString = Object.prototype.toString; + +jQuery.extend({ + noConflict: function( deep ) { + window.$ = _$; + + if ( deep ) + window.jQuery = _jQuery; + + return jQuery; + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return toString.call(obj) === "[object Function]"; + }, + + isArray: function( obj ) { + return toString.call(obj) === "[object Array]"; + }, + + // check if an element is in a (or is an) XML document + isXMLDoc: function( elem ) { + return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || + !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); + }, + + // Evalulates a script in a global context + globalEval: function( data ) { + if ( data && /\S/.test(data) ) { + // Inspired by code by Andrea Giammarchi + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html + var head = document.getElementsByTagName("head")[0] || document.documentElement, + script = document.createElement("script"); + + script.type = "text/javascript"; + if ( jQuery.support.scriptEval ) + script.appendChild( document.createTextNode( data ) ); + else + script.text = data; + + // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // This arises when a base node is used (#2709). + head.insertBefore( script, head.firstChild ); + head.removeChild( script ); + } + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, length = object.length; + + if ( args ) { + if ( length === undefined ) { + for ( name in object ) + if ( callback.apply( object[ name ], args ) === false ) + break; + } else + for ( ; i < length; ) + if ( callback.apply( object[ i++ ], args ) === false ) + break; + + // A special, fast, case for the most common use of each + } else { + if ( length === undefined ) { + for ( name in object ) + if ( callback.call( object[ name ], name, object[ name ] ) === false ) + break; + } else + for ( var value = object[0]; + i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} + } + + return object; + }, + + prop: function( elem, value, type, i, name ) { + // Handle executable functions + if ( jQuery.isFunction( value ) ) + value = value.call( elem, i ); + + // Handle passing in a number to a CSS property + return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? + value + "px" : + value; + }, + + className: { + // internal only, use addClass("class") + add: function( elem, classNames ) { + jQuery.each((classNames || "").split(/\s+/), function(i, className){ + if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) + elem.className += (elem.className ? " " : "") + className; + }); + }, + + // internal only, use removeClass("class") + remove: function( elem, classNames ) { + if (elem.nodeType == 1) + elem.className = classNames !== undefined ? + jQuery.grep(elem.className.split(/\s+/), function(className){ + return !jQuery.className.has( classNames, className ); + }).join(" ") : + ""; + }, + + // internal only, use hasClass("class") + has: function( elem, className ) { + return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; + } + }, + + // A method for quickly swapping in/out CSS properties to get correct calculations + swap: function( elem, options, callback ) { + var old = {}; + // Remember the old values, and insert the new ones + for ( var name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + callback.call( elem ); + + // Revert the old values + for ( var name in options ) + elem.style[ name ] = old[ name ]; + }, + + css: function( elem, name, force, extra ) { + if ( name == "width" || name == "height" ) { + var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; + + function getWH() { + val = name == "width" ? elem.offsetWidth : elem.offsetHeight; + + if ( extra === "border" ) + return; + + jQuery.each( which, function() { + if ( !extra ) + val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; + if ( extra === "margin" ) + val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; + else + val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; + }); + } + + if ( elem.offsetWidth !== 0 ) + getWH(); + else + jQuery.swap( elem, props, getWH ); + + return Math.max(0, Math.round(val)); + } + + return jQuery.curCSS( elem, name, force ); + }, + + curCSS: function( elem, name, force ) { + var ret, style = elem.style; + + // We need to handle opacity special in IE + if ( name == "opacity" && !jQuery.support.opacity ) { + ret = jQuery.attr( style, "opacity" ); + + return ret == "" ? + "1" : + ret; + } + + // Make sure we're using the right name for getting the float value + if ( name.match( /float/i ) ) + name = styleFloat; + + if ( !force && style && style[ name ] ) + ret = style[ name ]; + + else if ( defaultView.getComputedStyle ) { + + // Only "float" is needed here + if ( name.match( /float/i ) ) + name = "float"; + + name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); + + var computedStyle = defaultView.getComputedStyle( elem, null ); + + if ( computedStyle ) + ret = computedStyle.getPropertyValue( name ); + + // We should always get a number back from opacity + if ( name == "opacity" && ret == "" ) + ret = "1"; + + } else if ( elem.currentStyle ) { + var camelCase = name.replace(/\-(\w)/g, function(all, letter){ + return letter.toUpperCase(); + }); + + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { + // Remember the original values + var left = style.left, rsLeft = elem.runtimeStyle.left; + + // Put in the new values to get a computed value out + elem.runtimeStyle.left = elem.currentStyle.left; + style.left = ret || 0; + ret = style.pixelLeft + "px"; + + // Revert the changed values + style.left = left; + elem.runtimeStyle.left = rsLeft; + } + } + + return ret; + }, + + clean: function( elems, context, fragment ) { + context = context || document; + + // !context.createElement fails in IE with an error but returns typeof 'object' + if ( typeof context.createElement === "undefined" ) + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { + var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); + if ( match ) + return [ context.createElement( match[1] ) ]; + } + + var ret = [], scripts = [], div = context.createElement("div"); + + jQuery.each(elems, function(i, elem){ + if ( typeof elem === "number" ) + elem += ''; + + if ( !elem ) + return; + + // Convert html string into DOM nodes + if ( typeof elem === "string" ) { + // Fix "XHTML"-style tags in all browsers + elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ + return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? + all : + front + ">"; + }); + + // Trim whitespace, otherwise indexOf won't work as expected + var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); + + var wrap = + // option or optgroup + !tags.indexOf("", "" ] || + + !tags.indexOf("", "" ] || + + tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && + [ 1, "", "
" ] || + + !tags.indexOf("", "" ] || + + // matched above + (!tags.indexOf("", "" ] || + + !tags.indexOf("", "" ] || + + // IE can't serialize and + +

+ The mysqldump utility was not found in the subdirectory. + +        + + The backup file "" has been created. +

It appears as though the backup has been successful. +

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

+ + +
+ cd +
+ + The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. +

+ If you need to restore from this backup, you should be able to use the following statements: +

+ + +
+ + +
+ + + 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. +

+ + +
+ +
+ +
+ +        + +        + + 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) + { + if (is_file($dir . '/' . $mysqlname)) + { + return $dir; + } + } + + 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); + } + 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 new file mode 100644 index 0000000..edba512 --- /dev/null +++ b/setup/upgrade/steps/upgradeComplete.php @@ -0,0 +1,82 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + +class upgradeComplete extends Step { + + /** + * Reference to Database object + * + * @author KnowledgeTree Team + * @access private + * @var object + */ + private $_dbhandler = null; + + private $privileges_check = 'tick'; + private $database_check = 'tick'; + protected $silent = true; + + protected $util = null; + + public function __construct() { + $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); + $this->_dbhandler = new dbUtil(); + $this->util = new UpgradeUtil(); + } + + function doStep() { + $this->doRun(); + return 'landing'; + } + + function doRun() { + $this->storeSilent();// Set silent mode variables + } + + /** + * Set all silent mode varibles + * + */ + private function storeSilent() { + } +} +?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php new file mode 100644 index 0000000..2898ebb --- /dev/null +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -0,0 +1,564 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + +// include defaults +require '../../config/dmsDefaults.php'; +require_once KT_LIB_DIR . '/config/config.inc.php'; +include KT_LIB_DIR . '/upgrades/upgrade.inc.php'; + +class upgradeDatabase extends Step +{ + /** + * Reference to Database object + * + * @author KnowledgeTree Team + * @access public + * @var object + */ + public $_dbhandler = null; + + /** + * Reference to Database object + * + * @author KnowledgeTree Team + * @access public + * @var object + */ + public $_util = null; + + /** + * Database type + * + * @author KnowledgeTree Team + * @access private + * @var array + */ + private $dtype = ''; + + /** + * Database types + * + * @author KnowledgeTree Team + * @access private + * @var array + */ + private $dtypes = array(); + + /** + * Database host + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dhost = ''; + + /** + * Database port + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dport = ''; + + /** + * Database name + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dname = ''; + + /** + * Database root username + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $duname = ''; + + /** + * Database root password + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dpassword = ''; + + /** + * Database dms username + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dmsname = ''; + + /** + * Database dms password + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dmspassword = ''; + + /** + * Default dms user username + * + * @author KnowledgeTree Team + * @access private + * @var boolean + */ + private $dmsusername = ''; + + /** + * Default dms user password + * + * @author KnowledgeTree Team + * @access private + * @var boolean + */ + private $dmsuserpassword = ''; + + /** + * Location of database binaries. + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $mysqlDir; // TODO:multiple databases + + /** + * Name of database binary. + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $dbbinary = ''; // TODO:multiple databases + + /** + * Database table prefix + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $tprefix = ''; + + /** + * Flag to drop database + * + * @author KnowledgeTree Team + * @access private + * @var boolean + */ + private $ddrop = false; + + /** + * List of errors encountered + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + public $error = array(); + + /** + * List of errors used in template + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); + + /** + * Flag to store class information in session + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + public $storeInSession = true; + + /** + * Flag if step needs to be upgraded + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + protected $runUpgrade = true; + + /** + * Flag if step needs to run silently + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + protected $silent = true; + + /** + * Constructs database object + * + * @author KnowledgeTree Team + * @access public + * @param none + */ + public function __construct() { + $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent); + $this->_dbhandler = new UpgradedbUtil(); + $this->_util = new UpgradeUtil(); + if(WINDOWS_OS) + $this->mysqlDir = MYSQL_BIN; + } + + /** + * Main control of database setup + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return string + */ + public function doStep() { + parent::doStep(); + $this->initErrors(); + $this->setDetails(); // Set any posted variables + if(!$this->inStep("database")) { + $this->doRun(); + return 'landing'; + } + if($this->next()) { + if ($this->doRun()) { + return 'next'; + } + } else if($this->previous()) { + return 'previous'; + } + else if ($this->backup()) { + return 'backup'; + } + else if ($this->restore()) { + return 'restore'; + } + else if ($this->upgrading()) { + $this->doRun('runUpgrade'); + return 'next'; + } + else if ($this->confirm()) { + if ($this->doRun('confirm')) { + return 'next'; + } + return 'error'; + } + + $this->doRun(); + return 'landing'; + } + + function backup() { + return isset($_POST['Backup']); + } + + function restore() { + return isset($_POST['Restore']); + } + + function upgrading() { + return isset($_POST['RunUpgrade']); + } + + function doRun($action = null) { + $this->readConfig(KTConfig::getConfigFilename()); + + if($this->dbSettings['dbPort'] == '') { + $con = $this->_dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'], + $this->dbSettings['dbPass'], $this->dbSettings['dbName']); + } else { + $con = $this->_dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'], + $this->dbSettings['dbPass'], $this->dbSettings['dbName']); + } + + if (is_null($action) || ($action == 'preview')) { + $this->temp_variables['action'] = 'preview'; + $this->temp_variables['title'] = 'Preview Upgrade'; + $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); + } + else if ($action == 'runUpgrade') { + $this->temp_variables['action'] = 'runUpgrade'; + $this->temp_variables['title'] = 'Confirm Upgrade'; + $this->temp_variables['upgradeTable'] = $this->upgradeConfirm(); + } + else if ($action == 'confirm') { + $this->temp_variables['action'] = 'confirm'; + $this->temp_variables['title'] = 'Upgrade In Progress'; + if (!$this->upgrade()) { + $this->temp_variables['upgradeTable'] = $this->upgradeErrors(); + return false; + } + } + + return true; + } + + public function generateUpgradeTable() { + global $default; + + $this->temp_variables['systemVersion'] = $default->systemVersion; + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); + + $result = $this->_dbhandler->query($query); + if ($result) { + $lastVersionObj = $this->_dbhandler->fetchNextObject($result); + $lastVersion = $lastVersionObj->value; + } + $currentVersion = $default->systemVersion; + + $upgrades = describeUpgrade($lastVersion, $currentVersion); + + $ret = "\n"; + $ret .= "\n"; + $i=0; + foreach ($upgrades as $upgrade) { + $color=((($i++)%2)==0)?'white':'lightgrey'; + $ret .= sprintf("\n", + htmlspecialchars($upgrade->getDescriptor()), + htmlspecialchars($upgrade->getDescription()), + $upgrade->isAlreadyApplied() ? "Yes" : "No" + ); + } + $ret .= '
CodeDescriptionApplied
%s%s%s
'; + return $ret; + } + + /** + * 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 + * @params none + * @access public + * @return array + */ + public function getStepVars() { + return $this->temp_variables; + } + + /** + * Returns database errors + * + * @author KnowledgeTree Team + * @access public + * @params none + * @return array + */ + public function getErrors() { + + return $this->error; + } + + /** + * Initialize errors to false + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function initErrors() { + foreach ($this->templateErrors as $e) { + $this->error[$e] = false; + } + } + + private function readConfig($path) { + $ini = new UpgradeIni($path); + $dbSettings = $ini->getSection('db'); + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], + 'dbName'=> $dbSettings['dbName'], + 'dbUser'=> $dbSettings['dbUser'], + 'dbPass'=> $dbSettings['dbPass'], + 'dbPort'=> $dbSettings['dbPort'], + 'dbAdminUser'=> $dbSettings['dbAdminUser'], + 'dbAdminPass'=> $dbSettings['dbAdminPass'], + ); +// $ktSettings = $ini->getSection('KnowledgeTree'); +// $froot = $ktSettings['fileSystemRoot']; +// if ($froot == 'default') { +// $froot = $this->location; +// } +// $this->ktSettings = array('fileSystemRoot'=> $froot, +// ); +// $urlPaths = $ini->getSection('urls'); +// $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $froot.DS.'var'), +// array('name'=> 'Log Directory', 'path'=> $froot.DS.'log'), +// array('name'=> 'Document Root', 'path'=> $froot.DS.'Documents'), +// array('name'=> 'UI Directory', 'path'=> $froot.DS.'presentation'.DS.'lookAndFeel'.DS.'knowledgeTree'), +// array('name'=> 'Temporary Directory', 'path'=> $froot.DS.'tmp'), +// array('name'=> 'Cache Directory', 'path'=> $froot.DS.'cache'), +// ); +// $this->temp_variables['urlPaths'] = $this->urlPaths; +// $this->temp_variables['ktSettings'] = $this->ktSettings; + $this->temp_variables['dbSettings'] = $this->dbSettings; + } + + function upgradeConfirm() + { + if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) + { + $this->temp_variables['backupStatus'] = false; + } + } + + +function upgrade() +{ + global $default; +?> +

The table below describes the upgrades that have occurred to + upgrade your installation to systemVersion;?>. + + +Pre-Upgrade actions failed.
+ +

+Pre-Upgrade actions succeeded.
+ +

+ +Upgrade failed. + +

+Upgrade succeeded. + +

+ +Post-Upgrade actions failed.

+ +

+Post-Upgrade actions succeeded.

+ + + +       +       + \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeErrors.php b/setup/upgrade/steps/upgradeErrors.php new file mode 100644 index 0000000..ac6db1c --- /dev/null +++ b/setup/upgrade/steps/upgradeErrors.php @@ -0,0 +1,57 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrade +* @version Version 0.1 +*/ +class UpgradeErrors extends Step { + public $error = array(); + + function doStep() { + return 'landing'; + } + + function getErrors() { + return $this->error; + } + + function getName() { + return 'error'; + } +} +?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeInstallation.php b/setup/upgrade/steps/upgradeInstallation.php new file mode 100644 index 0000000..ce09f88 --- /dev/null +++ b/setup/upgrade/steps/upgradeInstallation.php @@ -0,0 +1,68 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrade +* @version Version 0.1 +*/ + +class UpgradeInstallation extends step +{ + /** + * Flag if step needs to run silently + * + * @author KnowledgeTree Team + * @access public + * @var array + */ + protected $silent = false; + + function __construct() { + $this->temp_variables = array("step_name"=>"welcome"); + } + + function doStep() { + parent::doStep(); + if($this->next()) { + return 'next'; // Just a welcome, so return "next" action + } + + return 'landing'; + } + +} +?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php new file mode 100644 index 0000000..06c1f8a --- /dev/null +++ b/setup/upgrade/steps/upgradeRestore.php @@ -0,0 +1,434 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + +require '../../config/dmsDefaults.php'; + +class upgradeRestore extends Step { + + /** + * Reference to Database object + * + * @author KnowledgeTree Team + * @access private + * @var object + */ + private $_dbhandler = null; + + private $privileges_check = 'tick'; + private $database_check = 'tick'; + protected $silent = true; + + protected $util = null; + + public function __construct() { + $this->temp_variables = array("step_name"=>"restore", "silent"=>$this->silent); + $this->_dbhandler = new UpgradedbUtil(); + $this->util = new UpgradeUtil(); + } + + function doStep() { + parent::doStep(); + if(!$this->inStep("restore")) { + $this->doRun(); + return 'landing'; + } + if($this->next()) { + if ($this->doRun()) { + return 'next'; + } + } else if($this->previous()) { + return 'previous'; + } + + $this->doRun(); + return 'landing'; + } + + function doRun() { + if ($this->select()) { + $this->restoreSelected(); + } + $this->restoreConfirm(); + $this->storeSilent();// Set silent mode variables + + return true; + } + + function select() { + return isset($_POST['RestoreSelect']); + } + + /** + * Set all silent mode varibles + * + */ + private function storeSilent() { + } + + function restore() +{ + check_state(1); + set_state(5); +// title('Restore In Progress'); + $status = $_SESSION['backupStatus']; + $filename=$_SESSION['backupFile']; + $stmt=create_restore_stmt($filename); + $dir=$stmt['dir']; + + + + + if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) + { + +?> + The restore is now underway. Please wait till it completes. + + + +

+ The mysql utility was not found in the subdirectory. + +       + + 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. +

+ + +
+ +
+ + +
+ +       + +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; +} + +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) + { + if (is_file($dir . '/' . $mysqlname)) + { + return $dir; + } + } + + 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); + } + return $dir; +} + + +function restoreSelect() +{ +// title('Select Backup to Restore'); + + $dir = $this->resolveTempDir(); + + $files = array(); + if ($dh = opendir($dir)) + { + while (($file = readdir($dh)) !== false) + { + if (!preg_match('/kt-backup.+\.sql/',$file)) + { + continue; + } + $files[] = $file; + } + closedir($dh); + } + + if (count($files) == 0) + { + ?> + 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 + +
+ + + +
+ +
+ + +

+       + resolveTempDir(); + $_SESSION['backupFile'] = $dir . '/' . $file; +?> +restoreSelect(); + exit; + } + + $status = $_SESSION['backupStatus']; + $filename=$_SESSION['backupFile']; + $stmt = $this->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 new file mode 100644 index 0000000..b311bcd --- /dev/null +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -0,0 +1,110 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @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; + + public function __construct() { + $this->temp_variables = array("step_name"=>"welcome"); + } + + public function doStep() { + if($this->next()) { + if ($this->doRun()) { + return 'next'; + } + else { + return 'error'; + } + } + + return 'landing'; + } + + private function doRun() { + // attempt login + $username = $_REQUEST['username']; + $password = $_REQUEST['password']; + + $authenticated = $this->checkPassword($username, $password); + + if (!$authenticated) + { + session_unset(); +// loginFailed(_kt('Could not authenticate administrative user')); + return false; + } + + $_SESSION['setup_user'] = $username; + + return true; + } + + private function checkPassword($username, $password) { + global $default; + + $sTable = KTUtil::getTableName('users'); + $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; + $aParams = array($username, md5($password)); + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); + if (PEAR::isError($res)) { return false; } + else { + $sTable = KTUtil::getTableName('users_groups_link'); + $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1"; + $aParams = array($res); + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); + if (PEAR::isError($res)) { return false; } + else { + return ($res == 1); + } + } + } + +} + +?> \ No newline at end of file diff --git a/setup/upgrade/template.php b/setup/upgrade/template.php new file mode 100644 index 0000000..f266686 --- /dev/null +++ b/setup/upgrade/template.php @@ -0,0 +1,111 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + +class Template +{ + /** + * Hold all the variables that are going to be imported into the template file + * @var array + */ + var $template_vars = Array(); + + + /** + * Constructor + * + * @author KnowledgeTree Team + * @param string $file the file name you want to load + * @access public + * @return void + */ + public function Template($file = null) + { + $this->file = $file; + } + + + /** + * Set a variable into the template + * If the variable is a template object, go and call its template::fetch() method + * + * @author KnowledgeTree Team + * @param string $name The name for this value in the template file + * @param string $value The value to show in the template file + * @access public + * @return void + */ + public function set($name, $value) + { + //if(is_a($value, 'Template')) { + $class = 'Template'; + $isA = $value instanceof $class; + if($isA) { + $value = $value->fetch(); + } + $this->template_vars[$name] = $value; + } + + + /** + * Create the template and import its variables + * + * @author KnowledgeTree Team + * @param string $file The file to use as the template + * @access public + * @return string The parsed template + */ + public function fetch($file = null) + { + if (is_null($file)) $file = $this->file; + if (!file_exists($file)) { + trigger_error('Template file '.$file.' does not exist ', E_USER_ERROR); + } + extract($this->template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + return $contents; + } + +} +?> \ No newline at end of file diff --git a/setup/upgrade/templates/backup.tpl b/setup/upgrade/templates/backup.tpl new file mode 100644 index 0000000..8ade6b5 --- /dev/null +++ b/setup/upgrade/templates/backup.tpl @@ -0,0 +1,58 @@ +

+

Confirm Backup

+ + ' + . '' + . 'Click Here for help on overcoming backup issues
'; + } + ?> +
+

+
+ + Are you sure you want to perform the backup? + +

+Your mysql installation has been resolved. Manually, you would do the following: +

+

+ + +
+cd "" +
+

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

+You can continue to do the backup manually using the following process: +

+ + +
+
+

+ + + + + + + + \ No newline at end of file diff --git a/setup/upgrade/templates/complete.tpl b/setup/upgrade/templates/complete.tpl new file mode 100644 index 0000000..d7fbce6 --- /dev/null +++ b/setup/upgrade/templates/complete.tpl @@ -0,0 +1,53 @@ +

+

Upgrade Completed

+ +

This allows you to check that your KnowledgeTree configuration is set + up correctly. You can run this at any time after configuration to check + that things are still set up correctly.

+ + ' + . '' + . 'Click Here for help on overcoming post Upgrade issues
'; + } + ?> +
+ +

+
+

     "; ?>Services

+ +
Show Details
+ + +
+
+ Goto Installer +
\ No newline at end of file diff --git a/setup/upgrade/templates/database.tpl b/setup/upgrade/templates/database.tpl new file mode 100644 index 0000000..42849c0 --- /dev/null +++ b/setup/upgrade/templates/database.tpl @@ -0,0 +1,34 @@ +
+

+
+
+ This step performs the necessary Database Upgrades. +
+
+

+ +

The table below describes the upgrades that need to occur to + upgrade your KnowledgeTree installation to . + Click on the button below the table to perform the upgrades.

+ + +
+ Please ensure that you have made a backup before continuing with the upgrade process. +

+
+ +

+ We are about to start the upgrade process. +

+

+
+ + + + + + + +
\ No newline at end of file diff --git a/setup/upgrade/templates/error.tpl b/setup/upgrade/templates/error.tpl new file mode 100644 index 0000000..5102838 --- /dev/null +++ b/setup/upgrade/templates/error.tpl @@ -0,0 +1,70 @@ + + + + KnowledgeTree Installer + + + + + + + +
+ +
+
+ + +
+
+
+
+

Welcome to the KnowledgeTree Upgrade Wizard

+ ".$error.""; + ?> + + '; + foreach ($errors as $msg){ + echo $msg . "
"; + ?> + Refresh + '; + } + } + ?> +
+
+
+
+
+
 
+
+ + +
+ + + \ No newline at end of file diff --git a/setup/upgrade/templates/errors.tpl b/setup/upgrade/templates/errors.tpl new file mode 100644 index 0000000..19dd15d --- /dev/null +++ b/setup/upgrade/templates/errors.tpl @@ -0,0 +1,14 @@ +

Welcome to the KnowledgeTree Database Upgrade Wizard

+ +
+ +'; + foreach ($errors as $msg){ + echo $msg . "
\n"; + } + echo '
'; +} +?> + \ No newline at end of file diff --git a/setup/upgrade/templates/installation.tpl b/setup/upgrade/templates/installation.tpl new file mode 100644 index 0000000..49c7ce7 --- /dev/null +++ b/setup/upgrade/templates/installation.tpl @@ -0,0 +1,25 @@ +
+

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. +

+ You will not be able to log into KnowledgeTree until your the database upgrade process is completed. +

+

+ !!NB!! You are advised to backup the database before attempting the upgrade. !!NB!! +

+

+ If you have already done this, you may skip this step and can continue directly to the upgrade. +
+ + + + + +
+ \ No newline at end of file diff --git a/setup/upgrade/templates/restore.tpl b/setup/upgrade/templates/restore.tpl new file mode 100644 index 0000000..2f3a176 --- /dev/null +++ b/setup/upgrade/templates/restore.tpl @@ -0,0 +1,64 @@ +
+

Confirm Restore

+ + ' + . '' + . 'Click Here for help on overcoming backup issues
'; + } + ?> +
+

+
+ +

+

+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): +

+ + + + +
+ +
+

+ + + + +Press Next to attempt the command(s) above. + +

+ + + + + + + + \ No newline at end of file diff --git a/setup/upgrade/templates/welcome.tpl b/setup/upgrade/templates/welcome.tpl new file mode 100644 index 0000000..df21f25 --- /dev/null +++ b/setup/upgrade/templates/welcome.tpl @@ -0,0 +1,18 @@ +

+

Welcome to the KnowledgeTree Database Upgrade Wizard

+ +
+
+
+

The database upgrade wizard completes the upgrade process on an existing KnowledgeTree installation. It applies + any upgrades to the database that may be required.

+

Only administrator users may access the upgrade wizard.

+
+ +
Username +
Password +
+
+
+ +
\ No newline at end of file diff --git a/setup/upgrade/templates/wizard.tpl b/setup/upgrade/templates/wizard.tpl new file mode 100644 index 0000000..b755f8f --- /dev/null +++ b/setup/upgrade/templates/wizard.tpl @@ -0,0 +1,41 @@ + + + + KnowledgeTree Upgrader + + + + + + +
+ +
+
+ +
+
+ +
+
+
+
 
+
+ + +
+ + + \ No newline at end of file diff --git a/setup/upgrade/upgrade b/setup/upgrade/upgrade new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/setup/upgrade/upgrade diff --git a/setup/upgrade/upgradeIni.php b/setup/upgrade/upgradeIni.php new file mode 100644 index 0000000..2dc52f3 --- /dev/null +++ b/setup/upgrade/upgradeIni.php @@ -0,0 +1,223 @@ +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +class UpgradeIni { + + private $cleanArray = array(); + private $iniFile = ''; + private $lineNum = 0; + private $exists = ''; + + function __construct($iniFile = '../../config.ini') { + $this->iniFile = $iniFile; + $this->backupIni($iniFile); + $this->read($iniFile); + } + + /** + * Create a backup with the date as an extension in the same location as the original config.ini + * + * @param string $iniFile + * @return boolean + */ + function backupIni($iniFile) + { + $content = file_get_contents($iniFile); + if ($content === false) + { + return false; + } + $date = date('YmdHis'); + + $backupFile = $iniFile . '.' .$date; + if (is_writeable($backupFile)) { + file_put_contents($backupFile, $content); + } + } + + function read($iniFile) { + + $iniArray = file($iniFile); + $section = ''; + foreach($iniArray as $iniLine) { + $this->lineNum++; + $iniLine = trim($iniLine); + $firstChar = substr($iniLine, 0, 1); + if($firstChar == ';') { + if($section == ''){ + $this->cleanArray['_comment_'.$this->lineNum]=$iniLine; + }else { + $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine; + } + continue; + } + if($iniLine == '') { + if($section == ''){ + $this->cleanArray['_blankline_'.$this->lineNum]=''; + }else { + $this->cleanArray[$section]['_blankline_'.$this->lineNum]=''; + } + continue; + } + + if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') { + $section = substr($iniLine, 1, -1); + $this->sections[] = $section; + } else { + $equalsPos = strpos($iniLine, '='); + if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) { + $key = trim(substr($iniLine, 0, $equalsPos)); + $value = trim(substr($iniLine, $equalsPos+1)); + if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { + $value = substr($value, 1, -1); + } + $this->cleanArray[$section][$key] = stripcslashes($value); + } else { + $this->cleanArray[$section][trim($iniLine)]=''; + } + } + } + return $this->cleanArray; + } + + function write($iniFile = "") { + + if(empty($iniFile)) { + $iniFile = $this->iniFile; + } + if (!is_writeable($iniFile)) { + return; + } + + $fileHandle = fopen($iniFile, 'wb'); + foreach ($this->cleanArray as $section => $items) { + if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { + fwrite ($fileHandle, "\r\n"); + continue; + } + if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { + fwrite ($fileHandle, "$items\r\n"); + continue; + } + fwrite ($fileHandle, "[".$section."]\r\n"); + foreach ($items as $key => $value) { + if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { + fwrite ($fileHandle, "\r\n"); + continue; + } + if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { + fwrite ($fileHandle, "$value\r\n"); + continue; + } + + $value = addcslashes($value,''); + //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); + fwrite ($fileHandle, $key.' = '.$value."\r\n"); + } + } + fclose($fileHandle); + } + + function itemExists($checkSection, $checkItem) { + + $this->exists = ''; + foreach($this->cleanArray as $section => $items) { + if($section == $checkSection) { + $this->exists = 'section'; + foreach ($items as $key => $value) { + if($key == $checkItem) { + return true; + } + } + } + } + return false; + } + + function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { + + if($this->itemExists($addSection, $addItem)) { + $this->delItem($addSection, $addItem); + } + + if($this->exists != 'section') { + $this->cleanArray['_blankline_'.$this->lineNum++]=''; + if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment; + } + if(!empty($itemComment)) { + $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment; + } + $this->cleanArray[$addSection][$addItem] = stripcslashes($value); + return true; + } + + function updateItem($addSection, $addItem, $value) { + + $this->cleanArray[$addSection][$addItem] = stripcslashes($value); + return true; + } + + function delItem($delSection, $delItem) { + + if(!$this->itemExists($delSection, $delItem)) return false; + + unset($this->cleanArray[$delSection][$delItem]); + return true; + } + + function delSection($delSection) { + + unset($this->cleanArray[$delSection]); + return true; + } + + // Return file line by line + public function getFileByLine() { + $data = $this->read($this->iniFile); + return $data['']; + } + + public function getSection($section) { + if (isset($this->cleanArray[$section])) { + return $this->cleanArray[$section]; + } + + return false; + } +} +?> diff --git a/setup/upgrade/upgradeSession.php b/setup/upgrade/upgradeSession.php new file mode 100644 index 0000000..019fded --- /dev/null +++ b/setup/upgrade/upgradeSession.php @@ -0,0 +1,224 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +class UpgradeSession +{ + private $salt = 'upgrade'; + /** + * Constructs session object + * + * @author KnowledgeTree Team + * @access public + * @param none + */ + public function __construct() { + $this->startSession(); + } + + /** + * Starts a session if one does not exist + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function startSession() { + if(!isset($_SESSION[$this->salt]['ready'])) { + session_start(); + $_SESSION[$this->salt] ['ready'] = TRUE; + } + } + + /** + * Sets a value key pair in session + * + * @author KnowledgeTree Team + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function set($fld, $val) { + $this->startSession(); + $_SESSION[$this->salt] [$fld] = $val; + } + + /** + * Sets a value key pair in a class in session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function setClass($class , $k, $v) { + $this->startSession(); + $classArray = $this->get($class); + if(isset($classArray[$k])) { + $classArray[$k] = $v; + } else { + $classArray[$k] = $v; + } + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Sets a error value key pair in a class in session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function setClassError($class, $k, $v) { + $this->startSession(); + $classArray = $this->get($class); + if(isset($classArray[$k])) { + $classArray[$k] = $v; + } else { + $classArray[$k] = $v; + } + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Clear error values in a class session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function clearErrors($class) { + $classArray = $this->get($class); + unset($classArray['errors']); + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Unset a value in session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return void + */ + public function un_set($fld) { + $this->startSession(); + unset($_SESSION[$this->salt] [$fld]); + } + + /** + * Unset a class value in session + * + * @author KnowledgeTree Team + * @param string $class + * @access public + * @return void + */ + public function un_setClass($class) { + $this->startSession(); + if(isset($_SESSION[$this->salt] [$class])) + unset($_SESSION[$this->salt] [$class]); + } + + /** + * Destroy the session + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function destroy() { + $this->startSession(); + unset($_SESSION[$this->salt]); + session_destroy(); + } + + /** + * Get a session value + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function get($fld) { + $this->startSession(); + if(isset($_SESSION[$this->salt] [$fld])) + return $_SESSION[$this->salt] [$fld]; + return false; + } + + /** + * Check if a field exists in session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function is_set($fld) { + $this->startSession(); + return isset($_SESSION[$this->salt] [$fld]); + } + + /** + * Return a class from session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function getClass($class) { + return $_SESSION[$this->salt][$class]; + } +} +?> \ No newline at end of file diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php new file mode 100644 index 0000000..3ae678b --- /dev/null +++ b/setup/upgrade/upgradeUtil.php @@ -0,0 +1,642 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +class UpgradeUtil { + /** + * Constructs upgradeation object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct() { + } + + /** + * Check if system needs to be upgraded + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function isSystemUpgradeed() { + if (file_exists(dirname(__FILE__)."/upgrade")) { + + return true; + } + + return false; + } + + public function error($error) { + $template_vars['error'] = $error; + $file = "templates/error.tpl"; + if (!file_exists($file)) { + return false; + } + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; + } + + /** + * Check if system needs to be upgraded + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function checkStructurePermissions() { + // Check if Wizard Directory is writable + if(!$this->_checkPermission(UPGRADE_DIR)) { + return 'wizard'; + } + + return true; + } + + + /** + * Redirect + * + * This function redirects the client. This is done by issuing + * a "Location" header and exiting if wanted. If you set $rfc2616 to true + * HTTP will output a hypertext note with the location of the redirect. + * + * @static + * @access public + * have already been sent. + * @param string $url URL where the redirect should go to. + * @param bool $exit Whether to exit immediately after redirection. + * @param bool $rfc2616 Wheter to output a hypertext note where we're + * redirecting to (Redirecting to ....) + * @return mixed Returns true on succes (or exits) or false if headers + */ + public function redirect($url, $exit = true, $rfc2616 = false) + { + if (headers_sent()) { + return false; + } + + $url = $this->absoluteURI($url); + header('Location: '. $url); + + if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) && + $_SERVER['REQUEST_METHOD'] != 'HEAD') { + printf('Redirecting to: %s.', $url, $url); + } + if ($exit) { + exit; + } + return true; + } + + /** + * Absolute URI + * + * This function returns the absolute URI for the partial URL passed. + * The current scheme (HTTP/HTTPS), host server, port, current script + * location are used if necessary to resolve any relative URLs. + * + * Offsets potentially created by PATH_INFO are taken care of to resolve + * relative URLs to the current script. + * + * You can choose a new protocol while resolving the URI. This is + * particularly useful when redirecting a web browser using relative URIs + * and to switch from HTTP to HTTPS, or vice-versa, at the same time. + * + * @author Philippe Jausions + * @static + * @access public + * @param string $url Absolute or relative URI the redirect should go to. + * @param string $protocol Protocol to use when redirecting URIs. + * @param integer $port A new port number. + * @return string The absolute URI. + */ + public function absoluteURI($url = null, $protocol = null, $port = null) + { + // filter CR/LF + $url = str_replace(array("\r", "\n"), ' ', $url); + + // Mess around with already absolute URIs + if (preg_match('!^([a-z0-9]+)://!i', $url)) { + if (empty($protocol) && empty($port)) { + return $url; + } + if (!empty($protocol)) { + $url = $protocol .':'. end($array = explode(':', $url, 2)); + } + if (!empty($port)) { + $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', + '\1:'. $port, $url); + } + return $url; + } + + $host = 'localhost'; + if (!empty($_SERVER['HTTP_HOST'])) { + list($host) = explode(':', $_SERVER['HTTP_HOST']); + } elseif (!empty($_SERVER['SERVER_NAME'])) { + list($host) = explode(':', $_SERVER['SERVER_NAME']); + } + + if (empty($protocol)) { + if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) { + $protocol = 'https'; + } else { + $protocol = 'http'; + } + if (!isset($port) || $port != intval($port)) { + $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; + } + } + + if ($protocol == 'http' && $port == 80) { + unset($port); + } + if ($protocol == 'https' && $port == 443) { + unset($port); + } + + $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); + + if (!strlen($url)) { + $url = isset($_SERVER['REQUEST_URI']) ? + $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']; + } + + if ($url{0} == '/') { + return $server . $url; + } + + // Check for PATH_INFO + if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && + $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) { + $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO']))); + } else { + $path = dirname($_SERVER['PHP_SELF']); + } + + if (substr($path = strtr($path, '\\', '/'), -1) != '/') { + $path .= '/'; + } + + return $server . $path . $url; + } + + /** + * Check whether a given directory / file path exists and is writable + * + * @author KnowledgeTree Team + * @access private + * @param string $dir The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return array The message and css class to use + */ + private function _checkPermission($dir) + { + if(is_readable($dir) && is_writable($dir)) { + return true; + } else { + return false; + } + + } + + /** + * Check whether a given directory / file path exists and is writable + * + * @author KnowledgeTree Team + * @access private + * @param string $dir The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return array The message and css class to use + */ + public function checkPermission($dir, $create=false) + { + $exist = 'Directory doesn\'t exist'; + $write = 'Directory not writable'; + $ret = array('class' => 'cross'); + + if(!file_exists($dir)){ + if($create === false){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + $par_dir = dirname($dir); + if(!file_exists($par_dir)){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + if(!is_writable($par_dir)){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + mkdir($dir, '0755'); + } + + if(is_writable($dir)){ + $ret['class'] = 'tick'; + + return $ret; + } + + $this->done = false; + $ret['msg'] = $write; + return $ret; + } + + /** + * Change permissions on a directory helper + * + * @author KnowledgeTree Team + * @access public + * @param string $folderPath The directory / file to check + * @return boolean + */ + public function canChangePermissions($folderPath) { + return $this->_chmodRecursive($folderPath, 0755); + } + + /** + * Change permissions on a directory (recursive) + * + * @author KnowledgeTree Team + * @access private + * @param string $folderPath The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return boolean + */ + private function _chmodRecursive($path, $filemode) { + if (!is_dir($path)) + return chmod($path, $filemode); + $dh = opendir($path); + while (($file = readdir($dh)) !== false) { + if($file != '.' && $file != '..') { + $fullpath = $path.'/'.$file; + if(is_link($fullpath)) + return false; + elseif(!is_dir($fullpath)) { + $perms = substr(sprintf('%o', fileperms($fullpath)), -4); + if($perms != $filemode) + if (!chmod($fullpath, $filemode)) + return false; + } elseif(!$this->chmodRecursive($fullpath, $filemode)) + return false; + } + } + closedir($dh); + $perms = substr(sprintf('%o', fileperms($path)), -4); + if($perms != $filemode) { + if(chmod($path, $filemode)) + return true; + else + return false; + } else { + return true; + } + } + + /** + * Check if a file can be written to a folder + * + * @author KnowledgeTree Team + * @access public + * @param string $filename the path to the file to create + * @return boolean + */ + public function canWriteFile($filename) { + $fh = fopen($filename, "w+"); + if($fr = fwrite($fh, 'test') === false) { + return false; + } + + fclose($fh); + return true; + } + + /** + * Attempt using the php-java bridge + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function javaBridge() { + try { + $javaSystem = new Java('java.lang.System'); + } catch (JavaException $e) { + return false; + } + return true; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava1() { + $response = $this->pexec("java -version"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + + return 'java'; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava2() { + $response = $this->pexec("java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + + return 'java'; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava3() { + $response = $this->pexec("whereis java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/java:/', '', $r); + } + } + } + + /** + * Check if user entered location of JRE + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + public function javaSpecified() { + if(isset($_POST['java'])) { + if($_POST['java'] != '') { + return $_POST['java']; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Check if user entered location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + public function phpSpecified() { + if(isset($_POST['php'])) { + if($_POST['php'] != '') { + return $_POST['php']; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Determine the location of JAVA_HOME + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + function getJava() { + $response = $this->tryJava1(); + if(!is_array($response)) { + $response = $this->tryJava2(); + if(!is_array($response)) { + $response = $this->tryJava3(); + } + } +// return false; + return $response; + } + + /** + * Determine the location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + function getPhp() { + $cmd = "whereis php"; + $res = $this->getPhpHelper($cmd); + if($res != '') { + return $res; + } + $cmd = "which php"; + return $this->getPhpHelper($cmd); + } + + function getPhpHelper($cmd) { + $response = $this->pexec($cmd); + if(is_array($response['out'])) { + if (isset($response['out'][0])) { + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/php:/', '', $r); + } + } + } + } + + return ''; + } + + function getOpenOffice() { + $cmd = "whereis soffice"; + $response = $this->pexec($cmd); + if(is_array($response['out'])) { + if (isset($response['out'][0])) { + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/soffice:/', '', $r); + } + } + } + } + + return ''; + } + /** + * Portably execute a command on any of the supported platforms. + * + * @author KnowledgeTree Team + * @access public + * @param string $aCmd + * @param array $aOptions + * @return array + */ + public function pexec($aCmd, $aOptions = null) { + if (is_array($aCmd)) { + $sCmd = $this->safeShellString($aCmd); + } else { + $sCmd = $aCmd; + } + $sAppend = $this->arrayGet($aOptions, 'append'); + if ($sAppend) { + $sCmd .= " >> " . escapeshellarg($sAppend); + } + $sPopen = $this->arrayGet($aOptions, 'popen'); + if ($sPopen) { + if (WINDOWS_OS) { + $sCmd = "start /b \"kt\" " . $sCmd; + } + return popen($sCmd, $sPopen); + } + // for exec, check return code and output... + $aRet = array(); + $aOutput = array(); + $iRet = ''; + if(WINDOWS_OS) { + $sCmd = 'call '.$sCmd; + } + + exec($sCmd, $aOutput, $iRet); + $aRet['ret'] = $iRet; + $aRet['out'] = $aOutput; + + return $aRet; + } + + /** + * + * + * @author KnowledgeTree Team + * @access public + * @return string + */ + public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { + if (!is_array($aArray)) { + $aArray = (array) $aArray; + } + + if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) { + return $mDefault; + } + if (array_key_exists($sKey, $aArray)) { + $mVal =& $aArray[$sKey]; + if (empty($mVal) && $bDefaultIfEmpty) { + return $mDefault; + } + return $mVal; + } + return $mDefault; + } + + /** + * + * + * @author KnowledgeTree Team + * @access public + * @return string + */ + public function safeShellString () { + $aArgs = func_get_args(); + $aSafeArgs = array(); + if (is_array($aArgs[0])) { + $aArgs = $aArgs[0]; + } + $aSafeArgs[] = escapeshellarg(array_shift($aArgs)); + if (is_array($aArgs[0])) { + $aArgs = $aArgs; + } + foreach ($aArgs as $sArg) { + if (empty($sArg)) { + $aSafeArgs[] = "''"; + } else { + $aSafeArgs[] = escapeshellarg($sArg); + } + } + return join(" ", $aSafeArgs); + } + +} +?> \ No newline at end of file diff --git a/setup/upgrade/upgradeWizard.php b/setup/upgrade/upgradeWizard.php new file mode 100644 index 0000000..c6afb42 --- /dev/null +++ b/setup/upgrade/upgradeWizard.php @@ -0,0 +1,236 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +include("path.php"); // Paths + +/** + * Auto loader to bind upgrader package + * + * @param string $class + * @return void + */ +function __autoload($class) { // Attempt and autoload classes + $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. + if(file_exists(UPGRADE_DIR."$class.php")) { + require_once(UPGRADE_DIR."$class.php"); + } elseif (file_exists(STEP_DIR."$class.php")) { + require_once(STEP_DIR."$class.php"); + } elseif (file_exists(WIZARD_LIB."$class.php")) { + require_once(WIZARD_LIB."$class.php"); + } else { + return null; + } +} + +class UpgradeWizard { + /** + * Upgrade bypass flag + * + * @author KnowledgeTree Team + * @access protected + * @var mixed + */ + protected $bypass = null; + + /** + * Reference to upgrader utility object + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $iutil = null; + + /** + * Constructs upgradeation wizard object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct(){} + + /** + * Check if system has been upgrade + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return boolean + */ + private function isSystemUpgradeed() { + return $this->iutil->isSystemUpgradeed(); + } + + /** + * Display the wizard + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + public function displayUpgrader($response = null) { + if($response) { + $ins = new Upgrader(); // Instantiate the upgrader + $ins->resolveErrors($response); // Run step + } else { + $ins = new Upgrader(new UpgradeSession()); // Instantiate the upgrader and pass the session class + $ins->step(); // Run step + } + } + + /** + * Set bypass flag + * + * @author KnowledgeTree Team + * @access private + * @param boolean + * @return void + */ + private function setBypass($bypass) { + $this->bypass = $bypass; + } + + /** + * Set util reference + * + * @author KnowledgeTree Team + * @access private + * @param object upgrader utility + * @return void + */ + private function setIUtil($iutil) { + $this->iutil = $iutil; + } + + /** + * Create upgrade file + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + private function createUpgradeFile() { + @touch("upgrade"); + } + + /** + * Remove upgrade file + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + private function removeUpgradeFile() { + @unlink("upgrade"); + } + + /** + * Load default values + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + function load() { + $this->setIUtil(new UpgradeUtil()); + } + + /** + * Run pre-upgradeation system checks + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function systemChecks() { + $res = $this->iutil->checkStructurePermissions(); + if($res === true) return $res; + switch ($res) { + case "wizard": + $this->iutil->error("Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)"); + return 'Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)'; + break; + case "/": + $this->iutil->error("System root is not writable (KT_Installation_Directory/)"); + return "System root is not writable (KT_Installation_Directory/)"; + break; + default: + return true; + break; + } + + return $res; + } + + /** + * Control all requests to wizard + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return void + */ + public function dispatch() { + $this->load(); + // is this necessary? + $this->createUpgradeFile(); +// if(!$this->isSystemUpgradeed()) { // Check if the systems not upgraded + $response = $this->systemChecks(); + if($response === true) { + $this->displayUpgrader(); + } else { + exit(); + } +// } else { +// // TODO: Die gracefully +// $this->iutil->error("System has been upgraded "); +// } + } +} + +$ic = new UpgradeWizard(); +$ic->dispatch(); +?> \ No newline at end of file diff --git a/setup/upgrade/upgradedbUtil.php b/setup/upgrade/upgradedbUtil.php new file mode 100644 index 0000000..f032782 --- /dev/null +++ b/setup/upgrade/upgradedbUtil.php @@ -0,0 +1,262 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +class UpgradedbUtil { + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbhost = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbname = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbuname = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbpassword = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var object mysql connection + */ + protected $dbconnection = ''; + + /** + * Any errors encountered + * + * @author KnowledgeTree Team + * @access protected + * @var array + */ + protected $error = array(); + + /** + * Constructs database connection object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct() { + + } + + public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { + $this->dbhost = $dhost; + $this->dbuname = $duname; + $this->dbpassword = $dpassword; + $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); + if($dbname != '') { + $this->setDb($dbname); + $this->useDb($dbname); + } + if($this->dbconnection) { + return $this->dbconnection; + } + else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Choose a database to use + * + * @param string $dbname name of the database + * @access public + * @return boolean + */ + public function useDb($dbname = '') { + if($dbname != '') { + $this->setDb($dbname); + } + + if(@mysql_select_db($this->dbname, $this->dbconnection)) + return true; + else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + public function setDb($dbname) { + $this->dbname = $dbname; + } + + /** + * Query the database. + * + * @param $query the sql query. + * @access public + * @return object The result of the query. + */ + public function query($query) { + $result = mysql_query($query, $this->dbconnection); + if($result) { + return $result; + } else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Do the same as query. + * + * @param $query the sql query. + * @access public + * @return boolean + */ + public function execute($query) { + $result = @mysql_query($query, $this->dbconnection); + if($result) { + return true; + } else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Convenience method for mysql_fetch_object(). + * + * @param $result The resource returned by query(). + * @access public + * @return object An object representing a data row. + */ + public function fetchNextObject($result = NULL) { + if ($result == NULL || @mysql_num_rows($result) < 1) + return NULL; + else + return @mysql_fetch_object($result); + } + + /** + * Convenience method for mysql_fetch_assoc(). + * + * @param $result The resource returned by query(). + * @access public + * @return array Returns an associative array of strings. + */ + public function fetchAssoc($result = NULL) { + $r = array(); + if ($result == NULL || @mysql_num_rows($result) < 1) + return NULL; + else { + $row = @mysql_fetch_assoc($result); + while ($row) { + $r[] = $row; + } + return $r; + } + } + + /** + * Close the connection with the database server. + * + * @param none. + * @access public + * @return void. + */ + public function close() { + @mysql_close($this->dbconnection); + } + + /** + * Get database errors. + * + * @param none. + * @access public + * @return array. + */ + public function getErrors() { + return $this->error; + } + + /** + * Fetches the last generated error + + * @return string + */ + function getLastError() { + return end($this->error); + } + + /** + * Start a database transaction + */ + public function startTransaction() { + $this->query("START TRANSACTION"); + } + + /** + * Roll back a database transaction + */ + public function rollback() { + $this->query("ROLLBACK"); + } +} +?> \ No newline at end of file diff --git a/setup/upgrade/upgrader.php b/setup/upgrade/upgrader.php new file mode 100644 index 0000000..be12dbe --- /dev/null +++ b/setup/upgrade/upgrader.php @@ -0,0 +1,680 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ + +class Upgrader { + /** + * Reference to simple xml object + * + * @author KnowledgeTree Team + * @access protected + * @var object SimpleXMLElement + */ + protected $simpleXmlObj = null; + + /** + * Reference to step action object + * + * @author KnowledgeTree Team + * @access protected + * @var object StepAction + */ + protected $stepAction = null; + + /** + * Reference to session object + * + * @author KnowledgeTree Team + * @access protected + * @var object Session + */ + protected $session = null; + + /** + * List of upgradeation steps as strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepClassNames = array(); + + /** + * List of upgradeation steps as human readable strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepNames = array(); + + /** + * List of upgradeation steps as human readable strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepObjects = array(); + + /** + * Order in which steps have to be upgraded + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $upgradeOrders = array(); + + /** + * List of upgradeation properties + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $upgradeProperties = array(); + + /** + * Flag if a step object needs confirmation + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $stepConfirmation = false; + + /** + * Flag if a step object needs confirmation + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $stepDisplayFirst = false; + + private $upgraderAction = ''; + + /** + * Constructs upgradeation object + * + * @author KnowledgeTree Team + * @access public + * @param object Session $session Instance of the Session object + */ + public function __construct($session = null) { + $this->session = $session; + } + + /** + * Read xml configuration file + * + * @author KnowledgeTree Team + * @param string $name of config file + * @access private + * @return object + */ + private function _readXml($name = "config.xml") { + try { + $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); + } catch (Exception $e) { + $iutil = new UpgradeUtil(); + $iutil->error("Error reading configuration file: $name"); + exit(); + } + } + + /** + * Checks if first step of upgrader + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function _firstStep() { + if(isset($_GET['step_name'])) { + return false; + } + + return true; + } + + /** + * Checks if first step of upgrader + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function _firstStepPeriod() { + if(isset($_GET['step_name'])) { + if($_GET['step_name'] != 'welcome') + return false; + } + + return true; + } + + /** + * Returns next step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _getNextStep() { + return $this->_getStepName(1); + } + + /** + * Returns previous step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _getPreviousStep() { + return $this->_getStepName(-1); + } + + /** + * Returns the step name, given a position + * + * @author KnowledgeTree Team + * @param integer $pos current position + * @access private + * @return string $name + */ + private function _getStepName($pos = 0) { + if($this->_firstStep()) { + $step = (string) $this->simpleXmlObj->steps->step[0]; + } else { + $pos += $this->getStepPosition(); + $step = (string) $this->simpleXmlObj->steps->step[$pos]; + } + + return $step; + } + + /** + * Executes next step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _proceed() { + $step_name = $this->_getNextStep(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes previous step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _backward() { + $step_name = $this->_getPreviousStep(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes step landing + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _landing() { + $step_name = $this->_getStepName(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes step based on step class name + * + * @author KnowledgeTree Team + * @param string $step_name + * @access private + * @return string + */ + private function _runStepAction($stepName) { + $this->stepAction = new stepAction($stepName); + $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getUpgradeProperties()); + + return $this->stepAction->doAction(); + } + + private function stepDisplayFirst() { + if($this->upgraderAction == 'edit') + return false; // + $class = $this->stepAction->createStep(); // Get step class + return $class->displayFirst(); // Check if class needs to display first + } + + /** + * Set steps class names in string format + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return array + */ + private function _getUpgradeOrders() { + return $this->upgradeOrders; + } + + /** + * Set steps as names + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsToArray() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step_name = (string) $d_step[0]; + $this->stepClassNames[] = $step_name; + } + $this->_loadToSession('stepClassNames', $this->stepClassNames); + } + } + + /** + * Set steps as human readable strings + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsNames() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step_name = (string) $d_step[0]; + $this->stepNames[$step_name] = (string) $d_step['name']; + } + $this->_loadToSession('stepNames', $this->stepNames); + } + } + + /** + * Set steps upgrade order + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsOrders() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + if(isset($d_step['order'])) { + $step_name = (string) $d_step[0]; + $order = (string) $d_step['order']; + $this->upgradeOrders[$order] = $step_name; // Store step upgrade order + } + } + $this->_loadToSession('upgradeOrders', $this->upgradeOrders); + } + } + + /** + * Set upgrade properties + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlUpgradeProperties() { + if(isset($this->simpleXmlObj)) { + $this->upgradeProperties['upgrade_version'] = (string) $this->simpleXmlObj['version']; + $this->upgradeProperties['upgrade_type'] = (string) $this->simpleXmlObj['type']; + $this->_loadToSession('upgradeProperties', $this->upgradeProperties); + } + } + + /** + * Upgrade steps + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _runStepsUpgrades() { + $steps = $this->_getUpgradeOrders(); + for ($i=1; $i< count($steps)+1; $i++) { + $this->_upgradeHelper($steps[$i]); + } + + $this->_completeUpgrade(); + } + + /** + * Complete upgrade cleanup process + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _completeUpgrade() { + @touch("upgrade"); + } + + /** + * Upgrade steps helper + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _upgradeHelper($className) { + $stepAction = new stepAction($className); // Instantiate a step action + $class = $stepAction->createStep(); // Get step class + if($class) { // Check if class Exists + if($class->runUpgrade()) { // Check if step needs to be upgraded + $class->setDataFromSession($className); // Set Session Information + $class->setPostConfig(); // Set any posted variables + $response = $class->upgradeStep(); // Run upgrade step + // TODO : Break on error response + } + } else { + $iutil = new UpgradeUtil(); + $iutil->error("Class File Missing in Step Directory: $className"); + exit(); + } + } + + /** + * Reset all session information on welcome landing + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _resetSessions() { + if($this->session) { + if($this->_firstStepPeriod()) { + foreach ($this->getSteps() as $class) { + $this->session->un_setClass($class); + } + foreach ($this->getStepNames() as $class) { + $this->session->un_setClass($class); + } + foreach ($this->_getUpgradeOrders() as $class) { + $this->session->un_setClass($class); + } + } + } + } + + function _loadFromSessions() { + $this->stepClassNames = $this->session->get('stepClassNames'); + if(!$this->stepClassNames) { + $this->_xmlStepsToArray(); // String steps + } + $this->stepNames = $this->session->get('stepNames'); + if(!$this->stepNames) { + $this->_xmlStepsNames(); + } + $this->upgradeOrders = $this->session->get('upgradeOrders'); + if(!$this->upgradeOrders) { + $this->_xmlStepsOrders(); + } + $this->upgradeProperties = $this->session->get('upgradeProperties'); + if(!$this->upgradeProperties) { + $this->_xmlUpgradeProperties(); + } + } + + private function loadNeeded() { + $this->_readXml(); // Xml steps + // Make sure session is cleared + $this->_resetSessions(); + $this->_loadFromSessions(); + if(isset($_POST['Next'])) { + $this->upgraderAction = 'next'; + $this->response = 'next'; + } elseif (isset($_POST['Previous'])) { + $this->upgraderAction = 'previous'; + $this->response = 'previous'; + } elseif (isset($_POST['Confirm'])) { + $this->upgraderAction = 'confirm'; + $this->response = 'next'; + } elseif (isset($_POST['Upgrade'])) { + $this->upgraderAction = 'upgrade'; + $this->response = 'next'; + } elseif (isset($_POST['Edit'])) { + $this->upgraderAction = 'edit'; + $this->response = 'next'; + } elseif (isset($_POST['Install'])) { + $this->upgraderAction = 'install'; + $this->response = 'install'; + } else { + $this->response = ''; + $this->upgraderAction = ''; + } + } + + /** + * Main control to handle the flow of upgrade + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function step() { + $this->loadNeeded(); + switch($this->response) { + case 'next': + $step_name = $this->_getStepName(); + $res = $this->_runStepAction($step_name); + if($res == 'next') { + $this->_proceed(); // Load next window + } elseif ($res == 'upgrade') { + $this->_runStepsUpgraders(); // Load landing + $this->_proceed(); // Load next window + } elseif ($res == 'confirm') { + if(!$this->stepDisplayFirst()) + $this->stepConfirmation = true; + $this->_landing(); + } elseif ($res == 'landing') { + $this->_landing(); + } else { + } + break; + case 'previous': + $this->_backward(); // Load previous page + break; + case 'install': + $iutil = new UpgradeUtil(); + $iutil->redirect('../wizard/index.php?step_name=installtype'); + break; + default: + // TODO : handle silent + $this->_landing(); + break; + } + $this->stepAction->paintAction(); // Display step + } + + /** + * Returns the step number + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return integer $pos + */ + public function getStepPosition() { + $pos = 0; + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step = (string) $d_step; + if ($step == $_GET['step_name']) { + break; + } + $pos++; + } + if(isset($_GET['step'])) { + if($_GET['step'] == "next") + $pos = $pos+1; + else + $pos = $pos-1; + } + + return $pos; + } + + /** + * Returns the step names for classes + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function getSteps() { + return $this->stepClassNames; + } + + /** + * Returns the steps as human readable string + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function getStepNames() { + return $this->stepNames; + } + + /** + * Returns whether or not a confirmation step is needed + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function getStepConfirmation() { + return $this->stepConfirmation; + } + + /** + * Return upgrade properties + * + * @author KnowledgeTree Team + * @param string + * @access public + * @return string + */ + public function getUpgradeProperties() { + return $this->upgradeProperties; + } + + /** + * Returns session + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function getSession() { + return $this->session; + } + + /** + * Dump of SESSION + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function showSession() { + echo '
';
+        print_r($_SESSION);
+        echo '
'; + } + + /** + * Display errors that are not allowing the upgrader to operate + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function resolveErrors($errors) { + echo $errors; + exit(); + } + + private function _loadToSession($type, $values) { + if($values) { + $this->session->set($type , $values); + } + } +} + +?> -- libgit2 0.21.4