Commit e8d28067d873076ac892fa209b8c28bf3355a7b8
1 parent
1fadd3cf
Start Upgrade Refactor
Committed by: Jarrett Jordaan Reviewed by: Megan Watson
Showing
9 changed files
with
58 additions
and
84 deletions
setup/migrate/steps/migrateComplete.php
| ... | ... | @@ -64,9 +64,19 @@ class migrateComplete extends Step { |
| 64 | 64 | $this->checkServices(); |
| 65 | 65 | $this->checkSqlDump(); |
| 66 | 66 | $this->checkPaths(); |
| 67 | + $this->removeInstallSessions(); | |
| 67 | 68 | $this->storeSilent();// Set silent mode variables |
| 68 | 69 | } |
| 69 | 70 | |
| 71 | + private function removeInstallSessions() { | |
| 72 | + $isteps = array('dependencies', 'configuration', 'services', 'database', 'registration', 'install', 'complete'); | |
| 73 | + foreach ($isteps as $step) { | |
| 74 | + if(isset($_SESSION['installers'][$step])) { | |
| 75 | + $_SESSION['installers'][$step] = null; | |
| 76 | + } | |
| 77 | + } | |
| 78 | + } | |
| 79 | + | |
| 70 | 80 | private function checkPaths() { |
| 71 | 81 | $installation = $this->getDataFromSession("installation"); // Get installation directory |
| 72 | 82 | foreach ($installation['urlPaths'] as $path) { | ... | ... |
setup/upgrade/step.php
| ... | ... | @@ -420,6 +420,22 @@ class Step |
| 420 | 420 | public function setErrors($error) { |
| 421 | 421 | $this->error = $error; |
| 422 | 422 | } |
| 423 | + | |
| 424 | + /** | |
| 425 | + * Get session data from package | |
| 426 | + * | |
| 427 | + * @author KnowledgeTree Team | |
| 428 | + * @params none | |
| 429 | + * @access private | |
| 430 | + * @return boolean | |
| 431 | + */ | |
| 432 | + public function getDataFromPackage($package, $class) { | |
| 433 | + if(empty($_SESSION[$package][$class])) { | |
| 434 | + return false; | |
| 435 | + } | |
| 436 | + | |
| 437 | + return $_SESSION[$package][$class]; | |
| 438 | + } | |
| 423 | 439 | } |
| 424 | 440 | |
| 425 | 441 | ?> |
| 426 | 442 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeInstallation.php
| ... | ... | @@ -54,19 +54,14 @@ class UpgradeInstallation extends step |
| 54 | 54 | |
| 55 | 55 | public function doStep() { |
| 56 | 56 | $this->temp_variables = array("step_name"=>"installation"); |
| 57 | -// parent::doStep(); | |
| 58 | 57 | if($this->next()) { |
| 59 | 58 | return 'next'; |
| 60 | 59 | } |
| 61 | 60 | else if ($this->restore()) { |
| 62 | -// header('Location: index.php?step_name=restore'); | |
| 63 | 61 | $this->util->redirect("index.php?step_name=restore"); |
| 64 | -// exit; | |
| 65 | 62 | } |
| 66 | 63 | else if ($this->upgrade()) { |
| 67 | - //header('Location: index.php?step_name=database'); | |
| 68 | 64 | $this->util->redirect("index.php?step_name=database"); |
| 69 | -// exit; | |
| 70 | 65 | } |
| 71 | 66 | |
| 72 | 67 | return 'landing'; | ... | ... |
setup/upgrade/steps/upgradeWelcome.php
| ... | ... | @@ -40,9 +40,6 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -require_once('../../config/dmsDefaults.php'); | |
| 44 | -require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; | |
| 45 | - | |
| 46 | 43 | class upgradeWelcome extends step { |
| 47 | 44 | |
| 48 | 45 | protected $silent = false; |
| ... | ... | @@ -66,38 +63,26 @@ class upgradeWelcome extends step { |
| 66 | 63 | // attempt login |
| 67 | 64 | $username = $_REQUEST['username']; |
| 68 | 65 | $password = $_REQUEST['password']; |
| 69 | - | |
| 70 | 66 | $authenticated = $this->checkPassword($username, $password); |
| 71 | - | |
| 72 | - if (!$authenticated) | |
| 73 | - { | |
| 67 | + if (!$authenticated) { | |
| 74 | 68 | session_unset(); |
| 75 | 69 | return false; |
| 76 | 70 | } |
| 77 | - | |
| 78 | 71 | $_SESSION['setup_user'] = $username; |
| 79 | - | |
| 80 | 72 | return true; |
| 81 | 73 | } |
| 82 | 74 | |
| 83 | 75 | private function checkPassword($username, $password) { |
| 84 | - global $default; | |
| 85 | - | |
| 86 | - $sTable = KTUtil::getTableName('users'); | |
| 87 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; | |
| 88 | - $aParams = array($username, md5($password)); | |
| 89 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | |
| 90 | - if (PEAR::isError($res)) { return false; } | |
| 91 | - else { | |
| 92 | - $sTable = KTUtil::getTableName('users_groups_link'); | |
| 93 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1"; | |
| 94 | - $aParams = array($res); | |
| 95 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | |
| 96 | - if (PEAR::isError($res)) { return false; } | |
| 97 | - else { | |
| 98 | - return ($res == 1); | |
| 99 | - } | |
| 76 | + $dconf = $this->getDataFromPackage('installers', 'database'); | |
| 77 | + $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | |
| 78 | + $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; | |
| 79 | + $res = $this->dbhandler->query($sQuery); | |
| 80 | + $ass = $this->dbhandler->fetchAssoc($res); | |
| 81 | + if(isset($ass[0]['match_count'])) { | |
| 82 | + if($ass[0]['match_count']) | |
| 83 | + return true; | |
| 100 | 84 | } |
| 85 | + return false; | |
| 101 | 86 | } |
| 102 | 87 | |
| 103 | 88 | } | ... | ... |
setup/wizard/install.lock
0 โ 100644
setup/wizard/installUtil.php
| ... | ... | @@ -692,43 +692,6 @@ class InstallUtil { |
| 692 | 692 | return ''; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | -/* function getOpenOffice() { | |
| 696 | - $cmd = "whereis soffice"; | |
| 697 | - $res = $this->getOpenOfficeHelper($cmd); | |
| 698 | - if($res != '' && preg_match('/soffice/', $res)) { | |
| 699 | - return $res; | |
| 700 | - } | |
| 701 | - $cmd = "which soffice"; | |
| 702 | - $res = $this->getOpenOfficeHelper($cmd); | |
| 703 | - if($res != '') { | |
| 704 | - return $res; | |
| 705 | - } | |
| 706 | - $cmd = "locate soffice"; | |
| 707 | - $res = $this->getOpenOfficeHelper($cmd); | |
| 708 | - if($res != '') { | |
| 709 | - return $res; | |
| 710 | - } | |
| 711 | - | |
| 712 | - return 'soffice'; | |
| 713 | - }*/ | |
| 714 | - | |
| 715 | -/* function getOpenOfficeHelper($cmd) { | |
| 716 | - $response = $this->pexec($cmd); | |
| 717 | - if(is_array($response['out'])) { | |
| 718 | - if (isset($response['out'][0])) { | |
| 719 | - $broke = explode(' ', $response['out'][0]); | |
| 720 | - foreach ($broke as $r) { | |
| 721 | - $match = preg_match('/bin/', $r); | |
| 722 | - if($match) { | |
| 723 | - return preg_replace('/soffice:/', '', $r); | |
| 724 | - } | |
| 725 | - } | |
| 726 | - } | |
| 727 | - } | |
| 728 | - | |
| 729 | - return ''; | |
| 730 | - }*/ | |
| 731 | - | |
| 732 | 695 | /** |
| 733 | 696 | * Deletes migration lock file if a clean install is chosen |
| 734 | 697 | * This is in case someone changes their mind after choosing upgrade/migrate and clicks back up to this step | ... | ... |
setup/wizard/steps/configuration.php
| ... | ... | @@ -312,10 +312,11 @@ class configuration extends Step |
| 312 | 312 | $paths = $conf['paths']; |
| 313 | 313 | if ($this->util->isMigration()) { // Check if its an upgrade |
| 314 | 314 | $this->readInstallation(); |
| 315 | + $configPath = $paths['configFile']['path']; | |
| 315 | 316 | } else { |
| 316 | 317 | $this->readConfigPath(); // initialise writing to config.ini |
| 317 | 318 | } |
| 318 | - $this->getFromConfigPath(); | |
| 319 | + $this->getFromConfigPath(); // Sets config Paths | |
| 319 | 320 | $ini = false; |
| 320 | 321 | if(file_exists($configPath)) { |
| 321 | 322 | $ini = new iniUtilities($configPath); |
| ... | ... | @@ -540,6 +541,7 @@ class configuration extends Step |
| 540 | 541 | return $configs; |
| 541 | 542 | } |
| 542 | 543 | |
| 544 | + | |
| 543 | 545 | /** |
| 544 | 546 | * Migration Path finder |
| 545 | 547 | * |
| ... | ... | @@ -571,9 +573,6 @@ class configuration extends Step |
| 571 | 573 | } |
| 572 | 574 | } |
| 573 | 575 | |
| 574 | - // Now for config path itself | |
| 575 | - if(isset($this->temp_variables[''])) | |
| 576 | - | |
| 577 | 576 | return true; |
| 578 | 577 | } |
| 579 | 578 | |
| ... | ... | @@ -647,17 +646,24 @@ class configuration extends Step |
| 647 | 646 | * @return boolean |
| 648 | 647 | */ |
| 649 | 648 | private function writeConfigPath($configPath = '') { |
| 650 | - $configPath = $this->getContentPath(); | |
| 651 | - if(!$configPath) return false; | |
| 652 | - $ini = new iniUtilities($configPath); | |
| 653 | - $data = $ini->getFileByLine(); | |
| 654 | - $configContent = ''; | |
| 655 | - foreach ($data as $k=>$v) { | |
| 656 | - if(preg_match('/config.ini/', $k)) { | |
| 657 | - $configContent = $k; | |
| 658 | - break; | |
| 659 | - } | |
| 660 | - } | |
| 649 | + $conf = $this->getDataFromSession("configuration"); // get data from the server | |
| 650 | + $paths = $conf['paths']; | |
| 651 | + if(isset($paths['configFile']['path'])) { | |
| 652 | + $configPath = $this->getContentPath(); | |
| 653 | + $configContent = $paths['configFile']['path']; | |
| 654 | + } else { | |
| 655 | + $configPath = $this->getContentPath(); | |
| 656 | + if(!$configPath) return false; | |
| 657 | + $ini = new iniUtilities($configPath); | |
| 658 | + $data = $ini->getFileByLine(); | |
| 659 | + $configContent = ''; | |
| 660 | + foreach ($data as $k=>$v) { | |
| 661 | + if(preg_match('/config.ini/', $k)) { | |
| 662 | + $configContent = $k; | |
| 663 | + break; | |
| 664 | + } | |
| 665 | + } | |
| 666 | + } | |
| 661 | 667 | $fp = fopen($configPath, 'w'); |
| 662 | 668 | if(fwrite($fp, $configContent)) |
| 663 | 669 | return true; | ... | ... |
setup/wizard/steps/database.php
| ... | ... | @@ -774,7 +774,6 @@ class database extends Step |
| 774 | 774 | $dbMigrate = $this->util->getDataFromPackage('migrate', 'database'); |
| 775 | 775 | $sqlFile = $dbMigrate['dumpLocation']; |
| 776 | 776 | $this->parse_mysql_dump($sqlFile); |
| 777 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 778 | 777 | $dropPluginHelper = "TRUNCATE plugin_helper;"; |
| 779 | 778 | $this->dbhandler->query($dropPluginHelper); |
| 780 | 779 | $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; | ... | ... |
setup/wizard/templates/complete.tpl
| ... | ... | @@ -134,7 +134,7 @@ |
| 134 | 134 | $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php"; |
| 135 | 135 | ?> |
| 136 | 136 | <?php if($migrate_check) { ?> |
| 137 | - <a href="../upgrade" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> | |
| 137 | + <a href="../upgrade/index.php" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> | |
| 138 | 138 | <?php } else { ?> |
| 139 | 139 | <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> |
| 140 | 140 | <?php } ?> | ... | ... |