Commit f3dd0f0518c458ff59fecd519091ffb0616aacc2
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
47 changed files
with
1452 additions
and
2675 deletions
bin/system_info.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * | |
| 5 | + * $Id: | |
| 6 | + * | |
| 7 | + * KnowledgeTree Community Edition | |
| 8 | + * Document Management Made Simple | |
| 9 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 10 | + * | |
| 11 | + * | |
| 12 | + * This program is free software; you can redistribute it and/or modify it under | |
| 13 | + * the terms of the GNU General Public License version 3 as published by the | |
| 14 | + * Free Software Foundation. | |
| 15 | + * | |
| 16 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 17 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 18 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 19 | + * details. | |
| 20 | + * | |
| 21 | + * You should have received a copy of the GNU General Public License | |
| 22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 23 | + * | |
| 24 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 25 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 26 | + * | |
| 27 | + * The interactive user interfaces in modified source and object code versions | |
| 28 | + * of this program must display Appropriate Legal Notices, as required under | |
| 29 | + * Section 5 of the GNU General Public License version 3. | |
| 30 | + * | |
| 31 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 32 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 33 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 34 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 35 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 36 | + * copyright notice. | |
| 37 | + * Contributor( s): ______________________________________ | |
| 38 | + */ | |
| 39 | + | |
| 40 | +/* | |
| 41 | +* Script to collect system information as part of a call home mechanism, no identifying information is stored. | |
| 42 | +* | |
| 43 | +* The following data is collected: | |
| 44 | +* Unique installation information: installation GUID, number of users in repository, number of documents in repository, | |
| 45 | +* operating system (platform, platform version, flavor if Linux), version and edition. | |
| 46 | +*/ | |
| 47 | +chdir(realpath(dirname(__FILE__))); | |
| 48 | +require_once('../config/dmsDefaults.php'); | |
| 49 | + | |
| 50 | +global $default; | |
| 51 | +$default->log->debug('System information collection script starting...'); | |
| 52 | + | |
| 53 | +// Get installation guid | |
| 54 | +function getGuid() | |
| 55 | +{ | |
| 56 | + $guid = KTUtil::getSystemIdentifier(); | |
| 57 | + | |
| 58 | + if(PEAR::isError($guid)){ | |
| 59 | + $guid = ''; | |
| 60 | + } | |
| 61 | + return $guid; | |
| 62 | +} | |
| 63 | + | |
| 64 | +// Get the number of users in the repository | |
| 65 | +function getUserCnt() | |
| 66 | +{ | |
| 67 | + $query = 'select count(*) as cnt, disabled from users where id > 0 group by disabled;'; | |
| 68 | + $result = DBUtil::getResultArray($query); | |
| 69 | + | |
| 70 | + if(empty($result) || PEAR::isError($result)){ | |
| 71 | + return ''; | |
| 72 | + } | |
| 73 | + $users = ''; | |
| 74 | + | |
| 75 | + foreach ($result as $row){ | |
| 76 | + $str = ''; | |
| 77 | + switch($row['disabled']){ | |
| 78 | + case 0: $str = 'Enabled'; break; | |
| 79 | + case 1: $str = 'Disabled'; break; | |
| 80 | + case 2: $str = 'Deleted'; break; | |
| 81 | + } | |
| 82 | + | |
| 83 | + $str .= ': '.$row['cnt']; | |
| 84 | + | |
| 85 | + $users .= (!empty($users)) ? '; ' : ''; | |
| 86 | + $users .= $str; | |
| 87 | + } | |
| 88 | + return $users; | |
| 89 | +} | |
| 90 | + | |
| 91 | +// Get the number of documents in the repository | |
| 92 | +function getDocCnt() | |
| 93 | +{ | |
| 94 | + $query = 'select count(*) as cnt, s.name from documents d, status_lookup s WHERE s.id = d.status_id group by d.status_id;'; | |
| 95 | + $result2 = DBUtil::getResultArray($query); | |
| 96 | + | |
| 97 | + if(empty($result2) || PEAR::isError($result2)){ | |
| 98 | + return ''; | |
| 99 | + } | |
| 100 | + $docs = ''; | |
| 101 | + | |
| 102 | + foreach ($result2 as $row){ | |
| 103 | + $docs .= (!empty($docs)) ? '; ' : ''; | |
| 104 | + $docs .= $row['name'].': '.$row['cnt']; | |
| 105 | + } | |
| 106 | + return $docs; | |
| 107 | +} | |
| 108 | + | |
| 109 | +// Get the version of KT | |
| 110 | +function getKTVersion() | |
| 111 | +{ | |
| 112 | + $version = KTUtil::getSystemSetting('knowledgeTreeVersion'); | |
| 113 | + if(empty($version) || PEAR::isError($version)){ | |
| 114 | + $version = file_get_contents(KT_DIR . 'docs/VERSION.txt'); | |
| 115 | + } | |
| 116 | + // remove newline that is in the version file | |
| 117 | + $version = str_replace("\n", '', $version); | |
| 118 | + return $version; | |
| 119 | +} | |
| 120 | + | |
| 121 | +// Get the edition of KT | |
| 122 | +function getKTEdition() | |
| 123 | +{ | |
| 124 | + $edition = 'Community'; | |
| 125 | + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { | |
| 126 | + $path = KTPluginUtil::getPluginPath('ktdms.wintools'); | |
| 127 | + require_once($path . 'baobabkeyutil.inc.php'); | |
| 128 | + $edition = BaobabKeyUtil::getName(); | |
| 129 | + | |
| 130 | + // Remove the brackets around the name | |
| 131 | + $edition = substr($edition, 1); | |
| 132 | + $edition = substr($edition, 0, strlen($edition)-1); | |
| 133 | + } | |
| 134 | + return $edition; | |
| 135 | +} | |
| 136 | + | |
| 137 | + | |
| 138 | +// Get OS info - platform, version, linux flavour | |
| 139 | +function getOSInfo() | |
| 140 | +{ | |
| 141 | + $server = php_uname(); | |
| 142 | + | |
| 143 | + if(strpos($server, 'Darwin') !== false){ | |
| 144 | + $os = 'Mac OS X'; | |
| 145 | + }else if(strpos($server, 'Win') !== false){ | |
| 146 | + $os = 'Windows'; | |
| 147 | + }else { | |
| 148 | + $os = 'Linux'; | |
| 149 | + } | |
| 150 | + | |
| 151 | + return $os; | |
| 152 | +} | |
| 153 | + | |
| 154 | +function sendForm($data) | |
| 155 | +{ | |
| 156 | + $url = 'http://ktnetwork.knowledgetree.com/call_home.php'; | |
| 157 | + //$url = 'http://10.33.20.250/knowledgetree/call_home.php'; | |
| 158 | + $data = http_build_query($data); | |
| 159 | + | |
| 160 | + $ch = curl_init($url); | |
| 161 | + curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); | |
| 162 | + curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false); | |
| 163 | + curl_setopt($ch, CURLOPT_POST, true); | |
| 164 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); | |
| 165 | + curl_exec($ch); | |
| 166 | + curl_close($ch); | |
| 167 | +} | |
| 168 | + | |
| 169 | +$post_str = getGuid() .'|'. getUserCnt() .'|'. getDocCnt() .'|'. getKTVersion() .'|'. getKTEdition() .'|'. getOSInfo(); | |
| 170 | +$data['system_info'] = $post_str; | |
| 171 | + | |
| 172 | +sendForm($data); | |
| 173 | + | |
| 174 | +$default->log->debug('System information collection script finishing.'); | |
| 175 | +exit(0); | |
| 176 | +?> | ... | ... |
setup/migrate/ini.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id:$ | |
| 4 | - * | |
| 5 | - * KnowledgeTree Community Edition | |
| 6 | - * Document Management Made Simple | |
| 7 | - * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 8 | - * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | - * | |
| 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 | |
| 12 | - * Free Software Foundation. | |
| 13 | - * | |
| 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 | |
| 16 | - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | - * details. | |
| 18 | - * | |
| 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/>. | |
| 21 | - * | |
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | - * California 94120-7775, or email info@knowledgetree.com. | |
| 24 | - * | |
| 25 | - * The interactive user interfaces in modified source and object code versions | |
| 26 | - * of this program must display Appropriate Legal Notices, as required under | |
| 27 | - * Section 5 of the GNU General Public License version 3. | |
| 28 | - * | |
| 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 | |
| 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 | |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | - * copyright notice. | |
| 35 | - * Contributor( s): ______________________________________ | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | -class Ini { | |
| 40 | - | |
| 41 | - private $cleanArray = array(); | |
| 42 | - private $iniFile = ''; | |
| 43 | - private $lineNum = 0; | |
| 44 | - private $exists = ''; | |
| 45 | - | |
| 46 | - function Ini($iniFile = '../../config.ini') { | |
| 47 | - $this->iniFile = $iniFile; | |
| 48 | - $this->backupIni($iniFile); | |
| 49 | - $this->read($iniFile); | |
| 50 | - } | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Create a backup with the date as an extension in the same location as the original config.ini | |
| 54 | - * | |
| 55 | - * @param string $iniFile | |
| 56 | - * @return boolean | |
| 57 | - */ | |
| 58 | - function backupIni($iniFile) | |
| 59 | - { | |
| 60 | - $content = file_get_contents($iniFile); | |
| 61 | - if ($content === false) | |
| 62 | - { | |
| 63 | - return false; | |
| 64 | - } | |
| 65 | - $date = date('YmdHis'); | |
| 66 | - | |
| 67 | - $backupFile = $iniFile . '.' .$date; | |
| 68 | - if (is_writeable($backupFile)) { | |
| 69 | - file_put_contents($backupFile, $content); | |
| 70 | - } | |
| 71 | - } | |
| 72 | - | |
| 73 | - function read($iniFile) { | |
| 74 | - | |
| 75 | - $iniArray = file($iniFile); | |
| 76 | - $section = ''; | |
| 77 | - foreach($iniArray as $iniLine) { | |
| 78 | - $this->lineNum++; | |
| 79 | - $iniLine = trim($iniLine); | |
| 80 | - $firstChar = substr($iniLine, 0, 1); | |
| 81 | - if($firstChar == ';') { | |
| 82 | - if($section == ''){ | |
| 83 | - $this->cleanArray['_comment_'.$this->lineNum]=$iniLine; | |
| 84 | - }else { | |
| 85 | - $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine; | |
| 86 | - } | |
| 87 | - continue; | |
| 88 | - } | |
| 89 | - if($iniLine == '') { | |
| 90 | - if($section == ''){ | |
| 91 | - $this->cleanArray['_blankline_'.$this->lineNum]=''; | |
| 92 | - }else { | |
| 93 | - $this->cleanArray[$section]['_blankline_'.$this->lineNum]=''; | |
| 94 | - } | |
| 95 | - continue; | |
| 96 | - } | |
| 97 | - | |
| 98 | - if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') { | |
| 99 | - $section = substr($iniLine, 1, -1); | |
| 100 | - $this->sections[] = $section; | |
| 101 | - } else { | |
| 102 | - $equalsPos = strpos($iniLine, '='); | |
| 103 | - if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) { | |
| 104 | - $key = trim(substr($iniLine, 0, $equalsPos)); | |
| 105 | - $value = trim(substr($iniLine, $equalsPos+1)); | |
| 106 | - if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { | |
| 107 | - $value = substr($value, 1, -1); | |
| 108 | - } | |
| 109 | - $this->cleanArray[$section][$key] = stripcslashes($value); | |
| 110 | - } else { | |
| 111 | - $this->cleanArray[$section][trim($iniLine)]=''; | |
| 112 | - } | |
| 113 | - } | |
| 114 | - } | |
| 115 | - return $this->cleanArray; | |
| 116 | - } | |
| 117 | - | |
| 118 | - function write($iniFile = "") { | |
| 119 | - | |
| 120 | - if(empty($iniFile)) { | |
| 121 | - $iniFile = $this->iniFile; | |
| 122 | - } | |
| 123 | - if (!is_writeable($iniFile)) { | |
| 124 | - return; | |
| 125 | - } | |
| 126 | - | |
| 127 | - $fileHandle = fopen($iniFile, 'wb'); | |
| 128 | - foreach ($this->cleanArray as $section => $items) { | |
| 129 | - if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { | |
| 130 | - fwrite ($fileHandle, "\r\n"); | |
| 131 | - continue; | |
| 132 | - } | |
| 133 | - if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { | |
| 134 | - fwrite ($fileHandle, "$items\r\n"); | |
| 135 | - continue; | |
| 136 | - } | |
| 137 | - fwrite ($fileHandle, "[".$section."]\r\n"); | |
| 138 | - foreach ($items as $key => $value) { | |
| 139 | - if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { | |
| 140 | - fwrite ($fileHandle, "\r\n"); | |
| 141 | - continue; | |
| 142 | - } | |
| 143 | - if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { | |
| 144 | - fwrite ($fileHandle, "$value\r\n"); | |
| 145 | - continue; | |
| 146 | - } | |
| 147 | - | |
| 148 | - $value = addcslashes($value,''); | |
| 149 | - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); | |
| 150 | - fwrite ($fileHandle, $key.' = '.$value."\r\n"); | |
| 151 | - } | |
| 152 | - } | |
| 153 | - fclose($fileHandle); | |
| 154 | - } | |
| 155 | - | |
| 156 | - function itemExists($checkSection, $checkItem) { | |
| 157 | - | |
| 158 | - $this->exists = ''; | |
| 159 | - foreach($this->cleanArray as $section => $items) { | |
| 160 | - if($section == $checkSection) { | |
| 161 | - $this->exists = 'section'; | |
| 162 | - foreach ($items as $key => $value) { | |
| 163 | - if($key == $checkItem) { | |
| 164 | - return true; | |
| 165 | - } | |
| 166 | - } | |
| 167 | - } | |
| 168 | - } | |
| 169 | - return false; | |
| 170 | - } | |
| 171 | - | |
| 172 | - function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { | |
| 173 | - | |
| 174 | - if($this->itemExists($addSection, $addItem)) { | |
| 175 | - $this->delItem($addSection, $addItem); | |
| 176 | - } | |
| 177 | - | |
| 178 | - if($this->exists != 'section') { | |
| 179 | - $this->cleanArray['_blankline_'.$this->lineNum++]=''; | |
| 180 | - if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment; | |
| 181 | - } | |
| 182 | - if(!empty($itemComment)) { | |
| 183 | - $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment; | |
| 184 | - } | |
| 185 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | |
| 186 | - return true; | |
| 187 | - } | |
| 188 | - | |
| 189 | - function updateItem($addSection, $addItem, $value) { | |
| 190 | - | |
| 191 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | |
| 192 | - return true; | |
| 193 | - } | |
| 194 | - | |
| 195 | - function delItem($delSection, $delItem) { | |
| 196 | - | |
| 197 | - if(!$this->itemExists($delSection, $delItem)) return false; | |
| 198 | - | |
| 199 | - unset($this->cleanArray[$delSection][$delItem]); | |
| 200 | - return true; | |
| 201 | - } | |
| 202 | - | |
| 203 | - function delSection($delSection) { | |
| 204 | - | |
| 205 | - unset($this->cleanArray[$delSection]); | |
| 206 | - return true; | |
| 207 | - } | |
| 208 | - | |
| 209 | - // Return file line by line | |
| 210 | - public function getFileByLine() { | |
| 211 | - $data = $this->read($this->iniFile); | |
| 212 | - return $data['']; | |
| 213 | - } | |
| 214 | - | |
| 215 | - public function getSection($section) { | |
| 216 | - if (isset($this->cleanArray[$section])) { | |
| 217 | - return $this->cleanArray[$section]; | |
| 218 | - } | |
| 219 | - | |
| 220 | - return false; | |
| 221 | - } | |
| 222 | -} | |
| 223 | -?> |
setup/migrate/migrateUtil.php
| ... | ... | @@ -142,6 +142,11 @@ class MigrateUtil { |
| 142 | 142 | return new $serviceName(); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | + public function loadInstallIni($path) { | |
| 146 | + require_once("../wizard/ini.php"); | |
| 147 | + return new Ini($path); | |
| 148 | + } | |
| 149 | + | |
| 145 | 150 | public function redirect($url, $exit = true, $rfc2616 = false) |
| 146 | 151 | { |
| 147 | 152 | return $this->bootstrap->redirect($url, $exit = true, $rfc2616 = false); | ... | ... |
setup/migrate/migrater.php
| ... | ... | @@ -510,6 +510,9 @@ class Migrater { |
| 510 | 510 | } elseif (isset($_POST['BInstall'])) { |
| 511 | 511 | $this->migraterAction = 'binstall'; |
| 512 | 512 | $this->response = 'binstall'; |
| 513 | +// } elseif (isset($_POST['Backup'])) { | |
| 514 | +// $this->migraterAction = 'backup'; | |
| 515 | +// $this->response = 'backup'; | |
| 513 | 516 | } else { |
| 514 | 517 | $this->response = ''; |
| 515 | 518 | $this->migraterAction = ''; |
| ... | ... | @@ -545,8 +548,8 @@ class Migrater { |
| 545 | 548 | } |
| 546 | 549 | break; |
| 547 | 550 | case 'previous': |
| 548 | - $this->_backward(); // Load previous page | |
| 549 | - break; | |
| 551 | + $this->_backward(); // Load previous page | |
| 552 | + break; | |
| 550 | 553 | case 'install': |
| 551 | 554 | $iutil = new MigrateUtil(); |
| 552 | 555 | $iutil->redirect('../wizard/index.php?step_name=installtype'); |
| ... | ... | @@ -555,6 +558,11 @@ class Migrater { |
| 555 | 558 | $iutil = new MigrateUtil(); |
| 556 | 559 | $iutil->redirect('../wizard/index.php?step_name=dependencies'); |
| 557 | 560 | break; |
| 561 | +// case 'backup': | |
| 562 | +// $iutil = new MigrateUtil(); | |
| 563 | +// $iutil->redirect('../upgrade/index.php?step_name=backup'); | |
| 564 | +// $iutil->redirect("..".DS."upgrade".DS."index.php?step_name=backup"); | |
| 565 | +// break; | |
| 558 | 566 | default: |
| 559 | 567 | // TODO : handle silent |
| 560 | 568 | $this->_landing(); | ... | ... |
setup/migrate/path.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Migrater Paths. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 9 | -* | |
| 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 | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 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 | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 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/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 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 | |
| 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 | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Migrater | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | - // Define installer environment | |
| 43 | - define('DEBUG', 0); | |
| 44 | - define('AJAX', 0); | |
| 45 | - // Define migrater environment | |
| 46 | - if (substr(php_uname(), 0, 7) == "Windows"){ | |
| 47 | - define('WINDOWS_OS', true); | |
| 48 | - define('UNIX_OS', false); | |
| 49 | - define('OS', 'windows'); | |
| 50 | - } else { | |
| 51 | - define('WINDOWS_OS', false); | |
| 52 | - define('UNIX_OS', true); | |
| 53 | - define('OS', 'unix'); | |
| 54 | - } | |
| 55 | - if(WINDOWS_OS) { | |
| 56 | - define('DS', '\\'); | |
| 57 | - } else { | |
| 58 | - define('DS', '/'); | |
| 59 | - } | |
| 60 | - // Define environment root | |
| 61 | - $wizard = realpath(dirname(__FILE__)); | |
| 62 | - $xdir = explode(DS, $wizard); | |
| 63 | - array_pop($xdir); | |
| 64 | - array_pop($xdir); | |
| 65 | - $sys = ''; | |
| 66 | - foreach ($xdir as $k=>$v) { | |
| 67 | - $sys .= $v.DS; | |
| 68 | - } | |
| 69 | - // Define paths to wizard | |
| 70 | - define('MIGRATE_DIR', $wizard.DS); | |
| 71 | - define('WIZARD_LIB', MIGRATE_DIR."lib".DS); | |
| 72 | - define('SERVICE_LIB', WIZARD_LIB."services".DS); | |
| 73 | - define('SQL_DIR', MIGRATE_DIR."sql".DS); | |
| 74 | - define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS); | |
| 75 | - define('CONF_DIR', MIGRATE_DIR."config".DS); | |
| 76 | - define('RES_DIR', MIGRATE_DIR."resources".DS); | |
| 77 | - define('STEP_DIR', MIGRATE_DIR."steps".DS); | |
| 78 | - define('TEMP_DIR', MIGRATE_DIR."templates".DS); | |
| 79 | - define('SHELL_DIR', MIGRATE_DIR."shells".DS); | |
| 80 | - define('OUTPUT_DIR', MIGRATE_DIR."output".DS); | |
| 81 | - // Define paths to system webroot | |
| 82 | - define('SYSTEM_DIR', $sys); | |
| 83 | - define('SYS_VAR_DIR', SYSTEM_DIR."var".DS); | |
| 84 | - define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); | |
| 85 | - define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS); | |
| 86 | - define('SYS_OUT_DIR', SYS_VAR_DIR); | |
| 87 | - define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS); | |
| 88 | - // Define paths to system | |
| 89 | - array_pop($xdir); | |
| 90 | - $asys = ''; | |
| 91 | - foreach ($xdir as $k=>$v) { | |
| 92 | - $asys .= $v.DS; | |
| 93 | - } | |
| 94 | - define('SYSTEM_ROOT', $asys); | |
| 95 | - // Migrate Type | |
| 96 | - preg_match('/Zend/', $sys, $matches); // TODO: Dirty | |
| 97 | - if($matches) { | |
| 98 | - $sysdir = explode(DS, $sys); | |
| 99 | - array_pop($sysdir); | |
| 100 | - array_pop($sysdir); | |
| 101 | - array_pop($sysdir); | |
| 102 | - array_pop($sysdir); | |
| 103 | - $zendsys = ''; | |
| 104 | - foreach ($sysdir as $k=>$v) { | |
| 105 | - $zendsys .= $v.DS; | |
| 106 | - } | |
| 107 | - define('INSTALL_TYPE', 'Zend'); | |
| 108 | - define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS); | |
| 109 | - } else { | |
| 110 | - $modules = get_loaded_extensions(); | |
| 111 | - // TODO: Dirty | |
| 112 | - if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) { | |
| 113 | - define('INSTALL_TYPE', 'Zend'); | |
| 114 | - define('PHP_DIR', ''); | |
| 115 | - } else { | |
| 116 | - define('INSTALL_TYPE', ''); | |
| 117 | - define('PHP_DIR', ''); | |
| 118 | - } | |
| 119 | - } | |
| 120 | - // Other | |
| 121 | - date_default_timezone_set('Africa/Johannesburg'); | |
| 122 | - if(WINDOWS_OS) { // Mysql bin [Windows] | |
| 123 | - $serverPaths = explode(';',$_SERVER['PATH']); | |
| 124 | - foreach ($serverPaths as $apath) { | |
| 125 | - preg_match('/mysql/i', $apath, $matches); | |
| 126 | - if($matches) { | |
| 127 | - define('MYSQL_BIN', $apath.DS); | |
| 128 | - break; | |
| 129 | - } | |
| 130 | - } | |
| 131 | - } else { | |
| 132 | - define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line | |
| 133 | - } | |
| 134 | - | |
| 135 | -?> |
setup/migrate/session.php
setup/migrate/steps/migrateComplete.php
| ... | ... | @@ -82,8 +82,9 @@ class migrateComplete extends Step { |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | private function checkSqlDump() { |
| 85 | - $tmpFolder = "/tmp/knowledgtree"; | |
| 86 | - $sqlFile = $tmpFolder."dms.sql"; | |
| 85 | + $database = $this->getDataFromSession("database"); // Get installation directory | |
| 86 | + // TODO | |
| 87 | + $sqlFile = $_SESSION['migrate']['database']['dumpLocation']; | |
| 87 | 88 | if(file_exists($sqlFile)) { |
| 88 | 89 | $this->temp_variables['sql']['class'] = "tick"; |
| 89 | 90 | $this->temp_variables['sql']['name'] = "dms.sql"; | ... | ... |
setup/migrate/steps/migrateDatabase.php
| ... | ... | @@ -52,14 +52,13 @@ class migrateDatabase extends Step |
| 52 | 52 | public $_dbhandler = null; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Reference to Database object | |
| 55 | + * Reference to Utility object | |
| 56 | 56 | * |
| 57 | 57 | * @author KnowledgeTree Team |
| 58 | 58 | * @access public |
| 59 | 59 | * @var object |
| 60 | 60 | */ |
| 61 | - public $_util = null; | |
| 62 | - | |
| 61 | + public $util = null; | |
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * List of errors encountered |
| ... | ... | @@ -95,7 +94,7 @@ class migrateDatabase extends Step |
| 95 | 94 | * @access public |
| 96 | 95 | * @var array |
| 97 | 96 | */ |
| 98 | - protected $silent = true; | |
| 97 | + protected $silent = false; | |
| 99 | 98 | |
| 100 | 99 | /** |
| 101 | 100 | * List of errors used in template |
| ... | ... | @@ -105,7 +104,7 @@ class migrateDatabase extends Step |
| 105 | 104 | * @var array |
| 106 | 105 | */ |
| 107 | 106 | public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); |
| 108 | - | |
| 107 | + private $sqlDumpFile = ''; | |
| 109 | 108 | /** |
| 110 | 109 | * Constructs database object |
| 111 | 110 | * |
| ... | ... | @@ -137,6 +136,7 @@ class migrateDatabase extends Step |
| 137 | 136 | } |
| 138 | 137 | if($this->next()) { |
| 139 | 138 | if($this->exportDatabase()) { |
| 139 | + $this->storeSilent(); | |
| 140 | 140 | return 'next'; |
| 141 | 141 | } |
| 142 | 142 | } else if($this->previous()) { |
| ... | ... | @@ -147,26 +147,78 @@ class migrateDatabase extends Step |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public function exportDatabase() { |
| 150 | - if(WINDOWS_OS) { | |
| 151 | - $tmpFolder = "../"; | |
| 152 | - } else { | |
| 153 | - $tmpFolder = "/tmp/knowledgtree"; | |
| 150 | + if($this->doTest()) { | |
| 151 | + $installation = $this->getDataFromSession("installation"); // Get installation directory | |
| 152 | + $dbSettings = $installation['dbSettings']; | |
| 153 | + $location = $installation['location']; | |
| 154 | + $uname = $this->temp_variables['duname']; | |
| 155 | + $pwrd = $this->temp_variables['dpassword']; | |
| 156 | + $tmpFolder = $this->resolveTempDir(); | |
| 157 | + if(WINDOWS_OS) { | |
| 158 | +// $tmpFolder = "tmp/"; | |
| 159 | + $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump | |
| 160 | + } else { | |
| 161 | +// $tmpFolder = "/tmp/"; | |
| 162 | + $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump | |
| 163 | + } | |
| 164 | + $sqlFile = $tmpFolder."/dms_migrate.sql"; | |
| 165 | + $dbAdminUser = $dbSettings['dbAdminUser']; | |
| 166 | + $dbAdminPass = $dbSettings['dbAdminPass']; | |
| 167 | + $dbName = $dbSettings['dbName']; | |
| 168 | + $cmd = "$exe -u{$dbAdminUser} -p{$dbAdminPass} $dbName > ".$sqlFile; | |
| 169 | +// echo $cmd; | |
| 170 | +// die; | |
| 171 | + $response = $this->util->pexec($cmd); | |
| 172 | + if(file_exists($sqlFile)) { | |
| 173 | + $fileContents = file_get_contents($sqlFile); | |
| 174 | + if(!empty($fileContents)) { | |
| 175 | + $this->sqlDumpFile = realpath($sqlFile); // Store location of dump | |
| 176 | + return true; | |
| 177 | + } | |
| 178 | + } | |
| 154 | 179 | } |
| 155 | - @mkdir($tmpFolder); | |
| 180 | + | |
| 181 | + return false; | |
| 182 | + } | |
| 183 | + | |
| 184 | + // TODO | |
| 185 | +function resolveTempDir() | |
| 186 | +{ | |
| 187 | + | |
| 188 | + if (!WINDOWS_OS) | |
| 189 | + { | |
| 190 | + $dir='/tmp/kt-db-backup'; | |
| 191 | + } | |
| 192 | + else | |
| 193 | + { | |
| 194 | + $dir='c:/kt-db-backup'; | |
| 195 | + } | |
| 196 | +// $oKTConfig =& KTConfig::getSingleton(); | |
| 197 | +// $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 198 | + | |
| 199 | + if (!is_dir($dir)) | |
| 200 | + { | |
| 201 | + mkdir($dir); | |
| 202 | + } | |
| 203 | + return $dir; | |
| 204 | +} | |
| 205 | + | |
| 206 | + public function doTest() { | |
| 207 | + return true; | |
| 156 | 208 | $installation = $this->getDataFromSession("installation"); // Get installation directory |
| 157 | 209 | $dbSettings = $installation['dbSettings']; |
| 210 | + $location = $installation['location']; | |
| 158 | 211 | $uname = $this->temp_variables['duname']; |
| 159 | 212 | $pwrd = $this->temp_variables['dpassword']; |
| 160 | - $sqlFile = $tmpFolder."dms.sql"; | |
| 161 | - $dbName = $dbSettings['dbName']; | |
| 162 | - $cmd = "mysqldump -u{$uname} -p{$pwrd} {$dbName} > ".$sqlFile; | |
| 163 | - echo $cmd; | |
| 164 | - $response = $this->util->pexec($cmd); | |
| 165 | - if(file_exists($sqlFile)) { | |
| 166 | - return true; | |
| 167 | - } else { | |
| 168 | - return false; | |
| 169 | - } | |
| 213 | + //dmsadmin //clean1 // 3316 // TODO | |
| 214 | + $dbhandler = $this->util->loadInstallDBUtil(); | |
| 215 | + $dbhandler->load("localhost:3316",$uname, $pwrd, "dms"); | |
| 216 | + if (!$dbhandler->getDatabaseLink()) { | |
| 217 | + $this->error['con'] = "Could not connect to the database, please check username and password"; | |
| 218 | + return false; | |
| 219 | + } | |
| 220 | + | |
| 221 | + return true; | |
| 170 | 222 | } |
| 171 | 223 | |
| 172 | 224 | /** |
| ... | ... | @@ -180,6 +232,7 @@ class migrateDatabase extends Step |
| 180 | 232 | private function setDetails() { |
| 181 | 233 | $this->temp_variables['duname'] = $this->getPostSafe('duname'); |
| 182 | 234 | $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword'); |
| 235 | + $this->temp_variables['dumpLocation'] = $this->getPostSafe('dumpLocation'); | |
| 183 | 236 | // create lock file to indicate migration mode |
| 184 | 237 | $this->createMigrateFile(); |
| 185 | 238 | } |
| ... | ... | @@ -245,5 +298,12 @@ class migrateDatabase extends Step |
| 245 | 298 | $this->error[$e] = false; |
| 246 | 299 | } |
| 247 | 300 | } |
| 301 | + | |
| 302 | + private function storeSilent() { | |
| 303 | + // TODO | |
| 304 | + $_SESSION['migrate']['database']['dumpLocation'] = $this->sqlDumpFile; | |
| 305 | + $this->temp_variables['dumpLocation'] = $this->sqlDumpFile; | |
| 306 | + } | |
| 307 | + | |
| 248 | 308 | } |
| 249 | 309 | ?> |
| 250 | 310 | \ No newline at end of file | ... | ... |
setup/migrate/steps/migrateInstallation.php
| ... | ... | @@ -78,15 +78,37 @@ class migrateInstallation extends step |
| 78 | 78 | */ |
| 79 | 79 | protected $silent = false; |
| 80 | 80 | |
| 81 | + /** | |
| 82 | + * Reference to Utility object | |
| 83 | + * | |
| 84 | + * @author KnowledgeTree Team | |
| 85 | + * @access public | |
| 86 | + * @var object | |
| 87 | + */ | |
| 88 | + public $util = null; | |
| 89 | + | |
| 81 | 90 | private $location = ''; |
| 82 | 91 | private $dbSettings = array(); |
| 83 | 92 | private $ktSettings = array(); |
| 84 | 93 | private $urlPaths = array(); |
| 85 | 94 | private $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path"); |
| 86 | 95 | private $knownUnixLocations = array("/opt/ktdms","/var/www/ktdms"); |
| 87 | - | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Installation Settings | |
| 99 | + * | |
| 100 | + * @author KnowledgeTree Team | |
| 101 | + * @access public | |
| 102 | + * @var object | |
| 103 | + */ | |
| 104 | + private $settings = array(); | |
| 105 | + private $supportedVersion = '3.6.1'; | |
| 106 | + private $foundVersion = 'Unknown'; | |
| 107 | + private $versionError = false; | |
| 108 | + | |
| 88 | 109 | function __construct() { |
| 89 | 110 | $this->temp_variables = array("step_name"=>"installation", "silent"=>$this->silent); |
| 111 | + $this->util = new MigrateUtil(); | |
| 90 | 112 | } |
| 91 | 113 | |
| 92 | 114 | public function doStep() { |
| ... | ... | @@ -120,7 +142,7 @@ class migrateInstallation extends step |
| 120 | 142 | $this->location = $loc; |
| 121 | 143 | } |
| 122 | 144 | } else { |
| 123 | - foreach ($this->knownUnixLocations as $loc) { | |
| 145 | + foreach ($this->knownUnixLocations as $loc=>$configPath) { | |
| 124 | 146 | if(file_exists($configPath)) |
| 125 | 147 | $this->location = $loc; |
| 126 | 148 | } |
| ... | ... | @@ -128,6 +150,44 @@ class migrateInstallation extends step |
| 128 | 150 | } |
| 129 | 151 | |
| 130 | 152 | public function doRun() { |
| 153 | + if(!$this->readConfig()) { | |
| 154 | + $this->storeSilent(); | |
| 155 | + return false; | |
| 156 | + } else { | |
| 157 | + if($this->readVersion()) { | |
| 158 | + $this->checkVersion(); | |
| 159 | + } | |
| 160 | + $this->storeSilent(); | |
| 161 | + return true; | |
| 162 | + } | |
| 163 | + | |
| 164 | + } | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + public function checkVersion() { | |
| 170 | + if($this->foundVersion <= $this->supportedVersion) { | |
| 171 | + $this->versionError = true; | |
| 172 | + $this->error[] = "KT installation needs to be 3.6.1 or higher"; | |
| 173 | + } else { | |
| 174 | + return true; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + public function readVersion() { | |
| 179 | + $verFile = $this->location."/knowledgeTree/docs/VERSION.txt"; | |
| 180 | + if(file_exists($verFile)) { | |
| 181 | + $this->foundVersion = file_get_contents($verFile); | |
| 182 | + return true; | |
| 183 | + } else { | |
| 184 | + $this->error[] = "KT installation version not found"; | |
| 185 | + } | |
| 186 | + | |
| 187 | + return false; | |
| 188 | + } | |
| 189 | + | |
| 190 | + public function readConfig() { | |
| 131 | 191 | $ktInstallPath = isset($_POST['location']) ? $_POST['location']: ''; |
| 132 | 192 | if($ktInstallPath != '') { |
| 133 | 193 | $this->location = $ktInstallPath; |
| ... | ... | @@ -136,7 +196,7 @@ class migrateInstallation extends step |
| 136 | 196 | if(file_exists($configPath)) { |
| 137 | 197 | $configFilePath = file_get_contents($configPath); |
| 138 | 198 | if(file_exists($configFilePath)) { // For 3.7 and after |
| 139 | - $this->readConfig($configFilePath); | |
| 199 | + $this->loadConfig($configFilePath); | |
| 140 | 200 | $this->storeSilent(); |
| 141 | 201 | |
| 142 | 202 | return true; |
| ... | ... | @@ -144,7 +204,7 @@ class migrateInstallation extends step |
| 144 | 204 | $configFilePath = $ktInstallPath.DS."knowledgeTree".DS.$configFilePath; // For older than 3.6.2 |
| 145 | 205 | $configFilePath = trim($configFilePath); |
| 146 | 206 | if(file_exists($configFilePath)) { |
| 147 | - $this->readConfig($configFilePath); | |
| 207 | + $this->loadConfig($configFilePath); | |
| 148 | 208 | $this->storeSilent(); |
| 149 | 209 | |
| 150 | 210 | return true; |
| ... | ... | @@ -158,19 +218,18 @@ class migrateInstallation extends step |
| 158 | 218 | $this->error[] = "KT installation not found"; |
| 159 | 219 | } |
| 160 | 220 | } |
| 161 | - $this->storeSilent(); | |
| 162 | 221 | |
| 163 | 222 | return false; |
| 164 | 223 | } |
| 165 | 224 | |
| 166 | - private function readConfig($path) { | |
| 167 | - $ini = new Ini($path); | |
| 225 | + private function loadConfig($path) { | |
| 226 | + $ini = $this->util->loadInstallIni($path);//new Ini($path); | |
| 168 | 227 | $dbSettings = $ini->getSection('db'); |
| 169 | 228 | $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], |
| 170 | 229 | 'dbName'=> $dbSettings['dbName'], |
| 171 | 230 | 'dbUser'=> $dbSettings['dbUser'], |
| 172 | 231 | 'dbPass'=> $dbSettings['dbPass'], |
| 173 | - 'dbPort'=> $dbSettings['dbPort'], | |
| 232 | + 'dbPort'=> $dbSettings['dbPort'] == 'default' ? "3306":"", | |
| 174 | 233 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], |
| 175 | 234 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], |
| 176 | 235 | ); |
| ... | ... | @@ -197,7 +256,9 @@ class migrateInstallation extends step |
| 197 | 256 | private function setDetails() { |
| 198 | 257 | $inst = $this->getDataFromSession("installation"); |
| 199 | 258 | if ($inst) { |
| 200 | - $this->location = $inst['location']; | |
| 259 | + if(file_exists($this->location)) { | |
| 260 | + $this->location = $inst['location']; | |
| 261 | + } | |
| 201 | 262 | } |
| 202 | 263 | } |
| 203 | 264 | |
| ... | ... | @@ -210,9 +271,11 @@ class migrateInstallation extends step |
| 210 | 271 | } |
| 211 | 272 | |
| 212 | 273 | public function storeSilent() { |
| 274 | + if($this->location==1) { $this->location = '';} | |
| 213 | 275 | $this->temp_variables['location'] = $this->location; |
| 214 | - | |
| 215 | - } | |
| 216 | - | |
| 276 | + $this->temp_variables['foundVersion'] = $this->foundVersion; | |
| 277 | + $this->temp_variables['versionError'] = $this->versionError; | |
| 278 | + $this->temp_variables['settings'] = $this->settings; | |
| 279 | + } | |
| 217 | 280 | } |
| 218 | 281 | ?> |
| 219 | 282 | \ No newline at end of file | ... | ... |
setup/migrate/templates/database.tpl
| ... | ... | @@ -2,31 +2,40 @@ |
| 2 | 2 | <p class="title">Migrate Database</p> |
| 3 | 3 | <div id="database" class="step1" style="display:block;"> |
| 4 | 4 | <div class="description"> |
| 5 | - This step configures the connection to the database server and migrates the database. The details for an administrative <br/> | |
| 6 | - user on the database server are required in order to be able to configure and migrate the database. | |
| 5 | + This step configures the connection to the database server and migrates the database. | |
| 6 | +<!-- The details for an administrative <br/>--> | |
| 7 | +<!-- user on the database server are required in order to be able to configure and migrate the database.--> | |
| 7 | 8 | </div> |
| 8 | 9 | <div id="step_content_database" class="step"> |
| 10 | + <br/><br/> | |
| 11 | + <span class="error">!!NB!! You are advised to backup your database before proceeding. !!NB!!</span> | |
| 12 | +<!-- <span class="error"> <?php if($errors['con']) { echo $errors['con']."<br/><br/>"; } ?> </span> | |
| 13 | + | |
| 14 | + | |
| 15 | + <p class="empty_space"> | |
| 16 | + Database Details | |
| 17 | + </p> | |
| 9 | 18 | <table class="dbconf"> |
| 10 | 19 | <?php |
| 11 | - $input_size = '35'; | |
| 12 | - $align = 'left'; | |
| 20 | +// $input_size = '35'; | |
| 21 | +// $align = 'left'; | |
| 13 | 22 | ?> |
| 14 | - <!-- TODO: Different Databases--> | |
| 15 | 23 | <tr> |
| 16 | 24 | <td><label for='duname'>Enter Database Administrative username: </label></td> |
| 17 | - <td><input type='text' value="<?php echo $duname?>" id='duname' name='duname' size='<?php echo $input_size; ?>' style="float:left"/></td> | |
| 18 | - <td id="error" class="error"><?php if($errors['duname']) echo $errors['duname']; ?></td> | |
| 25 | + <td><input type='text' value="<?php //echo $duname?>" id='duname' name='duname' size='<?php //echo $input_size; ?>' style="float:left"/></td> | |
| 26 | + <td id="error" class="error"><?php //if($errors['duname']) echo $errors['duname']; ?></td> | |
| 19 | 27 | </tr> |
| 20 | 28 | <tr> |
| 21 | 29 | <td><label for='dpassword'>Enter the password for the Administrator: </label></td> |
| 22 | - <td><input type='password' value="<?php echo $dpassword?>" id='dpassword' name='dpassword' size='<?php echo $input_size; ?>' style="float:left"/></td> | |
| 23 | - <td id="error" class="error"><?php if($errors['dpassword']) echo $errors['dpassword']; ?></td> | |
| 30 | + <td><input type='password' value="<?php //echo $dpassword?>" id='dpassword' name='dpassword' size='<?php //echo $input_size; ?>' style="float:left"/></td> | |
| 31 | + <td id="error" class="error"><?php //if($errors['dpassword']) echo $errors['dpassword']; ?></td> | |
| 24 | 32 | </tr> |
| 25 | 33 | </table> |
| 26 | - </div> | |
| 34 | + </div>--> | |
| 27 | 35 | </div> |
| 28 | - <input type="button" name="Previous" value="previous" class="button_previous"/> | |
| 29 | - <input type="submit" name="Next" value="next" class="button_next"/> | |
| 36 | + <input type="submit" name="Previous" value="Previous" class="button_previous"/> | |
| 37 | + <input type="submit" name="Next" value="Next" class="button_next"/> | |
| 38 | +<!-- <input type="submit" name="Backup" value="Backup" class="button_next"/>--> | |
| 30 | 39 | </form> |
| 31 | 40 | <script type="text/javascript"> |
| 32 | 41 | $("#duname").focus(); | ... | ... |
setup/migrate/templates/installation.tpl
| ... | ... | @@ -25,13 +25,11 @@ |
| 25 | 25 | <a href="http://wiki.knowledgetree.com/Web_Based_Migrater#Current_Installation" target="_blank">Click here for help on overcoming installation detection issues</a> |
| 26 | 26 | <?php } ?> |
| 27 | 27 | <div id="step_content" class="step"> |
| 28 | - <br/> | |
| 29 | - <br/> | |
| 30 | 28 | <p class="empty_space"> |
| 31 | 29 | Please verify the location of your current installation. |
| 32 | 30 | </p> |
| 33 | 31 | |
| 34 | - <input id="location" name="location" type="text" style="width:430px; float:left" value="<?php echo $location; ?>"> | |
| 32 | + <input id="location" name="location" type="text" style="width:430px; float:left" value="<?php if($location) echo $location; ?>"> | |
| 35 | 33 | <br/><br/> |
| 36 | 34 | <?php |
| 37 | 35 | if($errors) { | ... | ... |
setup/migrate/templates/installation_confirm.tpl
| ... | ... | @@ -26,11 +26,26 @@ |
| 26 | 26 | <?php } ?> |
| 27 | 27 | <!--Content--> |
| 28 | 28 | <div id="step_content" class="step"> |
| 29 | - <br/> | |
| 30 | - <br/> | |
| 31 | 29 | <p class="empty_space"> |
| 32 | 30 | Please verify your current installation settings. |
| 33 | 31 | </p> |
| 32 | + <h3>Installation Settings</h3> | |
| 33 | + <table class="conf_paths"> | |
| 34 | + <tr> | |
| 35 | + <?php | |
| 36 | + if($versionError) { | |
| 37 | + $w = '26%'; | |
| 38 | + $x = '10%'; | |
| 39 | + } else { | |
| 40 | + $w = '22%'; | |
| 41 | + $x = '50%'; | |
| 42 | + } | |
| 43 | + ?> | |
| 44 | + <td width="<?php echo $w; ?>">KnowledgeTree Version: </td> | |
| 45 | + <td width="<?php echo $x; ?>"><?php echo $foundVersion; ?></td> | |
| 46 | + <?php if($versionError) { ?> <td class="error" width="50%"> KnowledgeTree installation needs to be 3.6.1 or higher </td> <?php } ?> | |
| 47 | + </tr> | |
| 48 | + </table> | |
| 34 | 49 | |
| 35 | 50 | <h3>Database Settings</h3> |
| 36 | 51 | <table class="conf_paths"> | ... | ... |
setup/upgrade.php
| ... | ... | @@ -35,1125 +35,5 @@ |
| 35 | 35 | * Contributor( s): ______________________________________ |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | - | |
| 39 | -$GLOBALS["checkup"] = true; | |
| 40 | -session_start(); | |
| 41 | -require_once('../config/dmsDefaults.php'); | |
| 42 | -require_once(KT_LIB_DIR . '/authentication/authenticationutil.inc.php'); | |
| 43 | -require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); | |
| 44 | -require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | |
| 45 | - | |
| 46 | -function generateUpgradeTable () { | |
| 47 | - global $default; | |
| 48 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | |
| 49 | - $lastVersion = DBUtil::getOneResultKey($query, 'value'); | |
| 50 | - $currentVersion = $default->systemVersion; | |
| 51 | - | |
| 52 | - $upgrades = describeUpgrade($lastVersion, $currentVersion); | |
| 53 | - | |
| 54 | - $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; | |
| 55 | - $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; | |
| 56 | - $i=0; | |
| 57 | - foreach ($upgrades as $upgrade) { | |
| 58 | - $color=((($i++)%2)==0)?'white':'lightgrey'; | |
| 59 | - $ret .= sprintf("<tr bgcolor='$color'><td>%s</td><td>%s</td><td>%s</td></tr>\n", | |
| 60 | - htmlspecialchars($upgrade->getDescriptor()), | |
| 61 | - htmlspecialchars($upgrade->getDescription()), | |
| 62 | - $upgrade->isAlreadyApplied() ? "Yes" : "No" | |
| 63 | - ); | |
| 64 | - } | |
| 65 | - $ret .= '</table>'; | |
| 66 | - return $ret; | |
| 67 | -} | |
| 68 | - | |
| 69 | -function showResult($res) { | |
| 70 | - if (PEAR::isError($res)) { | |
| 71 | - if (is_a($res, 'Upgrade_Already_Applied')) { | |
| 72 | - return '<span style="color: orange">Already applied</span>'; | |
| 73 | - } | |
| 74 | - return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString())); | |
| 75 | - } | |
| 76 | - if ($res === true) { | |
| 77 | - return '<span style="color: green">Success</span>'; | |
| 78 | - } | |
| 79 | - if ($res === false) { | |
| 80 | - return '<span style="color: red">Failure</span>'; | |
| 81 | - } | |
| 82 | - return $res; | |
| 83 | -} | |
| 84 | - | |
| 85 | -$GLOBALS['row'] = 1; | |
| 86 | - | |
| 87 | -function performAllUpgrades () { | |
| 88 | - global $default; | |
| 89 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | |
| 90 | - $lastVersion = DBUtil::getOneResultKey($query, 'value'); | |
| 91 | - $currentVersion = $default->systemVersion; | |
| 92 | - | |
| 93 | - $upgrades = describeUpgrade($lastVersion, $currentVersion); | |
| 94 | - | |
| 95 | - foreach ($upgrades as $upgrade) { | |
| 96 | - if (($GLOBALS['row'] % 2) == 1) { | |
| 97 | - $class = "odd"; | |
| 98 | - } else { | |
| 99 | - $class = "even"; | |
| 100 | - } | |
| 101 | - printf('<div class="row %s"><div class="foo">%s</div>' . "\n", $class, htmlspecialchars($upgrade->getDescription())); | |
| 102 | - $GLOBALS['row']++; | |
| 103 | - ob_flush(); | |
| 104 | - flush(); | |
| 105 | - $res = $upgrade->performUpgrade(); | |
| 106 | - printf('<div class="bar">%s</div>', showResult($res)); | |
| 107 | - print '<br style="clear: both">' . "\n"; | |
| 108 | - ob_flush(); | |
| 109 | - flush(); | |
| 110 | - print "</div>\n"; | |
| 111 | - if (PEAR::isError($res)) { | |
| 112 | - if (!is_a($res, 'Upgrade_Already_Applied')) { | |
| 113 | - break; | |
| 114 | - } else { | |
| 115 | - $res = true; | |
| 116 | - } | |
| 117 | - } | |
| 118 | - if ($res === false) { | |
| 119 | - $res = PEAR::raiseError("Upgrade returned false"); | |
| 120 | - break; | |
| 121 | - } | |
| 122 | - } | |
| 123 | - | |
| 124 | - return $res; | |
| 125 | -} | |
| 126 | - | |
| 127 | -function performPreUpgradeActions() { | |
| 128 | - | |
| 129 | - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. | |
| 130 | - // It should idealy work the same as the upgrades. | |
| 131 | - | |
| 132 | - global $default; | |
| 133 | - | |
| 134 | - // Lock the scheduler | |
| 135 | - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 136 | - touch($lockFile); | |
| 137 | - return true; | |
| 138 | - | |
| 139 | -} | |
| 140 | - | |
| 141 | -function performPostUpgradeActions() { | |
| 142 | - | |
| 143 | - // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. | |
| 144 | - // It should idealy work the same as the upgrades. | |
| 145 | - | |
| 146 | - global $default; | |
| 147 | - | |
| 148 | - // Ensure all plugins are re-registered. | |
| 149 | - $sql = "TRUNCATE plugin_helper"; | |
| 150 | - $res = DBUtil::runQuery($sql); | |
| 151 | - | |
| 152 | - // Clear out all caches and proxies - they need to be regenerated with the new code | |
| 153 | - $proxyDir = $default->proxyCacheDirectory; | |
| 154 | - KTUtil::deleteDirectory($proxyDir); | |
| 155 | - | |
| 156 | - $oKTCache = new KTCache(); | |
| 157 | - $oKTCache->deleteAllCaches(); | |
| 158 | - | |
| 159 | - // Clear the configuration cache, it'll regenerate on next load | |
| 160 | - $oKTConfig = new KTConfig(); | |
| 161 | - $oKTConfig->clearCache(); | |
| 162 | - | |
| 163 | - // Unlock the scheduler | |
| 164 | - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 165 | - if(file_exists($lockFile)){ | |
| 166 | - @unlink($lockFile); | |
| 167 | - } | |
| 168 | - | |
| 169 | - return true; | |
| 170 | - | |
| 171 | -} | |
| 172 | - | |
| 173 | -if (PEAR::isError($loggingSupport)) { | |
| 174 | - print '<p><font color="red">Logging support is not currently working. Check post-installation checkup.</font></p>'; | |
| 175 | - exit(1); | |
| 176 | -} | |
| 177 | - | |
| 178 | -if (PEAR::isError($dbSupport)) { | |
| 179 | - print '<p><font color="red">Database support is not currently working. Check post-installation checkup or refresh this page (F5) to try again.</font></p>'; | |
| 180 | - exit(1); | |
| 181 | -} | |
| 182 | - | |
| 183 | - | |
| 184 | - | |
| 185 | -?> | |
| 186 | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"> | |
| 187 | -<html> | |
| 188 | - <head> | |
| 189 | - <title><?php echo APP_NAME;?> Upgrade</title> | |
| 190 | - <style type="text/css"> | |
| 191 | -th { text-align: left; } | |
| 192 | -td { vertical-align: top; } | |
| 193 | -.foo { float: left; } | |
| 194 | -.bar { padding-left: 2em; float: right; } | |
| 195 | -.odd { background-color: #eeeeee; } | |
| 196 | -.even { background-color: #dddddd; } | |
| 197 | -.row { padding: 0.5em 1em; } | |
| 198 | - </style> | |
| 199 | - </head> | |
| 200 | - | |
| 201 | - <body> | |
| 202 | - <img src="<?php | |
| 203 | - if($oKTConfig->get('ui/mainLogo')){ | |
| 204 | - echo $oKTConfig->get('ui/mainLogo'); | |
| 205 | - }else{ | |
| 206 | - echo '../resources/graphics/ktlogo-topbar_base.png'; | |
| 207 | - }?>"/> | |
| 208 | - <p> | |
| 209 | - <img src="upgrade-title.jpg"/> | |
| 210 | - <table style="width:800; height:500"> | |
| 211 | -<tr><td> | |
| 212 | -<P> | |
| 213 | - <script type="text/javascript"> | |
| 214 | -function do_start(action) | |
| 215 | -{ | |
| 216 | - document.location='?go=' + action; | |
| 217 | -} | |
| 218 | -</script> | |
| 219 | -<?php | |
| 220 | - | |
| 221 | -$action = trim($_REQUEST["go"]); | |
| 222 | -switch ($action) | |
| 223 | -{ | |
| 224 | - case 'UpgradeConfirm': | |
| 225 | - case 'UpgradePreview': | |
| 226 | - UpgradePreview(); | |
| 227 | - break; | |
| 228 | - case 'Upgrade': | |
| 229 | - Upgrade(); | |
| 230 | - break; | |
| 231 | - case 'BackupConfirm': | |
| 232 | - backupConfirm(); | |
| 233 | - break; | |
| 234 | - case 'Backup': | |
| 235 | - backup(); | |
| 236 | - break; | |
| 237 | - case 'BackupDone': | |
| 238 | - backupDone(); | |
| 239 | - break; | |
| 240 | - case 'RestoreConfirm': | |
| 241 | - restoreConfirm(); | |
| 242 | - break; | |
| 243 | - case 'RestoreSelect': | |
| 244 | - restoreSelect(); | |
| 245 | - break; | |
| 246 | - case 'RestoreSelected': | |
| 247 | - restoreSelected(); | |
| 248 | - break; | |
| 249 | - case 'Restore': | |
| 250 | - restore(); | |
| 251 | - break; | |
| 252 | - case 'RestoreDone': | |
| 253 | - restoreDone(); | |
| 254 | - break; | |
| 255 | - case 'Login': | |
| 256 | - login(); | |
| 257 | - break; | |
| 258 | - case 'LoginProcess': | |
| 259 | - loginProcess(); | |
| 260 | - break; | |
| 261 | - default: | |
| 262 | - if (!isset($_SESSION['setup_user'])) | |
| 263 | - login(); | |
| 264 | - else | |
| 265 | - welcome(); | |
| 266 | - break; | |
| 267 | -} | |
| 268 | - | |
| 269 | -function login() | |
| 270 | -{ | |
| 271 | -?> | |
| 272 | -<P> | |
| 273 | -The database upgrade wizard completes the upgrade process on an existing <?php echo APP_NAME;?> installation. It applies | |
| 274 | -any upgrades to the database that may be required. | |
| 275 | -<P> | |
| 276 | -Only administrator users may access the upgrade wizard. | |
| 277 | -<P> | |
| 278 | - | |
| 279 | -<form method=post action="?go=LoginProcess"> | |
| 280 | -<table> | |
| 281 | -<tr><td>Username<td><input name=username> | |
| 282 | -<tr><td>Password<td><input name=password type="password"> | |
| 283 | -<tr><td colspan=2 align=center><input type=submit value="login"> | |
| 284 | -</table> | |
| 285 | -</form> | |
| 286 | -<?php | |
| 287 | -} | |
| 288 | - | |
| 289 | -function loginProcess() | |
| 290 | -{ | |
| 291 | - $username=$_REQUEST['username']; | |
| 292 | - $password=$_REQUEST['password']; | |
| 293 | - | |
| 294 | - $authenticated = checkPassword($username, $password); | |
| 295 | - | |
| 296 | - if (!$authenticated) | |
| 297 | - { | |
| 298 | - session_unset(); | |
| 299 | - loginFailed(_kt('Could not authenticate administrative user')); | |
| 300 | - return; | |
| 301 | - } | |
| 302 | - | |
| 303 | - $_SESSION['setup_user'] = $username; | |
| 304 | - | |
| 305 | - welcome(); | |
| 306 | -} | |
| 307 | - | |
| 308 | -function checkPassword($username, $password) { | |
| 309 | - global $default; | |
| 310 | - | |
| 311 | - $sTable = KTUtil::getTableName('users'); | |
| 312 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; | |
| 313 | - $aParams = array($username, md5($password)); | |
| 314 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | |
| 315 | - if (PEAR::isError($res)) { return false; } | |
| 316 | - else { | |
| 317 | - $sTable = KTUtil::getTableName('users_groups_link'); | |
| 318 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1"; | |
| 319 | - $aParams = array($res); | |
| 320 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | |
| 321 | - if (PEAR::isError($res)) { return false; } | |
| 322 | - else { | |
| 323 | - return ($res == 1); | |
| 324 | - } | |
| 325 | - } | |
| 326 | -} | |
| 327 | - | |
| 328 | -function loginFailed($message) | |
| 329 | -{ | |
| 330 | - print "<font color=red>$message</font>"; | |
| 331 | - login(); | |
| 332 | -} | |
| 333 | - | |
| 334 | -function resolveMysqlDir() | |
| 335 | -{ | |
| 336 | - // possibly detect existing installations: | |
| 337 | - | |
| 338 | - if (OS_UNIX) | |
| 339 | - { | |
| 340 | - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); | |
| 341 | - $mysqlname ='mysql'; | |
| 342 | - } | |
| 343 | - else | |
| 344 | - { | |
| 345 | - $dirs = explode(';', $_SERVER['PATH']); | |
| 346 | - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; | |
| 347 | - $dirs[] = 'c:/program files/ktdms/mysql/bin'; | |
| 348 | - $mysqlname ='mysql.exe'; | |
| 349 | - } | |
| 350 | - | |
| 351 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 352 | - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); | |
| 353 | - $dirs[] = $mysqldir; | |
| 354 | - | |
| 355 | - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) | |
| 356 | - { | |
| 357 | - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); | |
| 358 | - } | |
| 359 | - | |
| 360 | - foreach($dirs as $dir) | |
| 361 | - { | |
| 362 | - if (is_file($dir . '/' . $mysqlname)) | |
| 363 | - { | |
| 364 | - return $dir; | |
| 365 | - } | |
| 366 | - } | |
| 367 | - | |
| 368 | - return ''; | |
| 369 | -} | |
| 370 | - | |
| 371 | - | |
| 372 | -function create_backup_stmt($targetfile=null) | |
| 373 | -{ | |
| 374 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 375 | - | |
| 376 | - $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 377 | - $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 378 | - $dbHost = $oKTConfig->get('db/dbHost'); | |
| 379 | - $dbName = $oKTConfig->get('db/dbName'); | |
| 380 | - | |
| 381 | - $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 382 | - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); | |
| 383 | - if (empty($dbPort)) $dbPort='3306'; | |
| 384 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 385 | - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 386 | - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 387 | - | |
| 388 | - $date=date('Y-m-d-H-i-s'); | |
| 389 | - | |
| 390 | - $dir=resolveMysqlDir(); | |
| 391 | - | |
| 392 | - $info['dir']=$dir; | |
| 393 | - | |
| 394 | - $prefix=''; | |
| 395 | - if (OS_UNIX) | |
| 396 | - { | |
| 397 | - $prefix .= "./"; | |
| 398 | - } | |
| 399 | - | |
| 400 | - if (@stat($dbSocket) !== false) | |
| 401 | - { | |
| 402 | - $mechanism="--socket=\"$dbSocket\""; | |
| 403 | - } | |
| 404 | - else | |
| 405 | - { | |
| 406 | - $mechanism="--port=\"$dbPort\""; | |
| 407 | - } | |
| 408 | - | |
| 409 | - $tmpdir=resolveTempDir(); | |
| 410 | - | |
| 411 | - if (is_null($targetfile)) | |
| 412 | - { | |
| 413 | - $targetfile="$tmpdir/kt-backup-$date.sql"; | |
| 414 | - } | |
| 415 | - | |
| 416 | - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; | |
| 417 | - $info['display']=$stmt; | |
| 418 | - $info['target']=$targetfile; | |
| 419 | - | |
| 420 | - | |
| 421 | - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; | |
| 422 | - $info['cmd']=$stmt; | |
| 423 | - return $info; | |
| 424 | -} | |
| 425 | - | |
| 426 | -function create_restore_stmt($targetfile) | |
| 427 | -{ | |
| 428 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 429 | - | |
| 430 | - $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 431 | - $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 432 | - $dbHost = $oKTConfig->get('db/dbHost'); | |
| 433 | - $dbName = $oKTConfig->get('db/dbName'); | |
| 434 | - $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 435 | - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); | |
| 436 | - if (empty($dbPort)) $dbPort='3306'; | |
| 437 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 438 | - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 439 | - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 440 | - | |
| 441 | - $dir=resolveMysqlDir(); | |
| 442 | - | |
| 443 | - $info['dir']=$dir; | |
| 444 | - | |
| 445 | - $prefix=''; | |
| 446 | - if (OS_UNIX) | |
| 447 | - { | |
| 448 | - $prefix .= "./"; | |
| 449 | - } | |
| 450 | - | |
| 451 | - if (@stat($dbSocket) !== false) | |
| 452 | - { | |
| 453 | - $mechanism="--socket=\"$dbSocket\""; | |
| 454 | - } | |
| 455 | - else | |
| 456 | - { | |
| 457 | - $mechanism="--port=\"$dbPort\""; | |
| 458 | - } | |
| 459 | - | |
| 460 | - $tmpdir=resolveTempDir(); | |
| 461 | - | |
| 462 | - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; | |
| 463 | - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; | |
| 464 | - | |
| 465 | - | |
| 466 | - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; | |
| 467 | - $info['display']=$stmt; | |
| 468 | - | |
| 469 | - | |
| 470 | - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; | |
| 471 | - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; | |
| 472 | - | |
| 473 | - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; | |
| 474 | - $info['cmd']=$stmt; | |
| 475 | - return $info; | |
| 476 | -} | |
| 477 | - | |
| 478 | -function title($title) | |
| 479 | -{ | |
| 480 | - if (!isset($_SESSION['setup_user'])) | |
| 481 | - { | |
| 482 | - print "<script type='text/javascript'>document.location='?go=Login'</script>"; | |
| 483 | - } | |
| 484 | - print "<h1>$title</h1>"; | |
| 485 | -} | |
| 486 | - | |
| 487 | -function resolveTempDir() | |
| 488 | -{ | |
| 489 | - | |
| 490 | - if (OS_UNIX) | |
| 491 | - { | |
| 492 | - $dir='/tmp/kt-db-backup'; | |
| 493 | - } | |
| 494 | - else | |
| 495 | - { | |
| 496 | - $dir='c:/kt-db-backup'; | |
| 497 | - } | |
| 498 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 499 | - $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 500 | - | |
| 501 | - if (!is_dir($dir)) | |
| 502 | - { | |
| 503 | - mkdir($dir); | |
| 504 | - } | |
| 505 | - return $dir; | |
| 506 | -} | |
| 507 | - | |
| 508 | - | |
| 509 | -function upgradeConfirm() | |
| 510 | -{ | |
| 511 | - title('Confirm Upgrade'); | |
| 512 | - if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) | |
| 513 | - { | |
| 514 | -?> | |
| 515 | -<br/> | |
| 516 | -<font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font> | |
| 517 | -<p> | |
| 518 | -<br/> | |
| 519 | -<?php | |
| 520 | - } | |
| 521 | -?> | |
| 522 | -<p> | |
| 523 | -We are about to start the upgrade process. | |
| 524 | -<P> | |
| 525 | - | |
| 526 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 527 | - <input type=button value="next" onclick="javascript:do_start('UpgradePreview')"> | |
| 528 | - | |
| 529 | -<?php | |
| 530 | - | |
| 531 | -} | |
| 532 | - | |
| 533 | - | |
| 534 | -function backupConfirm() | |
| 535 | -{ | |
| 536 | - title('Confirm Backup'); | |
| 537 | - $stmt=create_backup_stmt(); | |
| 538 | - $_SESSION['backupFile'] = $stmt['target']; | |
| 539 | - | |
| 540 | - $dir=$stmt['dir']; | |
| 541 | - if ($dir != '') | |
| 542 | - { | |
| 543 | -?> | |
| 544 | - | |
| 545 | -Are you sure you want to perform the backup? | |
| 546 | - | |
| 547 | -<P> | |
| 548 | -Your mysql installation has been resolved. Manually, you would do the following: | |
| 549 | -<P> | |
| 550 | -<table bgcolor="lightgrey"> | |
| 551 | -<tr> | |
| 552 | -<td> | |
| 553 | -<nobr>cd "<?php echo $dir;?>"</nobr> | |
| 554 | -<br/> | |
| 555 | -<?php | |
| 556 | - } | |
| 557 | - else | |
| 558 | - { | |
| 559 | -?> | |
| 560 | -The mysql backup utility could not be found automatically. Either do a manual backup, or edit the config.ini and update the backup/mysql Directory entry. | |
| 561 | -<P> | |
| 562 | -You can continue to do the backup manually using the following process: | |
| 563 | -<P> | |
| 564 | -<table bgcolor="lightgrey"> | |
| 565 | -<tr> | |
| 566 | -<td> | |
| 567 | -<?php | |
| 568 | - | |
| 569 | - } | |
| 570 | -?> | |
| 571 | -<nobr><?php echo $stmt['display'];?></nobr> | |
| 572 | -</table> | |
| 573 | -<P> | |
| 574 | - | |
| 575 | - <input type=button value="back" onclick="javascript:do_start('home')"> | |
| 576 | - | |
| 577 | -<?php | |
| 578 | -if ($dir != '') | |
| 579 | -{ | |
| 580 | -?> | |
| 581 | - | |
| 582 | -<input type=button value="next" onclick="javascript:do_start('Backup')"> | |
| 583 | - | |
| 584 | - | |
| 585 | -<?php | |
| 586 | -} | |
| 587 | -} | |
| 588 | - | |
| 589 | -function restoreSelect() | |
| 590 | -{ | |
| 591 | - title('Select Backup to Restore'); | |
| 592 | - | |
| 593 | - $dir = resolveTempDir(); | |
| 594 | - | |
| 595 | - $files = array(); | |
| 596 | - if ($dh = opendir($dir)) | |
| 597 | - { | |
| 598 | - while (($file = readdir($dh)) !== false) | |
| 599 | - { | |
| 600 | - if (!preg_match('/kt-backup.+\.sql/',$file)) | |
| 601 | - { | |
| 602 | - continue; | |
| 603 | - } | |
| 604 | - $files[] = $file; | |
| 605 | - } | |
| 606 | - closedir($dh); | |
| 607 | - } | |
| 608 | - | |
| 609 | - if (count($files) == 0) | |
| 610 | - { | |
| 611 | - ?> | |
| 612 | - There don't seem to be any backups to restore from the <i>"<?php echo $dir;?>"</i> directory. | |
| 613 | - <?php | |
| 614 | - } | |
| 615 | - else | |
| 616 | - { | |
| 617 | - ?> | |
| 618 | - <P> | |
| 619 | - Select a backup to restore from the list below: | |
| 620 | - <P> | |
| 621 | - <script type="text/javascript"> | |
| 622 | - function selectRestore(filename) | |
| 623 | - { | |
| 624 | - document.location='?go=RestoreSelected&file=' + filename; | |
| 625 | - } | |
| 626 | - </script> | |
| 627 | - <table border=1 cellpadding=1 cellspacing=1> | |
| 628 | - <tr bgcolor="darkgrey"> | |
| 629 | - <td>Filename | |
| 630 | - <td>File Size | |
| 631 | - <td>Action | |
| 632 | -<?php | |
| 633 | - $i=0; | |
| 634 | - foreach($files as $file) | |
| 635 | - { | |
| 636 | - $color=((($i++)%2)==0)?'white':'lightgrey'; | |
| 637 | -?> | |
| 638 | - <tr bgcolor="<?php echo $color;?>"> | |
| 639 | - <td><?php echo $file;?> | |
| 640 | - <td><?php echo filesize($dir . '/'.$file);?> | |
| 641 | - <td><input type=button value="restore" onclick="javascript:selectRestore('<?php echo $file;?>')"> | |
| 642 | -<?php | |
| 643 | - } | |
| 644 | -?> | |
| 645 | - </table> | |
| 646 | - <?php | |
| 647 | - } | |
| 648 | - ?> | |
| 649 | - | |
| 650 | - <p> | |
| 651 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 652 | - <?php | |
| 653 | - | |
| 654 | -} | |
| 655 | - | |
| 656 | -function restoreSelected() | |
| 657 | -{ | |
| 658 | - $file=$_REQUEST['file']; | |
| 659 | - | |
| 660 | - $dir = resolveTempDir(); | |
| 661 | - $_SESSION['backupFile'] = $dir . '/' . $file; | |
| 662 | -?> | |
| 663 | -<script type="text/javascript"> | |
| 664 | -document.location='?go=RestoreConfirm'; | |
| 665 | -</script> | |
| 666 | -<?php | |
| 667 | - | |
| 668 | -} | |
| 669 | - | |
| 670 | -function restoreConfirm() | |
| 671 | -{ | |
| 672 | - if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0) | |
| 673 | - { | |
| 674 | - restoreSelect(); | |
| 675 | - exit; | |
| 676 | - } | |
| 677 | - | |
| 678 | - title('Confirm Restore'); | |
| 679 | - $status = $_SESSION['backupStatus']; | |
| 680 | - $filename=$_SESSION['backupFile']; | |
| 681 | - $stmt=create_restore_stmt($filename); | |
| 682 | - | |
| 683 | - $dir=$stmt['dir']; | |
| 684 | - if ($dir != '') | |
| 685 | - { | |
| 686 | -?> | |
| 687 | -<P> | |
| 688 | -<P> | |
| 689 | -Manually, you would do the following to restore the backup: | |
| 690 | -<P> | |
| 691 | -<table bgcolor="lightgrey"> | |
| 692 | -<tr> | |
| 693 | -<td> | |
| 694 | -<nobr>cd "<?php echo $dir;?>"</nobr> | |
| 695 | -<br/> | |
| 696 | -<?php | |
| 697 | - } | |
| 698 | - else | |
| 699 | - { | |
| 700 | -?> | |
| 701 | -The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. | |
| 702 | -<P> | |
| 703 | -You can continue to do the restore manually using the following command(s): | |
| 704 | -<P> | |
| 705 | -<table bgcolor="lightgrey"> | |
| 706 | -<tr> | |
| 707 | -<td> | |
| 708 | -<?php | |
| 709 | - | |
| 710 | - } | |
| 711 | -?> | |
| 712 | -<nobr><?php echo $stmt['display'];?></nobr> | |
| 713 | -</td> | |
| 714 | -</tr> | |
| 715 | -</table> | |
| 716 | -<P> | |
| 717 | -<?php | |
| 718 | -if ($dir != '') | |
| 719 | -{ | |
| 720 | -?> | |
| 721 | -Press <i>continue to restore</i> to attempt the command(s) above. | |
| 722 | - | |
| 723 | -<P> | |
| 724 | -<?php | |
| 725 | -} | |
| 726 | -?> | |
| 727 | - | |
| 728 | - <input type=button value="back" onclick="javascript:do_start('home')"> | |
| 729 | - <input type=button value="select another backup" onclick="javascript:do_start('RestoreSelect')"> | |
| 730 | - | |
| 731 | -<?php | |
| 732 | -if ($dir != '') | |
| 733 | -{ | |
| 734 | -?> | |
| 735 | -<script type="text/javascript"> | |
| 736 | -function restore() | |
| 737 | -{ | |
| 738 | - if (confirm('Are you sure you want to restore? This is your last chance if the current data has not been backed up.')) | |
| 739 | - { | |
| 740 | - do_start('Restore'); | |
| 741 | - } | |
| 742 | -} | |
| 743 | -</script> | |
| 744 | - <input type=button value="next" onclick="javascript:restore()"> | |
| 745 | - | |
| 746 | - | |
| 747 | -<?php | |
| 748 | -} | |
| 749 | -} | |
| 750 | - | |
| 751 | - | |
| 752 | -function backupDone() | |
| 753 | -{ | |
| 754 | - check_state(2); | |
| 755 | - set_state(3); | |
| 756 | - title('Backup Status'); | |
| 757 | - $status = $_SESSION['backupStatus']; | |
| 758 | - $filename=$_SESSION['backupFile']; | |
| 759 | - | |
| 760 | - if ($status) | |
| 761 | - { | |
| 762 | - $stmt=create_restore_stmt($filename); | |
| 763 | -?> | |
| 764 | - The backup file <nobr><i>"<?php echo $filename;?>"</i></nobr> has been created. | |
| 765 | - <P> It appears as though the <font color=green>backup has been successful</font>. | |
| 766 | - <P> | |
| 767 | - <?php | |
| 768 | - if ($stmt['dir'] != '') | |
| 769 | - { | |
| 770 | - ?> | |
| 771 | - Manually, you would do the following to restore the backup: | |
| 772 | - <P> | |
| 773 | - <table bgcolor="lightgrey"> | |
| 774 | - <tr> | |
| 775 | - <td> | |
| 776 | - <nobr>cd <?php echo $stmt['dir'];?></nobr> | |
| 777 | - <br/> | |
| 778 | - <?php | |
| 779 | - } | |
| 780 | - else | |
| 781 | - { | |
| 782 | - ?> | |
| 783 | - The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. | |
| 784 | - <P> | |
| 785 | - If you need to restore from this backup, you should be able to use the following statements: | |
| 786 | - <P> | |
| 787 | - <table bgcolor="lightgrey"> | |
| 788 | - <tr> | |
| 789 | - <td> | |
| 790 | - <?php | |
| 791 | - } | |
| 792 | - ?> | |
| 793 | - <nobr><?php echo $stmt['display'];?></nobr> | |
| 794 | - </table> | |
| 795 | - | |
| 796 | -<?php | |
| 797 | - } | |
| 798 | - else | |
| 799 | - { | |
| 800 | -?> | |
| 801 | -It appears as though <font color=red>the backup process has failed</font>.<P></P> Unfortunately, it is difficult to diagnose these problems automatically | |
| 802 | -and would recommend that you try to do the backup process manually. | |
| 803 | -<P> | |
| 804 | -We appologise for the inconvenience. | |
| 805 | -<P> | |
| 806 | -<table bgcolor="lightgrey"> | |
| 807 | -<tr> | |
| 808 | -<td> | |
| 809 | -<?php echo $_SESSION['backupOutput'];?> | |
| 810 | -</table> | |
| 811 | -<?php | |
| 812 | - | |
| 813 | - } | |
| 814 | -?> | |
| 815 | -<br/> | |
| 816 | - | |
| 817 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 818 | -<?php | |
| 819 | - if ($status) | |
| 820 | - { | |
| 821 | - ?> | |
| 822 | - <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm')"> | |
| 823 | - | |
| 824 | -<?php | |
| 825 | - } | |
| 826 | -} | |
| 827 | -function restoreDone() | |
| 828 | -{ | |
| 829 | - check_state(5); | |
| 830 | - set_state(6); | |
| 831 | - title('Restore Status'); | |
| 832 | - $status = $_SESSION['restoreStatus']; | |
| 833 | - $filename=$_SESSION['backupFile']; | |
| 834 | - | |
| 835 | - if ($status) | |
| 836 | - { | |
| 837 | - | |
| 838 | -?> | |
| 839 | - The restore of <nobr><i>"<?php echo $filename;?>"</i></nobr> has been completed. | |
| 840 | - <P> | |
| 841 | - It appears as though the <font color=green>restore has been successful</font>. | |
| 842 | - <P> | |
| 843 | - | |
| 844 | - | |
| 845 | - | |
| 846 | -<?php | |
| 847 | - } | |
| 848 | - else | |
| 849 | - { | |
| 850 | -?> | |
| 851 | -It appears as though <font color=red>the restore process has failed</font>. <P> | |
| 852 | -Unfortunately, it is difficult to diagnose these problems automatically | |
| 853 | -and would recommend that you try to do the backup process manually. | |
| 854 | -<P> | |
| 855 | -We appologise for the inconvenience. | |
| 856 | -<P> | |
| 857 | -<table bgcolor="lightgrey"> | |
| 858 | -<tr> | |
| 859 | -<td> | |
| 860 | -<?php echo $_SESSION['restoreOutput'];?> | |
| 861 | -</table> | |
| 862 | -<?php | |
| 863 | - | |
| 864 | - } | |
| 865 | -?> | |
| 866 | - | |
| 867 | -<br/> | |
| 868 | - | |
| 869 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 870 | - | |
| 871 | -<?php | |
| 872 | - | |
| 873 | -} | |
| 874 | - | |
| 875 | -function set_state($value) | |
| 876 | -{ | |
| 877 | - $_SESSION['state'] = $value; | |
| 878 | -} | |
| 879 | -function check_state($value, $state='Home') | |
| 880 | -{ | |
| 881 | - if ($_SESSION['state'] != $value) | |
| 882 | - { | |
| 883 | - ?> | |
| 884 | - <script type="text/javascript"> | |
| 885 | - document.location="?go=<?php echo $state;?>"; | |
| 886 | - </script> | |
| 887 | - <?php | |
| 888 | - exit; | |
| 889 | - } | |
| 890 | -} | |
| 891 | - | |
| 892 | -function backup() | |
| 893 | -{ | |
| 894 | - check_state(1); | |
| 895 | - set_state(2); | |
| 896 | - title('Backup In Progress'); | |
| 897 | - $targetfile=$_SESSION['backupFile']; | |
| 898 | - $stmt=create_backup_stmt($targetfile); | |
| 899 | - $dir=$stmt['dir']; | |
| 900 | - | |
| 901 | - | |
| 902 | - | |
| 903 | - | |
| 904 | - if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe')) | |
| 905 | - { | |
| 906 | - ob_flush(); | |
| 907 | - flush(); | |
| 908 | -?> | |
| 909 | - The backup is now underway. Please wait till it completes. | |
| 910 | -<?php | |
| 911 | - | |
| 912 | - ob_flush(); | |
| 913 | - flush(); | |
| 914 | - $curdir=getcwd(); | |
| 915 | - chdir($dir); | |
| 916 | - ob_flush(); | |
| 917 | - flush(); | |
| 918 | - | |
| 919 | - $handle = popen($stmt['cmd'], 'r'); | |
| 920 | - $read = fread($handle, 10240); | |
| 921 | - pclose($handle); | |
| 922 | - $_SESSION['backupOutput']=$read; | |
| 923 | - $dir=resolveTempDir(); | |
| 924 | - $_SESSION['backupFile'] = $stmt['target']; | |
| 925 | - | |
| 926 | - if (OS_UNIX) | |
| 927 | - { | |
| 928 | - chmod($stmt['target'],0600); | |
| 929 | - } | |
| 930 | - | |
| 931 | - if (is_file($stmt['target']) && filesize($stmt['target']) > 0) | |
| 932 | - { | |
| 933 | - $_SESSION['backupStatus'] = true; | |
| 934 | - | |
| 935 | - } | |
| 936 | - else | |
| 937 | - { | |
| 938 | - $_SESSION['backupStatus'] = false; | |
| 939 | - } | |
| 940 | -?> | |
| 941 | - <script type="text/javascript"> | |
| 942 | - document.location="?go=BackupDone"; | |
| 943 | - </script> | |
| 944 | -<?php | |
| 945 | - | |
| 946 | - | |
| 947 | - } | |
| 948 | - else | |
| 949 | - { | |
| 950 | -?> | |
| 951 | -<P> | |
| 952 | - The <i>mysqldump</i> utility was not found in the <?php echo $dir;?> subdirectory. | |
| 953 | - | |
| 954 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 955 | -<?php | |
| 956 | - } | |
| 957 | - | |
| 958 | - | |
| 959 | - | |
| 960 | -} | |
| 961 | - | |
| 962 | - | |
| 963 | -function restore() | |
| 964 | -{ | |
| 965 | - check_state(1); | |
| 966 | - set_state(5); | |
| 967 | - title('Restore In Progress'); | |
| 968 | - $status = $_SESSION['backupStatus']; | |
| 969 | - $filename=$_SESSION['backupFile']; | |
| 970 | - $stmt=create_restore_stmt($filename); | |
| 971 | - $dir=$stmt['dir']; | |
| 972 | - | |
| 973 | - | |
| 974 | - | |
| 975 | - | |
| 976 | - if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) | |
| 977 | - { | |
| 978 | - | |
| 979 | -?> | |
| 980 | - The restore is now underway. Please wait till it completes. | |
| 981 | -<?php | |
| 982 | - print "\n"; | |
| 983 | - | |
| 984 | - | |
| 985 | - $curdir=getcwd(); | |
| 986 | - chdir($dir); | |
| 987 | - | |
| 988 | - | |
| 989 | - $ok=true; | |
| 990 | - $stmts=explode("\n",$stmt['cmd']); | |
| 991 | - foreach($stmts as $stmt) | |
| 992 | - { | |
| 993 | - | |
| 994 | - $handle = popen($stmt, 'r'); | |
| 995 | - if ($handle=='false') | |
| 996 | - { | |
| 997 | - $ok=false; | |
| 998 | - break; | |
| 999 | - } | |
| 1000 | - $read = fread($handle, 10240); | |
| 1001 | - pclose($handle); | |
| 1002 | - $_SESSION['restoreOutput']=$read; | |
| 1003 | - } | |
| 1004 | - | |
| 1005 | - | |
| 1006 | - | |
| 1007 | - | |
| 1008 | - | |
| 1009 | - $_SESSION['restoreStatus'] = $ok; | |
| 1010 | - | |
| 1011 | - | |
| 1012 | -?> | |
| 1013 | - <script type="text/javascript"> | |
| 1014 | - document.location="?go=RestoreDone"; | |
| 1015 | - </script> | |
| 1016 | -<?php | |
| 1017 | - | |
| 1018 | - | |
| 1019 | - } | |
| 1020 | - else | |
| 1021 | - { | |
| 1022 | -?> | |
| 1023 | -<P> | |
| 1024 | - The <i>mysql</i> utility was not found in the <?php echo $dir;?> subdirectory. | |
| 1025 | - | |
| 1026 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 1027 | -<?php | |
| 1028 | - } | |
| 1029 | - | |
| 1030 | - | |
| 1031 | - | |
| 1032 | -} | |
| 1033 | - | |
| 1034 | - | |
| 1035 | -function welcome() | |
| 1036 | -{ | |
| 1037 | - set_state(1); | |
| 1038 | -?> | |
| 1039 | -<br/> | |
| 1040 | -Welcome to the <?php echo APP_NAME;?> Database Upgrade Wizard.<P> If you have just updated | |
| 1041 | -your <?php echo APP_NAME;?> code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version. | |
| 1042 | -<P> | |
| 1043 | -You will not be able to log into <?php echo APP_NAME;?> until your the database upgrade process is completed. | |
| 1044 | -<P> | |
| 1045 | -<font color="#ffa500">!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!!</font> | |
| 1046 | -<P> | |
| 1047 | -If you have already done this, you may skip this step can continue directly to the upgrade. | |
| 1048 | -<P> | |
| 1049 | - | |
| 1050 | - | |
| 1051 | - <input type=button value="cancel" onclick="document.location='..';"/> | |
| 1052 | - <input type=button value="backup now" onclick="javascript:do_start('BackupConfirm');"/> | |
| 1053 | - <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm');"/> | |
| 1054 | - <input type=button value="restore database" onclick="javascript:do_start('RestoreConfirm');"/> | |
| 1055 | - | |
| 1056 | - | |
| 1057 | -<?php | |
| 1058 | - | |
| 1059 | - | |
| 1060 | -} | |
| 1061 | - | |
| 1062 | - | |
| 1063 | -function UpgradePreview() | |
| 1064 | -{ | |
| 1065 | - title('Preview Upgrade'); | |
| 1066 | - global $default; | |
| 1067 | -?> | |
| 1068 | - <p>The table below describes the upgrades that need to occur to | |
| 1069 | - upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>. | |
| 1070 | - Click on the button below the table to perform the upgrades.</p> | |
| 1071 | - <?php | |
| 1072 | - $upgradeTable = generateUpgradeTable(); | |
| 1073 | - print $upgradeTable; | |
| 1074 | - ?> | |
| 1075 | - <br/> | |
| 1076 | - | |
| 1077 | - <input type=button value="back" onclick="javascript:do_start('home')"> | |
| 1078 | - <input type=button value="next" onclick="javascript:do_start('Upgrade')"> | |
| 1079 | - <?php | |
| 1080 | - | |
| 1081 | -} | |
| 1082 | - | |
| 1083 | - | |
| 1084 | -function Upgrade() | |
| 1085 | -{ | |
| 1086 | - title('Upgrade In Progress'); | |
| 1087 | - global $default; | |
| 1088 | -?> | |
| 1089 | - <p>The table below describes the upgrades that have occurred to | |
| 1090 | - upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>. | |
| 1091 | - | |
| 1092 | - <?php | |
| 1093 | - $pre_res = performPreUpgradeActions(); | |
| 1094 | - if (PEAR::isError($pre_res)) | |
| 1095 | - { | |
| 1096 | -?> | |
| 1097 | -<font color="red">Pre-Upgrade actions failed.</font><br/> | |
| 1098 | -<?php | |
| 1099 | - } | |
| 1100 | - else | |
| 1101 | - { | |
| 1102 | -?> | |
| 1103 | -<p> | |
| 1104 | -<font color="green">Pre-Upgrade actions succeeded.</font><br/> | |
| 1105 | -<?php | |
| 1106 | - } | |
| 1107 | -?> | |
| 1108 | -<p> | |
| 1109 | - <?php | |
| 1110 | - $res = performAllUpgrades(); | |
| 1111 | - if (PEAR::isError($res) || PEAR::isError($pres)) | |
| 1112 | - { | |
| 1113 | -?> | |
| 1114 | -<font color="red">Upgrade failed.</font> | |
| 1115 | -<?php | |
| 1116 | - } | |
| 1117 | - else | |
| 1118 | - { | |
| 1119 | -?> | |
| 1120 | -<p> | |
| 1121 | -<font color="green">Upgrade succeeded.</font> | |
| 1122 | -<?php | |
| 1123 | - } | |
| 1124 | -?> | |
| 1125 | -<p> | |
| 1126 | - <?php | |
| 1127 | - $post_pres = performPostUpgradeActions(); | |
| 1128 | - if (PEAR::isError($post_res)) | |
| 1129 | - { | |
| 1130 | -?> | |
| 1131 | -<font color="red">Post-Upgrade actions failed.</font><br/><br/> | |
| 1132 | -<?php | |
| 1133 | - } | |
| 1134 | - else | |
| 1135 | - { | |
| 1136 | -?> | |
| 1137 | -<p> | |
| 1138 | -<font color="green">Post-Upgrade actions succeeded.</font><br/><br/> | |
| 1139 | -<script type="text/javascript"> | |
| 1140 | - alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'next' at the bottom of this page to continue.") | |
| 1141 | -</script> | |
| 1142 | -<?php | |
| 1143 | - } | |
| 1144 | -?> | |
| 1145 | - | |
| 1146 | - <input type=button value="back" onclick="javascript:do_start('home')"> | |
| 1147 | - <input type=button value="next" onclick="javascript:document.location='..';"> | |
| 1148 | -<?php | |
| 1149 | -} | |
| 1150 | - | |
| 1151 | -?> | |
| 1152 | -<tr> | |
| 1153 | -<td height=80 <?php | |
| 1154 | - if($oKTConfig->get('ui/poweredByDisabled') == '0'){ | |
| 1155 | - ?> align="right"><img src="<?php echo $oKTConfig->get('ui/powerLogo');?>"></td> | |
| 1156 | - <?php }else{ ?> | |
| 1157 | - background="../resources/graphics/ktbg.png"> </td> | |
| 1158 | - <?php }?> | |
| 1159 | -</table> | |
| 38 | +header("Location: upgrade/"); | |
| 39 | +exit(); | |
| 1160 | 40 | \ No newline at end of file | ... | ... |
setup/upgrade/index.php
setup/upgrade/step.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Step . | |
| 3 | +* Step Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -119,10 +119,10 @@ class Step |
| 119 | 119 | { |
| 120 | 120 | // if not authenticated, return to step 1 |
| 121 | 121 | if (!isset($_SESSION['setup_user'])) { |
| 122 | - header('index.php?step=welcome'); | |
| 122 | + header('Location: index.php?step=welcome'); | |
| 123 | 123 | exit; |
| 124 | 124 | } |
| 125 | - | |
| 125 | + | |
| 126 | 126 | return ''; |
| 127 | 127 | } |
| 128 | 128 | |
| ... | ... | @@ -254,38 +254,31 @@ class Step |
| 254 | 254 | |
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | - | |
| 258 | - /** | |
| 259 | - * Checks if Confirm button has been clicked | |
| 260 | - * | |
| 261 | - * @author KnowledgeTree Team | |
| 262 | - * @param none | |
| 263 | - * @access public | |
| 264 | - * @return boolean | |
| 265 | - */ | |
| 257 | + | |
| 258 | + /** | |
| 259 | + * Checks if Upgrade button has been clicked | |
| 260 | + * | |
| 261 | + * @author KnowledgeTree Team | |
| 262 | + * @param none | |
| 263 | + * @access public | |
| 264 | + * @return boolean | |
| 265 | + */ | |
| 266 | 266 | function upgrade() { |
| 267 | - if(isset($_POST['Upgrade'])) { | |
| 268 | - return true; | |
| 269 | - } | |
| 270 | - | |
| 271 | - return false; | |
| 267 | + return isset($_POST['Upgrade']); | |
| 272 | 268 | } |
| 273 | - | |
| 274 | - /** | |
| 275 | - * Checks if Confirm button has been clicked | |
| 276 | - * | |
| 277 | - * @author KnowledgeTree Team | |
| 278 | - * @param none | |
| 279 | - * @access public | |
| 280 | - * @return boolean | |
| 281 | - */ | |
| 282 | - function installer() { | |
| 283 | - if(isset($_POST['Install'])) { | |
| 284 | - return true; | |
| 285 | - } | |
| 286 | - | |
| 287 | - return false; | |
| 269 | + | |
| 270 | + /** | |
| 271 | + * Checks if Upgrade button has been clicked | |
| 272 | + * | |
| 273 | + * @author KnowledgeTree Team | |
| 274 | + * @param none | |
| 275 | + * @access public | |
| 276 | + * @return boolean | |
| 277 | + */ | |
| 278 | + function restore() { | |
| 279 | + return isset($_POST['Restore']); | |
| 288 | 280 | } |
| 281 | + | |
| 289 | 282 | /** |
| 290 | 283 | * Checks if we are currently in this class step |
| 291 | 284 | * | ... | ... |
setup/upgrade/steps/upgradeBackup.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Complete Step Controller. | |
| 3 | +* Backup Step Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -52,12 +52,9 @@ class upgradeBackup extends Step { |
| 52 | 52 | * @var object |
| 53 | 53 | */ |
| 54 | 54 | private $_dbhandler = null; |
| 55 | - | |
| 56 | - private $privileges_check = 'tick'; | |
| 57 | - private $database_check = 'tick'; | |
| 58 | - protected $silent = true; | |
| 59 | - | |
| 60 | 55 | protected $util = null; |
| 56 | + protected $silent = false; | |
| 57 | + protected $temp_variables = array(); | |
| 61 | 58 | |
| 62 | 59 | public function __construct() { |
| 63 | 60 | $this->temp_variables = array("step_name"=>"backup", "silent"=>$this->silent); |
| ... | ... | @@ -65,7 +62,7 @@ class upgradeBackup extends Step { |
| 65 | 62 | $this->util = new UpgradeUtil(); |
| 66 | 63 | } |
| 67 | 64 | |
| 68 | - function doStep() { | |
| 65 | + public function doStep() { | |
| 69 | 66 | parent::doStep(); |
| 70 | 67 | if(!$this->inStep("backup")) { |
| 71 | 68 | $this->doRun(); |
| ... | ... | @@ -75,16 +72,50 @@ class upgradeBackup extends Step { |
| 75 | 72 | if ($this->doRun()) { |
| 76 | 73 | return 'next'; |
| 77 | 74 | } |
| 78 | - } else if($this->previous()) { | |
| 75 | + } | |
| 76 | + else if ($this->confirm()) { | |
| 77 | + if ($this->doRun('confirm')) { | |
| 78 | + return 'confirm'; | |
| 79 | + } | |
| 80 | + } | |
| 81 | + else if ($this->backupNow()) { | |
| 82 | + if ($this->doRun('backupNow')) { | |
| 83 | + return 'next'; | |
| 84 | + } | |
| 85 | + else { | |
| 86 | + return 'error'; | |
| 87 | + } | |
| 88 | + } | |
| 89 | + else if($this->previous()) { | |
| 79 | 90 | return 'previous'; |
| 80 | 91 | } |
| 92 | + else if ($this->upgrade()) { | |
| 93 | + header('Location: index.php?step_name=database'); | |
| 94 | + exit; | |
| 95 | + } | |
| 81 | 96 | |
| 82 | 97 | $this->doRun(); |
| 83 | 98 | return 'landing'; |
| 84 | 99 | } |
| 85 | 100 | |
| 86 | - function doRun() { | |
| 87 | - $this->backupConfirm(); | |
| 101 | + private function backupNow() | |
| 102 | + { | |
| 103 | + return isset($_POST['BackupNow']); | |
| 104 | + } | |
| 105 | + | |
| 106 | + private function doRun($action = null) { | |
| 107 | + $this->temp_variables['action'] = $action; | |
| 108 | + | |
| 109 | + if (is_null($action) || ($action == 'confirm')) { | |
| 110 | + $this->temp_variables['title'] = 'Confirm Backup'; | |
| 111 | + $this->backupConfirm(); | |
| 112 | + } | |
| 113 | + else { | |
| 114 | + $this->temp_variables['title'] = 'Backup Created'; | |
| 115 | + $this->backup(); | |
| 116 | + // TODO error checking (done in backupDone at the moment) | |
| 117 | + $this->backupDone(); | |
| 118 | + } | |
| 88 | 119 | $this->storeSilent();// Set silent mode variables |
| 89 | 120 | |
| 90 | 121 | return true; |
| ... | ... | @@ -98,273 +129,146 @@ class upgradeBackup extends Step { |
| 98 | 129 | } |
| 99 | 130 | |
| 100 | 131 | private function backup() { |
| 101 | - check_state(1); | |
| 102 | - set_state(2); | |
| 103 | - title('Backup In Progress'); | |
| 104 | - $targetfile=$_SESSION['backupFile']; | |
| 105 | - $stmt=create_backup_stmt($targetfile); | |
| 106 | - $dir=$stmt['dir']; | |
| 107 | - | |
| 108 | - | |
| 109 | - | |
| 132 | + $targetfile = $_SESSION['backupFile']; | |
| 133 | + $stmt = $this->create_backup_stmt($targetfile); | |
| 134 | + $dir = $stmt['dir']; | |
| 110 | 135 | |
| 111 | 136 | if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe')) |
| 112 | 137 | { |
| 113 | - ob_flush(); | |
| 114 | - flush(); | |
| 115 | - ?> | |
| 116 | - The backup is now underway. Please wait till it completes. | |
| 117 | - <?php | |
| 118 | - | |
| 119 | - ob_flush(); | |
| 120 | - flush(); | |
| 121 | 138 | $curdir=getcwd(); |
| 122 | 139 | chdir($dir); |
| 123 | - ob_flush(); | |
| 124 | - flush(); | |
| 125 | - | |
| 140 | + | |
| 126 | 141 | $handle = popen($stmt['cmd'], 'r'); |
| 127 | 142 | $read = fread($handle, 10240); |
| 128 | 143 | pclose($handle); |
| 129 | 144 | $_SESSION['backupOutput']=$read; |
| 130 | - $dir=$this->resolveTempDir(); | |
| 145 | + $dir = $this->util->resolveTempDir(); | |
| 131 | 146 | $_SESSION['backupFile'] = $stmt['target']; |
| 132 | 147 | |
| 133 | - if (OS_UNIX) | |
| 134 | - { | |
| 135 | - chmod($stmt['target'],0600); | |
| 136 | - } | |
| 148 | + if (OS_UNIX) { | |
| 149 | + chmod($stmt['target'],0600); | |
| 150 | + } | |
| 137 | 151 | |
| 138 | - if (is_file($stmt['target']) && filesize($stmt['target']) > 0) | |
| 139 | - { | |
| 152 | + if (is_file($stmt['target']) && filesize($stmt['target']) > 0) { | |
| 140 | 153 | $_SESSION['backupStatus'] = true; |
| 141 | - | |
| 142 | 154 | } |
| 143 | - else | |
| 144 | - { | |
| 155 | + else { | |
| 145 | 156 | $_SESSION['backupStatus'] = false; |
| 146 | 157 | } |
| 147 | - ?> | |
| 148 | - <script type="text/javascript"> | |
| 149 | - document.location="?go=BackupDone"; | |
| 150 | - </script> | |
| 151 | - <?php | |
| 152 | - | |
| 153 | - | |
| 154 | - } | |
| 155 | - else | |
| 156 | - { | |
| 157 | - ?> | |
| 158 | - <P> | |
| 159 | - The <i>mysqldump</i> utility was not found in the <?php echo $dir;?> subdirectory. | |
| 160 | - | |
| 161 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 162 | - <?php | |
| 163 | 158 | } |
| 164 | - | |
| 165 | - | |
| 166 | - | |
| 167 | 159 | } |
| 168 | 160 | |
| 169 | 161 | private function backupDone() { |
| 170 | - check_state(2); | |
| 171 | - set_state(3); | |
| 172 | - title('Backup Status'); | |
| 173 | 162 | $status = $_SESSION['backupStatus']; |
| 174 | - $filename=$_SESSION['backupFile']; | |
| 163 | + $filename = $_SESSION['backupFile']; | |
| 164 | + | |
| 165 | + $this->temp_variables['backupStatus'] = $status; | |
| 175 | 166 | |
| 176 | 167 | if ($status) |
| 177 | 168 | { |
| 178 | - $stmt=create_restore_stmt($filename); | |
| 179 | - ?> | |
| 180 | - The backup file <nobr><i>"<?php echo $filename;?>"</i></nobr> has been created. | |
| 169 | + $stmt = $this->util->create_restore_stmt($filename); | |
| 170 | + $this->temp_variables['display'] = 'The backup file <nobr><i>"' . $filename . '"</i></nobr> has been created. | |
| 181 | 171 | <P> It appears as though the <font color=green>backup has been successful</font>. |
| 182 | - <P> | |
| 183 | - <?php | |
| 172 | + <P>'; | |
| 184 | 173 | if ($stmt['dir'] != '') |
| 185 | 174 | { |
| 186 | - ?> | |
| 187 | - Manually, you would do the following to restore the backup: | |
| 175 | + $this->temp_variables['dir'] = $stmt['dir']; | |
| 176 | + $this->temp_variables['display'] .= 'Manually, you would do the following to restore the backup: | |
| 188 | 177 | <P> |
| 189 | 178 | <table bgcolor="lightgrey"> |
| 190 | 179 | <tr> |
| 191 | 180 | <td> |
| 192 | - <nobr>cd <?php echo $stmt['dir'];?></nobr> | |
| 193 | - <br/> | |
| 194 | - <?php | |
| 181 | + <nobr>cd ' . $stmt['dir'] . '</nobr> | |
| 182 | + <br/>'; | |
| 195 | 183 | } |
| 196 | 184 | else |
| 197 | 185 | { |
| 198 | - ?> | |
| 199 | - The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. | |
| 186 | + $this->temp_variables['display'] .= 'The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. | |
| 200 | 187 | <P> |
| 201 | 188 | If you need to restore from this backup, you should be able to use the following statements: |
| 202 | 189 | <P> |
| 203 | 190 | <table bgcolor="lightgrey"> |
| 204 | 191 | <tr> |
| 205 | - <td> | |
| 206 | - <?php | |
| 192 | + <td>'; | |
| 207 | 193 | } |
| 208 | - ?> | |
| 209 | - <nobr><?php echo $stmt['display'];?></nobr> | |
| 210 | - </table> | |
| 211 | - | |
| 212 | - <?php | |
| 194 | + $this->temp_variables['display'] .= '<nobr>' . $stmt['display'] . '</nobr> | |
| 195 | + </table>'; | |
| 213 | 196 | } |
| 214 | 197 | else |
| 215 | 198 | { |
| 216 | - ?> | |
| 217 | - It appears as though <font color=red>the backup process has failed</font>.<P></P> Unfortunately, it is difficult to diagnose these problems automatically | |
| 218 | - and would recommend that you try to do the backup process manually. | |
| 219 | - <P> | |
| 220 | - We appologise for the inconvenience. | |
| 221 | - <P> | |
| 222 | - <table bgcolor="lightgrey"> | |
| 223 | - <tr> | |
| 224 | - <td> | |
| 225 | - <?php echo $_SESSION['backupOutput'];?> | |
| 226 | - </table> | |
| 227 | - <?php | |
| 228 | - | |
| 199 | + $this->temp_variables['display'] .= 'It appears as though <font color=red>the backup process has failed</font>.<P></P> Unfortunately, it is difficult to diagnose these problems automatically | |
| 200 | + and would recommend that you try to do the backup process manually. | |
| 201 | + <P> | |
| 202 | + We appologise for the inconvenience. | |
| 203 | + <P> | |
| 204 | + <table bgcolor="lightgrey"> | |
| 205 | + <tr> | |
| 206 | + <td>' . $_SESSION['backupOutput'] . '</table>'; | |
| 229 | 207 | } |
| 230 | - ?> | |
| 231 | - <br/> | |
| 208 | + } | |
| 209 | + | |
| 210 | + private function create_backup_stmt($targetfile=null) | |
| 211 | + { | |
| 212 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 232 | 213 | |
| 233 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 234 | - <?php | |
| 235 | - if ($status) | |
| 214 | + $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 215 | + $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 216 | + $dbHost = $oKTConfig->get('db/dbHost'); | |
| 217 | + $dbName = $oKTConfig->get('db/dbName'); | |
| 218 | + | |
| 219 | + $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 220 | + if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); | |
| 221 | + if (empty($dbPort)) $dbPort='3306'; | |
| 222 | + $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 223 | + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 224 | + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 225 | + | |
| 226 | + $date=date('Y-m-d-H-i-s'); | |
| 227 | + | |
| 228 | + $dir=$this->util->resolveMysqlDir(); | |
| 229 | + | |
| 230 | + $info['dir']=$dir; | |
| 231 | + | |
| 232 | + $prefix=''; | |
| 233 | + if (OS_UNIX) | |
| 236 | 234 | { |
| 237 | - ?> | |
| 238 | - <input type=button value="next" onclick="javascript:do_start('UpgradeConfirm')"> | |
| 235 | + $prefix .= "./"; | |
| 236 | + } | |
| 239 | 237 | |
| 240 | - <?php | |
| 238 | + if (@stat($dbSocket) !== false) | |
| 239 | + { | |
| 240 | + $mechanism="--socket=\"$dbSocket\""; | |
| 241 | 241 | } |
| 242 | -} | |
| 243 | - | |
| 244 | -function create_backup_stmt($targetfile=null) | |
| 245 | -{ | |
| 246 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 247 | - | |
| 248 | - $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 249 | - $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 250 | - $dbHost = $oKTConfig->get('db/dbHost'); | |
| 251 | - $dbName = $oKTConfig->get('db/dbName'); | |
| 252 | - | |
| 253 | - $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 254 | - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); | |
| 255 | - if (empty($dbPort)) $dbPort='3306'; | |
| 256 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 257 | - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 258 | - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 259 | - | |
| 260 | - $date=date('Y-m-d-H-i-s'); | |
| 261 | - | |
| 262 | - $dir=$this->resolveMysqlDir(); | |
| 263 | - | |
| 264 | - $info['dir']=$dir; | |
| 265 | - | |
| 266 | - $prefix=''; | |
| 267 | - if (OS_UNIX) | |
| 268 | - { | |
| 269 | - $prefix .= "./"; | |
| 270 | - } | |
| 271 | - | |
| 272 | - if (@stat($dbSocket) !== false) | |
| 273 | - { | |
| 274 | - $mechanism="--socket=\"$dbSocket\""; | |
| 275 | - } | |
| 276 | - else | |
| 277 | - { | |
| 278 | - $mechanism="--port=\"$dbPort\""; | |
| 279 | - } | |
| 280 | - | |
| 281 | - $tmpdir=$this->resolveTempDir(); | |
| 282 | - | |
| 283 | - if (is_null($targetfile)) | |
| 284 | - { | |
| 285 | - $targetfile="$tmpdir/kt-backup-$date.sql"; | |
| 286 | - } | |
| 287 | - | |
| 288 | - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; | |
| 289 | - $info['display']=$stmt; | |
| 290 | - $info['target']=$targetfile; | |
| 291 | - | |
| 292 | - | |
| 293 | - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; | |
| 294 | - $info['cmd']=$stmt; | |
| 295 | - return $info; | |
| 296 | -} | |
| 297 | - | |
| 298 | -function resolveMysqlDir() | |
| 299 | -{ | |
| 300 | - // possibly detect existing installations: | |
| 301 | - | |
| 302 | - if (OS_UNIX) | |
| 303 | - { | |
| 304 | - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); | |
| 305 | - $mysqlname ='mysql'; | |
| 306 | - } | |
| 307 | - else | |
| 308 | - { | |
| 309 | - $dirs = explode(';', $_SERVER['PATH']); | |
| 310 | - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; | |
| 311 | - $dirs[] = 'c:/program files/ktdms/mysql/bin'; | |
| 312 | - $mysqlname ='mysql.exe'; | |
| 313 | - } | |
| 314 | - | |
| 315 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 316 | - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); | |
| 317 | - $dirs[] = $mysqldir; | |
| 318 | - | |
| 319 | - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) | |
| 320 | - { | |
| 321 | - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); | |
| 322 | - } | |
| 323 | - | |
| 324 | - foreach($dirs as $dir) | |
| 325 | - { | |
| 326 | - if (is_file($dir . '/' . $mysqlname)) | |
| 242 | + else | |
| 327 | 243 | { |
| 328 | - return $dir; | |
| 244 | + $mechanism="--port=\"$dbPort\""; | |
| 329 | 245 | } |
| 246 | + | |
| 247 | + $tmpdir=$this->util->resolveTempDir(); | |
| 248 | + | |
| 249 | + if (is_null($targetfile)) | |
| 250 | + { | |
| 251 | + $targetfile="$tmpdir/kt-backup-$date.sql"; | |
| 252 | + } | |
| 253 | + | |
| 254 | + $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; | |
| 255 | + $info['display']=$stmt; | |
| 256 | + $info['target']=$targetfile; | |
| 257 | + | |
| 258 | + | |
| 259 | + $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; | |
| 260 | + $info['cmd']=$stmt; | |
| 261 | + return $info; | |
| 330 | 262 | } |
| 331 | 263 | |
| 332 | - return ''; | |
| 333 | -} | |
| 334 | - | |
| 335 | -function resolveTempDir() | |
| 336 | -{ | |
| 337 | - | |
| 338 | - if (OS_UNIX) | |
| 339 | - { | |
| 340 | - $dir='/tmp/kt-db-backup'; | |
| 341 | - } | |
| 342 | - else | |
| 343 | - { | |
| 344 | - $dir='c:/kt-db-backup'; | |
| 345 | - } | |
| 346 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 347 | - $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 348 | - | |
| 349 | - if (!is_dir($dir)) | |
| 264 | + private function backupConfirm() | |
| 350 | 265 | { |
| 351 | - mkdir($dir); | |
| 266 | + $stmt = $this->create_backup_stmt(); | |
| 267 | + $_SESSION['backupFile'] = $stmt['target']; | |
| 268 | + | |
| 269 | + $dir = $stmt['dir']; | |
| 270 | + $this->temp_variables['dir'] = $dir; | |
| 271 | + $this->temp_variables['display'] = $stmt['display']; | |
| 352 | 272 | } |
| 353 | - return $dir; | |
| 354 | -} | |
| 355 | - | |
| 356 | - | |
| 357 | -function backupConfirm() | |
| 358 | -{ | |
| 359 | - $stmt = $this->create_backup_stmt(); | |
| 360 | - $_SESSION['backupFile'] = $stmt['target']; | |
| 361 | - | |
| 362 | - $dir = $stmt['dir']; | |
| 363 | - $this->temp_variables['dir'] = $dir; | |
| 364 | - $this->temp_variables['display'] = $stmt['display']; | |
| 365 | -} | |
| 366 | - | |
| 367 | - | |
| 368 | - | |
| 369 | 273 | } |
| 370 | 274 | ?> |
| 371 | 275 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeComplete.php
| ... | ... | @@ -40,35 +40,24 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -class upgradeComplete extends Step { | |
| 43 | +require '../../config/dmsDefaults.php'; | |
| 44 | 44 | |
| 45 | - /** | |
| 46 | - * Reference to Database object | |
| 47 | - * | |
| 48 | - * @author KnowledgeTree Team | |
| 49 | - * @access private | |
| 50 | - * @var object | |
| 51 | - */ | |
| 52 | - private $_dbhandler = null; | |
| 45 | +class upgradeComplete extends Step { | |
| 53 | 46 | |
| 54 | - private $privileges_check = 'tick'; | |
| 55 | - private $database_check = 'tick'; | |
| 56 | - protected $silent = true; | |
| 57 | - | |
| 58 | 47 | protected $util = null; |
| 48 | + protected $silent = false; | |
| 49 | + protected $temp_variables = array(); | |
| 59 | 50 | |
| 60 | 51 | public function __construct() { |
| 61 | 52 | $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); |
| 62 | - $this->_dbhandler = new dbUtil(); | |
| 63 | - $this->util = new UpgradeUtil(); | |
| 64 | 53 | } |
| 65 | 54 | |
| 66 | - function doStep() { | |
| 55 | + public function doStep() { | |
| 67 | 56 | $this->doRun(); |
| 68 | 57 | return 'landing'; |
| 69 | 58 | } |
| 70 | 59 | |
| 71 | - function doRun() { | |
| 60 | + private function doRun() { | |
| 72 | 61 | $this->storeSilent();// Set silent mode variables |
| 73 | 62 | } |
| 74 | 63 | |
| ... | ... | @@ -78,5 +67,6 @@ class upgradeComplete extends Step { |
| 78 | 67 | */ |
| 79 | 68 | private function storeSilent() { |
| 80 | 69 | } |
| 70 | + | |
| 81 | 71 | } |
| 82 | 72 | ?> |
| 83 | 73 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeDatabase.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Database Step Controller. | |
| 3 | +* Upgrade Step Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -40,9 +40,9 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -// include defaults | |
| 44 | 43 | require '../../config/dmsDefaults.php'; |
| 45 | 44 | require_once KT_LIB_DIR . '/config/config.inc.php'; |
| 45 | +require_once KT_LIB_DIR . '/plugins/pluginutil.inc.php'; | |
| 46 | 46 | include KT_LIB_DIR . '/upgrades/upgrade.inc.php'; |
| 47 | 47 | |
| 48 | 48 | class upgradeDatabase extends Step |
| ... | ... | @@ -66,105 +66,6 @@ class upgradeDatabase extends Step |
| 66 | 66 | public $_util = null; |
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | - * Database type | |
| 70 | - * | |
| 71 | - * @author KnowledgeTree Team | |
| 72 | - * @access private | |
| 73 | - * @var array | |
| 74 | - */ | |
| 75 | - private $dtype = ''; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * Database types | |
| 79 | - * | |
| 80 | - * @author KnowledgeTree Team | |
| 81 | - * @access private | |
| 82 | - * @var array | |
| 83 | - */ | |
| 84 | - private $dtypes = array(); | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Database host | |
| 88 | - * | |
| 89 | - * @author KnowledgeTree Team | |
| 90 | - * @access private | |
| 91 | - * @var string | |
| 92 | - */ | |
| 93 | - private $dhost = ''; | |
| 94 | - | |
| 95 | - /** | |
| 96 | - * Database port | |
| 97 | - * | |
| 98 | - * @author KnowledgeTree Team | |
| 99 | - * @access private | |
| 100 | - * @var string | |
| 101 | - */ | |
| 102 | - private $dport = ''; | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * Database name | |
| 106 | - * | |
| 107 | - * @author KnowledgeTree Team | |
| 108 | - * @access private | |
| 109 | - * @var string | |
| 110 | - */ | |
| 111 | - private $dname = ''; | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * Database root username | |
| 115 | - * | |
| 116 | - * @author KnowledgeTree Team | |
| 117 | - * @access private | |
| 118 | - * @var string | |
| 119 | - */ | |
| 120 | - private $duname = ''; | |
| 121 | - | |
| 122 | - /** | |
| 123 | - * Database root password | |
| 124 | - * | |
| 125 | - * @author KnowledgeTree Team | |
| 126 | - * @access private | |
| 127 | - * @var string | |
| 128 | - */ | |
| 129 | - private $dpassword = ''; | |
| 130 | - | |
| 131 | - /** | |
| 132 | - * Database dms username | |
| 133 | - * | |
| 134 | - * @author KnowledgeTree Team | |
| 135 | - * @access private | |
| 136 | - * @var string | |
| 137 | - */ | |
| 138 | - private $dmsname = ''; | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * Database dms password | |
| 142 | - * | |
| 143 | - * @author KnowledgeTree Team | |
| 144 | - * @access private | |
| 145 | - * @var string | |
| 146 | - */ | |
| 147 | - private $dmspassword = ''; | |
| 148 | - | |
| 149 | - /** | |
| 150 | - * Default dms user username | |
| 151 | - * | |
| 152 | - * @author KnowledgeTree Team | |
| 153 | - * @access private | |
| 154 | - * @var boolean | |
| 155 | - */ | |
| 156 | - private $dmsusername = ''; | |
| 157 | - | |
| 158 | - /** | |
| 159 | - * Default dms user password | |
| 160 | - * | |
| 161 | - * @author KnowledgeTree Team | |
| 162 | - * @access private | |
| 163 | - * @var boolean | |
| 164 | - */ | |
| 165 | - private $dmsuserpassword = ''; | |
| 166 | - | |
| 167 | - /** | |
| 168 | 69 | * Location of database binaries. |
| 169 | 70 | * |
| 170 | 71 | * @author KnowledgeTree Team |
| ... | ... | @@ -180,25 +81,7 @@ class upgradeDatabase extends Step |
| 180 | 81 | * @access private |
| 181 | 82 | * @var string |
| 182 | 83 | */ |
| 183 | - private $dbbinary = ''; // TODO:multiple databases | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * Database table prefix | |
| 187 | - * | |
| 188 | - * @author KnowledgeTree Team | |
| 189 | - * @access private | |
| 190 | - * @var string | |
| 191 | - */ | |
| 192 | - private $tprefix = ''; | |
| 193 | - | |
| 194 | - /** | |
| 195 | - * Flag to drop database | |
| 196 | - * | |
| 197 | - * @author KnowledgeTree Team | |
| 198 | - * @access private | |
| 199 | - * @var boolean | |
| 200 | - */ | |
| 201 | - private $ddrop = false; | |
| 84 | + private $dbBinary = ''; // TODO:multiple databases | |
| 202 | 85 | |
| 203 | 86 | /** |
| 204 | 87 | * List of errors encountered |
| ... | ... | @@ -227,26 +110,11 @@ class upgradeDatabase extends Step |
| 227 | 110 | */ |
| 228 | 111 | public $storeInSession = true; |
| 229 | 112 | |
| 230 | - /** | |
| 231 | - * Flag if step needs to be upgraded | |
| 232 | - * | |
| 233 | - * @author KnowledgeTree Team | |
| 234 | - * @access public | |
| 235 | - * @var array | |
| 236 | - */ | |
| 237 | - protected $runUpgrade = true; | |
| 238 | - | |
| 239 | - /** | |
| 240 | - * Flag if step needs to run silently | |
| 241 | - * | |
| 242 | - * @author KnowledgeTree Team | |
| 243 | - * @access public | |
| 244 | - * @var array | |
| 245 | - */ | |
| 246 | - protected $silent = true; | |
| 113 | + protected $silent = false; | |
| 114 | + protected $temp_variables = array(); | |
| 247 | 115 | |
| 248 | 116 | /** |
| 249 | - * Constructs database object | |
| 117 | + * Constructs database upgrade object | |
| 250 | 118 | * |
| 251 | 119 | * @author KnowledgeTree Team |
| 252 | 120 | * @access public |
| ... | ... | @@ -271,30 +139,22 @@ class upgradeDatabase extends Step |
| 271 | 139 | public function doStep() { |
| 272 | 140 | parent::doStep(); |
| 273 | 141 | $this->initErrors(); |
| 274 | - $this->setDetails(); // Set any posted variables | |
| 275 | 142 | if(!$this->inStep("database")) { |
| 276 | 143 | $this->doRun(); |
| 277 | 144 | return 'landing'; |
| 278 | 145 | } |
| 279 | 146 | if($this->next()) { |
| 280 | - if ($this->doRun()) { | |
| 281 | - return 'next'; | |
| 282 | - } | |
| 147 | + $this->doRun('preview'); | |
| 148 | + return 'next'; | |
| 283 | 149 | } else if($this->previous()) { |
| 284 | 150 | return 'previous'; |
| 285 | 151 | } |
| 286 | - else if ($this->backup()) { | |
| 287 | - return 'backup'; | |
| 288 | - } | |
| 289 | - else if ($this->restore()) { | |
| 290 | - return 'restore'; | |
| 291 | - } | |
| 292 | - else if ($this->upgrading()) { | |
| 293 | - $this->doRun('runUpgrade'); | |
| 152 | + else if ($this->confirmUpgrade()) { | |
| 153 | + $this->doRun('confirm'); | |
| 294 | 154 | return 'next'; |
| 295 | 155 | } |
| 296 | - else if ($this->confirm()) { | |
| 297 | - if ($this->doRun('confirm')) { | |
| 156 | + else if ($this->upgrading()) { | |
| 157 | + if ($this->doRun('runUpgrade')) { | |
| 298 | 158 | return 'next'; |
| 299 | 159 | } |
| 300 | 160 | return 'error'; |
| ... | ... | @@ -304,19 +164,15 @@ class upgradeDatabase extends Step |
| 304 | 164 | return 'landing'; |
| 305 | 165 | } |
| 306 | 166 | |
| 307 | - function backup() { | |
| 308 | - return isset($_POST['Backup']); | |
| 167 | + private function confirmUpgrade() { | |
| 168 | + return isset($_POST['ConfirmUpgrade']); | |
| 309 | 169 | } |
| 310 | - | |
| 311 | - function restore() { | |
| 312 | - return isset($_POST['Restore']); | |
| 313 | - } | |
| 314 | - | |
| 315 | - function upgrading() { | |
| 170 | + | |
| 171 | + private function upgrading() { | |
| 316 | 172 | return isset($_POST['RunUpgrade']); |
| 317 | 173 | } |
| 318 | 174 | |
| 319 | - function doRun($action = null) { | |
| 175 | + private function doRun($action = null) { | |
| 320 | 176 | $this->readConfig(KTConfig::getConfigFilename()); |
| 321 | 177 | |
| 322 | 178 | if($this->dbSettings['dbPort'] == '') { |
| ... | ... | @@ -327,21 +183,18 @@ class upgradeDatabase extends Step |
| 327 | 183 | $this->dbSettings['dbPass'], $this->dbSettings['dbName']); |
| 328 | 184 | } |
| 329 | 185 | |
| 186 | + $this->temp_variables['action'] = $action; | |
| 330 | 187 | if (is_null($action) || ($action == 'preview')) { |
| 331 | - $this->temp_variables['action'] = 'preview'; | |
| 332 | 188 | $this->temp_variables['title'] = 'Preview Upgrade'; |
| 333 | 189 | $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); |
| 334 | 190 | } |
| 335 | - else if ($action == 'runUpgrade') { | |
| 336 | - $this->temp_variables['action'] = 'runUpgrade'; | |
| 191 | + else if ($action == 'confirm') { | |
| 337 | 192 | $this->temp_variables['title'] = 'Confirm Upgrade'; |
| 338 | 193 | $this->temp_variables['upgradeTable'] = $this->upgradeConfirm(); |
| 339 | 194 | } |
| 340 | - else if ($action == 'confirm') { | |
| 341 | - $this->temp_variables['action'] = 'confirm'; | |
| 195 | + else if ($action == 'runUpgrade') { | |
| 342 | 196 | $this->temp_variables['title'] = 'Upgrade In Progress'; |
| 343 | - if (!$this->upgrade()) { | |
| 344 | - $this->temp_variables['upgradeTable'] = $this->upgradeErrors(); | |
| 197 | + if (!$this->upgradeDatabase()) { | |
| 345 | 198 | return false; |
| 346 | 199 | } |
| 347 | 200 | } |
| ... | ... | @@ -349,7 +202,7 @@ class upgradeDatabase extends Step |
| 349 | 202 | return true; |
| 350 | 203 | } |
| 351 | 204 | |
| 352 | - public function generateUpgradeTable() { | |
| 205 | + private function generateUpgradeTable() { | |
| 353 | 206 | global $default; |
| 354 | 207 | |
| 355 | 208 | $this->temp_variables['systemVersion'] = $default->systemVersion; |
| ... | ... | @@ -372,7 +225,7 @@ class upgradeDatabase extends Step |
| 372 | 225 | $ret .= sprintf("<tr bgcolor='$color'><td>%s</td><td>%s</td><td>%s</td></tr>\n", |
| 373 | 226 | htmlspecialchars($upgrade->getDescriptor()), |
| 374 | 227 | htmlspecialchars($upgrade->getDescription()), |
| 375 | - $upgrade->isAlreadyApplied() ? "Yes" : "No" | |
| 228 | + $upgrade->isAlreadyApplied() ? "Yes" : "No" | |
| 376 | 229 | ); |
| 377 | 230 | } |
| 378 | 231 | $ret .= '</table>'; |
| ... | ... | @@ -380,42 +233,6 @@ class upgradeDatabase extends Step |
| 380 | 233 | } |
| 381 | 234 | |
| 382 | 235 | /** |
| 383 | - * Store options | |
| 384 | - * | |
| 385 | - * @author KnowledgeTree Team | |
| 386 | - * @params object SimpleXmlObject | |
| 387 | - * @access private | |
| 388 | - * @return void | |
| 389 | - */ | |
| 390 | - private function setDetails() { | |
| 391 | - // create lock file to indicate Upgrade mode | |
| 392 | - $this->createUpgradeFile(); | |
| 393 | - } | |
| 394 | - | |
| 395 | - /** | |
| 396 | - * Creates miUpgradeock file so that system knows it is supposed to run an upgrade installation | |
| 397 | - * | |
| 398 | - * @author KnowledgeTree Team | |
| 399 | - * @access private | |
| 400 | - * @return void | |
| 401 | - */ | |
| 402 | - private function createUpgradeFile() { | |
| 403 | - @touch($this->wizardLocation . DIRECTORY_SEPARATOR . "upgrade.lock"); | |
| 404 | - } | |
| 405 | - | |
| 406 | - /** | |
| 407 | - * Safer way to return post data | |
| 408 | - * | |
| 409 | - * @author KnowledgeTree Team | |
| 410 | - * @params SimpleXmlObject $simplexml | |
| 411 | - * @access public | |
| 412 | - * @return void | |
| 413 | - */ | |
| 414 | - public function getPostSafe($key) { | |
| 415 | - return isset($_POST[$key]) ? $_POST[$key] : ""; | |
| 416 | - } | |
| 417 | - | |
| 418 | - /** | |
| 419 | 236 | * Stores varibles used by template |
| 420 | 237 | * |
| 421 | 238 | * @author KnowledgeTree Team |
| ... | ... | @@ -465,100 +282,161 @@ class upgradeDatabase extends Step |
| 465 | 282 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], |
| 466 | 283 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], |
| 467 | 284 | ); |
| 468 | -// $ktSettings = $ini->getSection('KnowledgeTree'); | |
| 469 | -// $froot = $ktSettings['fileSystemRoot']; | |
| 470 | -// if ($froot == 'default') { | |
| 471 | -// $froot = $this->location; | |
| 472 | -// } | |
| 473 | -// $this->ktSettings = array('fileSystemRoot'=> $froot, | |
| 474 | -// ); | |
| 475 | -// $urlPaths = $ini->getSection('urls'); | |
| 476 | -// $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $froot.DS.'var'), | |
| 477 | -// array('name'=> 'Log Directory', 'path'=> $froot.DS.'log'), | |
| 478 | -// array('name'=> 'Document Root', 'path'=> $froot.DS.'Documents'), | |
| 479 | -// array('name'=> 'UI Directory', 'path'=> $froot.DS.'presentation'.DS.'lookAndFeel'.DS.'knowledgeTree'), | |
| 480 | -// array('name'=> 'Temporary Directory', 'path'=> $froot.DS.'tmp'), | |
| 481 | -// array('name'=> 'Cache Directory', 'path'=> $froot.DS.'cache'), | |
| 482 | -// ); | |
| 483 | -// $this->temp_variables['urlPaths'] = $this->urlPaths; | |
| 484 | -// $this->temp_variables['ktSettings'] = $this->ktSettings; | |
| 485 | 285 | $this->temp_variables['dbSettings'] = $this->dbSettings; |
| 486 | 286 | } |
| 487 | 287 | |
| 488 | - function upgradeConfirm() | |
| 288 | + private function upgradeConfirm() | |
| 489 | 289 | { |
| 490 | - if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) | |
| 491 | - { | |
| 290 | + if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) { | |
| 492 | 291 | $this->temp_variables['backupStatus'] = false; |
| 493 | 292 | } |
| 293 | + else { | |
| 294 | + $this->temp_variables['backupStatus'] = true; | |
| 295 | + } | |
| 494 | 296 | } |
| 495 | 297 | |
| 496 | - | |
| 497 | -function upgrade() | |
| 498 | -{ | |
| 499 | - global $default; | |
| 500 | -?> | |
| 501 | - <p>The table below describes the upgrades that have occurred to | |
| 502 | - upgrade your <?php echo APP_NAME;?> installation to <strong><?php echo $default->systemVersion;?></strong>. | |
| 503 | - | |
| 504 | - <?php | |
| 505 | - $pre_res = performPreUpgradeActions(); | |
| 506 | - if (PEAR::isError($pre_res)) | |
| 298 | + private function upgradeDatabase() | |
| 507 | 299 | { |
| 508 | -?> | |
| 509 | -<font color="red">Pre-Upgrade actions failed.</font><br/> | |
| 510 | -<?php | |
| 511 | - } | |
| 512 | - else | |
| 513 | - { | |
| 514 | -?> | |
| 515 | -<p> | |
| 516 | -<font color="green">Pre-Upgrade actions succeeded.</font><br/> | |
| 517 | -<?php | |
| 300 | + global $default; | |
| 301 | + | |
| 302 | + $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to | |
| 303 | + upgrade your KnowledgeTree installation to <strong>' . $default->systemVersion . '</strong>'; | |
| 304 | + | |
| 305 | + $pre_res = $this->performPreUpgradeActions(); | |
| 306 | + if (PEAR::isError($pre_res)) { | |
| 307 | + $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>'; | |
| 308 | + } | |
| 309 | + else { | |
| 310 | + $this->temp_variables['preUpgrade'] = '<font color="green">Pre-Upgrade actions succeeded.</font>'; | |
| 311 | + | |
| 312 | + } | |
| 313 | + | |
| 314 | + $res = $this->performAllUpgrades(); | |
| 315 | + if (PEAR::isError($res) || PEAR::isError($pres)) { | |
| 316 | + // TODO instantiate error details hideable section | |
| 317 | + $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font> | |
| 318 | + <br/><br/> | |
| 319 | + Please restore from your backup and ensure that the database does not contain | |
| 320 | + any unsupported modifications and try the upgrade process again. | |
| 321 | + <br/><br/> | |
| 322 | + If the problem persists, contact KnowledgeTree Support.'; | |
| 323 | + } | |
| 324 | + else { | |
| 325 | + $this->temp_variables['upgradeStatus'] = '<font color="green">Upgrade succeeded.</font>'; | |
| 326 | + } | |
| 327 | + | |
| 328 | + $post_pres = $this->performPostUpgradeActions(); | |
| 329 | + if (PEAR::isError($post_res)) { | |
| 330 | + $this->temp_variables['postUpgrade'] = '<font color="red">Post-Upgrade actions failed.</font>'; | |
| 331 | + } | |
| 332 | + else { | |
| 333 | + $this->temp_variables['postUpgrade'] = '<font color="green">Post-Upgrade actions succeeded.</font>'; | |
| 334 | + } | |
| 518 | 335 | } |
| 519 | -?> | |
| 520 | -<p> | |
| 521 | - <?php | |
| 522 | - $res = performAllUpgrades(); | |
| 523 | - if (PEAR::isError($res) || PEAR::isError($pres)) | |
| 524 | - { | |
| 525 | -?> | |
| 526 | -<font color="red">Upgrade failed.</font> | |
| 527 | -<?php | |
| 336 | + | |
| 337 | + private function performPreUpgradeActions() { | |
| 338 | + | |
| 339 | + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. | |
| 340 | + // It should idealy work the same as the upgrades. | |
| 341 | + | |
| 342 | + global $default; | |
| 343 | + | |
| 344 | + // Lock the scheduler | |
| 345 | + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 346 | + touch($lockFile); | |
| 347 | + return true; | |
| 348 | + | |
| 528 | 349 | } |
| 529 | - else | |
| 530 | - { | |
| 531 | -?> | |
| 532 | -<p> | |
| 533 | -<font color="green">Upgrade succeeded.</font> | |
| 534 | -<?php | |
| 350 | + | |
| 351 | + private function performPostUpgradeActions() { | |
| 352 | + | |
| 353 | + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. | |
| 354 | + // It should idealy work the same as the upgrades. | |
| 355 | + | |
| 356 | + global $default; | |
| 357 | + | |
| 358 | + // Ensure all plugins are re-registered. | |
| 359 | + $sql = "TRUNCATE plugin_helper"; | |
| 360 | + $res = DBUtil::runQuery($sql); | |
| 361 | + | |
| 362 | + // Clear out all caches and proxies - they need to be regenerated with the new code | |
| 363 | + $proxyDir = $default->proxyCacheDirectory; | |
| 364 | + KTUtil::deleteDirectory($proxyDir); | |
| 365 | + | |
| 366 | + $oKTCache = new KTCache(); | |
| 367 | + $oKTCache->deleteAllCaches(); | |
| 368 | + | |
| 369 | + // Clear the configuration cache, it'll regenerate on next load | |
| 370 | + $oKTConfig = new KTConfig(); | |
| 371 | + $oKTConfig->clearCache(); | |
| 372 | + | |
| 373 | + // Unlock the scheduler | |
| 374 | + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 375 | + if(file_exists($lockFile)){ | |
| 376 | + @unlink($lockFile); | |
| 377 | + } | |
| 378 | + | |
| 379 | + return true; | |
| 380 | + | |
| 535 | 381 | } |
| 536 | -?> | |
| 537 | -<p> | |
| 538 | - <?php | |
| 539 | - $post_pres = performPostUpgradeActions(); | |
| 540 | - if (PEAR::isError($post_res)) | |
| 541 | - { | |
| 542 | -?> | |
| 543 | -<font color="red">Post-Upgrade actions failed.</font><br/><br/> | |
| 544 | -<?php | |
| 382 | + | |
| 383 | + private function performAllUpgrades () { | |
| 384 | + global $default; | |
| 385 | + | |
| 386 | + $row = 1; | |
| 387 | + | |
| 388 | + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | |
| 389 | + $lastVersion = DBUtil::getOneResultKey($query, 'value'); | |
| 390 | + $currentVersion = $default->systemVersion; | |
| 391 | + | |
| 392 | + $upgrades = describeUpgrade($lastVersion, $currentVersion); | |
| 393 | + | |
| 394 | + $this->temp_variables['upgradeTable'] = ''; | |
| 395 | + | |
| 396 | + foreach ($upgrades as $upgrade) { | |
| 397 | + if (($row % 2) == 1) { | |
| 398 | + $class = "odd"; | |
| 399 | + } else { | |
| 400 | + $class = "even"; | |
| 401 | + } | |
| 402 | + $this->temp_variables['upgradeTable'] .= sprintf('<div class="row %s"><div class="foo">%s</div>' . "\n", $class, | |
| 403 | + htmlspecialchars($upgrade->getDescription())); | |
| 404 | + ++$row; | |
| 405 | + $res = $upgrade->performUpgrade(); | |
| 406 | + $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res)); | |
| 407 | + $this->temp_variables['upgradeTable'] .= '<br style="clear: both">' . "\n"; | |
| 408 | + $this->temp_variables['upgradeTable'] .= "</div>\n"; | |
| 409 | + if (PEAR::isError($res)) { | |
| 410 | + if (!is_a($res, 'Upgrade_Already_Applied')) { | |
| 411 | + break; | |
| 412 | + } else { | |
| 413 | + $res = true; | |
| 414 | + } | |
| 415 | + } | |
| 416 | + if ($res === false) { | |
| 417 | + $res = PEAR::raiseError("Upgrade returned false"); | |
| 418 | + break; | |
| 419 | + } | |
| 420 | + } | |
| 421 | + | |
| 422 | + return $res; | |
| 545 | 423 | } |
| 546 | - else | |
| 547 | - { | |
| 548 | -?> | |
| 549 | -<p> | |
| 550 | -<font color="green">Post-Upgrade actions succeeded.</font><br/><br/> | |
| 551 | -<script type="text/javascript"> | |
| 552 | - alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'next' at the bottom of this page to continue.") | |
| 553 | -</script> | |
| 554 | -<?php | |
| 424 | + | |
| 425 | + private function showResult($res) { | |
| 426 | + if (PEAR::isError($res)) { | |
| 427 | + if (is_a($res, 'Upgrade_Already_Applied')) { | |
| 428 | + return '<span style="color: orange">Already applied</span>'; | |
| 429 | + } | |
| 430 | + return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString())); | |
| 431 | + } | |
| 432 | + if ($res === true) { | |
| 433 | + return '<span style="color: green">Success</span>'; | |
| 434 | + } | |
| 435 | + if ($res === false) { | |
| 436 | + return '<span style="color: red">Failure</span>'; | |
| 437 | + } | |
| 438 | + return $res; | |
| 555 | 439 | } |
| 556 | -?> | |
| 557 | - | |
| 558 | - <input type=button value="back" onclick="javascript:do_start('home')"> | |
| 559 | - <input type=button value="next" onclick="javascript:document.location='..';"> | |
| 560 | -<?php | |
| 561 | -} | |
| 562 | 440 | |
| 563 | 441 | } |
| 564 | 442 | ?> |
| 565 | 443 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeInstallation.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Upgrade Step Controller. | |
| 3 | +* Notification Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -50,15 +50,24 @@ class UpgradeInstallation extends step |
| 50 | 50 | * @var array |
| 51 | 51 | */ |
| 52 | 52 | protected $silent = false; |
| 53 | + protected $temp_variables = array(); | |
| 53 | 54 | |
| 54 | - function __construct() { | |
| 55 | - $this->temp_variables = array("step_name"=>"welcome"); | |
| 55 | + public function __construct() { | |
| 56 | + $this->temp_variables = array("step_name"=>"installation"); | |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | - function doStep() { | |
| 59 | + public function doStep() { | |
| 59 | 60 | parent::doStep(); |
| 60 | 61 | if($this->next()) { |
| 61 | - return 'next'; // Just a welcome, so return "next" action | |
| 62 | + return 'next'; | |
| 63 | + } | |
| 64 | + else if ($this->restore()) { | |
| 65 | + header('Location: index.php?step_name=restore'); | |
| 66 | + exit; | |
| 67 | + } | |
| 68 | + else if ($this->upgrade()) { | |
| 69 | + header('Location: index.php?step_name=database'); | |
| 70 | + exit; | |
| 62 | 71 | } |
| 63 | 72 | |
| 64 | 73 | return 'landing'; | ... | ... |
setup/upgrade/steps/upgradeRestore.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Complete Step Controller. | |
| 3 | +* Restore Step Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -53,10 +53,8 @@ class upgradeRestore extends Step { |
| 53 | 53 | */ |
| 54 | 54 | private $_dbhandler = null; |
| 55 | 55 | |
| 56 | - private $privileges_check = 'tick'; | |
| 57 | - private $database_check = 'tick'; | |
| 58 | - protected $silent = true; | |
| 59 | - | |
| 56 | + protected $silent = false; | |
| 57 | + protected $temp_variables = array(); | |
| 60 | 58 | protected $util = null; |
| 61 | 59 | |
| 62 | 60 | public function __construct() { |
| ... | ... | @@ -65,8 +63,10 @@ class upgradeRestore extends Step { |
| 65 | 63 | $this->util = new UpgradeUtil(); |
| 66 | 64 | } |
| 67 | 65 | |
| 68 | - function doStep() { | |
| 66 | + public function doStep() { | |
| 69 | 67 | parent::doStep(); |
| 68 | + $this->temp_variables['restore'] = false; | |
| 69 | + | |
| 70 | 70 | if(!$this->inStep("restore")) { |
| 71 | 71 | $this->doRun(); |
| 72 | 72 | return 'landing'; |
| ... | ... | @@ -78,22 +78,40 @@ class upgradeRestore extends Step { |
| 78 | 78 | } else if($this->previous()) { |
| 79 | 79 | return 'previous'; |
| 80 | 80 | } |
| 81 | + else if ($this->restoreNow()) { | |
| 82 | + $this->temp_variables['restoreSuccessful'] = false; | |
| 83 | + $this->doRun(true); | |
| 84 | + return 'next'; | |
| 85 | + } | |
| 81 | 86 | |
| 82 | 87 | $this->doRun(); |
| 83 | 88 | return 'landing'; |
| 84 | 89 | } |
| 85 | 90 | |
| 86 | - function doRun() { | |
| 87 | - if ($this->select()) { | |
| 88 | - $this->restoreSelected(); | |
| 91 | + private function restoreNow() { | |
| 92 | + return isset($_POST['RunRestore']); | |
| 93 | + } | |
| 94 | + | |
| 95 | + private function doRun($restore = false) { | |
| 96 | + if (!$restore) { | |
| 97 | + $this->temp_variables['selected'] = false; | |
| 98 | + if ($this->select()) { | |
| 99 | + $this->restoreSelected(); | |
| 100 | + $this->temp_variables['selected'] = true; | |
| 101 | + $this->temp_variables['availableBackups'] = true; | |
| 102 | + } | |
| 103 | + $this->restoreConfirm(); | |
| 104 | + } // end not running a restore, just setting up | |
| 105 | + else { | |
| 106 | + $this->restoreDatabase(); | |
| 89 | 107 | } |
| 90 | - $this->restoreConfirm(); | |
| 108 | + | |
| 91 | 109 | $this->storeSilent();// Set silent mode variables |
| 92 | 110 | |
| 93 | 111 | return true; |
| 94 | 112 | } |
| 95 | 113 | |
| 96 | - function select() { | |
| 114 | + private function select() { | |
| 97 | 115 | return isset($_POST['RestoreSelect']); |
| 98 | 116 | } |
| 99 | 117 | |
| ... | ... | @@ -103,332 +121,126 @@ class upgradeRestore extends Step { |
| 103 | 121 | */ |
| 104 | 122 | private function storeSilent() { |
| 105 | 123 | } |
| 106 | - | |
| 107 | - function restore() | |
| 108 | -{ | |
| 109 | - check_state(1); | |
| 110 | - set_state(5); | |
| 111 | -// title('Restore In Progress'); | |
| 112 | - $status = $_SESSION['backupStatus']; | |
| 113 | - $filename=$_SESSION['backupFile']; | |
| 114 | - $stmt=create_restore_stmt($filename); | |
| 115 | - $dir=$stmt['dir']; | |
| 116 | - | |
| 117 | - | |
| 118 | 124 | |
| 119 | - | |
| 120 | - if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) | |
| 125 | + private function restoreDatabase() | |
| 121 | 126 | { |
| 122 | - | |
| 123 | -?> | |
| 124 | - The restore is now underway. Please wait till it completes. | |
| 125 | -<?php | |
| 126 | - print "\n"; | |
| 127 | - | |
| 128 | - | |
| 129 | - $curdir=getcwd(); | |
| 130 | - chdir($dir); | |
| 131 | - | |
| 132 | - | |
| 133 | - $ok=true; | |
| 134 | - $stmts=explode("\n",$stmt['cmd']); | |
| 135 | - foreach($stmts as $stmt) | |
| 127 | + $this->temp_variables['restore'] = true; | |
| 128 | + $status = $_SESSION['backupStatus']; | |
| 129 | + $filename = $_SESSION['backupFile']; | |
| 130 | + $stmt = $this->util->create_restore_stmt($filename); | |
| 131 | + $dir = $stmt['dir']; | |
| 132 | + | |
| 133 | + if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) | |
| 136 | 134 | { |
| 137 | - | |
| 138 | - $handle = popen($stmt, 'r'); | |
| 139 | - if ($handle=='false') | |
| 135 | + $curdir=getcwd(); | |
| 136 | + chdir($dir); | |
| 137 | + | |
| 138 | + $ok=true; | |
| 139 | + $stmts=explode("\n",$stmt['cmd']); | |
| 140 | + foreach($stmts as $stmt) | |
| 140 | 141 | { |
| 141 | - $ok=false; | |
| 142 | - break; | |
| 142 | + | |
| 143 | + $handle = popen($stmt, 'r'); | |
| 144 | + if ($handle=='false') | |
| 145 | + { | |
| 146 | + $ok=false; | |
| 147 | + break; | |
| 148 | + } | |
| 149 | + $read = fread($handle, 10240); | |
| 150 | + pclose($handle); | |
| 151 | + $_SESSION['restoreOutput']=$read; | |
| 143 | 152 | } |
| 144 | - $read = fread($handle, 10240); | |
| 145 | - pclose($handle); | |
| 146 | - $_SESSION['restoreOutput']=$read; | |
| 147 | - } | |
| 148 | - | |
| 149 | - | |
| 150 | - | |
| 151 | - | |
| 152 | - | |
| 153 | + | |
| 153 | 154 | $_SESSION['restoreStatus'] = $ok; |
| 154 | - | |
| 155 | - | |
| 156 | -?> | |
| 157 | - <script type="text/javascript"> | |
| 158 | - document.location="?go=RestoreDone"; | |
| 159 | - </script> | |
| 160 | -<?php | |
| 161 | - | |
| 162 | - | |
| 163 | - } | |
| 164 | - else | |
| 165 | - { | |
| 166 | -?> | |
| 167 | -<P> | |
| 168 | - The <i>mysql</i> utility was not found in the <?php echo $dir;?> subdirectory. | |
| 169 | - | |
| 170 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 171 | -<?php | |
| 172 | - } | |
| 173 | - | |
| 174 | - | |
| 175 | - | |
| 176 | -} | |
| 177 | - | |
| 178 | - | |
| 179 | -function restoreDone() | |
| 180 | -{ | |
| 181 | - check_state(5); | |
| 182 | - set_state(6); | |
| 183 | -// title('Restore Status'); | |
| 184 | - $status = $_SESSION['restoreStatus']; | |
| 185 | - $filename=$_SESSION['backupFile']; | |
| 186 | - | |
| 187 | - if ($status) | |
| 188 | - { | |
| 189 | - | |
| 190 | -?> | |
| 191 | - The restore of <nobr><i>"<?php echo $filename;?>"</i></nobr> has been completed. | |
| 192 | - <P> | |
| 193 | - It appears as though the <font color=green>restore has been successful</font>. | |
| 194 | - <P> | |
| 195 | - | |
| 196 | - | |
| 197 | - | |
| 198 | -<?php | |
| 199 | - } | |
| 200 | - else | |
| 201 | - { | |
| 202 | -?> | |
| 203 | -It appears as though <font color=red>the restore process has failed</font>. <P> | |
| 204 | -Unfortunately, it is difficult to diagnose these problems automatically | |
| 205 | -and would recommend that you try to do the backup process manually. | |
| 206 | -<P> | |
| 207 | -We appologise for the inconvenience. | |
| 208 | -<P> | |
| 209 | -<table bgcolor="lightgrey"> | |
| 210 | -<tr> | |
| 211 | -<td> | |
| 212 | -<?php echo $_SESSION['restoreOutput'];?> | |
| 213 | -</table> | |
| 214 | -<?php | |
| 215 | - | |
| 216 | - } | |
| 217 | -?> | |
| 218 | - | |
| 219 | -<br/> | |
| 220 | - | |
| 221 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 222 | - | |
| 223 | -<?php | |
| 224 | - | |
| 225 | -} | |
| 226 | - | |
| 227 | -function create_restore_stmt($targetfile) | |
| 228 | -{ | |
| 229 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 230 | - | |
| 231 | - $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 232 | - $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 233 | - $dbHost = $oKTConfig->get('db/dbHost'); | |
| 234 | - $dbName = $oKTConfig->get('db/dbName'); | |
| 235 | - $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 236 | - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); | |
| 237 | - if (empty($dbPort)) $dbPort='3306'; | |
| 238 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 239 | - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 240 | - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 241 | - | |
| 242 | - $dir = $this->resolveMysqlDir(); | |
| 243 | - | |
| 244 | - $info['dir']=$dir; | |
| 245 | - | |
| 246 | - $prefix=''; | |
| 247 | - if (OS_UNIX) | |
| 248 | - { | |
| 249 | - $prefix .= "./"; | |
| 250 | - } | |
| 251 | - | |
| 252 | - if (@stat($dbSocket) !== false) | |
| 253 | - { | |
| 254 | - $mechanism="--socket=\"$dbSocket\""; | |
| 255 | - } | |
| 256 | - else | |
| 257 | - { | |
| 258 | - $mechanism="--port=\"$dbPort\""; | |
| 259 | - } | |
| 260 | - | |
| 261 | - $tmpdir = $this->resolveTempDir(); | |
| 262 | - | |
| 263 | - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; | |
| 264 | - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; | |
| 265 | - | |
| 266 | - | |
| 267 | - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; | |
| 268 | - $info['display']=$stmt; | |
| 269 | - | |
| 270 | - | |
| 271 | - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; | |
| 272 | - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; | |
| 273 | - | |
| 274 | - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; | |
| 275 | - $info['cmd']=$stmt; | |
| 276 | - return $info; | |
| 277 | -} | |
| 278 | - | |
| 279 | -function resolveMysqlDir() | |
| 280 | -{ | |
| 281 | - // possibly detect existing installations: | |
| 282 | - | |
| 283 | - if (OS_UNIX) | |
| 284 | - { | |
| 285 | - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); | |
| 286 | - $mysqlname ='mysql'; | |
| 287 | - } | |
| 288 | - else | |
| 289 | - { | |
| 290 | - $dirs = explode(';', $_SERVER['PATH']); | |
| 291 | - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; | |
| 292 | - $dirs[] = 'c:/program files/ktdms/mysql/bin'; | |
| 293 | - $mysqlname ='mysql.exe'; | |
| 294 | - } | |
| 295 | - | |
| 296 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 297 | - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); | |
| 298 | - $dirs[] = $mysqldir; | |
| 299 | - | |
| 300 | - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) | |
| 301 | - { | |
| 302 | - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); | |
| 155 | + // should be some sort of error checking, really | |
| 156 | + $this->restoreDone(); | |
| 157 | + } | |
| 303 | 158 | } |
| 304 | 159 | |
| 305 | - foreach($dirs as $dir) | |
| 160 | + private function restoreDone() | |
| 306 | 161 | { |
| 307 | - if (is_file($dir . '/' . $mysqlname)) | |
| 162 | + $status = $_SESSION['restoreStatus']; | |
| 163 | + $filename = $_SESSION['backupFile']; | |
| 164 | + | |
| 165 | + if ($status) | |
| 308 | 166 | { |
| 309 | - return $dir; | |
| 167 | + $this->temp_variables['display'] = 'The restore of <nobr><i>"' . $filename . '"</i></nobr> has been completed. | |
| 168 | + <P> | |
| 169 | + It appears as though the <font color=green>restore has been successful</font>. | |
| 170 | + <P>'; | |
| 171 | + | |
| 172 | + $this->temp_variables['title'] = 'Restore Complete'; | |
| 173 | + $this->temp_variables['restoreSuccessful'] = true; | |
| 174 | + } | |
| 175 | + else | |
| 176 | + { | |
| 177 | + $this->temp_variables['display'] = 'It appears as though <font color=red>the restore process has failed</font>. <P> | |
| 178 | + Unfortunately, it is difficult to diagnose these problems automatically | |
| 179 | + and would recommend that you try to do the backup process manually. | |
| 180 | + <P> | |
| 181 | + We appologise for the inconvenience. | |
| 182 | + <P> | |
| 183 | + <table bgcolor="lightgrey"> | |
| 184 | + <tr> | |
| 185 | + <td>' . $_SESSION['restoreOutput'] . ' | |
| 186 | + </table>'; | |
| 187 | + $this->temp_variables['title'] = 'Restore Failed'; | |
| 188 | + $this->temp_variables['restoreSuccessful'] = false; | |
| 310 | 189 | } |
| 311 | 190 | } |
| 312 | - | |
| 313 | - return ''; | |
| 314 | -} | |
| 315 | - | |
| 316 | -function resolveTempDir() | |
| 317 | -{ | |
| 318 | - | |
| 319 | - if (OS_UNIX) | |
| 320 | - { | |
| 321 | - $dir='/tmp/kt-db-backup'; | |
| 322 | - } | |
| 323 | - else | |
| 324 | - { | |
| 325 | - $dir='c:/kt-db-backup'; | |
| 326 | - } | |
| 327 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 328 | - $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 329 | - | |
| 330 | - if (!is_dir($dir)) | |
| 331 | - { | |
| 332 | - mkdir($dir); | |
| 333 | - } | |
| 334 | - return $dir; | |
| 335 | -} | |
| 336 | - | |
| 337 | - | |
| 338 | -function restoreSelect() | |
| 339 | -{ | |
| 340 | -// title('Select Backup to Restore'); | |
| 341 | - | |
| 342 | - $dir = $this->resolveTempDir(); | |
| 343 | - | |
| 344 | - $files = array(); | |
| 345 | - if ($dh = opendir($dir)) | |
| 191 | + | |
| 192 | + private function restoreSelect() | |
| 346 | 193 | { |
| 347 | - while (($file = readdir($dh)) !== false) | |
| 194 | + $this->temp_variables['availableBackups'] = false; | |
| 195 | + $dir = $this->util->resolveTempDir(); | |
| 196 | + | |
| 197 | + $files = array(); | |
| 198 | + if ($dh = opendir($dir)) | |
| 348 | 199 | { |
| 349 | - if (!preg_match('/kt-backup.+\.sql/',$file)) | |
| 200 | + while (($file = readdir($dh)) !== false) | |
| 350 | 201 | { |
| 351 | - continue; | |
| 202 | + if (!preg_match('/kt-backup.+\.sql/',$file)) { | |
| 203 | + continue; | |
| 204 | + } | |
| 205 | + $files[] = $file; | |
| 352 | 206 | } |
| 353 | - $files[] = $file; | |
| 207 | + closedir($dh); | |
| 208 | + } | |
| 209 | + | |
| 210 | + $this->temp_variables['title'] = 'Select Backup to Restore'; | |
| 211 | + $this->temp_variables['dir'] = $dir; | |
| 212 | + if (count($files) != 0) { | |
| 213 | + $this->temp_variables['availableBackups'] = true; | |
| 214 | + $this->temp_variables['files'] = $files; | |
| 354 | 215 | } |
| 355 | - closedir($dh); | |
| 356 | - } | |
| 357 | - | |
| 358 | - if (count($files) == 0) | |
| 359 | - { | |
| 360 | - ?> | |
| 361 | - There don't seem to be any backups to restore from the <i>"<?php echo $dir;?>"</i> directory. | |
| 362 | - <?php | |
| 363 | 216 | } |
| 364 | - else | |
| 365 | - { | |
| 366 | - ?> | |
| 367 | - <P> | |
| 368 | - Select a backup to restore from the list below: | |
| 369 | - <P> | |
| 370 | - <form action="index.php?step_name=restore" method="post"> | |
| 371 | - | |
| 372 | - <table border=1 cellpadding=1 cellspacing=1> | |
| 373 | - <tr bgcolor="darkgrey"> | |
| 374 | - <td>Filename | |
| 375 | - <td>File Size | |
| 376 | - <td>Action | |
| 377 | -<?php | |
| 378 | - $i=0; | |
| 379 | - foreach($files as $file) | |
| 217 | + | |
| 218 | + private function restoreSelected() | |
| 380 | 219 | { |
| 381 | - $color=((($i++)%2)==0)?'white':'lightgrey'; | |
| 382 | -?> | |
| 383 | - <tr bgcolor="<?php echo $color;?>"> | |
| 384 | - <td><?php echo $file;?> | |
| 385 | - <td><?php echo filesize($dir . '/'.$file);?> | |
| 386 | - <td><input type="submit" name="RestoreSelect" value="restore"> | |
| 387 | -<?php | |
| 388 | - } | |
| 389 | -?> | |
| 390 | - </table> | |
| 391 | - <input type="hidden" name="file" value="<?php echo $file; ?>" /> | |
| 392 | - </form> | |
| 393 | - <?php | |
| 220 | + $file=$_REQUEST['file']; | |
| 221 | + | |
| 222 | + $dir = $this->util->resolveTempDir(); | |
| 223 | + $_SESSION['backupFile'] = $dir . '/' . $file; | |
| 394 | 224 | } |
| 395 | - ?> | |
| 396 | - | |
| 397 | - <p> | |
| 398 | - <input type=button value="back" onclick="javascript:do_start('welcome')"> | |
| 399 | - <?php | |
| 400 | - | |
| 401 | -} | |
| 402 | - | |
| 403 | -function restoreSelected() | |
| 404 | -{ | |
| 405 | - $file=$_REQUEST['file']; | |
| 406 | - | |
| 407 | - $dir = $this->resolveTempDir(); | |
| 408 | - $_SESSION['backupFile'] = $dir . '/' . $file; | |
| 409 | -?> | |
| 410 | -<?php | |
| 411 | - | |
| 412 | -} | |
| 413 | - | |
| 414 | -function restoreConfirm() | |
| 415 | -{ | |
| 416 | - if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0) | |
| 225 | + | |
| 226 | + private function restoreConfirm() | |
| 417 | 227 | { |
| 418 | - $this->restoreSelect(); | |
| 419 | - exit; | |
| 228 | + if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0) | |
| 229 | + { | |
| 230 | + $this->restoreSelect(); | |
| 231 | + return; | |
| 232 | + } | |
| 233 | + | |
| 234 | + $status = $_SESSION['backupStatus']; | |
| 235 | + $filename = $_SESSION['backupFile']; | |
| 236 | + $stmt = $this->util->create_restore_stmt($filename); | |
| 237 | + | |
| 238 | + $this->temp_variables['title'] = 'Confirm Restore'; | |
| 239 | + $this->temp_variables['dir'] = $stmt['dir']; | |
| 240 | + $this->temp_variables['display'] = $stmt['display']; | |
| 241 | + $this->temp_variables['availableBackups'] = true; | |
| 242 | + $this->temp_variables['selected'] = true; | |
| 420 | 243 | } |
| 421 | 244 | |
| 422 | - $status = $_SESSION['backupStatus']; | |
| 423 | - $filename=$_SESSION['backupFile']; | |
| 424 | - $stmt = $this->create_restore_stmt($filename); | |
| 425 | - | |
| 426 | - $this->temp_variables['dir'] = $stmt['dir']; | |
| 427 | - $this->temp_variables['display'] = $stmt['display']; | |
| 428 | -} | |
| 429 | - | |
| 430 | - | |
| 431 | - | |
| 432 | - | |
| 433 | 245 | } |
| 434 | 246 | ?> |
| 435 | 247 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeWelcome.php
| ... | ... | @@ -40,14 +40,13 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -global $default; | |
| 44 | -// include defaults | |
| 45 | 43 | include '../../config/dmsDefaults.php'; |
| 46 | 44 | require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; |
| 47 | 45 | |
| 48 | 46 | class upgradeWelcome extends step { |
| 49 | 47 | |
| 50 | - protected $silent = true; | |
| 48 | + protected $silent = false; | |
| 49 | + protected $temp_variables = array(); | |
| 51 | 50 | |
| 52 | 51 | public function __construct() { |
| 53 | 52 | $this->temp_variables = array("step_name"=>"welcome"); |
| ... | ... | @@ -76,7 +75,6 @@ class upgradeWelcome extends step { |
| 76 | 75 | if (!$authenticated) |
| 77 | 76 | { |
| 78 | 77 | session_unset(); |
| 79 | -// loginFailed(_kt('Could not authenticate administrative user')); | |
| 80 | 78 | return false; |
| 81 | 79 | } |
| 82 | 80 | ... | ... |
setup/upgrade/templates/backup.tpl
| 1 | 1 | <form action="index.php?step_name=backup" method="post"> |
| 2 | - <p class="title">Confirm Backup</p> | |
| 2 | + <p class="title"><?php echo $title; ?></p> | |
| 3 | 3 | |
| 4 | 4 | <?php |
| 5 | 5 | if($errors || $warnings){ |
| ... | ... | @@ -12,20 +12,22 @@ |
| 12 | 12 | <br/><br/> |
| 13 | 13 | <div> |
| 14 | 14 | <?php |
| 15 | -if ($dir != '') { | |
| 16 | -?> | |
| 17 | - Are you sure you want to perform the backup? | |
| 18 | - | |
| 19 | -<p> | |
| 20 | -Your mysql installation has been resolved. Manually, you would do the following: | |
| 21 | - </p> | |
| 22 | -<p> | |
| 23 | -<table bgcolor="lightgrey"> | |
| 24 | -<tr> | |
| 25 | -<td> | |
| 26 | -<nobr>cd "<?php echo $dir; ?>"</nobr> | |
| 27 | -<br/> | |
| 28 | -</p><?php | |
| 15 | + if ($dir != '') { | |
| 16 | + if (!$backupStatus) { | |
| 17 | + ?> | |
| 18 | + Are you sure you want to perform the backup? | |
| 19 | + | |
| 20 | + <p> | |
| 21 | + Your mysql installation has been resolved. Manually, you would do the following: | |
| 22 | + </p> | |
| 23 | + <p> | |
| 24 | + <table bgcolor="lightgrey"> | |
| 25 | + <tr> | |
| 26 | + <td> | |
| 27 | + <nobr>cd "<?php echo $dir; ?>"</nobr> | |
| 28 | + <br/> | |
| 29 | + </p><?php | |
| 30 | + } | |
| 29 | 31 | } |
| 30 | 32 | else |
| 31 | 33 | { |
| ... | ... | @@ -42,17 +44,23 @@ You can continue to do the backup manually using the following process: |
| 42 | 44 | ?><nobr><?php echo $display; ?></nobr> |
| 43 | 45 | </table> |
| 44 | 46 | <P> |
| 45 | - <?php if($silent) { ?> | |
| 46 | - </div> | |
| 47 | - <?php } ?> | |
| 48 | 47 | </div> |
| 49 | - <?php | |
| 48 | + </div> | |
| 49 | + <?php | |
| 50 | 50 | if ($dir != '') |
| 51 | 51 | { |
| 52 | -?><input type="submit" name="Next" value="Next" class="button_next"><?php | |
| 52 | + if (($action == '') || ($action == 'confirm')) { | |
| 53 | + ?><input type="submit" name="BackupNow" value="Next" class="button_next"><?php | |
| 54 | + } | |
| 55 | + else if ($backupStatus) { | |
| 56 | + ?><input type="submit" name="Next" value="Restore" class="button_next"> | |
| 57 | + <input type="submit" name="Upgrade" value="Upgrade" class="button_next"><?php | |
| 58 | + } | |
| 59 | + else { | |
| 60 | + ?><input type="submit" name="Next" value="Next" class="button_next"><?php | |
| 61 | + } | |
| 53 | 62 | } |
| 54 | 63 | |
| 55 | 64 | ?> |
| 56 | 65 | <input type="submit" name="Previous" value="Back" class="button_previous"> |
| 57 | - </div> | |
| 58 | 66 | </form> |
| 59 | 67 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/complete.tpl
| 1 | +<?php global $default; ?> | |
| 1 | 2 | <form> |
| 2 | - <p class="title">Upgrade Completed</p> | |
| 3 | + <p class="title">Database Upgrade Completed</p> | |
| 3 | 4 | |
| 4 | - <p class="description">This allows you to check that your KnowledgeTree configuration is set | |
| 5 | - up correctly. You can run this at any time after configuration to check | |
| 6 | - that things are still set up correctly.</p> | |
| 7 | - | |
| 8 | - <?php | |
| 9 | - if($errors || $warnings){ | |
| 10 | - echo '<div>' | |
| 11 | - . '<a href="http://wiki.knowledgetree.com/Web_Based_Upgrader#Post_Upgrade" target="_blank">' | |
| 12 | - . 'Click Here for help on overcoming post Upgrade issues</a></div><br/>'; | |
| 13 | - } | |
| 14 | - ?> | |
| 15 | 5 | <div id="step_content_complete" class="step"> |
| 16 | 6 | <!-- Services --> |
| 17 | 7 | <br/><br/> |
| 18 | 8 | <div> |
| 19 | - <h3><?php echo "<span class='{$services_check}'> </span>"; ?>Services</h3> | |
| 20 | - <?php if($silent) { ?> | |
| 21 | - <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div> | |
| 22 | - <div class="services_check" style="display:none"> | |
| 23 | - <?php } ?> | |
| 24 | - <table style="width:755px;"> | |
| 25 | - <tr> | |
| 26 | - <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'> </span>"; ?> </td> | |
| 27 | - <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 28 | - <?php if ($LuceneStatus != 'tick') { ?> | |
| 29 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 30 | - <?php } ?> | |
| 31 | - </tr> | |
| 32 | - <tr> | |
| 33 | - <td> <?php echo "<span class='{$SchedulerStatus}'> </span>"; ?> </td> | |
| 34 | - <td> Scheduler Service <?php if ($LuceneStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 35 | - <?php if ($SchedulerStatus != 'tick') { ?> | |
| 36 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 37 | - <?php } ?> | |
| 38 | - </tr> | |
| 39 | - <tr> | |
| 40 | - <td> <?php echo "<span class='{$OpenOfficeStatus}'> </span>"; ?> </td> | |
| 41 | - <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be stopped <?php } else { ?> Stopped <?php } ?></td> | |
| 42 | - <?php if ($OpenOfficeStatus != 'tick') { ?> | |
| 43 | - <td><a href="javascript:this.location.reload();" class="refresh">Refresh</a></td> | |
| 44 | - <?php } ?> | |
| 45 | - </tr> | |
| 46 | - </table> | |
| 47 | - <?php if($silent) { ?> | |
| 48 | - </div> | |
| 49 | - <?php } ?> | |
| 9 | + Your database has been upgraded to <?php echo $default->systemVersion; ?> | |
| 50 | 10 | </div> |
| 51 | 11 | </div> |
| 52 | - <a href="../wizard" class="buttons back" style="width:100px;">Goto Installer</a> | |
| 12 | + <a href="../../" class="buttons back" style="width:100px;">Goto Login</a> | |
| 53 | 13 | </form> |
| 54 | 14 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/database.tpl
| ... | ... | @@ -6,29 +6,47 @@ |
| 6 | 6 | </div> |
| 7 | 7 | <div id="step_content_database" class="step"> |
| 8 | 8 | <br/><br/> |
| 9 | - <?php if ($action == 'preview') { ?> | |
| 9 | + <?php if (empty($action) || ($action == 'preview')) { ?> | |
| 10 | 10 | <p>The table below describes the upgrades that need to occur to |
| 11 | 11 | upgrade your KnowledgeTree installation to <strong><?php echo $systemVersion;?></strong>. |
| 12 | 12 | Click on the button below the table to perform the upgrades.</p> |
| 13 | 13 | <?php echo $upgradeTable; ?> |
| 14 | 14 | <?php } |
| 15 | - else if ($action == 'runUpgrade') { ?> | |
| 16 | - <br/> | |
| 17 | - <font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font> | |
| 18 | - <p> | |
| 19 | - <br/> | |
| 20 | - <?php } ?> | |
| 21 | - <p> | |
| 22 | - We are about to start the upgrade process. | |
| 23 | - <P> | |
| 15 | + else if ($action == 'confirm') { | |
| 16 | + if (!$backupStatus) { ?> | |
| 17 | + <p>We are about to start the upgrade process.<P> | |
| 18 | + <?php } | |
| 19 | + else { ?> | |
| 20 | + <br/> | |
| 21 | + <font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font> | |
| 22 | + <p> | |
| 23 | + <?php } ?> | |
| 24 | + <?php } | |
| 25 | + else if ($action == 'runUpgrade') { | |
| 26 | + echo $preUpgrade; | |
| 27 | + echo '<br/><br/>'; | |
| 28 | + echo $upgradeTable; | |
| 29 | + echo '<br/><br/>'; | |
| 30 | + echo $postUpgrade; | |
| 31 | + echo '<br/><br/>'; | |
| 32 | + echo $upgradeStatus; | |
| 33 | + echo '<br/><br/>'; | |
| 34 | + } | |
| 35 | + ?> | |
| 24 | 36 | </div> |
| 25 | 37 | </div> |
| 26 | - <?php if ($action == 'preview') { ?> | |
| 38 | + <?php if (empty($action) || ($action == 'preview')) { ?> | |
| 27 | 39 | <input type="submit" name="Previous" value="previous" class="button_previous"/> |
| 40 | + <input type="submit" name="ConfirmUpgrade" value="next" class="button_next"/> | |
| 41 | + <?php } | |
| 42 | + else if ($action == 'confirm') { ?> | |
| 43 | + <input type="submit" name="Cancel" value="cancel" class="button_previous"/> | |
| 28 | 44 | <input type="submit" name="RunUpgrade" value="next" class="button_next"/> |
| 29 | 45 | <?php } |
| 30 | 46 | else if ($action == 'runUpgrade') { ?> |
| 31 | - <input type="submit" name="Cancel" value="cancel" class="button_previous"/> | |
| 32 | - <input type="submit" name="Confirm" value="next" class="button_next"/> | |
| 47 | + <script type="text/javascript"> | |
| 48 | + alert("To complete the upgrade please do the following before continuing:\n\n1. Restart the services as appropriate for your environment.\n\n\nOn first run of your upgraded installaton please do the following:\n\n1. Hard refresh your bowser (CTRL-F5) on first view of the Dashboard.\n2. Enable the new plugins you wish to use.\n\n\nSelect 'next' at the bottom of this page to continue.") | |
| 49 | + </script> | |
| 50 | + <input type="submit" name="Next" value="next" class="button_next"/> | |
| 33 | 51 | <?php } ?> |
| 34 | 52 | </form> |
| 35 | 53 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/installation.tpl
| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | <p class="title">Current Installation</p> |
| 3 | 3 | <div id="step_content" class="step"> |
| 4 | 4 | <p class="empty_space"> |
| 5 | - <?php // set_state(1); ?> | |
| 6 | 5 | <p class="empty_space"> If you have just updated |
| 7 | 6 | your KnowledgeTree code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version. |
| 8 | 7 | <p class="empty_space"> |
| ... | ... | @@ -19,7 +18,4 @@ |
| 19 | 18 | <input type="submit" name="Upgrade" value="Upgrade" class="button_next"/> |
| 20 | 19 | <input type="submit" name="Restore" value="Restore Database" class="button_next"/> |
| 21 | 20 | <input type="submit" name="Next" value="Backup Now" class="button_next"/> |
| 22 | -</form> | |
| 23 | -<script type="text/javascript"> | |
| 24 | - $("#location").focus(); | |
| 25 | -</script> | |
| 26 | 21 | \ No newline at end of file |
| 22 | +</form> | |
| 27 | 23 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/progress.tpl
0 → 100644
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| 2 | +<html> | |
| 3 | + <head> | |
| 4 | + <title>KnowledgeTree Upgrade Wizard</title> | |
| 5 | + <script type="text/javascript" src="resources/jquery.js"></script> | |
| 6 | + <script type="text/javascript" src="resources/wizard.js" ></script> | |
| 7 | + <link rel="stylesheet" type="text/css" href="resources/wizard.css" /> | |
| 8 | + | |
| 9 | + </head> | |
| 10 | + | |
| 11 | + <body onload=""> | |
| 12 | + <div id="outer-wrapper"> | |
| 13 | + <div id="header"> | |
| 14 | + <div id="logo"><img src="resources/graphics/dame/upgrader-header_logo.png"/></div> | |
| 15 | + <div id="install_details"> | |
| 16 | + <span style="font-size:120%;"> 3.7 </span> | |
| 17 | + <span style="font-size:80%;">Commercial Edition</span> | |
| 18 | + </div> | |
| 19 | + </div> | |
| 20 | + <div id="wrapper"> | |
| 21 | + <div id="container"> | |
| 22 | + <div id="sidebar"> | |
| 23 | + <?php echo $left; ?> | |
| 24 | + </div> | |
| 25 | + <div id="content"> | |
| 26 | + <div id="content_container"> | |
| 27 | + <p class="title"><?php echo $title; ?></p> | |
| 28 | + <form action="index.php?step_name=welcome" method="post"> | |
| 29 | + <div id="step_content" class="step"> | |
| 30 | + <?php if(isset($error)) { | |
| 31 | + echo "<span class='error'>".$error."</span>"; | |
| 32 | + ?> | |
| 33 | + <?php | |
| 34 | + } | |
| 35 | + ?> | |
| 36 | + <?php | |
| 37 | + if(isset($errors)) { | |
| 38 | + if($errors){ | |
| 39 | + echo '<div class="error">'; | |
| 40 | + foreach ($errors as $msg){ | |
| 41 | + echo $msg . "<br />"; | |
| 42 | + ?> | |
| 43 | + <a href="javascript:this.location.reload();" class="refresh">Refresh</a> | |
| 44 | + <?php | |
| 45 | + } | |
| 46 | + echo '</div>'; | |
| 47 | + } | |
| 48 | + } | |
| 49 | + ?> | |
| 50 | + <br/><br/> | |
| 51 | + <?php echo $content; ?> | |
| 52 | + </div> | |
| 53 | + </form> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + </div> | |
| 57 | + <div class="clearing"> </div> | |
| 58 | + </div> | |
| 59 | + | |
| 60 | + <div id="footer"> | |
| 61 | + | |
| 62 | + <img width="105" height="23" align="right" src="resources/graphics/dame/powered-by-kt.png" style="padding: 5px;"/> | |
| 63 | + </div> | |
| 64 | + </div> | |
| 65 | + </body> | |
| 66 | +</html> | |
| 67 | +<script> | |
| 68 | + var w = new wizard(); | |
| 69 | +</script> | |
| 0 | 70 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/restore.tpl
| 1 | 1 | <form action="index.php?step_name=restore" method="post"> |
| 2 | - <p class="title">Confirm Restore</p> | |
| 2 | + <p class="title"><?php echo $title; ?></p> | |
| 3 | 3 | |
| 4 | 4 | <?php |
| 5 | 5 | if($errors || $warnings){ |
| ... | ... | @@ -12,30 +12,65 @@ |
| 12 | 12 | <br/><br/> |
| 13 | 13 | <div> |
| 14 | 14 | <?php |
| 15 | -if ($dir != '') { | |
| 16 | -?> | |
| 17 | -<P> | |
| 18 | -<P> | |
| 19 | -Manually, you would do the following to restore the backup: | |
| 20 | -<P> | |
| 21 | -<table bgcolor="lightgrey"> | |
| 22 | -<tr> | |
| 23 | -<td> | |
| 24 | -<nobr>cd "<?php echo $dir;?>"</nobr> | |
| 25 | -<br/> | |
| 26 | -<?php | |
| 27 | - } | |
| 28 | - else | |
| 29 | - { | |
| 15 | + if (!$restore) { | |
| 16 | + if (!$availableBackups) { | |
| 17 | + ?>There don't seem to be any backups to restore from the <i>"<?php echo $dir;?>"</i> directory.<?php | |
| 18 | + } | |
| 19 | + else if (!$selected) { | |
| 20 | + ?> | |
| 21 | + <P> | |
| 22 | + Select a backup to restore from the list below: | |
| 23 | + <P> | |
| 24 | + <form action="index.php?step_name=restore" method="post"> | |
| 25 | + | |
| 26 | + <table border=1 cellpadding=1 cellspacing=1> | |
| 27 | + <tr bgcolor="darkgrey"> | |
| 28 | + <td>Filename | |
| 29 | + <td>File Size | |
| 30 | + <td>Action | |
| 31 | + <?php | |
| 32 | + $i=0; | |
| 33 | + foreach($files as $file) | |
| 34 | + { | |
| 35 | + $color=((($i++)%2)==0)?'white':'lightgrey'; | |
| 30 | 36 | ?> |
| 31 | - The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. | |
| 32 | -<P> | |
| 33 | -You can continue to do the restore manually using the following command(s): | |
| 34 | -<P> | |
| 35 | -<table bgcolor="lightgrey"> | |
| 36 | -<tr> | |
| 37 | -<td><?php | |
| 38 | - } | |
| 37 | + <tr bgcolor="<?php echo $color;?>"> | |
| 38 | + <td><?php echo $file;?> | |
| 39 | + <td><?php echo filesize($dir . '/'.$file);?> | |
| 40 | + <td><input type="submit" name="RestoreSelect" value="restore"> | |
| 41 | + <?php | |
| 42 | + } | |
| 43 | + ?> | |
| 44 | + </table> | |
| 45 | + <input type="hidden" name="file" value="<?php echo $file; ?>" /> | |
| 46 | + </form> | |
| 47 | + <?php | |
| 48 | + } | |
| 49 | + else if ($dir != '') { | |
| 50 | + ?> | |
| 51 | + <P> | |
| 52 | + <P> | |
| 53 | + Manually, you would do the following to restore the backup: | |
| 54 | + <P> | |
| 55 | + <table bgcolor="lightgrey"> | |
| 56 | + <tr> | |
| 57 | + <td> | |
| 58 | + <nobr>cd "<?php echo $dir;?>"</nobr> | |
| 59 | + <br/> | |
| 60 | + <?php | |
| 61 | + } | |
| 62 | + else | |
| 63 | + { | |
| 64 | + ?> | |
| 65 | + The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. | |
| 66 | + <P> | |
| 67 | + You can continue to do the restore manually using the following command(s): | |
| 68 | + <P> | |
| 69 | + <table bgcolor="lightgrey"> | |
| 70 | + <tr> | |
| 71 | + <td><?php | |
| 72 | + } | |
| 73 | + } // end not doing a restore, just preliminary steps | |
| 39 | 74 | ?> |
| 40 | 75 | <nobr><?php echo $display;?></nobr> |
| 41 | 76 | </td> |
| ... | ... | @@ -46,7 +81,7 @@ You can continue to do the restore manually using the following command(s): |
| 46 | 81 | </div> |
| 47 | 82 | <?php } ?> |
| 48 | 83 | <?php |
| 49 | -if ($dir != '') | |
| 84 | +if (($dir != '') && ($selected)) | |
| 50 | 85 | { |
| 51 | 86 | ?> |
| 52 | 87 | Press <i>Next</i> to attempt the command(s) above. |
| ... | ... | @@ -56,9 +91,12 @@ Press <i>Next</i> to attempt the command(s) above. |
| 56 | 91 | } |
| 57 | 92 | ?> |
| 58 | 93 | </div> |
| 59 | - | |
| 60 | - | |
| 94 | + </div> | |
| 61 | 95 | <input type="submit" name="Previous" value="Back" class="button_previous"> |
| 96 | + <?php if (($dir != '') && ($selected)) { ?> | |
| 97 | + <input type="submit" name="RunRestore" value="Next" class="button_next"> | |
| 98 | + <?php } | |
| 99 | + else { ?> | |
| 62 | 100 | <input type="submit" name="Next" value="Next" class="button_next"> |
| 63 | - </div> | |
| 101 | + <?php } ?> | |
| 64 | 102 | </form> |
| 65 | 103 | \ No newline at end of file | ... | ... |
setup/upgrade/upgradeUtil.php
| ... | ... | @@ -39,6 +39,9 @@ |
| 39 | 39 | * @package Upgrader |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | + | |
| 43 | +require '../../config/dmsDefaults.php'; | |
| 44 | + | |
| 42 | 45 | class UpgradeUtil { |
| 43 | 46 | /** |
| 44 | 47 | * Constructs upgradeation object |
| ... | ... | @@ -79,6 +82,31 @@ class UpgradeUtil { |
| 79 | 82 | ob_end_clean(); |
| 80 | 83 | echo $contents; |
| 81 | 84 | } |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Function to send output to the browser prior to normal dynamic loading of a template after code execution | |
| 88 | + * | |
| 89 | + * @param string $template The name of the template to use | |
| 90 | + * @param array $output [optional] Optional array containing output text to be inserted into the template | |
| 91 | + * @return | |
| 92 | + */ | |
| 93 | + public function flushOutput($template, $output = null) { | |
| 94 | + if (is_array($output)) { | |
| 95 | + foreach ($output as $key => $value) { | |
| 96 | + $template_vars[$key] = $value; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + $file = "templates/" . $template; | |
| 100 | + if (!file_exists($file)) { | |
| 101 | + return false; | |
| 102 | + } | |
| 103 | + extract($template_vars); // Extract the vars to local namespace | |
| 104 | + ob_start(); | |
| 105 | + include($file); | |
| 106 | + $contents = ob_get_contents(); | |
| 107 | + ob_end_clean(); | |
| 108 | + echo $contents; | |
| 109 | + } | |
| 82 | 110 | |
| 83 | 111 | /** |
| 84 | 112 | * Check if system needs to be upgraded |
| ... | ... | @@ -637,6 +665,107 @@ class UpgradeUtil { |
| 637 | 665 | } |
| 638 | 666 | return join(" ", $aSafeArgs); |
| 639 | 667 | } |
| 668 | + | |
| 669 | + public function create_restore_stmt($targetfile) | |
| 670 | + { | |
| 671 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 672 | + | |
| 673 | + $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 674 | + $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 675 | + $dbHost = $oKTConfig->get('db/dbHost'); | |
| 676 | + $dbName = $oKTConfig->get('db/dbName'); | |
| 677 | + $dbPort = trim($oKTConfig->get('db/dbPort')); | |
| 678 | + if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); | |
| 679 | + if (empty($dbPort)) $dbPort='3306'; | |
| 680 | + $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 681 | + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); | |
| 682 | + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; | |
| 683 | + | |
| 684 | + $dir = $this->resolveMysqlDir(); | |
| 685 | + | |
| 686 | + $info['dir']=$dir; | |
| 687 | + | |
| 688 | + $prefix=''; | |
| 689 | + if (OS_UNIX) { | |
| 690 | + $prefix .= "./"; | |
| 691 | + } | |
| 692 | + | |
| 693 | + if (@stat($dbSocket) !== false) { | |
| 694 | + $mechanism="--socket=\"$dbSocket\""; | |
| 695 | + } | |
| 696 | + else { | |
| 697 | + $mechanism="--port=\"$dbPort\""; | |
| 698 | + } | |
| 699 | + | |
| 700 | + $tmpdir = $this->resolveTempDir(); | |
| 701 | + | |
| 702 | + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; | |
| 703 | + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; | |
| 704 | + | |
| 705 | + | |
| 706 | + $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; | |
| 707 | + $info['display']=$stmt; | |
| 708 | + | |
| 709 | + | |
| 710 | + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; | |
| 711 | + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; | |
| 712 | + | |
| 713 | + $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; | |
| 714 | + $info['cmd']=$stmt; | |
| 715 | + return $info; | |
| 716 | + } | |
| 717 | + | |
| 718 | + public function resolveMysqlDir() | |
| 719 | + { | |
| 720 | + // possibly detect existing installations: | |
| 721 | + | |
| 722 | + if (OS_UNIX) { | |
| 723 | + $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); | |
| 724 | + $mysqlname ='mysql'; | |
| 725 | + } | |
| 726 | + else | |
| 727 | + { | |
| 728 | + $dirs = explode(';', $_SERVER['PATH']); | |
| 729 | + $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; | |
| 730 | + $dirs[] = 'c:/program files/ktdms/mysql/bin'; | |
| 731 | + $mysqlname ='mysql.exe'; | |
| 732 | + } | |
| 733 | + | |
| 734 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 735 | + $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); | |
| 736 | + $dirs[] = $mysqldir; | |
| 737 | + | |
| 738 | + if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { | |
| 739 | + $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); | |
| 740 | + } | |
| 741 | + | |
| 742 | + foreach($dirs as $dir) | |
| 743 | + { | |
| 744 | + if (is_file($dir . '/' . $mysqlname)) | |
| 745 | + { | |
| 746 | + return $dir; | |
| 747 | + } | |
| 748 | + } | |
| 749 | + | |
| 750 | + return ''; | |
| 751 | + } | |
| 752 | + | |
| 753 | + public function resolveTempDir() | |
| 754 | + { | |
| 755 | + if (OS_UNIX) { | |
| 756 | + $dir='/tmp/kt-db-backup'; | |
| 757 | + } | |
| 758 | + else { | |
| 759 | + $dir='c:/kt-db-backup'; | |
| 760 | + } | |
| 761 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 762 | + $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 763 | + | |
| 764 | + if (!is_dir($dir)) { | |
| 765 | + mkdir($dir); | |
| 766 | + } | |
| 767 | + return $dir; | |
| 768 | + } | |
| 640 | 769 | |
| 641 | 770 | } |
| 642 | 771 | ?> |
| 643 | 772 | \ No newline at end of file | ... | ... |
setup/upgrade/upgradeWizard.php
| ... | ... | @@ -186,6 +186,9 @@ class UpgradeWizard { |
| 186 | 186 | * @return mixed |
| 187 | 187 | */ |
| 188 | 188 | public function systemChecks() { |
| 189 | + // for now we don't write to any of these locations | |
| 190 | + return true; | |
| 191 | + | |
| 189 | 192 | $res = $this->iutil->checkStructurePermissions(); |
| 190 | 193 | if($res === true) return $res; |
| 191 | 194 | switch ($res) { | ... | ... |
setup/wizard/config/config.xml
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <step name="Service Dependency" order="3" mode="silent">services</step> |
| 18 | 18 | <step name="Database Configuration" order="1">database</step> |
| 19 | 19 | <step name="Registration">registration</step> |
| 20 | - <step name="Install" mode="silent">install</step> | |
| 20 | + <step name="Install" order="4" mode="silent">install</step> | |
| 21 | 21 | <step name="Complete">complete</step> |
| 22 | 22 | </steps> |
| 23 | 23 | </install> |
| 24 | 24 | \ No newline at end of file | ... | ... |
setup/wizard/config/databases.xml
| ... | ... | @@ -14,8 +14,8 @@ |
| 14 | 14 | <dhost>localhost</dhost> |
| 15 | 15 | <dport>3306</dport> |
| 16 | 16 | <dname>dms</dname> |
| 17 | - <duname>root</duname> | |
| 18 | - <dmsadminuser>dmsadminuser</dmsadminuser> | |
| 17 | + <duname>dms</duname> | |
| 18 | + <dmsadminuser>dmsadmin</dmsadminuser> | |
| 19 | 19 | <dmsaupass>js9281djw</dmsaupass> |
| 20 | 20 | <dmsuser>dmsuser</dmsuser> |
| 21 | 21 | <dmsupass>djw9281js</dmsupass> | ... | ... |
setup/wizard/dbUtil.php
| ... | ... | @@ -146,8 +146,8 @@ class dbUtil { |
| 146 | 146 | * @return object The result of the query. |
| 147 | 147 | */ |
| 148 | 148 | public function query($query) { |
| 149 | - $this->useDb(); | |
| 150 | - $result = mysql_query($query, $this->dbconnection); | |
| 149 | + $this->useDb(); | |
| 150 | + $result = mysql_query($query, $this->dbconnection); | |
| 151 | 151 | if($result) { |
| 152 | 152 | return $result; |
| 153 | 153 | } else { |
| ... | ... | @@ -165,13 +165,12 @@ class dbUtil { |
| 165 | 165 | */ |
| 166 | 166 | public function execute($query) { |
| 167 | 167 | $this->useDb(); |
| 168 | - $result = @mysql_query($query, $this->dbconnection); | |
| 169 | - if($result) { | |
| 170 | - return true; | |
| 171 | - } else { | |
| 168 | + $result = @mysql_query($query, $this->dbconnection); | |
| 169 | + if(!$result) { | |
| 172 | 170 | $this->error[] = @mysql_error($this->dbconnection); |
| 173 | - return false; | |
| 174 | 171 | } |
| 172 | + | |
| 173 | + return $result; | |
| 175 | 174 | } |
| 176 | 175 | |
| 177 | 176 | /** |
| ... | ... | @@ -200,10 +199,7 @@ class dbUtil { |
| 200 | 199 | if ($result == NULL || @mysql_num_rows($result) < 1) |
| 201 | 200 | return NULL; |
| 202 | 201 | else { |
| 203 | - $row = @mysql_fetch_assoc($result); | |
| 204 | - while ($row) { | |
| 205 | - $r[] = $row; | |
| 206 | - } | |
| 202 | + while(($r[] = mysql_fetch_assoc($result)) || array_pop($r)); | |
| 207 | 203 | return $r; |
| 208 | 204 | } |
| 209 | 205 | } | ... | ... |
setup/wizard/ini.php
| ... | ... | @@ -206,9 +206,18 @@ class Ini { |
| 206 | 206 | return true; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | + // Return file line by line | |
| 209 | 210 | public function getFileByLine() { |
| 210 | 211 | $data = $this->read($this->iniFile); |
| 211 | 212 | return $data['']; |
| 212 | 213 | } |
| 214 | + | |
| 215 | + public function getSection($section) { | |
| 216 | + if (isset($this->cleanArray[$section])) { | |
| 217 | + return $this->cleanArray[$section]; | |
| 218 | + } | |
| 219 | + | |
| 220 | + return false; | |
| 221 | + } | |
| 213 | 222 | } |
| 214 | 223 | -?> |
| 224 | +?> | |
| 215 | 225 | \ No newline at end of file | ... | ... |
setup/wizard/installUtil.php
| ... | ... | @@ -39,8 +39,8 @@ |
| 39 | 39 | * @package Installer |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | -class InstallUtil { | |
| 43 | - | |
| 42 | +class InstallUtil { | |
| 43 | + | |
| 44 | 44 | private $salt = 'installers'; |
| 45 | 45 | /** |
| 46 | 46 | * Constructs installation object |
| ... | ... | @@ -50,7 +50,7 @@ class InstallUtil { |
| 50 | 50 | */ |
| 51 | 51 | public function __construct() { |
| 52 | 52 | } |
| 53 | - | |
| 53 | + | |
| 54 | 54 | /** |
| 55 | 55 | * Check if system needs to be installed |
| 56 | 56 | * |
| ... | ... | @@ -64,7 +64,7 @@ class InstallUtil { |
| 64 | 64 | |
| 65 | 65 | return true; |
| 66 | 66 | } |
| 67 | - | |
| 67 | + | |
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
| ... | ... | @@ -100,13 +100,13 @@ class InstallUtil { |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Redirect |
| 103 | - * | |
| 103 | + * | |
| 104 | 104 | * This function redirects the client. This is done by issuing |
| 105 | 105 | * a "Location" header and exiting if wanted. If you set $rfc2616 to true |
| 106 | 106 | * HTTP will output a hypertext note with the location of the redirect. |
| 107 | - * | |
| 108 | - * @static | |
| 109 | - * @access public | |
| 107 | + * | |
| 108 | + * @static | |
| 109 | + * @access public | |
| 110 | 110 | * have already been sent. |
| 111 | 111 | * @param string $url URL where the redirect should go to. |
| 112 | 112 | * @param bool $exit Whether to exit immediately after redirection. |
| ... | ... | @@ -119,10 +119,10 @@ class InstallUtil { |
| 119 | 119 | if (headers_sent()) { |
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | - | |
| 122 | + | |
| 123 | 123 | $url = $this->absoluteURI($url); |
| 124 | 124 | header('Location: '. $url); |
| 125 | - | |
| 125 | + | |
| 126 | 126 | if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) && |
| 127 | 127 | $_SERVER['REQUEST_METHOD'] != 'HEAD') { |
| 128 | 128 | printf('Redirecting to: <a href="%s">%s</a>.', $url, $url); |
| ... | ... | @@ -135,21 +135,21 @@ class InstallUtil { |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Absolute URI |
| 138 | - * | |
| 138 | + * | |
| 139 | 139 | * This function returns the absolute URI for the partial URL passed. |
| 140 | 140 | * The current scheme (HTTP/HTTPS), host server, port, current script |
| 141 | 141 | * location are used if necessary to resolve any relative URLs. |
| 142 | - * | |
| 142 | + * | |
| 143 | 143 | * Offsets potentially created by PATH_INFO are taken care of to resolve |
| 144 | 144 | * relative URLs to the current script. |
| 145 | - * | |
| 146 | - * You can choose a new protocol while resolving the URI. This is | |
| 147 | - * particularly useful when redirecting a web browser using relative URIs | |
| 145 | + * | |
| 146 | + * You can choose a new protocol while resolving the URI. This is | |
| 147 | + * particularly useful when redirecting a web browser using relative URIs | |
| 148 | 148 | * and to switch from HTTP to HTTPS, or vice-versa, at the same time. |
| 149 | - * | |
| 150 | - * @author Philippe Jausions <Philippe.Jausions@11abacus.com> | |
| 151 | - * @static | |
| 152 | - * @access public | |
| 149 | + * | |
| 150 | + * @author Philippe Jausions <Philippe.Jausions@11abacus.com> | |
| 151 | + * @static | |
| 152 | + * @access public | |
| 153 | 153 | * @param string $url Absolute or relative URI the redirect should go to. |
| 154 | 154 | * @param string $protocol Protocol to use when redirecting URIs. |
| 155 | 155 | * @param integer $port A new port number. |
| ... | ... | @@ -159,7 +159,7 @@ class InstallUtil { |
| 159 | 159 | { |
| 160 | 160 | // filter CR/LF |
| 161 | 161 | $url = str_replace(array("\r", "\n"), ' ', $url); |
| 162 | - | |
| 162 | + | |
| 163 | 163 | // Mess around with already absolute URIs |
| 164 | 164 | if (preg_match('!^([a-z0-9]+)://!i', $url)) { |
| 165 | 165 | if (empty($protocol) && empty($port)) { |
| ... | ... | @@ -169,12 +169,12 @@ class InstallUtil { |
| 169 | 169 | $url = $protocol .':'. end($array = explode(':', $url, 2)); |
| 170 | 170 | } |
| 171 | 171 | if (!empty($port)) { |
| 172 | - $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', | |
| 172 | + $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', | |
| 173 | 173 | '\1:'. $port, $url); |
| 174 | 174 | } |
| 175 | 175 | return $url; |
| 176 | 176 | } |
| 177 | - | |
| 177 | + | |
| 178 | 178 | $host = 'localhost'; |
| 179 | 179 | if (!empty($_SERVER['HTTP_HOST'])) { |
| 180 | 180 | list($host) = explode(':', $_SERVER['HTTP_HOST']); |
| ... | ... | @@ -192,7 +192,7 @@ class InstallUtil { |
| 192 | 192 | $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; |
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | - | |
| 195 | + | |
| 196 | 196 | if ($protocol == 'http' && $port == 80) { |
| 197 | 197 | unset($port); |
| 198 | 198 | } |
| ... | ... | @@ -201,31 +201,31 @@ class InstallUtil { |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); |
| 204 | - | |
| 204 | + | |
| 205 | 205 | if (!strlen($url)) { |
| 206 | - $url = isset($_SERVER['REQUEST_URI']) ? | |
| 206 | + $url = isset($_SERVER['REQUEST_URI']) ? | |
| 207 | 207 | $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']; |
| 208 | 208 | } |
| 209 | - | |
| 209 | + | |
| 210 | 210 | if ($url{0} == '/') { |
| 211 | 211 | return $server . $url; |
| 212 | 212 | } |
| 213 | - | |
| 213 | + | |
| 214 | 214 | // Check for PATH_INFO |
| 215 | - if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && | |
| 215 | + if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && | |
| 216 | 216 | $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) { |
| 217 | 217 | $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO']))); |
| 218 | 218 | } else { |
| 219 | 219 | $path = dirname($_SERVER['PHP_SELF']); |
| 220 | 220 | } |
| 221 | - | |
| 221 | + | |
| 222 | 222 | if (substr($path = strtr($path, '\\', '/'), -1) != '/') { |
| 223 | 223 | $path .= '/'; |
| 224 | 224 | } |
| 225 | - | |
| 225 | + | |
| 226 | 226 | return $server . $path . $url; |
| 227 | 227 | } |
| 228 | - | |
| 228 | + | |
| 229 | 229 | /** |
| 230 | 230 | * Check whether a given directory / file path exists and is writable |
| 231 | 231 | * |
| ... | ... | @@ -244,7 +244,7 @@ class InstallUtil { |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | } |
| 247 | - | |
| 247 | + | |
| 248 | 248 | /** |
| 249 | 249 | * Check whether a given directory / file path exists and is writable |
| 250 | 250 | * |
| ... | ... | @@ -258,7 +258,7 @@ class InstallUtil { |
| 258 | 258 | { |
| 259 | 259 | if(!$file) |
| 260 | 260 | $exist = 'Directory doesn\'t exist'; |
| 261 | - else | |
| 261 | + else | |
| 262 | 262 | $exist = 'File doesn\'t exist'; |
| 263 | 263 | $write = 'Directory not writable'; |
| 264 | 264 | $ret = array('class' => 'cross'); |
| ... | ... | @@ -280,12 +280,12 @@ class InstallUtil { |
| 280 | 280 | $ret['msg'] = $exist; |
| 281 | 281 | return $ret; |
| 282 | 282 | } |
| 283 | - mkdir($dir, '0755'); | |
| 283 | + mkdir($dir, 0755); | |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | if(is_writable($dir)){ |
| 287 | 287 | $ret['class'] = 'tick'; |
| 288 | - | |
| 288 | + | |
| 289 | 289 | return $ret; |
| 290 | 290 | } |
| 291 | 291 | |
| ... | ... | @@ -293,7 +293,7 @@ class InstallUtil { |
| 293 | 293 | $ret['msg'] = $write; |
| 294 | 294 | return $ret; |
| 295 | 295 | } |
| 296 | - | |
| 296 | + | |
| 297 | 297 | /** |
| 298 | 298 | * Change permissions on a directory helper |
| 299 | 299 | * |
| ... | ... | @@ -305,7 +305,7 @@ class InstallUtil { |
| 305 | 305 | public function canChangePermissions($folderPath) { |
| 306 | 306 | return $this->_chmodRecursive($folderPath, 0755); |
| 307 | 307 | } |
| 308 | - | |
| 308 | + | |
| 309 | 309 | /** |
| 310 | 310 | * Change permissions on a directory (recursive) |
| 311 | 311 | * |
| ... | ... | @@ -344,7 +344,7 @@ class InstallUtil { |
| 344 | 344 | return true; |
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | - | |
| 347 | + | |
| 348 | 348 | /** |
| 349 | 349 | * Check if a file can be written to a folder |
| 350 | 350 | * |
| ... | ... | @@ -358,11 +358,11 @@ class InstallUtil { |
| 358 | 358 | if($fr = fwrite($fh, 'test') === false) { |
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | - | |
| 361 | + | |
| 362 | 362 | fclose($fh); |
| 363 | 363 | return true; |
| 364 | 364 | } |
| 365 | - | |
| 365 | + | |
| 366 | 366 | /** |
| 367 | 367 | * Attempt using the php-java bridge |
| 368 | 368 | * |
| ... | ... | @@ -379,7 +379,7 @@ class InstallUtil { |
| 379 | 379 | } |
| 380 | 380 | return true; |
| 381 | 381 | } |
| 382 | - | |
| 382 | + | |
| 383 | 383 | /** |
| 384 | 384 | * Check if Zend Bridge is enabled |
| 385 | 385 | * |
| ... | ... | @@ -390,12 +390,12 @@ class InstallUtil { |
| 390 | 390 | */ |
| 391 | 391 | public function zendBridge() { |
| 392 | 392 | $mods = get_loaded_extensions(); |
| 393 | - if(in_array('Zend Java Bridge', $mods)) | |
| 393 | + if(in_array('Zend Java Bridge', $mods)) | |
| 394 | 394 | return true; |
| 395 | - else | |
| 395 | + else | |
| 396 | 396 | return false; |
| 397 | 397 | } |
| 398 | - | |
| 398 | + | |
| 399 | 399 | /** |
| 400 | 400 | * Attempt java detection |
| 401 | 401 | * |
| ... | ... | @@ -412,7 +412,7 @@ class InstallUtil { |
| 412 | 412 | |
| 413 | 413 | return 'java'; |
| 414 | 414 | } |
| 415 | - | |
| 415 | + | |
| 416 | 416 | /** |
| 417 | 417 | * Attempt java detection |
| 418 | 418 | * |
| ... | ... | @@ -429,7 +429,7 @@ class InstallUtil { |
| 429 | 429 | |
| 430 | 430 | return 'java'; |
| 431 | 431 | } |
| 432 | - | |
| 432 | + | |
| 433 | 433 | /** |
| 434 | 434 | * Attempt java detection |
| 435 | 435 | * |
| ... | ... | @@ -451,7 +451,7 @@ class InstallUtil { |
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | - | |
| 454 | + | |
| 455 | 455 | /** |
| 456 | 456 | * Check if user entered location of JRE |
| 457 | 457 | * |
| ... | ... | @@ -471,7 +471,7 @@ class InstallUtil { |
| 471 | 471 | return false; |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | - | |
| 474 | + | |
| 475 | 475 | /** |
| 476 | 476 | * Check if user entered location of PHP |
| 477 | 477 | * |
| ... | ... | @@ -491,7 +491,7 @@ class InstallUtil { |
| 491 | 491 | return false; |
| 492 | 492 | } |
| 493 | 493 | } |
| 494 | - | |
| 494 | + | |
| 495 | 495 | public function openOfficeSpecified() { |
| 496 | 496 | if(isset($_POST['soffice'])) { |
| 497 | 497 | if($_POST['soffice'] != '') { |
| ... | ... | @@ -503,7 +503,7 @@ class InstallUtil { |
| 503 | 503 | return false; |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | - | |
| 506 | + | |
| 507 | 507 | /** |
| 508 | 508 | * Get session data from post |
| 509 | 509 | * |
| ... | ... | @@ -516,10 +516,10 @@ class InstallUtil { |
| 516 | 516 | if(empty($_SESSION[$this->salt][$class])) { |
| 517 | 517 | return false; |
| 518 | 518 | } |
| 519 | - | |
| 519 | + | |
| 520 | 520 | return $_SESSION[$this->salt][$class]; |
| 521 | 521 | } |
| 522 | - | |
| 522 | + | |
| 523 | 523 | /** |
| 524 | 524 | * Determine the location of JAVA_HOME |
| 525 | 525 | * |
| ... | ... | @@ -539,7 +539,7 @@ class InstallUtil { |
| 539 | 539 | |
| 540 | 540 | return $response; |
| 541 | 541 | } |
| 542 | - | |
| 542 | + | |
| 543 | 543 | /** |
| 544 | 544 | * Determine the location of PHP |
| 545 | 545 | * |
| ... | ... | @@ -562,10 +562,10 @@ class InstallUtil { |
| 562 | 562 | if(file_exists(PHP_DIR."php")) { |
| 563 | 563 | return PHP_DIR."php"; |
| 564 | 564 | } |
| 565 | - | |
| 565 | + | |
| 566 | 566 | return 'php'; |
| 567 | 567 | } |
| 568 | - | |
| 568 | + | |
| 569 | 569 | function getPhpHelper($cmd) { |
| 570 | 570 | $response = $this->pexec($cmd); |
| 571 | 571 | if(is_array($response['out'])) { |
| ... | ... | @@ -579,10 +579,10 @@ class InstallUtil { |
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | } |
| 582 | - | |
| 583 | - return ''; | |
| 582 | + | |
| 583 | + return ''; | |
| 584 | 584 | } |
| 585 | - | |
| 585 | + | |
| 586 | 586 | function getOpenOffice() { |
| 587 | 587 | $cmd = "whereis soffice"; |
| 588 | 588 | $res = $this->getOpenOfficeHelper($cmd); |
| ... | ... | @@ -594,10 +594,10 @@ class InstallUtil { |
| 594 | 594 | if($res != '') { |
| 595 | 595 | return $res; |
| 596 | 596 | } |
| 597 | - | |
| 597 | + | |
| 598 | 598 | return 'soffice'; |
| 599 | 599 | } |
| 600 | - | |
| 600 | + | |
| 601 | 601 | function getOpenOfficeHelper($cmd) { |
| 602 | 602 | $response = $this->pexec($cmd); |
| 603 | 603 | if(is_array($response['out'])) { |
| ... | ... | @@ -611,11 +611,11 @@ class InstallUtil { |
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | - | |
| 614 | + | |
| 615 | 615 | return ''; |
| 616 | 616 | } |
| 617 | - | |
| 618 | - | |
| 617 | + | |
| 618 | + | |
| 619 | 619 | /** |
| 620 | 620 | * Portably execute a command on any of the supported platforms. |
| 621 | 621 | * |
| ... | ... | @@ -656,9 +656,9 @@ class InstallUtil { |
| 656 | 656 | |
| 657 | 657 | return $aRet; |
| 658 | 658 | } |
| 659 | - | |
| 659 | + | |
| 660 | 660 | /** |
| 661 | - * | |
| 661 | + * | |
| 662 | 662 | * |
| 663 | 663 | * @author KnowledgeTree Team |
| 664 | 664 | * @access public |
| ... | ... | @@ -681,9 +681,9 @@ class InstallUtil { |
| 681 | 681 | } |
| 682 | 682 | return $mDefault; |
| 683 | 683 | } |
| 684 | - | |
| 684 | + | |
| 685 | 685 | /** |
| 686 | - * | |
| 686 | + * | |
| 687 | 687 | * |
| 688 | 688 | * @author KnowledgeTree Team |
| 689 | 689 | * @access public | ... | ... |
setup/wizard/lib/services/unixOpenOffice.php
| ... | ... | @@ -112,37 +112,68 @@ class unixOpenOffice extends unixService { |
| 112 | 112 | |
| 113 | 113 | public function status($updrade = false) { |
| 114 | 114 | sleep(1); |
| 115 | - if($updrade) { | |
| 116 | - $cmd = "ps ax | grep soffice"; | |
| 117 | - } else { | |
| 118 | - $cmd = "netstat -npa | grep ".$this->getPort(); | |
| 119 | - } | |
| 120 | - $response = $this->util->pexec($cmd); | |
| 115 | + $cmd = "ps ax | grep soffice"; | |
| 116 | + $response = $this->util->pexec($cmd); | |
| 121 | 117 | if(is_array($response['out'])) { |
| 122 | - if(count($response['out']) > 0) { | |
| 123 | - preg_match('/8100/', $response['out'][0], $matches); // Ignore grep | |
| 124 | - if($matches) { | |
| 125 | - if($matches[0] == '8100') { | |
| 118 | + if(count($response['out']) > 1) { | |
| 119 | + foreach ($response['out'] as $r) { | |
| 120 | + preg_match('/grep/', $r, $matches); // Ignore grep | |
| 121 | + if(!$matches) { | |
| 126 | 122 | return 'STARTED'; |
| 127 | 123 | } |
| 128 | - } | |
| 124 | + } | |
| 129 | 125 | } else { |
| 130 | 126 | return ''; |
| 131 | 127 | } |
| 132 | 128 | } |
| 133 | - | |
| 129 | + /* | |
| 130 | + if($updrade) { | |
| 131 | + $cmd = "ps ax | grep soffice"; | |
| 132 | + $response = $this->util->pexec($cmd); | |
| 133 | + if(is_array($response['out'])) { | |
| 134 | + if(count($response['out']) > 1) { | |
| 135 | + foreach ($response['out'] as $r) { | |
| 136 | + preg_match('/grep/', $r, $matches); // Ignore grep | |
| 137 | + if(!$matches) { | |
| 138 | + return 'STARTED'; | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } else { | |
| 142 | + return ''; | |
| 143 | + } | |
| 144 | + } | |
| 145 | + } else { | |
| 146 | + $cmd = "netstat -npa | grep ".$this->getPort(); | |
| 147 | + $response = $this->util->pexec($cmd); | |
| 148 | + if(is_array($response['out'])) { | |
| 149 | + if(count($response['out']) > 0) { | |
| 150 | + preg_match('/8100/', $response['out'][0], $matches); // Ignore grep | |
| 151 | + if($matches) { | |
| 152 | + if($matches[0] == '8100') { | |
| 153 | + return 'STARTED'; | |
| 154 | + } | |
| 155 | + } | |
| 156 | + } else { | |
| 157 | + return ''; | |
| 158 | + } | |
| 159 | + } | |
| 160 | + } | |
| 161 | + */ | |
| 134 | 162 | return ''; |
| 135 | 163 | } |
| 136 | 164 | |
| 137 | 165 | public function start() { |
| 138 | 166 | $state = $this->status(); |
| 139 | 167 | if($state != 'STARTED') { |
| 140 | - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; | |
| 168 | + //$cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; | |
| 169 | +// $cmd = "{$this->getBin()} ".$this->getOption(); | |
| 170 | +//"/usr/bin/java" openOffice -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" /usr/bin/soffice | |
| 171 | +//"/usr/bin/java" -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" openOffice /usr/bin/soffice | |
| 172 | + $cmd = "\"{$this->util->getJava()}\" -cp \"".SYS_DIR."\" openOffice ".$this->getBin(); | |
| 141 | 173 | if(DEBUG) { |
| 142 | 174 | echo "Command : $cmd<br/>"; |
| 143 | 175 | return ; |
| 144 | 176 | } |
| 145 | - $cmd .= "\"{$this->util->getJava()}\" -cp \"".SYS_DIR.";\" openOffice \""; | |
| 146 | 177 | $response = $this->util->pexec($cmd); |
| 147 | 178 | |
| 148 | 179 | return $response; | ... | ... |
setup/wizard/lib/system/openOffice.class
No preview for this file type
setup/wizard/lib/system/openOffice.java
| ... | ... | @@ -5,12 +5,13 @@ import java.util.Properties; |
| 5 | 5 | public class openOffice { |
| 6 | 6 | |
| 7 | 7 | public static void main(String args[]) throws Exception { |
| 8 | + String openoffice = args[0]; | |
| 8 | 9 | try { |
| 9 | 10 | // Execute a command without arguments |
| 10 | - String command = "nohup /usr/bin/soffice -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\" > /dev/null 2>&1 & echo $!"; | |
| 11 | + String command = "nohup "+openoffice+" -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\""; | |
| 11 | 12 | Process child = Runtime.getRuntime().exec(command); |
| 12 | 13 | } catch (IOException e) { |
| 13 | 14 | System.err.println("Error: " + e.getMessage()); |
| 14 | 15 | } |
| 15 | 16 | } |
| 16 | -} | |
| 17 | 17 | \ No newline at end of file |
| 18 | +} | ... | ... |
setup/wizard/resources/js/wizard.js
| ... | ... | @@ -219,10 +219,16 @@ wizard.prototype.sendRegistration = function () { |
| 219 | 219 | |
| 220 | 220 | wizard.prototype.clearSessions = function () { |
| 221 | 221 | var address = 'session.php?action=destroyInstall'; |
| 222 | + w.clearASession(address); | |
| 223 | + var address = 'session.php?action=destroyMigrate'; | |
| 224 | + w.clearASession(address); | |
| 225 | +} | |
| 226 | + | |
| 227 | +wizard.prototype.clearASession = function (address) { | |
| 222 | 228 | $.ajax({ |
| 223 | 229 | url: address, |
| 224 | 230 | dataType: "html", |
| 225 | 231 | type: "POST", |
| 226 | 232 | cache: false, |
| 227 | - }); | |
| 233 | + }); | |
| 228 | 234 | } |
| 229 | 235 | \ No newline at end of file | ... | ... |
setup/wizard/steps/complete.php
| ... | ... | @@ -84,6 +84,7 @@ class complete extends Step { |
| 84 | 84 | // check services |
| 85 | 85 | $this->checkServices(); |
| 86 | 86 | $this->storeSilent();// Set silent mode variables |
| 87 | + | |
| 87 | 88 | } |
| 88 | 89 | |
| 89 | 90 | private function checkFileSystem() |
| ... | ... | @@ -172,7 +173,8 @@ class complete extends Step { |
| 172 | 173 | } |
| 173 | 174 | |
| 174 | 175 | // make db connection - user |
| 175 | - $loaded = $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | |
| 176 | + $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | |
| 177 | + $loaded = $this->_dbhandler->getDatabaseLink(); | |
| 176 | 178 | // if we can log in to the database, check access |
| 177 | 179 | // TODO check write access? |
| 178 | 180 | if ($loaded) |
| ... | ... | @@ -242,6 +244,11 @@ class complete extends Step { |
| 242 | 244 | $this->temp_variables['paths_check'] = $this->paths_check; |
| 243 | 245 | $this->temp_variables['privileges_check'] = $this->privileges_check; |
| 244 | 246 | $this->temp_variables['database_check'] = $this->database_check; |
| 247 | + if (file_exists('migrate.lock')) { | |
| 248 | + $this->temp_variables['migrate_check'] = true; | |
| 249 | + } else { | |
| 250 | + $this->temp_variables['migrate_check'] = false; | |
| 251 | + } | |
| 245 | 252 | } |
| 246 | 253 | } |
| 247 | 254 | ?> |
| 248 | 255 | \ No newline at end of file | ... | ... |
setup/wizard/steps/configuration.php
| ... | ... | @@ -296,8 +296,8 @@ class configuration extends Step |
| 296 | 296 | */ |
| 297 | 297 | public function registerDBConfig($server, $dbconf) { // Adjust server variables |
| 298 | 298 | $server['dbName'] = array('where'=>'file', 'name'=>ucwords($dbconf['dname']), 'section'=>'db', 'value'=>$dbconf['dname'], 'setting'=>'dbName'); |
| 299 | - $server['dbUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['duname']), 'section'=>'db', 'value'=>$dbconf['duname'], 'setting'=>'dbUser'); | |
| 300 | - $server['dbPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dpassword']), 'section'=>'db', 'value'=>$dbconf['dpassword'], 'setting'=>'dbPass'); | |
| 299 | + $server['dbUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmsname']), 'section'=>'db', 'value'=>$dbconf['dmsname'], 'setting'=>'dbUser'); | |
| 300 | + $server['dbPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmspassword']), 'section'=>'db', 'value'=>$dbconf['dmspassword'], 'setting'=>'dbPass'); | |
| 301 | 301 | $server['dbPort'] = array('where'=>'file', 'name'=>ucwords($dbconf['dport']), 'section'=>'db', 'value'=>$dbconf['dport'], 'setting'=>'dbPort'); |
| 302 | 302 | $server['dbAdminUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmsname']), 'section'=>'db', 'value'=>$dbconf['dmsname'], 'setting'=>'dbAdminUser'); |
| 303 | 303 | $server['dbAdminPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmspassword']), 'section'=>'db', 'value'=>$dbconf['dmspassword'], 'setting'=>'dbAdminPass'); | ... | ... |
setup/wizard/steps/database.php
| ... | ... | @@ -636,6 +636,10 @@ class database extends Step |
| 636 | 636 | |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | + if(!$this->importExportedDB()) { | |
| 640 | + $this->error['con'] = "Could not Import "; | |
| 641 | + } | |
| 642 | + | |
| 639 | 643 | return true; |
| 640 | 644 | } |
| 641 | 645 | |
| ... | ... | @@ -755,7 +759,7 @@ class database extends Step |
| 755 | 759 | } else { |
| 756 | 760 | $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";"; |
| 757 | 761 | $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";"; |
| 758 | - if ($this->_dbhandler->execute($user1) && $this->_dbhandler->execute($user2)) { | |
| 762 | + if ($this->_dbhandler->query($user1) && $this->_dbhandler->query($user2)) { | |
| 759 | 763 | return true; |
| 760 | 764 | } else { |
| 761 | 765 | $this->error['con'] = "Could not create users for database: {$this->dname}"; |
| ... | ... | @@ -784,7 +788,7 @@ class database extends Step |
| 784 | 788 | while (!feof($handle)) { |
| 785 | 789 | $query.= fgets($handle, 4096); |
| 786 | 790 | if (substr(rtrim($query), -1) == ';') { |
| 787 | - $this->_dbhandler->execute($query); | |
| 791 | + $this->_dbhandler->query($query); | |
| 788 | 792 | $query = ''; |
| 789 | 793 | } |
| 790 | 794 | } |
| ... | ... | @@ -805,6 +809,20 @@ class database extends Step |
| 805 | 809 | return $this->parse_mysql_dump(SQL_INSTALL_DIR."data.sql"); |
| 806 | 810 | } |
| 807 | 811 | |
| 812 | + private function importExportedDB() { | |
| 813 | + if (!WINDOWS_OS) { | |
| 814 | + $dir='/tmp/kt-db-backup'; | |
| 815 | + } | |
| 816 | + else { | |
| 817 | + $dir='c:/kt-db-backup'; | |
| 818 | + } | |
| 819 | + $sqlFile = $dir."/dms_migrate.sql"; | |
| 820 | + $this->parse_mysql_dump($sqlFile); | |
| 821 | + $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 822 | +// $this->_dbhandler->query("TRUNCATE plugins;"); | |
| 823 | + $this->_dbhandler->query("TRUNCATE plugin_helper;"); | |
| 824 | + return true; | |
| 825 | + } | |
| 808 | 826 | /** |
| 809 | 827 | * Close connection if it exists |
| 810 | 828 | * | ... | ... |
setup/wizard/steps/install.php
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* Install Step Controller. | |
| 3 | +* Install Step Controller. | |
| 4 | 4 | * |
| 5 | 5 | * KnowledgeTree Community Edition |
| 6 | 6 | * Document Management Made Simple |
| ... | ... | @@ -40,9 +40,27 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -class install extends step | |
| 43 | +class install extends step | |
| 44 | 44 | { |
| 45 | 45 | |
| 46 | + /** | |
| 47 | + * Flag to store class information in session | |
| 48 | + * | |
| 49 | + * @author KnowledgeTree Team | |
| 50 | + * @access public | |
| 51 | + * @var array | |
| 52 | + */ | |
| 53 | + protected $storeInSession = true; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Flag if step needs to be installed | |
| 57 | + * | |
| 58 | + * @author KnowledgeTree Team | |
| 59 | + * @access public | |
| 60 | + * @var array | |
| 61 | + */ | |
| 62 | + protected $runInstall = true; | |
| 63 | + | |
| 46 | 64 | function __construct() { |
| 47 | 65 | $this->temp_variables = array("step_name"=>"install"); |
| 48 | 66 | } |
| ... | ... | @@ -52,12 +70,14 @@ class install extends step |
| 52 | 70 | return 'landing'; |
| 53 | 71 | } |
| 54 | 72 | if($this->install()) { |
| 73 | + $this->doRun(); | |
| 55 | 74 | return 'install'; |
| 56 | 75 | } else if($this->previous()) { |
| 57 | 76 | return 'previous'; |
| 58 | 77 | } |
| 59 | 78 | |
| 60 | - return 'landing'; | |
| 79 | + $this->doRun(); | |
| 80 | + return 'landing'; | |
| 61 | 81 | } |
| 62 | 82 | |
| 63 | 83 | public function getStepVars() |
| ... | ... | @@ -68,5 +88,41 @@ class install extends step |
| 68 | 88 | public function getErrors() { |
| 69 | 89 | return $this->error; |
| 70 | 90 | } |
| 91 | + | |
| 92 | + public function doRun() | |
| 93 | + { | |
| 94 | + if(isset($_POST['Install'])) { | |
| 95 | + if(isset($_POST['call_home'])){ | |
| 96 | + $value = $_POST['call_home']; | |
| 97 | + }else{ | |
| 98 | + $value = 'disable'; | |
| 99 | + } | |
| 100 | + $this->temp_variables['call_home'] = $value; | |
| 101 | + | |
| 102 | + // Force a set session | |
| 103 | + // TODO: fix this to correctly set the session | |
| 104 | + $_SESSION['installers'] ['install']['call_home'] = $value; | |
| 105 | + } | |
| 106 | + } | |
| 107 | + | |
| 108 | + public function installStep() | |
| 109 | + { | |
| 110 | + $conf = $this->getDataFromSession("install"); | |
| 111 | + // retrieve database information from session | |
| 112 | + // initialise the db connection | |
| 113 | + $this->_dbhandler = new dbUtil(); | |
| 114 | + $dbconf = $this->getDataFromSession("database"); | |
| 115 | + $this->_dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); | |
| 116 | + | |
| 117 | + $complete = 1; | |
| 118 | + if($conf['call_home'] == 'enable'){ | |
| 119 | + $complete = 0; | |
| 120 | + } | |
| 121 | + $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'"; | |
| 122 | + $this->_dbhandler->query($query); | |
| 123 | + | |
| 124 | + // close the database connection | |
| 125 | + $this->_dbhandler->close(); | |
| 126 | + } | |
| 71 | 127 | } |
| 72 | 128 | ?> |
| 73 | 129 | \ No newline at end of file | ... | ... |
setup/wizard/templates/complete.tpl
| ... | ... | @@ -117,7 +117,12 @@ |
| 117 | 117 | <?php } ?> |
| 118 | 118 | </div> |
| 119 | 119 | </div> |
| 120 | - <a href="../../" class="buttons back" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 120 | + <?php if($migrate_check) { ?> | |
| 121 | +<!-- <a href="../upgrade" class="buttons back" style="width:62px;" onclick="javascript:{w.clearSessions();}">Upgrade</a>--> | |
| 122 | + <a href="../../login.php" class="buttons back upgrade" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 123 | + <?php } else { ?> | |
| 124 | + <a href="../../login.php" class="buttons back upgrade" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 125 | + <?php } ?> | |
| 121 | 126 | <?php |
| 122 | 127 | if (INSTALL_TYPE == 'Zend') { |
| 123 | 128 | ?> | ... | ... |
setup/wizard/templates/install.tpl
| ... | ... | @@ -5,9 +5,14 @@ |
| 5 | 5 | <br/> |
| 6 | 6 | <br/> |
| 7 | 7 | <p class="empty_space"> |
| 8 | - The wizard will now complete the installation and run a final check on the system. | |
| 8 | + The wizard will now complete the installation and run a final check on the system. | |
| 9 | + </p> | |
| 10 | + <div class="demo"><?php echo $html->image('kt_browse.png'); ?></div> | |
| 11 | + <br/> | |
| 12 | + <br/> | |
| 13 | + <p> | |
| 14 | + <input type='checkbox' name='call_home' value='enable' checked /> Enable the monitoring system | |
| 9 | 15 | </p> |
| 10 | - <div class="demo"><?php echo $html->image('dame/kt_browse.png'); ?></div> | |
| 11 | 16 | </div> |
| 12 | 17 | <input type="submit" name="Previous" value="Previous" class="button_previous"/> |
| 13 | 18 | <input type="submit" name="Install" value="Install" class="button_next"/> | ... | ... |
sql/mysql/install/data.sql
| ... | ... | @@ -1376,7 +1376,8 @@ INSERT INTO `scheduler_tasks` VALUES |
| 1376 | 1376 | (8,'Disk Usage and Folder Utilisation Statistics','plugins/housekeeper/bin/UpdateStats.php','',0,'5mins','2007-10-01 00:00:00',NULL,0,'enabled'), |
| 1377 | 1377 | (9,'Refresh Index Statistics','search2/bin/cronIndexStats.php','',0,'1min','2007-10-01',NULL,0,'enabled'), |
| 1378 | 1378 | (10,'Refresh Resource Dependancies','search2/bin/cronResources.php','',0,'1min','2007-10-01',NULL,0,'enabled'), |
| 1379 | -(11,'Bulk Download Queue','bin/ajaxtasks/downloadTask.php','',0,'1min','2007-10-01',NULL,0,'system'); | |
| 1379 | +(11,'Bulk Download Queue','bin/ajaxtasks/downloadTask.php','',0,'1min','2007-10-01',NULL,0,'system'), | |
| 1380 | +(12,'Call Home','bin/system_info.php','',0,'daily','2009-10-01',NULL,0,'system'); | |
| 1380 | 1381 | |
| 1381 | 1382 | /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; |
| 1382 | 1383 | UNLOCK TABLES; |
| ... | ... | @@ -1767,7 +1768,9 @@ INSERT INTO `upgrades` VALUES |
| 1767 | 1768 | (225,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3'), |
| 1768 | 1769 | (226,'sql*3.7.0*0*3.7.0/plugins_admin.sql','Database upgrade to version 3.7.0: Plugins admin','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), |
| 1769 | 1770 | (227,'sql*3.7.0*0*3.7.0/config_settings.sql','Database upgrade to version 3.7.0: Config settings','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), |
| 1770 | -(228,'upgrade*3.7.0*99*upgrade3.7.0','Upgrade from version 3.6.3 to 3.7.0','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'); | |
| 1771 | +(228,'sql*3.7.0*0*3.7.0/plugin_helper.sql','Database upgrade to version 3.7.0: Plugin helper','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), | |
| 1772 | +(229,'sql*3.7.0*0*3.7.0/call_home_task.sql','Database upgrade to version 3.7.0: Call home task','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), | |
| 1773 | +(230,'upgrade*3.7.0*99*upgrade3.7.0','Upgrade from version 3.6.3 to 3.7.0','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'); | |
| 1771 | 1774 | /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; |
| 1772 | 1775 | UNLOCK TABLES; |
| 1773 | 1776 | ... | ... |
sql/mysql/upgrade/3.7.0/call_home_task.sql
0 → 100644
templates/ktcore/ktoffice_i18n.smarty
| ... | ... | @@ -22,16 +22,14 @@ i18n['Upload succeeded'] = '{i18n}Upload succeeded{/i18n}'; |
| 22 | 22 | |
| 23 | 23 | i18n['Document type changed'] = '{i18n}Document type changed{/i18n}'; |
| 24 | 24 | |
| 25 | -i18n['Upload failed'] = '{i18n}Upload failed{/i18n}'; | |
| 26 | - | |
| 27 | -i18n['Your document has not been saved.'] = '{i18n}Your document has not been saved.{/i18n}'; | |
| 28 | - | |
| 29 | -i18n['A newer version of this document is available. Would you like to open it instead?'] = '{i18n}A newer version of this document is available. Would you like to open it instead?{/i18n}'; | |
| 30 | - | |
| 31 | 25 | i18n['Upload'] = '{i18n}Upload{/i18n}'; |
| 32 | 26 | |
| 33 | 27 | i18n['Upload cancelled'] = '{i18n}Upload cancelled{/i18n}'; |
| 34 | 28 | |
| 29 | +i18n['Upload failed'] = '{i18n}Upload failed{/i18n}'; | |
| 30 | + | |
| 31 | +i18n['Your document has not been saved.'] = '{i18n}Your document has not been saved.{/i18n}'; | |
| 32 | + | |
| 35 | 33 | i18n['Your document has been saved.'] = '{i18n}Your document has been saved.{/i18n}'; |
| 36 | 34 | |
| 37 | 35 | i18n['Download failed'] = '{i18n}Download failed{/i18n}'; |
| ... | ... | @@ -62,13 +60,13 @@ i18n['Document checked in.'] = '{i18n}Document checked in.{/i18n}'; |
| 62 | 60 | |
| 63 | 61 | i18n['Document checked out.'] = '{i18n}Document checked out.{/i18n}'; |
| 64 | 62 | |
| 65 | -i18n['Cancel edit failed'] = '{i18n}Cancel edit failed{/i18n}'; | |
| 63 | +i18n['Cancel checkout failed'] = '{i18n}Cancel checkout failed{/i18n}'; | |
| 66 | 64 | |
| 67 | -i18n['The edit has not been cancelled.'] = '{i18n}The edit has not been cancelled.{/i18n}'; | |
| 65 | +i18n['The check-out has not been cancelled.'] = '{i18n}The check-out has not been cancelled.{/i18n}'; | |
| 68 | 66 | |
| 69 | -i18n['Cancel edit succeeded'] = '{i18n}Cancel edit succeeded{/i18n}'; | |
| 67 | +i18n['Cancel checkout succeeded'] = '{i18n}Cancel checkout succeeded{/i18n}'; | |
| 70 | 68 | |
| 71 | -i18n['The edit has been cancelled.'] = '{i18n}The edit has been cancelled.{/i18n}'; | |
| 69 | +i18n['The check-out has been cancelled.'] = '{i18n}The check-out has been cancelled.{/i18n}'; | |
| 72 | 70 | |
| 73 | 71 | i18n['Properties could not be saved.'] = '{i18n}Properties could not be saved.{/i18n}'; |
| 74 | 72 | |
| ... | ... | @@ -172,16 +170,6 @@ i18n['Login'] = '{i18n}Login{/i18n}'; |
| 172 | 170 | |
| 173 | 171 | i18n['Document already open'] = '{i18n}Document already open{/i18n}'; |
| 174 | 172 | |
| 175 | -i18n['Unable to delete folder'] = '{i18n}Unable to delete folder{/i18n}'; | |
| 176 | - | |
| 177 | -i18n['Delete Folder'] = '{i18n}Delete Folder{/i18n}'; | |
| 178 | - | |
| 179 | -i18n['This will delete this folder.<br/>Are you sure you want to continue?'] = '{i18n}This will delete this folder.<br/>Are you sure you want to continue?{/i18n}'; | |
| 180 | - | |
| 181 | -i18n['Unable to Delete Folder'] = '{i18n}Unable to Delete Folder{/i18n}'; | |
| 182 | - | |
| 183 | -i18n['This folder contains other documents/folders<br/>and may not be deleted.'] = '{i18n}This folder contains other documents/folders<br/>and may not be deleted.{/i18n}'; | |
| 184 | - | |
| 185 | 173 | i18n['Introduction'] = '{i18n}Introduction{/i18n}'; |
| 186 | 174 | |
| 187 | 175 | i18n['The requested action has not been implemented'] = '{i18n}The requested action has not been implemented{/i18n}'; |
| ... | ... | @@ -204,16 +192,6 @@ i18n['Save'] = '{i18n}Save{/i18n}'; |
| 204 | 192 | |
| 205 | 193 | i18n['Adds your open Office document to KnowledgeTree. You must have \'write\' permissions on the folder.'] = '{i18n}Adds your open Office document to KnowledgeTree. You must have \'write\' permissions on the folder.{/i18n}'; |
| 206 | 194 | |
| 207 | -i18n['Add Folder'] = '{i18n}Add Folder{/i18n}'; | |
| 208 | - | |
| 209 | -i18n['Provides an interface to create a new folder under the current folder. You must have \'add\' permissions on the folder.'] = '{i18n}Provides an interface to create a new folder under the current folder. You must have \'add\' permissions on the folder.{/i18n}'; | |
| 210 | - | |
| 211 | -i18n['Rename Folder'] = '{i18n}Rename Folder{/i18n}'; | |
| 212 | - | |
| 213 | -i18n['Provides an interface to rename the current folder. You must have \'rename\' permissions on the folder.'] = '{i18n}Provides an interface to rename the current folder. You must have \'rename\' permissions on the folder.{/i18n}'; | |
| 214 | - | |
| 215 | -i18n['Provides an interface to delete the current folder. You must have \'delete\' permissions on the folder.'] = '{i18n}Provides an interface to delete the current folder. You must have \'delete\' permissions on the folder.{/i18n}'; | |
| 216 | - | |
| 217 | 195 | i18n['New folder'] = '{i18n}New folder{/i18n}'; |
| 218 | 196 | |
| 219 | 197 | i18n['Saves active document to a new folder. You must have \'write\' permissions on the folder.'] = '{i18n}Saves active document to a new folder. You must have \'write\' permissions on the folder.{/i18n}'; |
| ... | ... | @@ -316,8 +294,6 @@ i18n['Please complete all required fields.'] = '{i18n}Please complete all requir |
| 316 | 294 | |
| 317 | 295 | i18n['Editing'] = '{i18n}Editing{/i18n}'; |
| 318 | 296 | |
| 319 | -i18n['File Type'] = '{i18n}File Type{/i18n}'; | |
| 320 | - | |
| 321 | 297 | i18n['Type'] = '{i18n}Type{/i18n}'; |
| 322 | 298 | |
| 323 | 299 | i18n['Some fields are required'] = '{i18n}Some fields are required{/i18n}'; |
| ... | ... | @@ -364,6 +340,6 @@ i18n['You do not have the required permissions to view the root folder. Please c |
| 364 | 340 | |
| 365 | 341 | i18n['Search for documents'] = '{i18n}Search for documents{/i18n}'; |
| 366 | 342 | |
| 367 | -// Total Language Strings: 153 | |
| 343 | +// Total Language Strings: 141 | |
| 368 | 344 | |
| 369 | -// Unique Strings: 153 | |
| 370 | 345 | \ No newline at end of file |
| 346 | +// Unique Strings: 141 | |
| 371 | 347 | \ No newline at end of file | ... | ... |