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,9 +64,19 @@ class migrateComplete extends Step { | ||
| 64 | $this->checkServices(); | 64 | $this->checkServices(); |
| 65 | $this->checkSqlDump(); | 65 | $this->checkSqlDump(); |
| 66 | $this->checkPaths(); | 66 | $this->checkPaths(); |
| 67 | + $this->removeInstallSessions(); | ||
| 67 | $this->storeSilent();// Set silent mode variables | 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 | private function checkPaths() { | 80 | private function checkPaths() { |
| 71 | $installation = $this->getDataFromSession("installation"); // Get installation directory | 81 | $installation = $this->getDataFromSession("installation"); // Get installation directory |
| 72 | foreach ($installation['urlPaths'] as $path) { | 82 | foreach ($installation['urlPaths'] as $path) { |
setup/upgrade/step.php
| @@ -420,6 +420,22 @@ class Step | @@ -420,6 +420,22 @@ class Step | ||
| 420 | public function setErrors($error) { | 420 | public function setErrors($error) { |
| 421 | $this->error = $error; | 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 | \ No newline at end of file | 442 | \ No newline at end of file |
setup/upgrade/steps/upgradeInstallation.php
| @@ -54,19 +54,14 @@ class UpgradeInstallation extends step | @@ -54,19 +54,14 @@ class UpgradeInstallation extends step | ||
| 54 | 54 | ||
| 55 | public function doStep() { | 55 | public function doStep() { |
| 56 | $this->temp_variables = array("step_name"=>"installation"); | 56 | $this->temp_variables = array("step_name"=>"installation"); |
| 57 | -// parent::doStep(); | ||
| 58 | if($this->next()) { | 57 | if($this->next()) { |
| 59 | return 'next'; | 58 | return 'next'; |
| 60 | } | 59 | } |
| 61 | else if ($this->restore()) { | 60 | else if ($this->restore()) { |
| 62 | -// header('Location: index.php?step_name=restore'); | ||
| 63 | $this->util->redirect("index.php?step_name=restore"); | 61 | $this->util->redirect("index.php?step_name=restore"); |
| 64 | -// exit; | ||
| 65 | } | 62 | } |
| 66 | else if ($this->upgrade()) { | 63 | else if ($this->upgrade()) { |
| 67 | - //header('Location: index.php?step_name=database'); | ||
| 68 | $this->util->redirect("index.php?step_name=database"); | 64 | $this->util->redirect("index.php?step_name=database"); |
| 69 | -// exit; | ||
| 70 | } | 65 | } |
| 71 | 66 | ||
| 72 | return 'landing'; | 67 | return 'landing'; |
setup/upgrade/steps/upgradeWelcome.php
| @@ -40,9 +40,6 @@ | @@ -40,9 +40,6 @@ | ||
| 40 | * @version Version 0.1 | 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 | class upgradeWelcome extends step { | 43 | class upgradeWelcome extends step { |
| 47 | 44 | ||
| 48 | protected $silent = false; | 45 | protected $silent = false; |
| @@ -66,38 +63,26 @@ class upgradeWelcome extends step { | @@ -66,38 +63,26 @@ class upgradeWelcome extends step { | ||
| 66 | // attempt login | 63 | // attempt login |
| 67 | $username = $_REQUEST['username']; | 64 | $username = $_REQUEST['username']; |
| 68 | $password = $_REQUEST['password']; | 65 | $password = $_REQUEST['password']; |
| 69 | - | ||
| 70 | $authenticated = $this->checkPassword($username, $password); | 66 | $authenticated = $this->checkPassword($username, $password); |
| 71 | - | ||
| 72 | - if (!$authenticated) | ||
| 73 | - { | 67 | + if (!$authenticated) { |
| 74 | session_unset(); | 68 | session_unset(); |
| 75 | return false; | 69 | return false; |
| 76 | } | 70 | } |
| 77 | - | ||
| 78 | $_SESSION['setup_user'] = $username; | 71 | $_SESSION['setup_user'] = $username; |
| 79 | - | ||
| 80 | return true; | 72 | return true; |
| 81 | } | 73 | } |
| 82 | 74 | ||
| 83 | private function checkPassword($username, $password) { | 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,43 +692,6 @@ class InstallUtil { | ||
| 692 | return ''; | 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 | * Deletes migration lock file if a clean install is chosen | 696 | * Deletes migration lock file if a clean install is chosen |
| 734 | * This is in case someone changes their mind after choosing upgrade/migrate and clicks back up to this step | 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,10 +312,11 @@ class configuration extends Step | ||
| 312 | $paths = $conf['paths']; | 312 | $paths = $conf['paths']; |
| 313 | if ($this->util->isMigration()) { // Check if its an upgrade | 313 | if ($this->util->isMigration()) { // Check if its an upgrade |
| 314 | $this->readInstallation(); | 314 | $this->readInstallation(); |
| 315 | + $configPath = $paths['configFile']['path']; | ||
| 315 | } else { | 316 | } else { |
| 316 | $this->readConfigPath(); // initialise writing to config.ini | 317 | $this->readConfigPath(); // initialise writing to config.ini |
| 317 | } | 318 | } |
| 318 | - $this->getFromConfigPath(); | 319 | + $this->getFromConfigPath(); // Sets config Paths |
| 319 | $ini = false; | 320 | $ini = false; |
| 320 | if(file_exists($configPath)) { | 321 | if(file_exists($configPath)) { |
| 321 | $ini = new iniUtilities($configPath); | 322 | $ini = new iniUtilities($configPath); |
| @@ -540,6 +541,7 @@ class configuration extends Step | @@ -540,6 +541,7 @@ class configuration extends Step | ||
| 540 | return $configs; | 541 | return $configs; |
| 541 | } | 542 | } |
| 542 | 543 | ||
| 544 | + | ||
| 543 | /** | 545 | /** |
| 544 | * Migration Path finder | 546 | * Migration Path finder |
| 545 | * | 547 | * |
| @@ -571,9 +573,6 @@ class configuration extends Step | @@ -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 | return true; | 576 | return true; |
| 578 | } | 577 | } |
| 579 | 578 | ||
| @@ -647,17 +646,24 @@ class configuration extends Step | @@ -647,17 +646,24 @@ class configuration extends Step | ||
| 647 | * @return boolean | 646 | * @return boolean |
| 648 | */ | 647 | */ |
| 649 | private function writeConfigPath($configPath = '') { | 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 | $fp = fopen($configPath, 'w'); | 667 | $fp = fopen($configPath, 'w'); |
| 662 | if(fwrite($fp, $configContent)) | 668 | if(fwrite($fp, $configContent)) |
| 663 | return true; | 669 | return true; |
setup/wizard/steps/database.php
| @@ -774,7 +774,6 @@ class database extends Step | @@ -774,7 +774,6 @@ class database extends Step | ||
| 774 | $dbMigrate = $this->util->getDataFromPackage('migrate', 'database'); | 774 | $dbMigrate = $this->util->getDataFromPackage('migrate', 'database'); |
| 775 | $sqlFile = $dbMigrate['dumpLocation']; | 775 | $sqlFile = $dbMigrate['dumpLocation']; |
| 776 | $this->parse_mysql_dump($sqlFile); | 776 | $this->parse_mysql_dump($sqlFile); |
| 777 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | ||
| 778 | $dropPluginHelper = "TRUNCATE plugin_helper;"; | 777 | $dropPluginHelper = "TRUNCATE plugin_helper;"; |
| 779 | $this->dbhandler->query($dropPluginHelper); | 778 | $this->dbhandler->query($dropPluginHelper); |
| 780 | $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; | 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,7 +134,7 @@ | ||
| 134 | $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php"; | 134 | $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php"; |
| 135 | ?> | 135 | ?> |
| 136 | <?php if($migrate_check) { ?> | 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 | <?php } else { ?> | 138 | <?php } else { ?> |
| 139 | <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | 139 | <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> |
| 140 | <?php } ?> | 140 | <?php } ?> |