diff --git a/bin/system_info.php b/bin/system_info.php
index e9b39d0..c61ed8d 100644
--- a/bin/system_info.php
+++ b/bin/system_info.php
@@ -151,22 +151,28 @@ function getKTEdition()
function getOSInfo()
{
$server = php_uname();
- $flavour = '';//'|-';
+ $server_arr = explode(' ', $server);
+
+ // kernel version and os type - 32bit / 64bit
+ $kernel_v = $server_arr[2];
+ $os_v = array_pop($server_arr);
if(strpos($server, 'Darwin') !== false){
$os = 'Mac OS X';
}else if(strpos($server, 'Win') !== false){
$os = 'Windows';
+ // windows differs from *nix
+ // kernel version = windows version
+ // os version = build number
+ $kernel_v = $server_arr[3];
+ $os_v = array_pop($server_arr);
}else if(strpos($server, 'Linux') !== false) {
- // Again regular expressions would be nice...
- // $pos = strpos($server, 'SMP');
- // $flavour = '|'.substr($server, 6, $pos-7);
$os = 'Linux';
}else {
$os = 'Unix';
}
- return $os.$flavour;
+ return $os.'|'.$kernel_v.'|'.$os_v;
}
function sendForm($data)
diff --git a/setup/upgrade/lib/UpgradeItems.inc.php b/setup/upgrade/lib/UpgradeItems.inc.php
index 4ed2cd5..561401c 100644
--- a/setup/upgrade/lib/UpgradeItems.inc.php
+++ b/setup/upgrade/lib/UpgradeItems.inc.php
@@ -49,19 +49,24 @@
*/
// }}}
-//require_once(KT_LIB_DIR . '/upgrades/UpgradeFunctions.inc.php');
require_once('sqlfile.inc.php');
-require_once('datetime.inc');
+require_once('datetime.inc.php');
+
+require_once("../wizard/iniUtilities.php");
+require_once("../wizard/dbUtilities.php");
// {{{ Upgrade_Already_Applied
-class Upgrade_Already_Applied { //extends PEAR_Error {
+class Upgrade_Already_Applied {
+
function Upgrade_Already_Applied($oUpgradeItem) {
$this->oUpgradeItem = $oUpgradeItem;
}
+
}
// }}}
-class UpgradeItem extends InstallUtil {
+class UpgradeItem {
+
var $type = "";
var $name;
var $version;
@@ -81,9 +86,9 @@ class UpgradeItem extends InstallUtil {
$this->description = $description;
$this->phase = $phase;
$this->priority = $priority;
- parent::__construct();
-// print_r($this);
-// die;
+
+ $this->dbUtilities = new dbUtilities();
+ $this->iniUtilities = new iniUtilities();
}
function setParent($parent) {
@@ -117,41 +122,35 @@ class UpgradeItem extends InstallUtil {
return $this->type;
}
- function runDBQuery($query, $checkResult = false, $typeCheck = false) {
- require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
+ /**
+ * Runs a DB query and returns a result based on arguments which specify what to look for
+ *
+ * @param string $query The query to run
+ * @param boolean $checkResult Whether to check that a result was found (not needed for update/delete, only select): This result may be empty
+ * @param boolean $resultCheck Whether to check for returned results from the query
+ * @return unknown
+ */
+ function runDBQuery($query, $checkResult = false, $resultCheck = false) {
+ if(!isset($this->iniUtilities) || !is_object($this->iniUtilities)) {
+ $this->dbUtilities = new dbUtilities();
+ $this->iniUtilities = new iniUtilities();
+ }
+
$wizConfigHandler = new configuration();
$configPath = $wizConfigHandler->readConfigPathIni();
- if(!is_object($this->iniUtilities)) {
- parent::__construct();
- }
+
$this->iniUtilities->load($configPath);
$dconf = $this->iniUtilities->getSection('db');
$this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
$result = $this->dbUtilities->query($query);
-// echo "$query
";
-// echo '
'; -// print_r($result); -// echo ''; if($checkResult) { $assArr = $this->dbUtilities->fetchAssoc($result); -// echo '
'; -// print_r($assArr); -// echo ''; -// if(is_null($assArr)) { -// echo '=== null ===
'; -// print_r($assArr); -// echo ''; return !is_null($result); } @@ -185,14 +184,7 @@ class UpgradeItem extends InstallUtil { return new Upgrade_Already_Applied($this); } } -// if (!$res) { -// $this->error[] = 'An Error Has Occured'; -// } -// $oCache =& KTCache::getSingleton(); -// $save = $oCache->bEnabled; -// $oCache->bEnabled = false; $res = $this->_performUpgrade(); -// $oCache->bEnabled = $save; if (!$res) { $this->_recordUpgrade(false); $this->error[] = $this->dbUtilities->getErrors(); @@ -200,7 +192,7 @@ class UpgradeItem extends InstallUtil { } $res = $this->_recordUpgrade(true); if (!$res) { - $this->error[] = 'An Error Has Occured 1'; + $this->error[] = 'An Error Has Occured'; return false; } return true; @@ -220,21 +212,20 @@ class UpgradeItem extends InstallUtil { } else { $parentid = null; } - $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES ('', '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')"; + $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')"; $this->dbUtilities->query($sql); return true; } - // STATIC function getAllUpgrades() { return array(); } - -} +} // end class UpgradeItem class SQLUpgradeItem extends UpgradeItem { + function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) { $this->type = "sql"; $this->priority = 0; @@ -270,18 +261,15 @@ class SQLUpgradeItem extends UpgradeItem { * STATIC */ public static function getUpgrades($origVersion, $currVersion) { -// global $default; - -// $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/'; - $dbType = 'mysql'; - $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; + $dbType = 'mysql'; + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; $ret = array(); if (!is_dir($sqlupgradedir)) { -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); + return false; } if (!($dh = opendir($sqlupgradedir))) { -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); + return false; } while (($file = readdir($dh)) !== false) { @@ -309,9 +297,6 @@ class SQLUpgradeItem extends UpgradeItem { if (!lte_version($details[1], $currVersion)) { continue; } - //print "Will run $file\n"; -// print_r($this->util->dbUtilities); -// die; $ret[] = new SQLUpgradeItem($file); } } @@ -330,10 +315,6 @@ class SQLUpgradeItem extends UpgradeItem { if (!lte_version($details[1], $currVersion)) { continue; } - //print "Will run $file\n"; -// print_r(SQLUpgradeItem::); -// die; -// new InstallUtil(); $ret[] = new SQLUpgradeItem($relpath); } } @@ -384,10 +365,10 @@ class SQLUpgradeItem extends UpgradeItem { return $this->dbUtilities->runQueries($queries); } - -} +} // end class SQLUpgradeItem class KTRebuildPermissionObserver { + function start() { $this->lastBeat = time(); } @@ -401,9 +382,11 @@ class KTRebuildPermissionObserver { } function end() { } + } class RecordUpgradeItem extends UpgradeItem { + function RecordUpgradeItem ($version, $oldversion = null) { $this->type = "upgrade"; if (is_null($oldversion)) { @@ -417,24 +400,30 @@ class RecordUpgradeItem extends UpgradeItem { } function _performUpgrade() { -// $this->_deleteSmartyFiles(); -// $this->_deleteProxyFiles(); -// require_once(KT_LIB_DIR . '/cache/cache.inc.php'); -// $oCache =& KTCache::getSingleton(); -// $oCache->deleteAllCaches(); + // What did this do? + /* + $this->_deleteSmartyFiles(); + $this->_deleteProxyFiles(); + require_once(KT_LIB_DIR . '/cache/cache.inc.php'); + $oCache =& KTCache::getSingleton(); + $oCache->deleteAllCaches(); // TODO : clear cache folder -// require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); - // TODO : What does this do -// $po =& new KTRebuildPermissionObserver($this); -// $po->start(); -// $oChannel =& KTPermissionChannel::getSingleton(); -// $oChannel->addObserver($po); + require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); + TODO : What does this do + $po =& new KTRebuildPermissionObserver($this); + $po->start(); + $oChannel =& KTPermissionChannel::getSingleton(); + $oChannel->addObserver($po); + */ set_time_limit(0); ignore_user_abort(true); -// KTPermissionUtil::rebuildPermissionLookups(true); -// $po->end(); + // What did this do? + /* + KTPermissionUtil::rebuildPermissionLookups(true); + $po->end(); + */ $versionFile=KT_DIR . '/docs/VERSION-NAME.txt'; $fp = fopen($versionFile,'rt'); @@ -470,7 +459,6 @@ class RecordUpgradeItem extends UpgradeItem { } } - function _deleteProxyFiles() { $oKTConfig =& KTConfig::getSingleton(); @@ -505,6 +493,7 @@ class RecordUpgradeItem extends UpgradeItem { @unlink($sFile); } } -} + +} // end class RecordUpgradeItem ?> diff --git a/setup/upgrade/lib/datetime.inc b/setup/upgrade/lib/datetime.inc.php index 6bcffd2..6bcffd2 100644 --- a/setup/upgrade/lib/datetime.inc +++ b/setup/upgrade/lib/datetime.inc.php diff --git a/setup/upgrade/lib/upgrade.inc.php b/setup/upgrade/lib/upgrade.inc.php index c3dcd18..2fa9a9a 100644 --- a/setup/upgrade/lib/upgrade.inc.php +++ b/setup/upgrade/lib/upgrade.inc.php @@ -40,31 +40,34 @@ require_once('UpgradeItems.inc.php'); -//function setupAdminDatabase() { -// global $default; -// $dsn = array( -// 'phptype' => $default->dbType, -// 'username' => $default->dbAdminUser, -// 'password' => $default->dbAdminPass, -// 'hostspec' => $default->dbHost, -// 'database' => $default->dbName, -// 'port' => $default->dbPort, -// ); -// -// $options = array( -// 'debug' => 2, -// 'portability' => DB_PORTABILITY_ERRORS, -// 'seqname_format' => 'zseq_%s', -// ); -// -// $default->_admindb = &DB::connect($dsn, $options); -// if (PEAR::isError($default->_admindb)) { -// die($default->_admindb->toString()); -// } -// $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC); -// return; -//} -//setupAdminDatabase(); +// What did this do? +/* +function setupAdminDatabase() { + global $default; + $dsn = array( + 'phptype' => $default->dbType, + 'username' => $default->dbAdminUser, + 'password' => $default->dbAdminPass, + 'hostspec' => $default->dbHost, + 'database' => $default->dbName, + 'port' => $default->dbPort, + ); + + $options = array( + 'debug' => 2, + 'portability' => DB_PORTABILITY_ERRORS, + 'seqname_format' => 'zseq_%s', + ); + + $default->_admindb = &DB::connect($dsn, $options); + if (PEAR::isError($default->_admindb)) { + die($default->_admindb->toString()); + } + $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC); + return; +} +setupAdminDatabase(); +*/ // {{{ Format of the descriptor /** @@ -196,7 +199,7 @@ function compare_version($version1, $version2) { */ function lte_version($version1, $version2) { if (in_array(compare_version($version1, $version2), array(-1, 0))) { - return true; + return true; } return false; } @@ -208,7 +211,7 @@ function lte_version($version1, $version2) { */ function gte_version($version1, $version2) { if (in_array(compare_version($version1, $version2), array(0, 1))) { - return true; + return true; } return false; } diff --git a/setup/upgrade/step.php b/setup/upgrade/step.php index 2cf5254..355fabe 100644 --- a/setup/upgrade/step.php +++ b/setup/upgrade/step.php @@ -39,6 +39,9 @@ * @package Upgrader * @version Version 0.1 */ + +require_once("../wizard/steps/configuration.php"); // configuration to read the ini path + class Step { /** @@ -435,6 +438,44 @@ class Step return $_SESSION[$package][$class]; } + + protected function readConfig() { + $wizConfigHandler = new configuration(); + $path = $wizConfigHandler->readConfigPathIni(); + $this->util->iniUtilities->load($path); + $dbSettings = $this->util->iniUtilities->getSection('db'); + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], + 'dbName'=> $dbSettings['dbName'], + 'dbUser'=> $dbSettings['dbUser'], + 'dbPass'=> $dbSettings['dbPass'], + 'dbPort'=> $dbSettings['dbPort'], + 'dbAdminUser'=> $dbSettings['dbAdminUser'], + 'dbAdminPass'=> $dbSettings['dbAdminPass'], + ); + $this->paths = $this->util->iniUtilities->getSection('urls'); + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); + $this->sysVersion = $this->readVersion(); + $this->cachePath = $wizConfigHandler->readCachePath(); + $this->proxyPath = $this->cachePath."/.."; // Total guess. + $this->proxyPath = realpath($this->proxyPath."/proxies"); + $this->storeSilent(); + } + + protected function readVersion() { + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt"; + if(file_exists($verFile)) { + $foundVersion = file_get_contents($verFile); + return $foundVersion; + } else { + $this->error[] = "KT installation version not found"; + } + + return false; + } + + protected function storeSilent() { + + } } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeBackup.php b/setup/upgrade/steps/upgradeBackup.php index fa91eff..51f28d8 100644 --- a/setup/upgrade/steps/upgradeBackup.php +++ b/setup/upgrade/steps/upgradeBackup.php @@ -101,7 +101,6 @@ class upgradeBackup extends Step { // TODO error checking (done in backupDone at the moment) $this->backupDone(); } -// $this->storeSilent();// Set silent mode variables return true; } @@ -246,43 +245,6 @@ class upgradeBackup extends Step { $this->temp_variables['dir'] = $dir; $this->temp_variables['display'] = $stmt['display']; } - - // TODO this function needs to be refactored out into the parent Step class?? - private function readConfig() { - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path - $wizConfigHandler = new configuration(); - $path = $wizConfigHandler->readConfigPathIni(); - $this->util->iniUtilities->load($path); - $dbSettings = $this->util->iniUtilities->getSection('db'); - - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], - 'dbName'=> $dbSettings['dbName'], - 'dbUser'=> $dbSettings['dbUser'], - 'dbPass'=> $dbSettings['dbPass'], - 'dbPort'=> $dbSettings['dbPort'], - // dbSocket doesn't exist as far as I can find, where was it coming from? - //'dbSocket'=> $dbSettings['dbSocket'], - 'dbAdminUser'=> $dbSettings['dbAdminUser'], - 'dbAdminPass'=> $dbSettings['dbAdminPass'], - ); - $this->paths = $this->util->iniUtilities->getSection('urls'); - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); - $this->temp_variables['dbSettings'] = $this->dbSettings; - $this->sysVersion = $this->readVersion(); - $this->cachePath = $wizConfigHandler->readCachePath(); - } - - // TODO this function needs to be refactored out into the parent Step class - public function readVersion() { - $verFile = SYSTEM_DIR."docs".DS."VERSION.txt"; - if(file_exists($verFile)) { - $foundVersion = file_get_contents($verFile); - return $foundVersion; - } else { - $this->error[] = "KT installation version not found"; - } - return false; - } } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeComplete.php b/setup/upgrade/steps/upgradeComplete.php index 11f48d8..efa0ef9 100644 --- a/setup/upgrade/steps/upgradeComplete.php +++ b/setup/upgrade/steps/upgradeComplete.php @@ -61,7 +61,7 @@ class upgradeComplete extends Step { * Set all silent mode varibles * */ - private function storeSilent() { + protected function storeSilent() { $v = $this->getDataFromSession('upgradeProperties'); $this->temp_variables['sysVersion'] = $v['upgrade_version']; } diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index ef5d3fd..c3360c7 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -65,15 +65,6 @@ class upgradeDatabase extends Step private $dbBinary = ''; // TODO:multiple databases /** - * List of errors encountered - * - * @author KnowledgeTree Team - * @access public - * @var array - */ - public $error = array(); - - /** * List of errors used in template * * @author KnowledgeTree Team @@ -143,8 +134,10 @@ class upgradeDatabase extends Step private function doRun($action = null) { $this->readConfig(); + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']); $this->temp_variables['action'] = $action; + if (is_null($action) || ($action == 'preview')) { $this->temp_variables['title'] = 'Preview Upgrade'; $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); @@ -206,31 +199,6 @@ class upgradeDatabase extends Step return false; } - - /** - * Stores varibles used by template - * - * @author KnowledgeTree Team - * @params none - * @access public - * @return array - */ - public function getStepVars() { - return $this->temp_variables; - } - - /** - * Returns database errors - * - * @author KnowledgeTree Team - * @access public - * @params none - * @return array - */ - public function getErrors() { - - return $this->error; - } /** * Initialize errors to false @@ -246,29 +214,6 @@ class upgradeDatabase extends Step } } - private function readConfig() { - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path - $wizConfigHandler = new configuration(); - $path = $wizConfigHandler->readConfigPathIni(); - $this->util->iniUtilities->load($path); - $dbSettings = $this->util->iniUtilities->getSection('db'); - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], - 'dbName'=> $dbSettings['dbName'], - 'dbUser'=> $dbSettings['dbUser'], - 'dbPass'=> $dbSettings['dbPass'], - 'dbPort'=> $dbSettings['dbPort'], - 'dbAdminUser'=> $dbSettings['dbAdminUser'], - 'dbAdminPass'=> $dbSettings['dbAdminPass'], - ); - $this->paths = $this->util->iniUtilities->getSection('urls'); - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); - $this->sysVersion = $this->readVersion(); - $this->cachePath = $wizConfigHandler->readCachePath(); - $this->proxyPath = $this->cachePath."/.."; // Total guess. - $this->proxyPath = realpath($this->proxyPath."/proxies"); - $this->storeSilent(); - } - public function storeSilent() { $this->temp_variables['paths'] = $this->paths; $this->temp_variables['sysVersion'] = $this->sysVersion; @@ -329,6 +274,8 @@ class upgradeDatabase extends Step } private function deleteDirectory($sPath) { + if (empty($sPath) || !is_dir($sPath)) return; + if (!WINDOWS_OS) { if (file_exists('/bin/rm')) { $this->util->pexec(array('/bin/rm', '-rf', $sPath)); @@ -364,17 +311,11 @@ class upgradeDatabase extends Step // Ensure all plugins are re-registered. $sql = "TRUNCATE plugin_helper"; - //$res = DBUtil::runQuery($sql); $res = $this->util->dbUtilities->query($sql); // Clear out all caches and proxies - they need to be regenerated with the new code $this->deleteDirectory($this->proxyPath); -// $oKTCache = new KTCache(); -// $oKTCache->deleteAllCaches(); $this->deleteDirectory($this->cachePath); - // Clear the configuration cache, it'll regenerate on next load -// $oKTConfig = new KTConfig(); -// $oKTConfig->clearCache(); // Unlock the scheduler $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock'; @@ -409,17 +350,8 @@ class upgradeDatabase extends Step $this->temp_variables['upgradeTable'] .= sprintf('', $this->showResult($res)); $this->temp_variables['upgradeTable'] .= '
We are about to start the upgrade process.
-
- Please ensure that you have made a backup before continuing with the upgrade process.
-
+
Please ensure that you have made a backup before continuing with the upgrade process.
util->checkPermission($path['path']); $output = sprintf($pathhtml, $result['class'], $path['path'], (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ), diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index 7024af7..bdfca7d 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -450,7 +450,7 @@ class configuration extends Step } $dirs = $this->getFromConfigPath(); // Store contents } - $varDirectory = $fileSystemRoot . DS . 'var'; + foreach ($dirs as $key => $dir){ $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path']; @@ -460,6 +460,7 @@ class configuration extends Step if(WINDOWS_OS) $path = preg_replace('/\//', '\\',$path); $dirs[$key]['path'] = $path; + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows if(isset($dir['file'])) $class = $this->util->checkPermission($path, $dir['create'], true); else diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php index 6f5d309..153796d 100644 --- a/setup/wizard/steps/services.php +++ b/setup/wizard/steps/services.php @@ -219,7 +219,7 @@ class services extends Step $srv = new $className(); $srv->load(); $status = $this->serviceInstalled($srv); - if($status != 'STARTED') { + if($status != 'STARTED' || $status != 'STOPPED') { if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists $passed = $this->$class->binaryChecks(); // Run Binary Pre Checks if ($passed) { // Install Service