Commit 724725cf6fa7937e53a26fcebcfd6271069b1272

Authored by kevin_fourie
1 parent b9c940f2

Merged in from DEV trunk...

KTS-3479
"Put a lock on the scheduler during upgrades"
In progress. Added the check in the scheduler. Added the creation / deletion of the lock file in the upgrade script.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/branches/3.5.3-Branch@8760 c91229c3-7414-0410-bfa2-8a42b809f60b
bin/scheduler.php
... ... @@ -42,6 +42,15 @@ require_once(KT_LIB_DIR . '/database/dbutil.inc');
42 42 // Set the time limit to 0 to prevent the script timing out
43 43 set_time_limit(0);
44 44  
  45 +global $default;
  46 +
  47 +// Check the lock file before starting
  48 +$lock = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
  49 +if(file_exists($lock)){
  50 + $default->log->debug('Scheduler: can\'t start - lock file exists');
  51 + exit(0);
  52 +}
  53 +
45 54  
46 55 /* ** Set up functions ** */
47 56  
... ... @@ -107,11 +116,8 @@ function getTaskList() {
107 116 return $result;
108 117 }
109 118  
110   -
111 119 /* ** Scheduler script ** */
112 120  
113   -global $default;
114   -
115 121 $default->log->debug('Scheduler: starting');
116 122  
117 123 // Get task list
... ... @@ -256,4 +262,4 @@ if (empty($aList))
256 262  
257 263 $default->log->debug('Scheduler: stopping');
258 264  
259 265 -?>
  266 +?>
260 267 \ No newline at end of file
... ...
setup/upgrade.php
... ... @@ -6,31 +6,31 @@
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21   - *
22   - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31   - * KnowledgeTree" logo and retain the original copyright notice. If the display of the
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   - * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -120,24 +120,37 @@ function performAllUpgrades () {
120 120 break;
121 121 }
122 122 }
123   -
  123 +
124 124 return $res;
125 125 }
126 126  
127 127 function performPreUpgradeActions() {
128   -
  128 +
129 129 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
130 130 // It should idealy work the same as the upgrades.
131   -
  131 +
  132 + global $default;
  133 +
  134 + // Lock the scheduler
  135 + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
  136 + touch($lockFile);
132 137 return true;
133 138  
134 139 }
135 140  
136 141 function performPostUpgradeActions() {
137   -
  142 +
138 143 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
139 144 // It should idealy work the same as the upgrades.
140   -
  145 +
  146 + global $default;
  147 +
  148 + // Unlock the scheduler
  149 + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
  150 + if(file_exists($lockFile)){
  151 + unlink($lockFile);
  152 + }
  153 +
141 154 // Clean out the plugin_helper table
142 155 $sql = "DELETE FROM plugin_helper";
143 156 $res = DBUtil::runQuery($sql);
... ... @@ -184,7 +197,7 @@ td { vertical-align: top; }
184 197 </head>
185 198  
186 199 <body>
187   - <img src="<?php
  200 + <img src="<?php
188 201 if($oKTConfig->get('ui/mainLogo')){
189 202 echo $oKTConfig->get('ui/mainLogo');
190 203 }else{
... ... @@ -219,31 +232,31 @@ switch ($action)
219 232 case 'Backup':
220 233 backup();
221 234 break;
222   - case 'BackupDone':
  235 + case 'BackupDone':
223 236 backupDone();
224   - break;
225   - case 'RestoreConfirm':
  237 + break;
  238 + case 'RestoreConfirm':
226 239 restoreConfirm();
227   - break;
228   - case 'RestoreSelect':
  240 + break;
  241 + case 'RestoreSelect':
229 242 restoreSelect();
230   - break;
231   - case 'RestoreSelected':
  243 + break;
  244 + case 'RestoreSelected':
232 245 restoreSelected();
233   - break;
234   - case 'Restore':
  246 + break;
  247 + case 'Restore':
235 248 restore();
236   - break;
237   - case 'RestoreDone':
  249 + break;
  250 + case 'RestoreDone':
238 251 restoreDone();
239   - break;
  252 + break;
240 253 case 'Login':
241 254 login();
242 255 break;
243 256 case 'LoginProcess':
244 257 loginProcess();
245 258 break;
246   - default:
  259 + default:
247 260 if (!isset($_SESSION['setup_user']))
248 261 login();
249 262 else
... ... @@ -268,26 +281,26 @@ Only administrator users may access the upgrade wizard.
268 281 <tr><td colspan=2 align=center><input type=submit value="login">
269 282 </table>
270 283 </form>
271   -<?php
  284 +<?php
272 285 }
273 286  
274 287 function loginProcess()
275 288 {
276 289 $username=$_REQUEST['username'];
277 290 $password=$_REQUEST['password'];
278   -
  291 +
279 292 $authenticated = checkPassword($username, $password);
280   -
  293 +
281 294 if (!$authenticated)
282 295 {
283 296 session_unset();
284 297 loginFailed(_kt('Could not authenticate administrative user'));
285 298 return;
286 299 }
287   -
  300 +
288 301 $_SESSION['setup_user'] = $username;
289   -
290   - welcome();
  302 +
  303 + welcome();
291 304 }
292 305  
293 306 function checkPassword($username, $password) {
... ... @@ -317,31 +330,31 @@ function loginFailed($message)
317 330 }
318 331  
319 332 function resolveMysqlDir()
320   -{
  333 +{
321 334 // possibly detect existing installations:
322   -
  335 +
323 336 if (OS_UNIX)
324 337 {
325 338 $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin');
326 339 $mysqlname ='mysql';
327 340 }
328   - else
  341 + else
329 342 {
330   - $dirs = explode(';', $_SERVER['PATH']);
  343 + $dirs = explode(';', $_SERVER['PATH']);
331 344 $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin';
332 345 $dirs[] = 'c:/program files/ktdms/mysql/bin';
333 346 $mysqlname ='mysql.exe';
334 347 }
335   -
  348 +
336 349 $oKTConfig =& KTConfig::getSingleton();
337 350 $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
338   - $dirs[] = $mysqldir;
339   -
  351 + $dirs[] = $mysqldir;
  352 +
340 353 if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false)
341 354 {
342 355 $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
343 356 }
344   -
  357 +
345 358 foreach($dirs as $dir)
346 359 {
347 360 if (is_file($dir . '/' . $mysqlname))
... ... @@ -349,7 +362,7 @@ function resolveMysqlDir()
349 362 return $dir;
350 363 }
351 364 }
352   -
  365 +
353 366 return '';
354 367 }
355 368  
... ... @@ -362,18 +375,18 @@ function create_backup_stmt($targetfile=null)
362 375 $adminPwd = $oKTConfig->get('db/dbAdminPass');
363 376 $dbHost = $oKTConfig->get('db/dbHost');
364 377 $dbName = $oKTConfig->get('db/dbName');
365   -
  378 +
366 379 $dbPort = trim($oKTConfig->get('db/dbPort'));
367 380 if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port');
368 381 if (empty($dbPort)) $dbPort='3306';
369 382 $dbSocket = trim($oKTConfig->get('db/dbSocket'));
370 383 if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket');
371 384 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
372   -
  385 +
373 386 $date=date('Y-m-d-H-i-s');
374 387  
375 388 $dir=resolveMysqlDir();
376   -
  389 +
377 390 $info['dir']=$dir;
378 391  
379 392 $prefix='';
... ... @@ -381,28 +394,28 @@ function create_backup_stmt($targetfile=null)
381 394 {
382 395 $prefix .= "./";
383 396 }
384   -
  397 +
385 398 if (@stat($dbSocket) !== false)
386 399 {
387 400 $mechanism="--socket=\"$dbSocket\"";
388 401 }
389   - else
  402 + else
390 403 {
391 404 $mechanism="--port=\"$dbPort\"";
392 405 }
393   -
  406 +
394 407 $tmpdir=resolveTempDir();
395   -
  408 +
396 409 if (is_null($targetfile))
397 410 {
398 411 $targetfile="$tmpdir/kt-backup-$date.sql";
399 412 }
400   -
  413 +
401 414 $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\"";
402 415 $info['display']=$stmt;
403 416 $info['target']=$targetfile;
404 417  
405   -
  418 +
406 419 $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\"";
407 420 $info['cmd']=$stmt;
408 421 return $info;
... ... @@ -424,7 +437,7 @@ function create_restore_stmt($targetfile)
424 437 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
425 438  
426 439 $dir=resolveMysqlDir();
427   -
  440 +
428 441 $info['dir']=$dir;
429 442  
430 443 $prefix='';
... ... @@ -432,29 +445,29 @@ function create_restore_stmt($targetfile)
432 445 {
433 446 $prefix .= "./";
434 447 }
435   -
  448 +
436 449 if (@stat($dbSocket) !== false)
437 450 {
438 451 $mechanism="--socket=\"$dbSocket\"";
439 452 }
440   - else
  453 + else
441 454 {
442 455 $mechanism="--port=\"$dbPort\"";
443 456 }
444   -
  457 +
445 458 $tmpdir=resolveTempDir();
446   -
  459 +
447 460 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br>";
448 461 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br>";
449   -
450   -
  462 +
  463 +
451 464 $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n";
452 465 $info['display']=$stmt;
453 466  
454   -
  467 +
455 468 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n";
456 469 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n";
457   -
  470 +
458 471 $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\"";
459 472 $info['cmd']=$stmt;
460 473 return $info;
... ... @@ -471,18 +484,18 @@ function title($title)
471 484  
472 485 function resolveTempDir()
473 486 {
474   -
  487 +
475 488 if (OS_UNIX)
476 489 {
477   - $dir='/tmp/kt-db-backup';
  490 + $dir='/tmp/kt-db-backup';
478 491 }
479   - else
  492 + else
480 493 {
481   - $dir='c:/kt-db-backup';
  494 + $dir='c:/kt-db-backup';
482 495 }
483 496 $oKTConfig =& KTConfig::getSingleton();
484 497 $dir = $oKTConfig->get('backup/backupDirectory',$dir);
485   -
  498 +
486 499 if (!is_dir($dir))
487 500 {
488 501 mkdir($dir);
... ... @@ -505,14 +518,14 @@ function upgradeConfirm()
505 518 }
506 519 ?>
507 520 <p>
508   -We are about to start the upgrade process.
  521 +We are about to start the upgrade process.
509 522 <P>
510   -
511   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
512   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradePreview')">
  523 +
  524 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  525 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradePreview')">
513 526  
514 527 <?php
515   -
  528 +
516 529 }
517 530  
518 531  
... ... @@ -521,14 +534,14 @@ function backupConfirm()
521 534 title('Confirm Backup');
522 535 $stmt=create_backup_stmt();
523 536 $_SESSION['backupFile'] = $stmt['target'];
524   -
  537 +
525 538 $dir=$stmt['dir'];
526 539 if ($dir != '')
527 540 {
528 541 ?>
529   -
  542 +
530 543 Are you sure you want to perform the backup?
531   -
  544 +
532 545 <P>
533 546 Your mysql installation has been resolved. Manually, you would do the following:
534 547 <P>
... ... @@ -537,7 +550,7 @@ Your mysql installation has been resolved. Manually, you would do the following:
537 550 <td>
538 551 <nobr>cd "<?php echo $dir;?>"</nobr>
539 552 <br>
540   -<?php
  553 +<?php
541 554 }
542 555 else
543 556 {
... ... @@ -556,15 +569,15 @@ You can continue to do the backup manually using the following process:
556 569 <nobr><?php echo $stmt['display'];?>
557 570 </table>
558 571 <P>
559   -
560   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')"> &nbsp;&nbsp; &nbsp; &nbsp;
  572 +
  573 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')"> &nbsp;&nbsp; &nbsp; &nbsp;
561 574  
562 575 <?php
563 576 if ($dir != '')
564 577 {
565 578 ?>
566 579  
567   -<input type=button value="next" onclick="javascript:do_start('Backup')">
  580 +<input type=button value="next" onclick="javascript:do_start('Backup')">
568 581  
569 582  
570 583 <?php
... ... @@ -574,13 +587,13 @@ if ($dir != &#39;&#39;)
574 587 function restoreSelect()
575 588 {
576 589 title('Select Backup to Restore');
577   -
  590 +
578 591 $dir = resolveTempDir();
579   -
  592 +
580 593 $files = array();
581   - if ($dh = opendir($dir))
  594 + if ($dh = opendir($dir))
582 595 {
583   - while (($file = readdir($dh)) !== false)
  596 + while (($file = readdir($dh)) !== false)
584 597 {
585 598 if (!preg_match('/kt-backup.+\.sql/',$file))
586 599 {
... ... @@ -590,14 +603,14 @@ function restoreSelect()
590 603 }
591 604 closedir($dh);
592 605 }
593   -
  606 +
594 607 if (count($files) == 0)
595 608 {
596 609 ?>
597 610 There don't seem to be any backups to restore from the <i>"<?php echo $dir;?>"</i> directory.
598 611 <?php
599 612 }
600   - else
  613 + else
601 614 {
602 615 ?>
603 616 <P>
... ... @@ -618,22 +631,22 @@ function restoreSelect()
618 631 $i=0;
619 632 foreach($files as $file)
620 633 {
621   - $color=((($i++)%2)==0)?'white':'lightgrey';
  634 + $color=((($i++)%2)==0)?'white':'lightgrey';
622 635 ?>
623 636 <tr bgcolor="<?php echo $color;?>">
624 637 <td><?php echo $file;?>
625 638 <td><?php echo filesize($dir . '/'.$file);?>
626 639 <td><input type=button value="restore" onclick="javascript:selectRestore('<?php echo $file;?>')">
627   -<?php
  640 +<?php
628 641 }
629 642 ?>
630 643 </table>
631   - <?php
  644 + <?php
632 645 }
633 646 ?>
634 647  
635 648 <p>
636   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  649 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
637 650 <?php
638 651  
639 652 }
... ... @@ -641,7 +654,7 @@ function restoreSelect()
641 654 function restoreSelected()
642 655 {
643 656 $file=$_REQUEST['file'];
644   -
  657 +
645 658 $dir = resolveTempDir();
646 659 $_SESSION['backupFile'] = $dir . '/' . $file;
647 660 ?>
... ... @@ -659,10 +672,10 @@ function restoreConfirm()
659 672 restoreSelect();
660 673 exit;
661 674 }
662   -
  675 +
663 676 title('Confirm Restore');
664 677 $status = $_SESSION['backupStatus'];
665   - $filename=$_SESSION['backupFile'];
  678 + $filename=$_SESSION['backupFile'];
666 679 $stmt=create_restore_stmt($filename);
667 680  
668 681 $dir=$stmt['dir'];
... ... @@ -678,7 +691,7 @@ Manually, you would do the following to restore the backup:
678 691 <td>
679 692 <nobr>cd "<?php echo $dir;?>"</nobr>
680 693 <br>
681   -<?php
  694 +<?php
682 695 }
683 696 else
684 697 {
... ... @@ -707,9 +720,9 @@ Press &lt;i&gt;continue to restore&lt;/i&gt; to attempt the command(s) above.
707 720 <?php
708 721 }
709 722 ?>
710   -
711   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
712   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="select another backup" onclick="javascript:do_start('RestoreSelect')">
  723 +
  724 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
  725 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="select another backup" onclick="javascript:do_start('RestoreSelect')">
713 726  
714 727 <?php
715 728 if ($dir != '')
... ... @@ -724,7 +737,7 @@ function restore()
724 737 }
725 738 }
726 739 </script>
727   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:restore()">
  740 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:restore()">
728 741  
729 742  
730 743 <?php
... ... @@ -739,7 +752,7 @@ function backupDone()
739 752 title('Backup Status');
740 753 $status = $_SESSION['backupStatus'];
741 754 $filename=$_SESSION['backupFile'];
742   -
  755 +
743 756 if ($status)
744 757 {
745 758 $stmt=create_restore_stmt($filename);
... ... @@ -758,7 +771,7 @@ function backupDone()
758 771 <td>
759 772 <nobr>cd <?php echo $stmt['dir'];?></nobr>
760 773 <br>
761   - <?php
  774 + <?php
762 775 }
763 776 else
764 777 {
... ... @@ -775,10 +788,10 @@ function backupDone()
775 788 ?>
776 789 <nobr><?php echo $stmt['display'];?>
777 790 </table>
778   -
  791 +
779 792 <?php
780 793 }
781   - else
  794 + else
782 795 {
783 796 ?>
784 797 It appears as though <font color=red>the backup process has failed</font>.<P></P> Unfortunately, it is difficult to diagnose these problems automatically
... ... @@ -792,19 +805,19 @@ We appologise for the inconvenience.
792 805 <?php echo $_SESSION['backupOutput'];?>
793 806 </table>
794 807 <?php
795   -
  808 +
796 809 }
797 810 ?>
798   -<br>
799   -
800   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  811 +<br>
  812 +
  813 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
801 814 <?php
802 815 if ($status)
803 816 {
804 817 ?>
805   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm')">
806   -
807   -<?php
  818 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm')">
  819 +
  820 +<?php
808 821 }
809 822 }
810 823 function restoreDone()
... ... @@ -814,21 +827,21 @@ function restoreDone()
814 827 title('Restore Status');
815 828 $status = $_SESSION['restoreStatus'];
816 829 $filename=$_SESSION['backupFile'];
817   -
  830 +
818 831 if ($status)
819 832 {
820   -
  833 +
821 834 ?>
822   - The restore of <nobr><I>"<?php echo $filename;?>"</i></nobr> has been completed.
  835 + The restore of <nobr><I>"<?php echo $filename;?>"</i></nobr> has been completed.
823 836 <P>
824 837 It appears as though the <font color=green>restore has been successful</font>.
825 838 <P>
826 839  
827 840  
828   -
  841 +
829 842 <?php
830 843 }
831   - else
  844 + else
832 845 {
833 846 ?>
834 847 It appears as though <font color=red>the restore process has failed</font>. <P>
... ... @@ -843,16 +856,16 @@ We appologise for the inconvenience.
843 856 <?php echo $_SESSION['restoreOutput'];?>
844 857 </table>
845 858 <?php
846   -
  859 +
847 860 }
848 861 ?>
849 862  
850   -<br>
851   -
852   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  863 +<br>
  864 +
  865 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  866 +
  867 +<?php
853 868  
854   -<?php
855   -
856 869 }
857 870  
858 871 function set_state($value)
... ... @@ -882,8 +895,8 @@ function backup()
882 895 $dir=$stmt['dir'];
883 896  
884 897  
885   -
886   -
  898 +
  899 +
887 900 if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe'))
888 901 {
889 902 ob_flush();
... ... @@ -905,18 +918,18 @@ function backup()
905 918 $_SESSION['backupOutput']=$read;
906 919 $dir=resolveTempDir();
907 920 $_SESSION['backupFile'] = $stmt['target'];
908   -
  921 +
909 922 if (OS_UNIX)
910 923 {
911 924 chmod($stmt['target'],0600);
912 925 }
913   -
  926 +
914 927 if (is_file($stmt['target']) && filesize($stmt['target']) > 0)
915 928 {
916 929 $_SESSION['backupStatus'] = true;
917   -
  930 +
918 931 }
919   - else
  932 + else
920 933 {
921 934 $_SESSION['backupStatus'] = false;
922 935 }
... ... @@ -924,18 +937,18 @@ function backup()
924 937 <script>
925 938 document.location="?go=BackupDone";
926 939 </script>
927   -<?php
928   -
929   -
  940 +<?php
  941 +
  942 +
930 943 }
931   - else
  944 + else
932 945 {
933 946 ?>
934 947 <P>
935 948 The <i>mysqldump</i> utility was not found in the <?php echo $dir;?> subdirectory.
936   -
937   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
938   -<?php
  949 +
  950 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  951 +<?php
939 952 }
940 953  
941 954  
... ... @@ -949,31 +962,31 @@ function restore()
949 962 set_state(5);
950 963 title('Restore In Progress');
951 964 $status = $_SESSION['backupStatus'];
952   - $filename=$_SESSION['backupFile'];
  965 + $filename=$_SESSION['backupFile'];
953 966 $stmt=create_restore_stmt($filename);
954 967 $dir=$stmt['dir'];
955 968  
956   -
957   -
958   -
  969 +
  970 +
  971 +
959 972 if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe'))
960 973 {
961   -
  974 +
962 975 ?>
963 976 The restore is now underway. Please wait till it completes.
964 977 <?php
965 978 print "\n";
966 979  
967   -
  980 +
968 981 $curdir=getcwd();
969 982 chdir($dir);
970   -
  983 +
971 984  
972 985 $ok=true;
973 986 $stmts=explode("\n",$stmt['cmd']);
974 987 foreach($stmts as $stmt)
975 988 {
976   -
  989 +
977 990 $handle = popen($stmt, 'r');
978 991 if ($handle=='false')
979 992 {
... ... @@ -984,30 +997,30 @@ function restore()
984 997 pclose($handle);
985 998 $_SESSION['restoreOutput']=$read;
986 999 }
987   -
988   -
989   -
990   -
991   -
  1000 +
  1001 +
  1002 +
  1003 +
  1004 +
992 1005 $_SESSION['restoreStatus'] = $ok;
993   -
994   -
  1006 +
  1007 +
995 1008 ?>
996 1009 <script>
997 1010 document.location="?go=RestoreDone";
998 1011 </script>
999   -<?php
1000   -
1001   -
  1012 +<?php
  1013 +
  1014 +
1002 1015 }
1003   - else
  1016 + else
1004 1017 {
1005 1018 ?>
1006 1019 <P>
1007 1020 The <i>mysql</i> utility was not found in the <?php echo $dir;?> subdirectory.
1008   -
1009   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
1010   -<?php
  1021 +
  1022 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('welcome')">
  1023 +<?php
1011 1024 }
1012 1025  
1013 1026  
... ... @@ -1029,12 +1042,12 @@ You will not be able to log into &lt;?php echo APP_NAME;?&gt; until your the database
1029 1042 <P>
1030 1043 If you have already done this, you may skip this step can continue directly to the upgrade.
1031 1044 <P>
1032   -
1033   -
1034   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="cancel" onclick="document.location='..';">
1035   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');">
1036   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');">
1037   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');">
  1045 +
  1046 +
  1047 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="cancel" onclick="document.location='..';">
  1048 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');">
  1049 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');">
  1050 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');">
1038 1051  
1039 1052  
1040 1053 <?php
... ... @@ -1055,10 +1068,10 @@ function UpgradePreview()
1055 1068 $upgradeTable = generateUpgradeTable();
1056 1069 print $upgradeTable;
1057 1070 ?>
1058   - <br>
1059   -
1060   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
1061   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('Upgrade')">
  1071 + <br>
  1072 +
  1073 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
  1074 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:do_start('Upgrade')">
1062 1075 <?php
1063 1076  
1064 1077 }
... ... @@ -1066,21 +1079,21 @@ function UpgradePreview()
1066 1079  
1067 1080 function Upgrade()
1068 1081 {
1069   - title('Upgrade In Progress');
  1082 + title('Upgrade In Progress');
1070 1083 global $default;
1071 1084 ?>
1072 1085 <p>The table below describes the upgrades that have occurred to
1073 1086 upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>.
1074   -
  1087 +
1075 1088 <?php
1076 1089 $pre_res = performPreUpgradeActions();
1077   - if (PEAR::isError($pre_res))
  1090 + if (PEAR::isError($pre_res))
1078 1091 {
1079 1092 ?>
1080 1093 <font color="red">Pre-Upgrade actions failed.</font><br>
1081 1094 <?php
1082   - }
1083   - else
  1095 + }
  1096 + else
1084 1097 {
1085 1098 ?>
1086 1099 <p>
... ... @@ -1091,13 +1104,13 @@ function Upgrade()
1091 1104 <p>
1092 1105 <?php
1093 1106 $res = performAllUpgrades();
1094   - if (PEAR::isError($res) || PEAR::isError($pres))
  1107 + if (PEAR::isError($res) || PEAR::isError($pres))
1095 1108 {
1096 1109 ?>
1097 1110 <font color="red">Upgrade failed.</font>
1098 1111 <?php
1099   - }
1100   - else
  1112 + }
  1113 + else
1101 1114 {
1102 1115 ?>
1103 1116 <p>
... ... @@ -1108,13 +1121,13 @@ function Upgrade()
1108 1121 <p>
1109 1122 <?php
1110 1123 $post_pres = performPostUpgradeActions();
1111   - if (PEAR::isError($post_res))
  1124 + if (PEAR::isError($post_res))
1112 1125 {
1113 1126 ?>
1114 1127 <font color="red">Post-Upgrade actions failed.</font><br><br>
1115 1128 <?php
1116   - }
1117   - else
  1129 + }
  1130 + else
1118 1131 {
1119 1132 ?>
1120 1133 <p>
... ... @@ -1126,14 +1139,14 @@ function Upgrade()
1126 1139 }
1127 1140 ?>
1128 1141  
1129   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
1130   -&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:document.location='..';">
1131   -<?php
  1142 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="back" onclick="javascript:do_start('home')">
  1143 +&nbsp;&nbsp; &nbsp; &nbsp; <input type=button value="next" onclick="javascript:document.location='..';">
  1144 +<?php
1132 1145 }
1133 1146  
1134 1147 ?>
1135 1148 <tr>
1136   -<td height=80 <?php
  1149 +<td height=80 <?php
1137 1150 if($oKTConfig->get('ui/poweredByDisabled') == '0'){
1138 1151 ?> align="right"><img src="<?php echo $oKTConfig->get('ui/powerLogo');?>"></td>
1139 1152 <?php }else{ ?>
... ...