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; } } KTPluginUtil::registerPlugins(); 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.

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

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
getSysAdmin()) { $is_admin=true; break; } } if (!$is_admin) { session_unset(); loginFailed(_kt('Could not identify administrator')); return; } $authenticated = KTAuthenticationUtil::checkPassword($oUser, $password); if (!$authenticated) { session_unset(); loginFailed(_kt('Could not authenticate user')); return; } $_SESSION['setup_user'] = $oUser; welcome(); } function loginFailed($message) { print "$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/mysqlDirectory 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/mysqlDirectory 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/mysqlDirectory 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 upgade.

                           

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?>. Upgrade failed.

Upgrade succeeded.

             

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