Commit 7f0a8d06d642acc3384edcb274f0db729beebf44

Authored by Mark Holtzhausen
2 parents a08a1c03 23a42e25

Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge

bin/system_info.php
... ... @@ -151,22 +151,28 @@ function getKTEdition()
151 151 function getOSInfo()
152 152 {
153 153 $server = php_uname();
154   - $flavour = '';//'|-';
  154 + $server_arr = explode(' ', $server);
  155 +
  156 + // kernel version and os type - 32bit / 64bit
  157 + $kernel_v = $server_arr[2];
  158 + $os_v = array_pop($server_arr);
155 159  
156 160 if(strpos($server, 'Darwin') !== false){
157 161 $os = 'Mac OS X';
158 162 }else if(strpos($server, 'Win') !== false){
159 163 $os = 'Windows';
  164 + // windows differs from *nix
  165 + // kernel version = windows version
  166 + // os version = build number
  167 + $kernel_v = $server_arr[3];
  168 + $os_v = array_pop($server_arr);
160 169 }else if(strpos($server, 'Linux') !== false) {
161   - // Again regular expressions would be nice...
162   - // $pos = strpos($server, 'SMP');
163   - // $flavour = '|'.substr($server, 6, $pos-7);
164 170 $os = 'Linux';
165 171 }else {
166 172 $os = 'Unix';
167 173 }
168 174  
169   - return $os.$flavour;
  175 + return $os.'|'.$kernel_v.'|'.$os_v;
170 176 }
171 177  
172 178 function sendForm($data)
... ...
setup/upgrade/lib/UpgradeItems.inc.php
... ... @@ -49,19 +49,24 @@
49 49 */
50 50 // }}}
51 51  
52   -//require_once(KT_LIB_DIR . '/upgrades/UpgradeFunctions.inc.php');
53 52 require_once('sqlfile.inc.php');
54   -require_once('datetime.inc');
  53 +require_once('datetime.inc.php');
  54 +
  55 +require_once("../wizard/iniUtilities.php");
  56 +require_once("../wizard/dbUtilities.php");
55 57  
56 58 // {{{ Upgrade_Already_Applied
57   -class Upgrade_Already_Applied { //extends PEAR_Error {
  59 +class Upgrade_Already_Applied {
  60 +
58 61 function Upgrade_Already_Applied($oUpgradeItem) {
59 62 $this->oUpgradeItem = $oUpgradeItem;
60 63 }
  64 +
61 65 }
62 66 // }}}
63 67  
64   -class UpgradeItem extends InstallUtil {
  68 +class UpgradeItem {
  69 +
65 70 var $type = "";
66 71 var $name;
67 72 var $version;
... ... @@ -81,9 +86,9 @@ class UpgradeItem extends InstallUtil {
81 86 $this->description = $description;
82 87 $this->phase = $phase;
83 88 $this->priority = $priority;
84   - parent::__construct();
85   -// print_r($this);
86   -// die;
  89 +
  90 + $this->dbUtilities = new dbUtilities();
  91 + $this->iniUtilities = new iniUtilities();
87 92 }
88 93  
89 94 function setParent($parent) {
... ... @@ -117,41 +122,35 @@ class UpgradeItem extends InstallUtil {
117 122 return $this->type;
118 123 }
119 124  
120   - function runDBQuery($query, $checkResult = false, $typeCheck = false) {
121   - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  125 + /**
  126 + * Runs a DB query and returns a result based on arguments which specify what to look for
  127 + *
  128 + * @param string $query The query to run
  129 + * @param boolean $checkResult Whether to check that a result was found (not needed for update/delete, only select): This result may be empty
  130 + * @param boolean $resultCheck Whether to check for returned results from the query
  131 + * @return unknown
  132 + */
  133 + function runDBQuery($query, $checkResult = false, $resultCheck = false) {
  134 + if(!isset($this->iniUtilities) || !is_object($this->iniUtilities)) {
  135 + $this->dbUtilities = new dbUtilities();
  136 + $this->iniUtilities = new iniUtilities();
  137 + }
  138 +
122 139 $wizConfigHandler = new configuration();
123 140 $configPath = $wizConfigHandler->readConfigPathIni();
124   - if(!is_object($this->iniUtilities)) {
125   - parent::__construct();
126   - }
  141 +
127 142 $this->iniUtilities->load($configPath);
128 143 $dconf = $this->iniUtilities->getSection('db');
129 144 $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
130 145 $result = $this->dbUtilities->query($query);
131   -// echo "$query<br/>";
132   -// echo '<pre>';
133   -// print_r($result);
134   -// echo '</pre>';
135 146 if($checkResult) {
136 147 $assArr = $this->dbUtilities->fetchAssoc($result);
137   -// echo '<pre>';
138   -// print_r($assArr);
139   -// echo '</pre>';
140   -// if(is_null($assArr)) {
141   -// echo '=== null ===<br/>';
142   -// return false;
143   -// } else {
144   -// echo '=== not null ===<br/>';
145   -// }
146   - if($typeCheck) {
  148 + if($resultCheck) {
147 149 return !is_null($assArr);
148 150 } else {
149 151 return is_null($assArr);
150 152 }
151 153 }
152   -// echo '<pre>';
153   -// print_r($assArr);
154   -// echo '</pre>';
155 154 return !is_null($result);
156 155 }
157 156  
... ... @@ -185,14 +184,7 @@ class UpgradeItem extends InstallUtil {
185 184 return new Upgrade_Already_Applied($this);
186 185 }
187 186 }
188   -// if (!$res) {
189   -// $this->error[] = 'An Error Has Occured';
190   -// }
191   -// $oCache =& KTCache::getSingleton();
192   -// $save = $oCache->bEnabled;
193   -// $oCache->bEnabled = false;
194 187 $res = $this->_performUpgrade();
195   -// $oCache->bEnabled = $save;
196 188 if (!$res) {
197 189 $this->_recordUpgrade(false);
198 190 $this->error[] = $this->dbUtilities->getErrors();
... ... @@ -200,7 +192,7 @@ class UpgradeItem extends InstallUtil {
200 192 }
201 193 $res = $this->_recordUpgrade(true);
202 194 if (!$res) {
203   - $this->error[] = 'An Error Has Occured 1';
  195 + $this->error[] = 'An Error Has Occured';
204 196 return false;
205 197 }
206 198 return true;
... ... @@ -220,21 +212,20 @@ class UpgradeItem extends InstallUtil {
220 212 } else {
221 213 $parentid = null;
222 214 }
223   - $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES ('', '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')";
  215 + $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')";
224 216 $this->dbUtilities->query($sql);
225 217  
226 218 return true;
227 219 }
228 220  
229   - // STATIC
230 221 function getAllUpgrades() {
231 222 return array();
232 223 }
233   -
234 224  
235   -}
  225 +} // end class UpgradeItem
236 226  
237 227 class SQLUpgradeItem extends UpgradeItem {
  228 +
238 229 function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) {
239 230 $this->type = "sql";
240 231 $this->priority = 0;
... ... @@ -270,18 +261,15 @@ class SQLUpgradeItem extends UpgradeItem {
270 261 * STATIC
271 262 */
272 263 public static function getUpgrades($origVersion, $currVersion) {
273   -// global $default;
274   -
275   -// $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/';
276   - $dbType = 'mysql';
277   - $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
  264 + $dbType = 'mysql';
  265 + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
278 266 $ret = array();
279 267  
280 268 if (!is_dir($sqlupgradedir)) {
281   -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible");
  269 + return false;
282 270 }
283 271 if (!($dh = opendir($sqlupgradedir))) {
284   -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible");
  272 + return false;
285 273 }
286 274  
287 275 while (($file = readdir($dh)) !== false) {
... ... @@ -309,9 +297,6 @@ class SQLUpgradeItem extends UpgradeItem {
309 297 if (!lte_version($details[1], $currVersion)) {
310 298 continue;
311 299 }
312   - //print "Will run $file\n";
313   -// print_r($this->util->dbUtilities);
314   -// die;
315 300 $ret[] = new SQLUpgradeItem($file);
316 301 }
317 302 }
... ... @@ -330,10 +315,6 @@ class SQLUpgradeItem extends UpgradeItem {
330 315 if (!lte_version($details[1], $currVersion)) {
331 316 continue;
332 317 }
333   - //print "Will run $file\n";
334   -// print_r(SQLUpgradeItem::);
335   -// die;
336   -// new InstallUtil();
337 318 $ret[] = new SQLUpgradeItem($relpath);
338 319 }
339 320 }
... ... @@ -384,10 +365,10 @@ class SQLUpgradeItem extends UpgradeItem {
384 365 return $this->dbUtilities->runQueries($queries);
385 366 }
386 367  
387   -
388   -}
  368 +} // end class SQLUpgradeItem
389 369  
390 370 class KTRebuildPermissionObserver {
  371 +
391 372 function start() {
392 373 $this->lastBeat = time();
393 374 }
... ... @@ -401,9 +382,11 @@ class KTRebuildPermissionObserver {
401 382 }
402 383 function end() {
403 384 }
  385 +
404 386 }
405 387  
406 388 class RecordUpgradeItem extends UpgradeItem {
  389 +
407 390 function RecordUpgradeItem ($version, $oldversion = null) {
408 391 $this->type = "upgrade";
409 392 if (is_null($oldversion)) {
... ... @@ -417,24 +400,30 @@ class RecordUpgradeItem extends UpgradeItem {
417 400 }
418 401  
419 402 function _performUpgrade() {
420   -// $this->_deleteSmartyFiles();
421   -// $this->_deleteProxyFiles();
422   -// require_once(KT_LIB_DIR . '/cache/cache.inc.php');
423   -// $oCache =& KTCache::getSingleton();
424   -// $oCache->deleteAllCaches();
  403 + // What did this do?
  404 + /*
  405 + $this->_deleteSmartyFiles();
  406 + $this->_deleteProxyFiles();
  407 + require_once(KT_LIB_DIR . '/cache/cache.inc.php');
  408 + $oCache =& KTCache::getSingleton();
  409 + $oCache->deleteAllCaches();
425 410 // TODO : clear cache folder
426   -// require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');
427   - // TODO : What does this do
428   -// $po =& new KTRebuildPermissionObserver($this);
429   -// $po->start();
430   -// $oChannel =& KTPermissionChannel::getSingleton();
431   -// $oChannel->addObserver($po);
  411 + require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');
  412 + TODO : What does this do
  413 + $po =& new KTRebuildPermissionObserver($this);
  414 + $po->start();
  415 + $oChannel =& KTPermissionChannel::getSingleton();
  416 + $oChannel->addObserver($po);
  417 + */
432 418  
433 419 set_time_limit(0);
434 420 ignore_user_abort(true);
435 421  
436   -// KTPermissionUtil::rebuildPermissionLookups(true);
437   -// $po->end();
  422 + // What did this do?
  423 + /*
  424 + KTPermissionUtil::rebuildPermissionLookups(true);
  425 + $po->end();
  426 + */
438 427  
439 428 $versionFile=KT_DIR . '/docs/VERSION-NAME.txt';
440 429 $fp = fopen($versionFile,'rt');
... ... @@ -470,7 +459,6 @@ class RecordUpgradeItem extends UpgradeItem {
470 459 }
471 460 }
472 461  
473   -
474 462 function _deleteProxyFiles() {
475 463 $oKTConfig =& KTConfig::getSingleton();
476 464  
... ... @@ -505,6 +493,7 @@ class RecordUpgradeItem extends UpgradeItem {
505 493 @unlink($sFile);
506 494 }
507 495 }
508   -}
  496 +
  497 +} // end class RecordUpgradeItem
509 498  
510 499 ?>
... ...
setup/upgrade/lib/datetime.inc renamed to setup/upgrade/lib/datetime.inc.php
setup/upgrade/lib/upgrade.inc.php
... ... @@ -40,31 +40,34 @@
40 40  
41 41 require_once('UpgradeItems.inc.php');
42 42  
43   -//function setupAdminDatabase() {
44   -// global $default;
45   -// $dsn = array(
46   -// 'phptype' => $default->dbType,
47   -// 'username' => $default->dbAdminUser,
48   -// 'password' => $default->dbAdminPass,
49   -// 'hostspec' => $default->dbHost,
50   -// 'database' => $default->dbName,
51   -// 'port' => $default->dbPort,
52   -// );
53   -//
54   -// $options = array(
55   -// 'debug' => 2,
56   -// 'portability' => DB_PORTABILITY_ERRORS,
57   -// 'seqname_format' => 'zseq_%s',
58   -// );
59   -//
60   -// $default->_admindb = &DB::connect($dsn, $options);
61   -// if (PEAR::isError($default->_admindb)) {
62   -// die($default->_admindb->toString());
63   -// }
64   -// $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC);
65   -// return;
66   -//}
67   -//setupAdminDatabase();
  43 +// What did this do?
  44 +/*
  45 +function setupAdminDatabase() {
  46 + global $default;
  47 + $dsn = array(
  48 + 'phptype' => $default->dbType,
  49 + 'username' => $default->dbAdminUser,
  50 + 'password' => $default->dbAdminPass,
  51 + 'hostspec' => $default->dbHost,
  52 + 'database' => $default->dbName,
  53 + 'port' => $default->dbPort,
  54 + );
  55 +
  56 + $options = array(
  57 + 'debug' => 2,
  58 + 'portability' => DB_PORTABILITY_ERRORS,
  59 + 'seqname_format' => 'zseq_%s',
  60 + );
  61 +
  62 + $default->_admindb = &DB::connect($dsn, $options);
  63 + if (PEAR::isError($default->_admindb)) {
  64 + die($default->_admindb->toString());
  65 + }
  66 + $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC);
  67 + return;
  68 +}
  69 +setupAdminDatabase();
  70 +*/
68 71  
69 72 // {{{ Format of the descriptor
70 73 /**
... ... @@ -196,7 +199,7 @@ function compare_version($version1, $version2) {
196 199 */
197 200 function lte_version($version1, $version2) {
198 201 if (in_array(compare_version($version1, $version2), array(-1, 0))) {
199   - return true;
  202 + return true;
200 203 }
201 204 return false;
202 205 }
... ... @@ -208,7 +211,7 @@ function lte_version($version1, $version2) {
208 211 */
209 212 function gte_version($version1, $version2) {
210 213 if (in_array(compare_version($version1, $version2), array(0, 1))) {
211   - return true;
  214 + return true;
212 215 }
213 216 return false;
214 217 }
... ...
setup/upgrade/step.php
... ... @@ -39,6 +39,9 @@
39 39 * @package Upgrader
40 40 * @version Version 0.1
41 41 */
  42 +
  43 +require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  44 +
42 45 class Step
43 46 {
44 47 /**
... ... @@ -435,6 +438,44 @@ class Step
435 438  
436 439 return $_SESSION[$package][$class];
437 440 }
  441 +
  442 + protected function readConfig() {
  443 + $wizConfigHandler = new configuration();
  444 + $path = $wizConfigHandler->readConfigPathIni();
  445 + $this->util->iniUtilities->load($path);
  446 + $dbSettings = $this->util->iniUtilities->getSection('db');
  447 + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
  448 + 'dbName'=> $dbSettings['dbName'],
  449 + 'dbUser'=> $dbSettings['dbUser'],
  450 + 'dbPass'=> $dbSettings['dbPass'],
  451 + 'dbPort'=> $dbSettings['dbPort'],
  452 + 'dbAdminUser'=> $dbSettings['dbAdminUser'],
  453 + 'dbAdminPass'=> $dbSettings['dbAdminPass'],
  454 + );
  455 + $this->paths = $this->util->iniUtilities->getSection('urls');
  456 + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
  457 + $this->sysVersion = $this->readVersion();
  458 + $this->cachePath = $wizConfigHandler->readCachePath();
  459 + $this->proxyPath = $this->cachePath."/.."; // Total guess.
  460 + $this->proxyPath = realpath($this->proxyPath."/proxies");
  461 + $this->storeSilent();
  462 + }
  463 +
  464 + protected function readVersion() {
  465 + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt";
  466 + if(file_exists($verFile)) {
  467 + $foundVersion = file_get_contents($verFile);
  468 + return $foundVersion;
  469 + } else {
  470 + $this->error[] = "KT installation version not found";
  471 + }
  472 +
  473 + return false;
  474 + }
  475 +
  476 + protected function storeSilent() {
  477 +
  478 + }
438 479 }
439 480  
440 481 ?>
441 482 \ No newline at end of file
... ...
setup/upgrade/steps/upgradeBackup.php
... ... @@ -101,7 +101,6 @@ class upgradeBackup extends Step {
101 101 // TODO error checking (done in backupDone at the moment)
102 102 $this->backupDone();
103 103 }
104   -// $this->storeSilent();// Set silent mode variables
105 104  
106 105 return true;
107 106 }
... ... @@ -246,43 +245,6 @@ class upgradeBackup extends Step {
246 245 $this->temp_variables['dir'] = $dir;
247 246 $this->temp_variables['display'] = $stmt['display'];
248 247 }
249   -
250   - // TODO this function needs to be refactored out into the parent Step class??
251   - private function readConfig() {
252   - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
253   - $wizConfigHandler = new configuration();
254   - $path = $wizConfigHandler->readConfigPathIni();
255   - $this->util->iniUtilities->load($path);
256   - $dbSettings = $this->util->iniUtilities->getSection('db');
257   -
258   - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
259   - 'dbName'=> $dbSettings['dbName'],
260   - 'dbUser'=> $dbSettings['dbUser'],
261   - 'dbPass'=> $dbSettings['dbPass'],
262   - 'dbPort'=> $dbSettings['dbPort'],
263   - // dbSocket doesn't exist as far as I can find, where was it coming from?
264   - //'dbSocket'=> $dbSettings['dbSocket'],
265   - 'dbAdminUser'=> $dbSettings['dbAdminUser'],
266   - 'dbAdminPass'=> $dbSettings['dbAdminPass'],
267   - );
268   - $this->paths = $this->util->iniUtilities->getSection('urls');
269   - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
270   - $this->temp_variables['dbSettings'] = $this->dbSettings;
271   - $this->sysVersion = $this->readVersion();
272   - $this->cachePath = $wizConfigHandler->readCachePath();
273   - }
274   -
275   - // TODO this function needs to be refactored out into the parent Step class
276   - public function readVersion() {
277   - $verFile = SYSTEM_DIR."docs".DS."VERSION.txt";
278   - if(file_exists($verFile)) {
279   - $foundVersion = file_get_contents($verFile);
280   - return $foundVersion;
281   - } else {
282   - $this->error[] = "KT installation version not found";
283   - }
284 248  
285   - return false;
286   - }
287 249 }
288 250 ?>
289 251 \ No newline at end of file
... ...
setup/upgrade/steps/upgradeComplete.php
... ... @@ -61,7 +61,7 @@ class upgradeComplete extends Step {
61 61 * Set all silent mode varibles
62 62 *
63 63 */
64   - private function storeSilent() {
  64 + protected function storeSilent() {
65 65 $v = $this->getDataFromSession('upgradeProperties');
66 66 $this->temp_variables['sysVersion'] = $v['upgrade_version'];
67 67 }
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -65,15 +65,6 @@ class upgradeDatabase extends Step
65 65 private $dbBinary = ''; // TODO:multiple databases
66 66  
67 67 /**
68   - * List of errors encountered
69   - *
70   - * @author KnowledgeTree Team
71   - * @access public
72   - * @var array
73   - */
74   - public $error = array();
75   -
76   - /**
77 68 * List of errors used in template
78 69 *
79 70 * @author KnowledgeTree Team
... ... @@ -143,8 +134,10 @@ class upgradeDatabase extends Step
143 134  
144 135 private function doRun($action = null) {
145 136 $this->readConfig();
  137 +
146 138 $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
147 139 $this->temp_variables['action'] = $action;
  140 +
148 141 if (is_null($action) || ($action == 'preview')) {
149 142 $this->temp_variables['title'] = 'Preview Upgrade';
150 143 $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable();
... ... @@ -206,31 +199,6 @@ class upgradeDatabase extends Step
206 199  
207 200 return false;
208 201 }
209   -
210   - /**
211   - * Stores varibles used by template
212   - *
213   - * @author KnowledgeTree Team
214   - * @params none
215   - * @access public
216   - * @return array
217   - */
218   - public function getStepVars() {
219   - return $this->temp_variables;
220   - }
221   -
222   - /**
223   - * Returns database errors
224   - *
225   - * @author KnowledgeTree Team
226   - * @access public
227   - * @params none
228   - * @return array
229   - */
230   - public function getErrors() {
231   -
232   - return $this->error;
233   - }
234 202  
235 203 /**
236 204 * Initialize errors to false
... ... @@ -246,29 +214,6 @@ class upgradeDatabase extends Step
246 214 }
247 215 }
248 216  
249   - private function readConfig() {
250   - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
251   - $wizConfigHandler = new configuration();
252   - $path = $wizConfigHandler->readConfigPathIni();
253   - $this->util->iniUtilities->load($path);
254   - $dbSettings = $this->util->iniUtilities->getSection('db');
255   - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
256   - 'dbName'=> $dbSettings['dbName'],
257   - 'dbUser'=> $dbSettings['dbUser'],
258   - 'dbPass'=> $dbSettings['dbPass'],
259   - 'dbPort'=> $dbSettings['dbPort'],
260   - 'dbAdminUser'=> $dbSettings['dbAdminUser'],
261   - 'dbAdminPass'=> $dbSettings['dbAdminPass'],
262   - );
263   - $this->paths = $this->util->iniUtilities->getSection('urls');
264   - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
265   - $this->sysVersion = $this->readVersion();
266   - $this->cachePath = $wizConfigHandler->readCachePath();
267   - $this->proxyPath = $this->cachePath."/.."; // Total guess.
268   - $this->proxyPath = realpath($this->proxyPath."/proxies");
269   - $this->storeSilent();
270   - }
271   -
272 217 public function storeSilent() {
273 218 $this->temp_variables['paths'] = $this->paths;
274 219 $this->temp_variables['sysVersion'] = $this->sysVersion;
... ... @@ -329,6 +274,8 @@ class upgradeDatabase extends Step
329 274 }
330 275  
331 276 private function deleteDirectory($sPath) {
  277 + if (empty($sPath) || !is_dir($sPath)) return;
  278 +
332 279 if (!WINDOWS_OS) {
333 280 if (file_exists('/bin/rm')) {
334 281 $this->util->pexec(array('/bin/rm', '-rf', $sPath));
... ... @@ -364,17 +311,11 @@ class upgradeDatabase extends Step
364 311  
365 312 // Ensure all plugins are re-registered.
366 313 $sql = "TRUNCATE plugin_helper";
367   - //$res = DBUtil::runQuery($sql);
368 314 $res = $this->util->dbUtilities->query($sql);
369 315  
370 316 // Clear out all caches and proxies - they need to be regenerated with the new code
371 317 $this->deleteDirectory($this->proxyPath);
372   -// $oKTCache = new KTCache();
373   -// $oKTCache->deleteAllCaches();
374 318 $this->deleteDirectory($this->cachePath);
375   - // Clear the configuration cache, it'll regenerate on next load
376   -// $oKTConfig = new KTConfig();
377   -// $oKTConfig->clearCache();
378 319  
379 320 // Unlock the scheduler
380 321 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
... ... @@ -409,17 +350,8 @@ class upgradeDatabase extends Step
409 350 $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res));
410 351 $this->temp_variables['upgradeTable'] .= '<br>' . "\n";
411 352 $this->temp_variables['upgradeTable'] .= "</div>\n";
412   -// if (!$res) {
413   -// if (!is_a($res, 'Upgrade_Already_Applied')) {
414   -// $res = false;
415   -// } else {
416   -// $res = true;
417   -// }
418   -// }
419 353 if ($res === false) {
420   - die;
421 354 $this->error = $this->util->dbUtilities->getErrors();
422   -// print_r($this->error);
423 355 break;
424 356 }
425 357 }
... ... @@ -428,11 +360,8 @@ class upgradeDatabase extends Step
428 360 }
429 361  
430 362 private function showResult($res) {
431   - if ($res) {
432   - if (is_a($res, 'Upgrade_Already_Applied')) {
433   - return '<span style="color: orange">Already applied</span>';
434   - }
435   -// return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res));
  363 + if ($res && is_a($res, 'Upgrade_Already_Applied')) {
  364 + return '<span style="color: orange">Already applied</span>';
436 365 }
437 366 if ($res === true) {
438 367 return '<span style="color: green">Success</span>';
... ...
setup/upgrade/steps/upgradeRestore.php
... ... @@ -94,8 +94,6 @@ class upgradeRestore extends Step {
94 94 $this->restoreDatabase();
95 95 }
96 96  
97   -// $this->storeSilent();// Set silent mode variables
98   -
99 97 return true;
100 98 }
101 99  
... ... @@ -223,43 +221,5 @@ class upgradeRestore extends Step {
223 221 $this->temp_variables['selected'] = true;
224 222 }
225 223  
226   - // TODO this function needs to be refactored out into the parent Step class??
227   - private function readConfig() {
228   - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
229   - $wizConfigHandler = new configuration();
230   - $path = $wizConfigHandler->readConfigPathIni();
231   - $this->util->iniUtilities->load($path);
232   - $dbSettings = $this->util->iniUtilities->getSection('db');
233   -
234   - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
235   - 'dbName'=> $dbSettings['dbName'],
236   - 'dbUser'=> $dbSettings['dbUser'],
237   - 'dbPass'=> $dbSettings['dbPass'],
238   - 'dbPort'=> $dbSettings['dbPort'],
239   - // dbSocket doesn't exist as far as I can find, where was it coming from?
240   - //'dbSocket'=> $dbSettings['dbSocket'],
241   - 'dbAdminUser'=> $dbSettings['dbAdminUser'],
242   - 'dbAdminPass'=> $dbSettings['dbAdminPass'],
243   - );
244   - $this->paths = $this->util->iniUtilities->getSection('urls');
245   - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
246   - $this->temp_variables['dbSettings'] = $this->dbSettings;
247   - $this->sysVersion = $this->readVersion();
248   - $this->cachePath = $wizConfigHandler->readCachePath();
249   - }
250   -
251   - // TODO this function needs to be refactored out into the parent Step class
252   - public function readVersion() {
253   - $verFile = SYSTEM_DIR."docs".DS."VERSION.txt";
254   - if(file_exists($verFile)) {
255   - $foundVersion = file_get_contents($verFile);
256   - return $foundVersion;
257   - } else {
258   - $this->error[] = "KT installation version not found";
259   - }
260   -
261   - return false;
262   - }
263   -
264 224 }
265 225 ?>
266 226 \ No newline at end of file
... ...
setup/upgrade/templates/database.tpl
... ... @@ -20,13 +20,11 @@
20 20 <?php echo $upgradeTable; ?>
21 21 <?php }
22 22 else if ($action == 'confirm') {
23   - if (!$backupStatus) { ?>
  23 + if ($backupStatus) { ?>
24 24 <p>We are about to start the upgrade process.<P>
25 25 <?php }
26 26 else { ?>
27   - <br/>
28   - <font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font>
29   - <p>
  27 + <p><font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font><p>
30 28 <?php } ?>
31 29 <?php }
32 30 else if ($action == 'runUpgrade') {
... ...
setup/wizard/steps/complete.php
... ... @@ -96,6 +96,7 @@ class complete extends Step {
96 96 foreach ($paths as $path)
97 97 {
98 98 $output = '';
  99 + $path['path'] = $class = strtolower(substr($path['path'],0,1)).substr($path['path'],1); // Damn you windows
99 100 $result = $this->util->checkPermission($path['path']);
100 101 $output = sprintf($pathhtml, $result['class'], $path['path'],
101 102 (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ),
... ...
setup/wizard/steps/configuration.php
... ... @@ -450,7 +450,7 @@ class configuration extends Step
450 450 }
451 451 $dirs = $this->getFromConfigPath(); // Store contents
452 452 }
453   - $varDirectory = $fileSystemRoot . DS . 'var';
  453 +
454 454 foreach ($dirs as $key => $dir){
455 455 $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path'];
456 456  
... ... @@ -460,6 +460,7 @@ class configuration extends Step
460 460 if(WINDOWS_OS)
461 461 $path = preg_replace('/\//', '\\',$path);
462 462 $dirs[$key]['path'] = $path;
  463 + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
463 464 if(isset($dir['file']))
464 465 $class = $this->util->checkPermission($path, $dir['create'], true);
465 466 else
... ...
setup/wizard/steps/services.php
... ... @@ -219,7 +219,7 @@ class services extends Step
219 219 $srv = new $className();
220 220 $srv->load();
221 221 $status = $this->serviceInstalled($srv);
222   - if($status != 'STARTED') {
  222 + if($status != 'STARTED' || $status != 'STOPPED') {
223 223 if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists
224 224 $passed = $this->$class->binaryChecks(); // Run Binary Pre Checks
225 225 if ($passed) { // Install Service
... ...