Commit 1fede6cad35c59d58683ccb8bc416e64bf53b985

Authored by Jarrett Jordaan
1 parent 3f416054

Story Id:1166869 Daily Commit

Committed by: Jarrett Jordaan

Reviewed by: Paul Barrett
setup/migrate/session.php
... ... @@ -175,7 +175,7 @@ class Session
175 175 * @access public
176 176 * @return void
177 177 */
178   - public function destroy() {
  178 + public function destroyMigrate() {
179 179 $this->startSession();
180 180 unset($_SESSION[$this->salt]);
181 181 session_destroy();
... ...
setup/migrate/steps/migrateComplete.php
... ... @@ -84,10 +84,7 @@ class migrateComplete extends Step {
84 84 private function checkSqlDump() {
85 85 $database = $this->getDataFromSession("database"); // Get installation directory
86 86 // TODO
87   - $sqlFile = $_SESSION['database']['dumpLocation'];
88   -// $tmpFolder = $database['dumpLocation'];
89   -// $sqlFile = $tmpFolder."dms.sql";
90   - //echo $sqlFile;
  87 + $sqlFile = $_SESSION['migrate']['database']['dumpLocation'];
91 88 if(file_exists($sqlFile)) {
92 89 $this->temp_variables['sql']['class'] = "tick";
93 90 $this->temp_variables['sql']['name'] = "dms.sql";
... ...
setup/migrate/steps/migrateDatabase.php
... ... @@ -301,7 +301,7 @@ function resolveTempDir()
301 301  
302 302 private function storeSilent() {
303 303 // TODO
304   - $_SESSION['database']['dumpLocation'] = $this->sqlDumpFile;
  304 + $_SESSION['migrate']['database']['dumpLocation'] = $this->sqlDumpFile;
305 305 $this->temp_variables['dumpLocation'] = $this->sqlDumpFile;
306 306 }
307 307  
... ...
setup/upgrade.php
... ... @@ -35,1125 +35,5 @@
35 35 * Contributor( s): ______________________________________
36 36 *
37 37 */
38   -
39   -$GLOBALS["checkup"] = true;
40   -session_start();
41   -require_once('../config/dmsDefaults.php');
42   -require_once(KT_LIB_DIR . '/authentication/authenticationutil.inc.php');
43   -require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php');
44   -require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php');
45   -
46   -function generateUpgradeTable () {
47   - global $default;
48   - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
49   - $lastVersion = DBUtil::getOneResultKey($query, 'value');
50   - $currentVersion = $default->systemVersion;
51   -
52   - $upgrades = describeUpgrade($lastVersion, $currentVersion);
53   -
54   - $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n";
55   - $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n";
56   - $i=0;
57   - foreach ($upgrades as $upgrade) {
58   - $color=((($i++)%2)==0)?'white':'lightgrey';
59   - $ret .= sprintf("<tr bgcolor='$color'><td>%s</td><td>%s</td><td>%s</td></tr>\n",
60   - htmlspecialchars($upgrade->getDescriptor()),
61   - htmlspecialchars($upgrade->getDescription()),
62   - $upgrade->isAlreadyApplied() ? "Yes" : "No"
63   - );
64   - }
65   - $ret .= '</table>';
66   - return $ret;
67   -}
68   -
69   -function showResult($res) {
70   - if (PEAR::isError($res)) {
71   - if (is_a($res, 'Upgrade_Already_Applied')) {
72   - return '<span style="color: orange">Already applied</span>';
73   - }
74   - return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString()));
75   - }
76   - if ($res === true) {
77   - return '<span style="color: green">Success</span>';
78   - }
79   - if ($res === false) {
80   - return '<span style="color: red">Failure</span>';
81   - }
82   - return $res;
83   -}
84   -
85   -$GLOBALS['row'] = 1;
86   -
87   -function performAllUpgrades () {
88   - global $default;
89   - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
90   - $lastVersion = DBUtil::getOneResultKey($query, 'value');
91   - $currentVersion = $default->systemVersion;
92   -
93   - $upgrades = describeUpgrade($lastVersion, $currentVersion);
94   -
95   - foreach ($upgrades as $upgrade) {
96   - if (($GLOBALS['row'] % 2) == 1) {
97   - $class = "odd";
98   - } else {
99   - $class = "even";
100   - }
101   - printf('<div class="row %s"><div class="foo">%s</div>' . "\n", $class, htmlspecialchars($upgrade->getDescription()));
102   - $GLOBALS['row']++;
103   - ob_flush();
104   - flush();
105   - $res = $upgrade->performUpgrade();
106   - printf('<div class="bar">%s</div>', showResult($res));
107   - print '<br style="clear: both">' . "\n";
108   - ob_flush();
109   - flush();
110   - print "</div>\n";
111   - if (PEAR::isError($res)) {
112   - if (!is_a($res, 'Upgrade_Already_Applied')) {
113   - break;
114   - } else {
115   - $res = true;
116   - }
117   - }
118   - if ($res === false) {
119   - $res = PEAR::raiseError("Upgrade returned false");
120   - break;
121   - }
122   - }
123   -
124   - return $res;
125   -}
126   -
127   -function performPreUpgradeActions() {
128   -
129   - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
130   - // It should idealy work the same as the upgrades.
131   -
132   - global $default;
133   -
134   - // Lock the scheduler
135   - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
136   - touch($lockFile);
137   - return true;
138   -
139   -}
140   -
141   -function performPostUpgradeActions() {
142   -
143   - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
144   - // It should idealy work the same as the upgrades.
145   -
146   - global $default;
147   -
148   - // Ensure all plugins are re-registered.
149   - $sql = "TRUNCATE plugin_helper";
150   - $res = DBUtil::runQuery($sql);
151   -
152   - // Clear out all caches and proxies - they need to be regenerated with the new code
153   - $proxyDir = $default->proxyCacheDirectory;
154   - KTUtil::deleteDirectory($proxyDir);
155   -
156   - $oKTCache = new KTCache();
157   - $oKTCache->deleteAllCaches();
158   -
159   - // Clear the configuration cache, it'll regenerate on next load
160   - $oKTConfig = new KTConfig();
161   - $oKTConfig->clearCache();
162   -
163   - // Unlock the scheduler
164   - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
165   - if(file_exists($lockFile)){
166   - @unlink($lockFile);
167   - }
168   -
169   - return true;
170   -
171   -}
172   -
173   -if (PEAR::isError($loggingSupport)) {
174   - print '<p><font color="red">Logging support is not currently working. Check post-installation checkup.</font></p>';
175   - exit(1);
176   -}
177   -
178   -if (PEAR::isError($dbSupport)) {
179   - print '<p><font color="red">Database support is not currently working. Check post-installation checkup or refresh this page (F5) to try again.</font></p>';
180   - exit(1);
181   -}
182   -
183   -
184   -
185   -?>
186   -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
187   -<html>
188   - <head>
189   - <title><?php echo APP_NAME;?> Upgrade</title>
190   - <style type="text/css">
191   -th { text-align: left; }
192   -td { vertical-align: top; }
193   -.foo { float: left; }
194   -.bar { padding-left: 2em; float: right; }
195   -.odd { background-color: #eeeeee; }
196   -.even { background-color: #dddddd; }
197   -.row { padding: 0.5em 1em; }
198   - </style>
199   - </head>
200   -
201   - <body>
202   - <img src="<?php
203   - if($oKTConfig->get('ui/mainLogo')){
204   - echo $oKTConfig->get('ui/mainLogo');
205   - }else{
206   - echo '../resources/graphics/ktlogo-topbar_base.png';
207   - }?>"/>
208   - <p>
209   - <img src="upgrade-title.jpg"/>
210   - <table style="width:800; height:500">
211   -<tr><td>
212   -<P>
213   - <script type="text/javascript">
214   -function do_start(action)
215   -{
216   - document.location='?go=' + action;
217   -}
218   -</script>
219   -<?php
220   -
221   -$action = trim($_REQUEST["go"]);
222   -switch ($action)
223   -{
224   - case 'UpgradeConfirm':
225   - case 'UpgradePreview':
226   - UpgradePreview();
227   - break;
228   - case 'Upgrade':
229   - Upgrade();
230   - break;
231   - case 'BackupConfirm':
232   - backupConfirm();
233   - break;
234   - case 'Backup':
235   - backup();
236   - break;
237   - case 'BackupDone':
238   - backupDone();
239   - break;
240   - case 'RestoreConfirm':
241   - restoreConfirm();
242   - break;
243   - case 'RestoreSelect':
244   - restoreSelect();
245   - break;
246   - case 'RestoreSelected':
247   - restoreSelected();
248   - break;
249   - case 'Restore':
250   - restore();
251   - break;
252   - case 'RestoreDone':
253   - restoreDone();
254   - break;
255   - case 'Login':
256   - login();
257   - break;
258   - case 'LoginProcess':
259   - loginProcess();
260   - break;
261   - default:
262   - if (!isset($_SESSION['setup_user']))
263   - login();
264   - else
265   - welcome();
266   - break;
267   -}
268   -
269   -function login()
270   -{
271   -?>
272   -<P>
273   -The database upgrade wizard completes the upgrade process on an existing <?php echo APP_NAME;?> installation. It applies
274   -any upgrades to the database that may be required.
275   -<P>
276   -Only administrator users may access the upgrade wizard.
277   -<P>
278   -
279   -<form method=post action="?go=LoginProcess">
280   -<table>
281   -<tr><td>Username<td><input name=username>
282   -<tr><td>Password<td><input name=password type="password">
283   -<tr><td colspan=2 align=center><input type=submit value="login">
284   -</table>
285   -</form>
286   -<?php
287   -}
288   -
289   -function loginProcess()
290   -{
291   - $username=$_REQUEST['username'];
292   - $password=$_REQUEST['password'];
293   -
294   - $authenticated = checkPassword($username, $password);
295   -
296   - if (!$authenticated)
297   - {
298   - session_unset();
299   - loginFailed(_kt('Could not authenticate administrative user'));
300   - return;
301   - }
302   -
303   - $_SESSION['setup_user'] = $username;
304   -
305   - welcome();
306   -}
307   -
308   -function checkPassword($username, $password) {
309   - global $default;
310   -
311   - $sTable = KTUtil::getTableName('users');
312   - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?";
313   - $aParams = array($username, md5($password));
314   - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count');
315   - if (PEAR::isError($res)) { return false; }
316   - else {
317   - $sTable = KTUtil::getTableName('users_groups_link');
318   - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1";
319   - $aParams = array($res);
320   - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count');
321   - if (PEAR::isError($res)) { return false; }
322   - else {
323   - return ($res == 1);
324   - }
325   - }
326   -}
327   -
328   -function loginFailed($message)
329   -{
330   - print "<font color=red>$message</font>";
331   - login();
332   -}
333   -
334   -function resolveMysqlDir()
335   -{
336   - // possibly detect existing installations:
337   -
338   - if (OS_UNIX)
339   - {
340   - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin');
341   - $mysqlname ='mysql';
342   - }
343   - else
344   - {
345   - $dirs = explode(';', $_SERVER['PATH']);
346   - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin';
347   - $dirs[] = 'c:/program files/ktdms/mysql/bin';
348   - $mysqlname ='mysql.exe';
349   - }
350   -
351   - $oKTConfig =& KTConfig::getSingleton();
352   - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
353   - $dirs[] = $mysqldir;
354   -
355   - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false)
356   - {
357   - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
358   - }
359   -
360   - foreach($dirs as $dir)
361   - {
362   - if (is_file($dir . '/' . $mysqlname))
363   - {
364   - return $dir;
365   - }
366   - }
367   -
368   - return '';
369   -}
370   -
371   -
372   -function create_backup_stmt($targetfile=null)
373   -{
374   - $oKTConfig =& KTConfig::getSingleton();
375   -
376   - $adminUser = $oKTConfig->get('db/dbAdminUser');
377   - $adminPwd = $oKTConfig->get('db/dbAdminPass');
378   - $dbHost = $oKTConfig->get('db/dbHost');
379   - $dbName = $oKTConfig->get('db/dbName');
380   -
381   - $dbPort = trim($oKTConfig->get('db/dbPort'));
382   - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port');
383   - if (empty($dbPort)) $dbPort='3306';
384   - $dbSocket = trim($oKTConfig->get('db/dbSocket'));
385   - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket');
386   - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
387   -
388   - $date=date('Y-m-d-H-i-s');
389   -
390   - $dir=resolveMysqlDir();
391   -
392   - $info['dir']=$dir;
393   -
394   - $prefix='';
395   - if (OS_UNIX)
396   - {
397   - $prefix .= "./";
398   - }
399   -
400   - if (@stat($dbSocket) !== false)
401   - {
402   - $mechanism="--socket=\"$dbSocket\"";
403   - }
404   - else
405   - {
406   - $mechanism="--port=\"$dbPort\"";
407   - }
408   -
409   - $tmpdir=resolveTempDir();
410   -
411   - if (is_null($targetfile))
412   - {
413   - $targetfile="$tmpdir/kt-backup-$date.sql";
414   - }
415   -
416   - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\"";
417   - $info['display']=$stmt;
418   - $info['target']=$targetfile;
419   -
420   -
421   - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\"";
422   - $info['cmd']=$stmt;
423   - return $info;
424   -}
425   -
426   -function create_restore_stmt($targetfile)
427   -{
428   - $oKTConfig =& KTConfig::getSingleton();
429   -
430   - $adminUser = $oKTConfig->get('db/dbAdminUser');
431   - $adminPwd = $oKTConfig->get('db/dbAdminPass');
432   - $dbHost = $oKTConfig->get('db/dbHost');
433   - $dbName = $oKTConfig->get('db/dbName');
434   - $dbPort = trim($oKTConfig->get('db/dbPort'));
435   - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port');
436   - if (empty($dbPort)) $dbPort='3306';
437   - $dbSocket = trim($oKTConfig->get('db/dbSocket'));
438   - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket');
439   - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
440   -
441   - $dir=resolveMysqlDir();
442   -
443   - $info['dir']=$dir;
444   -
445   - $prefix='';
446   - if (OS_UNIX)
447   - {
448   - $prefix .= "./";
449   - }
450   -
451   - if (@stat($dbSocket) !== false)
452   - {
453   - $mechanism="--socket=\"$dbSocket\"";
454   - }
455   - else
456   - {
457   - $mechanism="--port=\"$dbPort\"";
458   - }
459   -
460   - $tmpdir=resolveTempDir();
461   -
462   - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>";
463   - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>";
464   -
465   -
466   - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n";
467   - $info['display']=$stmt;
468   -
469   -
470   - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n";
471   - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n";
472   -
473   - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\"";
474   - $info['cmd']=$stmt;
475   - return $info;
476   -}
477   -
478   -function title($title)
479   -{
480   - if (!isset($_SESSION['setup_user']))
481   - {
482   - print "<script type='text/javascript'>document.location='?go=Login'</script>";
483   - }
484   - print "<h1>$title</h1>";
485   -}
486   -
487   -function resolveTempDir()
488   -{
489   -
490   - if (OS_UNIX)
491   - {
492   - $dir='/tmp/kt-db-backup';
493   - }
494   - else
495   - {
496   - $dir='c:/kt-db-backup';
497   - }
498   - $oKTConfig =& KTConfig::getSingleton();
499   - $dir = $oKTConfig->get('backup/backupDirectory',$dir);
500   -
501   - if (!is_dir($dir))
502   - {
503   - mkdir($dir);
504   - }
505   - return $dir;
506   -}
507   -
508   -
509   -function upgradeConfirm()
510   -{
511   - title('Confirm Upgrade');
512   - if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false)
513   - {
514   -?>
515   -<br/>
516   -<font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font>
517   -<p>
518   -<br/>
519   -<?php
520   - }
521   -?>
522   -<p>
523   -We are about to start the upgrade process.
524   -<P>
525   -
526   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
527   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradePreview')">
528   -
529   -<?php
530   -
531   -}
532   -
533   -
534   -function backupConfirm()
535   -{
536   - title('Confirm Backup');
537   - $stmt=create_backup_stmt();
538   - $_SESSION['backupFile'] = $stmt['target'];
539   -
540   - $dir=$stmt['dir'];
541   - if ($dir != '')
542   - {
543   -?>
544   -
545   -Are you sure you want to perform the backup?
546   -
547   -<P>
548   -Your mysql installation has been resolved. Manually, you would do the following:
549   -<P>
550   -<table bgcolor="lightgrey">
551   -<tr>
552   -<td>
553   -<nobr>cd "<?php echo $dir;?>"</nobr>
554   -<br/>
555   -<?php
556   - }
557   - else
558   - {
559   -?>
560   -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.
561   -<P>
562   -You can continue to do the backup manually using the following process:
563   -<P>
564   -<table bgcolor="lightgrey">
565   -<tr>
566   -<td>
567   -<?php
568   -
569   - }
570   -?>
571   -<nobr><?php echo $stmt['display'];?></nobr>
572   -</table>
573   -<P>
574   -
575   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')"> &nbsp;&nbsp; &nbsp; &nbsp;
576   -
577   -<?php
578   -if ($dir != '')
579   -{
580   -?>
581   -
582   -<input type=button value="next" onclick="javascript:do_start('Backup')">
583   -
584   -
585   -<?php
586   -}
587   -}
588   -
589   -function restoreSelect()
590   -{
591   - title('Select Backup to Restore');
592   -
593   - $dir = resolveTempDir();
594   -
595   - $files = array();
596   - if ($dh = opendir($dir))
597   - {
598   - while (($file = readdir($dh)) !== false)
599   - {
600   - if (!preg_match('/kt-backup.+\.sql/',$file))
601   - {
602   - continue;
603   - }
604   - $files[] = $file;
605   - }
606   - closedir($dh);
607   - }
608   -
609   - if (count($files) == 0)
610   - {
611   - ?>
612   - There don't seem to be any backups to restore from the <i>"<?php echo $dir;?>"</i> directory.
613   - <?php
614   - }
615   - else
616   - {
617   - ?>
618   - <P>
619   - Select a backup to restore from the list below:
620   - <P>
621   - <script type="text/javascript">
622   - function selectRestore(filename)
623   - {
624   - document.location='?go=RestoreSelected&file=' + filename;
625   - }
626   - </script>
627   - <table border=1 cellpadding=1 cellspacing=1>
628   - <tr bgcolor="darkgrey">
629   - <td>Filename
630   - <td>File Size
631   - <td>Action
632   -<?php
633   - $i=0;
634   - foreach($files as $file)
635   - {
636   - $color=((($i++)%2)==0)?'white':'lightgrey';
637   -?>
638   - <tr bgcolor="<?php echo $color;?>">
639   - <td><?php echo $file;?>
640   - <td><?php echo filesize($dir . '/'.$file);?>
641   - <td><input type=button value="restore" onclick="javascript:selectRestore('<?php echo $file;?>')">
642   -<?php
643   - }
644   -?>
645   - </table>
646   - <?php
647   - }
648   - ?>
649   -
650   - <p>
651   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
652   - <?php
653   -
654   -}
655   -
656   -function restoreSelected()
657   -{
658   - $file=$_REQUEST['file'];
659   -
660   - $dir = resolveTempDir();
661   - $_SESSION['backupFile'] = $dir . '/' . $file;
662   -?>
663   -<script type="text/javascript">
664   -document.location='?go=RestoreConfirm';
665   -</script>
666   -<?php
667   -
668   -}
669   -
670   -function restoreConfirm()
671   -{
672   - if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0)
673   - {
674   - restoreSelect();
675   - exit;
676   - }
677   -
678   - title('Confirm Restore');
679   - $status = $_SESSION['backupStatus'];
680   - $filename=$_SESSION['backupFile'];
681   - $stmt=create_restore_stmt($filename);
682   -
683   - $dir=$stmt['dir'];
684   - if ($dir != '')
685   - {
686   -?>
687   -<P>
688   -<P>
689   -Manually, you would do the following to restore the backup:
690   -<P>
691   -<table bgcolor="lightgrey">
692   -<tr>
693   -<td>
694   -<nobr>cd "<?php echo $dir;?>"</nobr>
695   -<br/>
696   -<?php
697   - }
698   - else
699   - {
700   -?>
701   -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.
702   -<P>
703   -You can continue to do the restore manually using the following command(s):
704   -<P>
705   -<table bgcolor="lightgrey">
706   -<tr>
707   -<td>
708   -<?php
709   -
710   - }
711   -?>
712   -<nobr><?php echo $stmt['display'];?></nobr>
713   -</td>
714   -</tr>
715   -</table>
716   -<P>
717   -<?php
718   -if ($dir != '')
719   -{
720   -?>
721   -Press <i>continue to restore</i> to attempt the command(s) above.
722   -
723   -<P>
724   -<?php
725   -}
726   -?>
727   -
728   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
729   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="select another backup" onclick="javascript:do_start('RestoreSelect')">
730   -
731   -<?php
732   -if ($dir != '')
733   -{
734   -?>
735   -<script type="text/javascript">
736   -function restore()
737   -{
738   - if (confirm('Are you sure you want to restore? This is your last chance if the current data has not been backed up.'))
739   - {
740   - do_start('Restore');
741   - }
742   -}
743   -</script>
744   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:restore()">
745   -
746   -
747   -<?php
748   -}
749   -}
750   -
751   -
752   -function backupDone()
753   -{
754   - check_state(2);
755   - set_state(3);
756   - title('Backup Status');
757   - $status = $_SESSION['backupStatus'];
758   - $filename=$_SESSION['backupFile'];
759   -
760   - if ($status)
761   - {
762   - $stmt=create_restore_stmt($filename);
763   -?>
764   - The backup file <nobr><i>"<?php echo $filename;?>"</i></nobr> has been created.
765   - <P> It appears as though the <font color=green>backup has been successful</font>.
766   - <P>
767   - <?php
768   - if ($stmt['dir'] != '')
769   - {
770   - ?>
771   - Manually, you would do the following to restore the backup:
772   - <P>
773   - <table bgcolor="lightgrey">
774   - <tr>
775   - <td>
776   - <nobr>cd <?php echo $stmt['dir'];?></nobr>
777   - <br/>
778   - <?php
779   - }
780   - else
781   - {
782   - ?>
783   - The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry.
784   - <P>
785   - If you need to restore from this backup, you should be able to use the following statements:
786   - <P>
787   - <table bgcolor="lightgrey">
788   - <tr>
789   - <td>
790   - <?php
791   - }
792   - ?>
793   - <nobr><?php echo $stmt['display'];?></nobr>
794   - </table>
795   -
796   -<?php
797   - }
798   - else
799   - {
800   -?>
801   -It appears as though <font color=red>the backup process has failed</font>.<P></P> Unfortunately, it is difficult to diagnose these problems automatically
802   -and would recommend that you try to do the backup process manually.
803   -<P>
804   -We appologise for the inconvenience.
805   -<P>
806   -<table bgcolor="lightgrey">
807   -<tr>
808   -<td>
809   -<?php echo $_SESSION['backupOutput'];?>
810   -</table>
811   -<?php
812   -
813   - }
814   -?>
815   -<br/>
816   -
817   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
818   -<?php
819   - if ($status)
820   - {
821   - ?>
822   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm')">
823   -
824   -<?php
825   - }
826   -}
827   -function restoreDone()
828   -{
829   - check_state(5);
830   - set_state(6);
831   - title('Restore Status');
832   - $status = $_SESSION['restoreStatus'];
833   - $filename=$_SESSION['backupFile'];
834   -
835   - if ($status)
836   - {
837   -
838   -?>
839   - The restore of <nobr><i>"<?php echo $filename;?>"</i></nobr> has been completed.
840   - <P>
841   - It appears as though the <font color=green>restore has been successful</font>.
842   - <P>
843   -
844   -
845   -
846   -<?php
847   - }
848   - else
849   - {
850   -?>
851   -It appears as though <font color=red>the restore process has failed</font>. <P>
852   -Unfortunately, it is difficult to diagnose these problems automatically
853   -and would recommend that you try to do the backup process manually.
854   -<P>
855   -We appologise for the inconvenience.
856   -<P>
857   -<table bgcolor="lightgrey">
858   -<tr>
859   -<td>
860   -<?php echo $_SESSION['restoreOutput'];?>
861   -</table>
862   -<?php
863   -
864   - }
865   -?>
866   -
867   -<br/>
868   -
869   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
870   -
871   -<?php
872   -
873   -}
874   -
875   -function set_state($value)
876   -{
877   - $_SESSION['state'] = $value;
878   -}
879   -function check_state($value, $state='Home')
880   -{
881   - if ($_SESSION['state'] != $value)
882   - {
883   - ?>
884   - <script type="text/javascript">
885   - document.location="?go=<?php echo $state;?>";
886   - </script>
887   - <?php
888   - exit;
889   - }
890   -}
891   -
892   -function backup()
893   -{
894   - check_state(1);
895   - set_state(2);
896   - title('Backup In Progress');
897   - $targetfile=$_SESSION['backupFile'];
898   - $stmt=create_backup_stmt($targetfile);
899   - $dir=$stmt['dir'];
900   -
901   -
902   -
903   -
904   - if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe'))
905   - {
906   - ob_flush();
907   - flush();
908   -?>
909   - The backup is now underway. Please wait till it completes.
910   -<?php
911   -
912   - ob_flush();
913   - flush();
914   - $curdir=getcwd();
915   - chdir($dir);
916   - ob_flush();
917   - flush();
918   -
919   - $handle = popen($stmt['cmd'], 'r');
920   - $read = fread($handle, 10240);
921   - pclose($handle);
922   - $_SESSION['backupOutput']=$read;
923   - $dir=resolveTempDir();
924   - $_SESSION['backupFile'] = $stmt['target'];
925   -
926   - if (OS_UNIX)
927   - {
928   - chmod($stmt['target'],0600);
929   - }
930   -
931   - if (is_file($stmt['target']) && filesize($stmt['target']) > 0)
932   - {
933   - $_SESSION['backupStatus'] = true;
934   -
935   - }
936   - else
937   - {
938   - $_SESSION['backupStatus'] = false;
939   - }
940   -?>
941   - <script type="text/javascript">
942   - document.location="?go=BackupDone";
943   - </script>
944   -<?php
945   -
946   -
947   - }
948   - else
949   - {
950   -?>
951   -<P>
952   - The <i>mysqldump</i> utility was not found in the <?php echo $dir;?> subdirectory.
953   -
954   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
955   -<?php
956   - }
957   -
958   -
959   -
960   -}
961   -
962   -
963   -function restore()
964   -{
965   - check_state(1);
966   - set_state(5);
967   - title('Restore In Progress');
968   - $status = $_SESSION['backupStatus'];
969   - $filename=$_SESSION['backupFile'];
970   - $stmt=create_restore_stmt($filename);
971   - $dir=$stmt['dir'];
972   -
973   -
974   -
975   -
976   - if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe'))
977   - {
978   -
979   -?>
980   - The restore is now underway. Please wait till it completes.
981   -<?php
982   - print "\n";
983   -
984   -
985   - $curdir=getcwd();
986   - chdir($dir);
987   -
988   -
989   - $ok=true;
990   - $stmts=explode("\n",$stmt['cmd']);
991   - foreach($stmts as $stmt)
992   - {
993   -
994   - $handle = popen($stmt, 'r');
995   - if ($handle=='false')
996   - {
997   - $ok=false;
998   - break;
999   - }
1000   - $read = fread($handle, 10240);
1001   - pclose($handle);
1002   - $_SESSION['restoreOutput']=$read;
1003   - }
1004   -
1005   -
1006   -
1007   -
1008   -
1009   - $_SESSION['restoreStatus'] = $ok;
1010   -
1011   -
1012   -?>
1013   - <script type="text/javascript">
1014   - document.location="?go=RestoreDone";
1015   - </script>
1016   -<?php
1017   -
1018   -
1019   - }
1020   - else
1021   - {
1022   -?>
1023   -<P>
1024   - The <i>mysql</i> utility was not found in the <?php echo $dir;?> subdirectory.
1025   -
1026   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
1027   -<?php
1028   - }
1029   -
1030   -
1031   -
1032   -}
1033   -
1034   -
1035   -function welcome()
1036   -{
1037   - set_state(1);
1038   -?>
1039   -<br/>
1040   -Welcome to the <?php echo APP_NAME;?> Database Upgrade Wizard.<P> If you have just updated
1041   -your <?php echo APP_NAME;?> code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version.
1042   -<P>
1043   -You will not be able to log into <?php echo APP_NAME;?> until your the database upgrade process is completed.
1044   -<P>
1045   -<font color="#ffa500">!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!!</font>
1046   -<P>
1047   -If you have already done this, you may skip this step can continue directly to the upgrade.
1048   -<P>
1049   -
1050   -
1051   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="cancel" onclick="document.location='..';"/>
1052   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');"/>
1053   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');"/>
1054   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');"/>
1055   -
1056   -
1057   -<?php
1058   -
1059   -
1060   -}
1061   -
1062   -
1063   -function UpgradePreview()
1064   -{
1065   - title('Preview Upgrade');
1066   - global $default;
1067   -?>
1068   - <p>The table below describes the upgrades that need to occur to
1069   - upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>.
1070   - Click on the button below the table to perform the upgrades.</p>
1071   - <?php
1072   - $upgradeTable = generateUpgradeTable();
1073   - print $upgradeTable;
1074   - ?>
1075   - <br/>
1076   -
1077   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
1078   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('Upgrade')">
1079   - <?php
1080   -
1081   -}
1082   -
1083   -
1084   -function Upgrade()
1085   -{
1086   - title('Upgrade In Progress');
1087   - global $default;
1088   -?>
1089   - <p>The table below describes the upgrades that have occurred to
1090   - upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>.
1091   -
1092   - <?php
1093   - $pre_res = performPreUpgradeActions();
1094   - if (PEAR::isError($pre_res))
1095   - {
1096   -?>
1097   -<font color="red">Pre-Upgrade actions failed.</font><br/>
1098   -<?php
1099   - }
1100   - else
1101   - {
1102   -?>
1103   -<p>
1104   -<font color="green">Pre-Upgrade actions succeeded.</font><br/>
1105   -<?php
1106   - }
1107   -?>
1108   -<p>
1109   - <?php
1110   - $res = performAllUpgrades();
1111   - if (PEAR::isError($res) || PEAR::isError($pres))
1112   - {
1113   -?>
1114   -<font color="red">Upgrade failed.</font>
1115   -<?php
1116   - }
1117   - else
1118   - {
1119   -?>
1120   -<p>
1121   -<font color="green">Upgrade succeeded.</font>
1122   -<?php
1123   - }
1124   -?>
1125   -<p>
1126   - <?php
1127   - $post_pres = performPostUpgradeActions();
1128   - if (PEAR::isError($post_res))
1129   - {
1130   -?>
1131   -<font color="red">Post-Upgrade actions failed.</font><br/><br/>
1132   -<?php
1133   - }
1134   - else
1135   - {
1136   -?>
1137   -<p>
1138   -<font color="green">Post-Upgrade actions succeeded.</font><br/><br/>
1139   -<script type="text/javascript">
1140   - alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'next' at the bottom of this page to continue.")
1141   -</script>
1142   -<?php
1143   - }
1144   -?>
1145   -
1146   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
1147   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:document.location='..';">
1148   -<?php
1149   -}
1150   -
1151   -?>
1152   -<tr>
1153   -<td height=80 <?php
1154   - if($oKTConfig->get('ui/poweredByDisabled') == '0'){
1155   - ?> align="right"><img src="<?php echo $oKTConfig->get('ui/powerLogo');?>"></td>
1156   - <?php }else{ ?>
1157   - background="../resources/graphics/ktbg.png">&nbsp;</td>
1158   - <?php }?>
1159   -</table>
  38 +header("Location: upgrade/");
  39 +exit();
1160 40 \ No newline at end of file
... ...
setup/wizard/lib/services/unixOpenOffice.php
... ... @@ -112,37 +112,68 @@ class unixOpenOffice extends unixService {
112 112  
113 113 public function status($updrade = false) {
114 114 sleep(1);
115   - if($updrade) {
116   - $cmd = "ps ax | grep soffice";
117   - } else {
118   - $cmd = "netstat -npa | grep ".$this->getPort();
119   - }
120   - $response = $this->util->pexec($cmd);
  115 + $cmd = "ps ax | grep soffice";
  116 + $response = $this->util->pexec($cmd);
121 117 if(is_array($response['out'])) {
122   - if(count($response['out']) > 0) {
123   - preg_match('/8100/', $response['out'][0], $matches); // Ignore grep
124   - if($matches) {
125   - if($matches[0] == '8100') {
  118 + if(count($response['out']) > 1) {
  119 + foreach ($response['out'] as $r) {
  120 + preg_match('/grep/', $r, $matches); // Ignore grep
  121 + if(!$matches) {
126 122 return 'STARTED';
127 123 }
128   - }
  124 + }
129 125 } else {
130 126 return '';
131 127 }
132 128 }
133   -
  129 + /*
  130 + if($updrade) {
  131 + $cmd = "ps ax | grep soffice";
  132 + $response = $this->util->pexec($cmd);
  133 + if(is_array($response['out'])) {
  134 + if(count($response['out']) > 1) {
  135 + foreach ($response['out'] as $r) {
  136 + preg_match('/grep/', $r, $matches); // Ignore grep
  137 + if(!$matches) {
  138 + return 'STARTED';
  139 + }
  140 + }
  141 + } else {
  142 + return '';
  143 + }
  144 + }
  145 + } else {
  146 + $cmd = "netstat -npa | grep ".$this->getPort();
  147 + $response = $this->util->pexec($cmd);
  148 + if(is_array($response['out'])) {
  149 + if(count($response['out']) > 0) {
  150 + preg_match('/8100/', $response['out'][0], $matches); // Ignore grep
  151 + if($matches) {
  152 + if($matches[0] == '8100') {
  153 + return 'STARTED';
  154 + }
  155 + }
  156 + } else {
  157 + return '';
  158 + }
  159 + }
  160 + }
  161 + */
134 162 return '';
135 163 }
136 164  
137 165 public function start() {
138 166 $state = $this->status();
139 167 if($state != 'STARTED') {
140   - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!";
  168 + //$cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!";
  169 +// $cmd = "{$this->getBin()} ".$this->getOption();
  170 +//"/usr/bin/java" openOffice -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" /usr/bin/soffice
  171 +//"/usr/bin/java" -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" openOffice /usr/bin/soffice
  172 + $cmd = "\"{$this->util->getJava()}\" -cp \"".SYS_DIR."\" openOffice ".$this->getBin();
141 173 if(DEBUG) {
142 174 echo "Command : $cmd<br/>";
143 175 return ;
144 176 }
145   - $cmd .= "\"{$this->util->getJava()}\" -cp \"".SYS_DIR.";\" openOffice \"";
146 177 $response = $this->util->pexec($cmd);
147 178  
148 179 return $response;
... ...
setup/wizard/lib/system/openOffice.class
No preview for this file type
setup/wizard/lib/system/openOffice.java
... ... @@ -5,12 +5,13 @@ import java.util.Properties;
5 5 public class openOffice {
6 6  
7 7 public static void main(String args[]) throws Exception {
  8 + String openoffice = args[0];
8 9 try {
9 10 // Execute a command without arguments
10   - String command = "nohup /usr/bin/soffice -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\" > /dev/null 2>&1 & echo $!";
  11 + String command = "nohup "+openoffice+" -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\"";
11 12 Process child = Runtime.getRuntime().exec(command);
12 13 } catch (IOException e) {
13 14 System.err.println("Error: " + e.getMessage());
14 15 }
15 16 }
16   -}
17 17 \ No newline at end of file
  18 +}
... ...
setup/wizard/resources/js/wizard.js
... ... @@ -219,10 +219,16 @@ wizard.prototype.sendRegistration = function () {
219 219  
220 220 wizard.prototype.clearSessions = function () {
221 221 var address = 'session.php?action=destroyInstall';
  222 + w.clearASession(address);
  223 + var address = 'session.php?action=destroyMigrate';
  224 + w.clearASession(address);
  225 +}
  226 +
  227 +wizard.prototype.clearASession = function (address) {
222 228 $.ajax({
223 229 url: address,
224 230 dataType: "html",
225 231 type: "POST",
226 232 cache: false,
227   - });
  233 + });
228 234 }
229 235 \ No newline at end of file
... ...
setup/wizard/steps/complete.php
... ... @@ -84,6 +84,7 @@ class complete extends Step {
84 84 // check services
85 85 $this->checkServices();
86 86 $this->storeSilent();// Set silent mode variables
  87 +
87 88 }
88 89  
89 90 private function checkFileSystem()
... ... @@ -172,7 +173,8 @@ class complete extends Step {
172 173 }
173 174  
174 175 // make db connection - user
175   - $loaded = $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']);
  176 + $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']);
  177 + $loaded = $this->_dbhandler->getDatabaseLink();
176 178 // if we can log in to the database, check access
177 179 // TODO check write access?
178 180 if ($loaded)
... ... @@ -242,6 +244,11 @@ class complete extends Step {
242 244 $this->temp_variables['paths_check'] = $this->paths_check;
243 245 $this->temp_variables['privileges_check'] = $this->privileges_check;
244 246 $this->temp_variables['database_check'] = $this->database_check;
  247 + if (file_exists('migrate.lock')) {
  248 + $this->temp_variables['migrate_check'] = true;
  249 + } else {
  250 + $this->temp_variables['migrate_check'] = false;
  251 + }
245 252 }
246 253 }
247 254 ?>
248 255 \ No newline at end of file
... ...
setup/wizard/steps/database.php
... ... @@ -636,6 +636,10 @@ class database extends Step
636 636  
637 637 }
638 638  
  639 + if(!$this->importExportedDB()) {
  640 + $this->error['con'] = "Could not Import ";
  641 + }
  642 +
639 643 return true;
640 644 }
641 645  
... ... @@ -805,6 +809,20 @@ class database extends Step
805 809 return $this->parse_mysql_dump(SQL_INSTALL_DIR."data.sql");
806 810 }
807 811  
  812 + private function importExportedDB() {
  813 + if (!WINDOWS_OS) {
  814 + $dir='/tmp/kt-db-backup';
  815 + }
  816 + else {
  817 + $dir='c:/kt-db-backup';
  818 + }
  819 + $sqlFile = $dir."/dms_migrate.sql";
  820 + $this->parse_mysql_dump($sqlFile);
  821 + $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
  822 +// $this->_dbhandler->query("TRUNCATE plugins;");
  823 + $this->_dbhandler->query("TRUNCATE plugin_helper;");
  824 + return true;
  825 + }
808 826 /**
809 827 * Close connection if it exists
810 828 *
... ...
setup/wizard/steps/install.php
... ... @@ -91,7 +91,7 @@ class install extends step
91 91  
92 92 public function doRun()
93 93 {
94   - if(isset($_POST['Install'])){
  94 + if(isset($_POST['Install'])) {
95 95 if(isset($_POST['call_home'])){
96 96 $value = $_POST['call_home'];
97 97 }else{
... ...
setup/wizard/templates/complete.tpl
... ... @@ -117,7 +117,12 @@
117 117 <?php } ?>
118 118 </div>
119 119 </div>
120   - <a href="../../" class="buttons back" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  120 + <?php if($migrate_check) { ?>
  121 +<!-- <a href="../upgrade" class="buttons back" style="width:62px;" onclick="javascript:{w.clearSessions();}">Upgrade</a>-->
  122 + <a href="../../login.php" class="buttons back upgrade" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  123 + <?php } else { ?>
  124 + <a href="../../login.php" class="buttons back upgrade" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  125 + <?php } ?>
121 126 <?php
122 127 if (INSTALL_TYPE == 'Zend') {
123 128 ?>
... ...