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