. * * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, * Blake Street, Observatory, 7925 South Africa. 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): ______________________________________ * */ $GLOBALS["checkup"] = true; session_start(); require_once('../config/dmsDefaults.php'); require_once(KT_LIB_DIR . '/authentication/authenticationutil.inc.php'); require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); function generateUpgradeTable () { global $default; $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); $lastVersion = DBUtil::getOneResultKey($query, 'value'); $currentVersion = $default->systemVersion; $upgrades = describeUpgrade($lastVersion, $currentVersion); $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; } function showResult($res) { if (PEAR::isError($res)) { if (is_a($res, 'Upgrade_Already_Applied')) { return 'Already applied'; } return sprintf('%s', htmlspecialchars($res->toString())); } if ($res === true) { return 'Success'; } if ($res === false) { return 'Failure'; } return $res; } $GLOBALS['row'] = 1; function performAllUpgrades () { global $default; $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); $lastVersion = DBUtil::getOneResultKey($query, 'value'); $currentVersion = $default->systemVersion; $upgrades = describeUpgrade($lastVersion, $currentVersion); foreach ($upgrades as $upgrade) { if (($GLOBALS['row'] % 2) == 1) { $class = "odd"; } else { $class = "even"; } printf('
%s
' . "\n", $class, htmlspecialchars($upgrade->getDescription())); $GLOBALS['row']++; ob_flush(); flush(); $res = $upgrade->performUpgrade(); printf('
%s
', showResult($res)); print '
' . "\n"; ob_flush(); flush(); print "
\n"; if (PEAR::isError($res)) { if (!is_a($res, 'Upgrade_Already_Applied')) { break; } else { $res = true; } } if ($res === false) { $res = PEAR::raiseError("Upgrade returned false"); break; } } return $res; } function performPreUpgradeActions() { // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. // It should idealy work the same as the upgrades. return true; } function performPostUpgradeActions() { // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. // It should idealy work the same as the upgrades. // Clean out the plugin_helper table $sql = "DELETE FROM plugin_helper"; $res = DBUtil::runQuery($sql); return $res; } function failWritablePath($name, $path) { if (!is_writable($path)) { sprintf("The path for setting %s, which is set to %s, can not be written to. Correct this situation before continuing.", $name, $path); exit(1); } } failWritablePath('Log directory', $default->logDirectory); failWritablePath('Document directory', $default->documentRoot); if (PEAR::isError($loggingSupport)) { print '

Logging support is not currently working. Check post-installation checkup.

'; exit(1); } if (PEAR::isError($dbSupport)) { print '

Database support is not currently working. Check post-installation checkup or refresh this page (F5) to try again.

'; exit(1); } ?> <?php echo APP_NAME;?> Upgrade

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

Only administrator users may access the upgrade wizard.

Username
Password
$message"; login(); } 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 create_backup_stmt($targetfile=null) { $oKTConfig =& KTConfig::getSingleton(); $adminUser = $oKTConfig->get('db/dbAdminUser'); $adminPwd = $oKTConfig->get('db/dbAdminPass'); $dbHost = $oKTConfig->get('db/dbHost'); $dbName = $oKTConfig->get('db/dbName'); $dbPort = trim($oKTConfig->get('db/dbPort')); if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); if (empty($dbPort)) $dbPort='3306'; $dbSocket = trim($oKTConfig->get('db/dbSocket')); if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; $date=date('Y-m-d-H-i-s'); $dir=resolveMysqlDir(); $info['dir']=$dir; $prefix=''; if (OS_UNIX) { $prefix .= "./"; } if (@stat($dbSocket) !== false) { $mechanism="--socket=\"$dbSocket\""; } else { $mechanism="--port=\"$dbPort\""; } $tmpdir=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 create_restore_stmt($targetfile) { $oKTConfig =& KTConfig::getSingleton(); $adminUser = $oKTConfig->get('db/dbAdminUser'); $adminPwd = $oKTConfig->get('db/dbAdminPass'); $dbHost = $oKTConfig->get('db/dbHost'); $dbName = $oKTConfig->get('db/dbName'); $dbPort = trim($oKTConfig->get('db/dbPort')); if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); if (empty($dbPort)) $dbPort='3306'; $dbSocket = trim($oKTConfig->get('db/dbSocket')); if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; $dir=resolveMysqlDir(); $info['dir']=$dir; $prefix=''; if (OS_UNIX) { $prefix .= "./"; } if (@stat($dbSocket) !== false) { $mechanism="--socket=\"$dbSocket\""; } else { $mechanism="--port=\"$dbPort\""; } $tmpdir=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 title($title) { if (!isset($_SESSION['setup_user'])) { print ""; } print "

$title

"; } 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 upgradeConfirm() { title('Confirm Upgrade'); if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) { ?>
Please ensure that you have made a backup before continuing with the upgrade process.


We are about to start the upgrade process.

              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:

              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

      

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 continue to restore to attempt the command(s) above.

                     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:

background="../resources/graphics/ktbg.png"> 
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.


              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.


       The backup is now underway. Please wait till it completes. 0) { $_SESSION['backupStatus'] = true; } else { $_SESSION['backupStatus'] = false; } ?>

The mysqldump utility was not found in the subdirectory.        The restore is now underway. Please wait till it completes.

The mysql utility was not found in the subdirectory.       
Welcome to the Database Upgrade Wizard.

If you have just updated your 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 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 can continue directly to the upgrade.

                           

The table below describes the upgrades that need to occur to upgrade your installation to systemVersion;?>. Click on the button below the table to perform the upgrades.


             

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.

             

get('ui/poweredByDisabled') == '0'){ ?> align="right">