diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php index 28fd474..9f8b573 100644 --- a/setup/migrate/migrateUtil.php +++ b/setup/migrate/migrateUtil.php @@ -62,15 +62,15 @@ class MigrateUtil extends InstallUtil { public function error($error) { $template_vars['error'] = $error; $file = "templates/error.tpl"; - if (!file_exists($file)) { - return false; + if (file_exists($file)) { + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; } - extract($template_vars); // Extract the vars to local namespace - ob_start(); - include($file); - $contents = ob_get_contents(); - ob_end_clean(); - echo $contents; + return false; } /** diff --git a/setup/migrate/migrateWizard.php b/setup/migrate/migrateWizard.php index 3b7b5bd..a03c2d1 100644 --- a/setup/migrate/migrateWizard.php +++ b/setup/migrate/migrateWizard.php @@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes if ($class == "template") { // Load existing templating classes require_once("../wizard/template.php"); require_once("../wizard/lib/helpers/htmlHelper.php"); - return ; - } - if(file_exists(WIZARD_DIR."$class.php")) { - require_once(WIZARD_DIR."$class.php"); - } elseif (file_exists(STEP_DIR."$class.php")) { - require_once(STEP_DIR."$class.php"); - } elseif (file_exists(WIZARD_LIB."$class.php")) { - require_once(WIZARD_LIB."$class.php"); + } else { - return null; + if(file_exists(WIZARD_DIR."$class.php")) { + require_once(WIZARD_DIR."$class.php"); + } elseif (file_exists(STEP_DIR."$class.php")) { + require_once(STEP_DIR."$class.php"); + } elseif (file_exists(WIZARD_LIB."$class.php")) { + require_once(WIZARD_LIB."$class.php"); + } } + return true; } class MigrateWizard { @@ -233,8 +233,6 @@ class MigrateWizard { return true; break; } - - return $res; } /** diff --git a/setup/migrate/migrater.php b/setup/migrate/migrater.php index 249fa36..86f78f5 100644 --- a/setup/migrate/migrater.php +++ b/setup/migrate/migrater.php @@ -157,7 +157,7 @@ class Migrater { $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); } catch (Exception $e) { $util = new MigrateUtil(); - $util->error("Error reading configuration file: $name"); + $util->error("Error reading configuration file: $e"); exit(); } } @@ -431,8 +431,7 @@ class Migrater { if($class->runMigrate()) { // Check if step needs to be migrated $class->setDataFromSession($className); // Set Session Information $class->setPostConfig(); // Set any posted variables - $response = $class->migrateStep(); // Run migrate step - // TODO : Break on error response + $class->migrateStep(); // Run migrate step } } else { $util = new MigrateUtil(); diff --git a/setup/migrate/step.php b/setup/migrate/step.php index 897b710..9188209 100644 --- a/setup/migrate/step.php +++ b/setup/migrate/step.php @@ -186,30 +186,6 @@ class Step } /** - * Load default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return void - */ - public function loadDefaults() { - - } - - /** - * Return default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return array - */ - public function getDefaults() { - return array(); - } - - /** * Checks if edit button has been clicked * * @author KnowledgeTree Team diff --git a/setup/migrate/stepAction.php b/setup/migrate/stepAction.php index 30724ed..e6ac993 100644 --- a/setup/migrate/stepAction.php +++ b/setup/migrate/stepAction.php @@ -229,12 +229,14 @@ class stepAction { } else { $this->_clearErrors($this->stepName); // Send Errors to session } - return $response; } else { $this->stepName = 'errors'; $this->action = $this->createStep(); $this->action->error = array('Class File Missing in Step Directory'); + $response = ''; } + + return $response; } /** @@ -308,7 +310,7 @@ class stepAction { $menu = ''; $active = false; if($this->stepClassNames) { - foreach ($this->stepClassNames as $k=>$step) { + foreach ($this->stepClassNames as $step) { if($this->step_names[$step] != '') { $item = $this->step_names[$step]; } else { @@ -452,7 +454,7 @@ class stepAction { * @access private * @return void */ - private function _loadValueToSession($class, $k, $v, $overwrite = false) { + private function _loadValueToSession($class, $k, $v) { if($this->session != null) { $this->session->setClass($class, $k, $v); } else { @@ -502,8 +504,7 @@ class stepAction { * @access private * @return void */ - private function _loadErrorToSession($class, $k, $v, $overwrite = false) { - $k = "errors"; + private function _loadErrorToSession($class, $k = "errors", $v) { if($this->session != null) { $this->session->setClassError($class, $k, $v); } else { diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php index 9eb236f..d0eaaa3 100644 --- a/setup/migrate/steps/migrateDatabase.php +++ b/setup/migrate/steps/migrateDatabase.php @@ -122,19 +122,17 @@ class migrateDatabase extends Step $manual = false; // If file was exported manually $dbSettings = $installation['dbSettings']; $location = $installation['location']; - $uname = $this->temp_variables['duname']; - $pwrd = $this->temp_variables['dpassword']; $port = $this->util->getPort($location); $tmpFolder = $this->resolveTempDir(); if(WINDOWS_OS) { $termOrBash = "command prompt window"; - $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump + $exe = "\"$location".DS."mysql".DS."bin".DS."mysqldump.exe\""; // Location of dump } else { $termOrBash = "terminal window"; $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump } $date = date('Y-m-d-H-i-s'); - if(isset($database)) { + if(isset($database['manual_export'])) { $sqlFile = $database['manual_export']; if(file_exists($sqlFile)) { $manual = true; @@ -147,7 +145,7 @@ class migrateDatabase extends Step if(!$manual) { // Try to export database $sqlFile = $tmpFolder."/kt-backup-$date.sql"; $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; -// $response = $this->util->pexec($cmd); + $this->util->pexec($cmd); } if(file_exists($sqlFile)) { $fileContents = file_get_contents($sqlFile); @@ -157,10 +155,14 @@ class migrateDatabase extends Step } } // Handle failed dump - $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions + if(WINDOWS_OS) { + $sqlFile = "\"C:\kt-backup-$date.sql\""; // Use tmp instead due to permissions + } else { + $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions + } $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; - $this->error[]['error'] = "Could not export database:"; - $this->error[]['msg'] = "Execute the following command in a $termOrBash."; + $this->error[]['error'] = "Could not export database"; + $this->error[]['msg'] = "Execute the following command in a $termOrBash:"; $this->error[]['cmd'] = $cmd; $this->temp_variables['manual_export'] = $sqlFile; diff --git a/setup/migrate/steps/migrateInstallation.php b/setup/migrate/steps/migrateInstallation.php index 07230bb..a7cea9b 100644 --- a/setup/migrate/steps/migrateInstallation.php +++ b/setup/migrate/steps/migrateInstallation.php @@ -162,6 +162,7 @@ class migrateInstallation extends step if($this->foundVersion < $this->supportedVersion) { $this->versionError = true; $this->error[] = "KT installation needs to be 3.6.1 or higher"; + return false; } else { return true; } @@ -222,6 +223,8 @@ class migrateInstallation extends step } else { $this->error[] = "Please Enter a Location"; } + + return false; } private function loadConfig($path) { @@ -242,7 +245,6 @@ class migrateInstallation extends step } $this->ktSettings = array('fileSystemRoot'=> $froot, ); - $urlPaths = $ini->getSection('urls'); $varDir = $froot.DS.'var'; $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir), array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'), diff --git a/setup/migrate/steps/migrateServices.php b/setup/migrate/steps/migrateServices.php index b0bc18e..50f9e5b 100644 --- a/setup/migrate/steps/migrateServices.php +++ b/setup/migrate/steps/migrateServices.php @@ -202,11 +202,11 @@ class migrateServices extends Step */ public function unixStop() { $cmd = $this->conf['location']."/dmsctl.sh stop lucene"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); $cmd = $this->conf['location']."/dmsctl.sh stop scheduler"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); $cmd = $this->conf['location']."/dmsctl.sh stop soffice"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); } /** @@ -215,11 +215,11 @@ class migrateServices extends Step */ public function windowsStop() { $cmd = "sc delete KTLucene"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); $cmd = "sc delete KTScheduler"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); $cmd = "sc delete KTOpenoffice"; - $res = $this->util->pexec($cmd); + $this->util->pexec($cmd); } /** @@ -233,7 +233,7 @@ class migrateServices extends Step $serv->load(); $sStatus = $serv->status(); if($sStatus != '') { - $res = $serv->uninstall(); + $serv->uninstall(); } } } diff --git a/setup/upgrade/step.php b/setup/upgrade/step.php index 49890fd..0b8c103 100644 --- a/setup/upgrade/step.php +++ b/setup/upgrade/step.php @@ -172,30 +172,6 @@ class Step public function getWarnings() { return $this->warnings; } - - /** - * Load default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return void - */ - public function loadDefaults() { - - } - - /** - * Return default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return array - */ - public function getDefaults() { - return array(); - } /** * Checks if edit button has been clicked diff --git a/setup/upgrade/stepAction.php b/setup/upgrade/stepAction.php index 438df77..48083f0 100644 --- a/setup/upgrade/stepAction.php +++ b/setup/upgrade/stepAction.php @@ -229,12 +229,14 @@ class stepAction { } else { $this->_clearErrors($this->stepName); // Send Errors to session } - return $response; } else { $this->stepName = 'errors'; $this->action = $this->createStep(); $this->action->error = array('Class File Missing in Step Directory'); + $response = ''; } + + return $response; } /** @@ -308,7 +310,7 @@ class stepAction { $menu = ''; $active = false; if($this->stepClassNames) { - foreach ($this->stepClassNames as $k=>$step) { + foreach ($this->stepClassNames as $step) { if($this->step_names[$step] != '') { $item = $this->step_names[$step]; } else { @@ -452,7 +454,7 @@ class stepAction { * @access private * @return void */ - private function _loadValueToSession($class, $k, $v, $overwrite = false) { + private function _loadValueToSession($class, $k, $v) { if($this->session != null) { $this->session->setClass($class, $k, $v); } else { @@ -502,8 +504,7 @@ class stepAction { * @access private * @return void */ - private function _loadErrorToSession($class, $k, $v, $overwrite = false) { - $k = "errors"; + private function _loadErrorToSession($class, $k = "errors", $v) { if($this->session != null) { $this->session->setClassError($class, $k, $v); } else { diff --git a/setup/upgrade/steps/upgradeBackup.php b/setup/upgrade/steps/upgradeBackup.php index 6977416..ba5219e 100644 --- a/setup/upgrade/steps/upgradeBackup.php +++ b/setup/upgrade/steps/upgradeBackup.php @@ -120,7 +120,7 @@ class upgradeBackup extends Step { if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe')) { - $curdir=getcwd(); +// $curdir=getcwd(); chdir($dir); $handle = popen($stmt['cmd'], 'r'); @@ -198,7 +198,7 @@ class upgradeBackup extends Step { $adminUser = $oKTConfig->get('db/dbAdminUser'); $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); +// $dbHost = $oKTConfig->get('db/dbHost'); $dbName = $oKTConfig->get('db/dbName'); $dbPort = trim($oKTConfig->get('db/dbPort')); diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index f58f571..945db30 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -144,10 +144,10 @@ class upgradeDatabase extends Step $this->readConfig(KTConfig::getConfigFilename()); if($this->dbSettings['dbPort'] == '') { - $con = $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'], + $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'], $this->dbSettings['dbPass'], $this->dbSettings['dbName']); } else { - $con = $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'], + $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'], $this->dbSettings['dbPass'], $this->dbSettings['dbName']); } @@ -285,7 +285,8 @@ class upgradeDatabase extends Step } $res = $this->performAllUpgrades(); - if (PEAR::isError($res) || PEAR::isError($pres)) { +// if (PEAR::isError($res) || PEAR::isError($pres)) { + if (PEAR::isError($res)) { $errors = true; // TODO instantiate error details hideable section? $this->temp_variables['upgradeStatus'] = 'Database upgrade failed @@ -300,7 +301,8 @@ class upgradeDatabase extends Step } $post_pres = $this->performPostUpgradeActions(); - if (PEAR::isError($post_res)) { +// if (PEAR::isError($post_res)) { + if (PEAR::isError($post_pres)) { $errors = true; $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.'; } @@ -334,7 +336,7 @@ class upgradeDatabase extends Step // Ensure all plugins are re-registered. $sql = "TRUNCATE plugin_helper"; - $res = DBUtil::runQuery($sql); + DBUtil::runQuery($sql); // Clear out all caches and proxies - they need to be regenerated with the new code $proxyDir = $default->proxyCacheDirectory; diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php index 270978f..25a6aa8 100644 --- a/setup/upgrade/steps/upgradeRestore.php +++ b/setup/upgrade/steps/upgradeRestore.php @@ -111,14 +111,14 @@ class upgradeRestore extends Step { private function restoreDatabase() { $this->temp_variables['restore'] = true; - $status = $_SESSION['backupStatus']; +// $status = $_SESSION['backupStatus']; $filename = $_SESSION['backupFile']; $stmt = $this->util->create_restore_stmt($filename); $dir = $stmt['dir']; if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) { - $curdir=getcwd(); +// $curdir=getcwd(); chdir($dir); $ok=true; @@ -181,9 +181,11 @@ class upgradeRestore extends Step { $dir = $this->util->resolveTempDir(); $files = array(); - if ($dh = opendir($dir)) + $dh = opendir($dir); + if ($dh) { - while (($file = readdir($dh)) !== false) + $file = readdir($dh); + while ($file !== false) { if (!preg_match('/kt-backup.+\.sql/',$file)) { continue; @@ -217,7 +219,7 @@ class upgradeRestore extends Step { return; } - $status = $_SESSION['backupStatus']; +// $status = $_SESSION['backupStatus']; $filename = $_SESSION['backupFile']; $stmt = $this->util->create_restore_stmt($filename); diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php index 0082985..c07b07f 100644 --- a/setup/upgrade/steps/upgradeWelcome.php +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -81,7 +81,7 @@ class upgradeWelcome extends step { } private function checkPassword($username, $password) { - global $default; +// global $default; $sTable = KTUtil::getTableName('users'); $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php index 3bc2ea5..a2b571b 100644 --- a/setup/upgrade/upgradeUtil.php +++ b/setup/upgrade/upgradeUtil.php @@ -64,15 +64,16 @@ class UpgradeUtil extends InstallUtil { public function error($error) { $template_vars['error'] = $error; $file = "templates/error.tpl"; - if (!file_exists($file)) { - return false; + if (file_exists($file)) { + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; } - extract($template_vars); // Extract the vars to local namespace - ob_start(); - include($file); - $contents = ob_get_contents(); - ob_end_clean(); - echo $contents; + + return false; } public function loadInstallIni($path) { @@ -99,15 +100,16 @@ class UpgradeUtil extends InstallUtil { } } $file = "templates/" . $template; - if (!file_exists($file)) { - return false; + if (file_exists($file)) { + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; } - extract($template_vars); // Extract the vars to local namespace - ob_start(); - include($file); - $contents = ob_get_contents(); - ob_end_clean(); - echo $contents; + + return false; } /** @@ -133,7 +135,7 @@ class UpgradeUtil extends InstallUtil { $adminUser = $oKTConfig->get('db/dbAdminUser'); $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); +// $dbHost = $oKTConfig->get('db/dbHost'); $dbName = $oKTConfig->get('db/dbName'); $dbPort = trim($oKTConfig->get('db/dbPort')); if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); @@ -158,7 +160,7 @@ class UpgradeUtil extends InstallUtil { $mechanism="--port=\"$dbPort\""; } - $tmpdir = $this->resolveTempDir(); +// $tmpdir = $this->resolveTempDir(); $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; @@ -193,11 +195,13 @@ class UpgradeUtil extends InstallUtil { } $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); +// $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); + $mysqldir = $oKTConfig->get('backup/mysqlDirectory'); $dirs[] = $mysqldir; if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); +// $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); + $dirs [] = realpath('/../../mysql/bin'); } foreach($dirs as $dir) diff --git a/setup/upgrade/upgradeWizard.php b/setup/upgrade/upgradeWizard.php index fa2b6b3..b05ca5c 100644 --- a/setup/upgrade/upgradeWizard.php +++ b/setup/upgrade/upgradeWizard.php @@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes if ($class == "template") { // Load existing templating classes require_once("../wizard/template.php"); require_once("../wizard/lib/helpers/htmlHelper.php"); - return ; - } - if(file_exists(WIZARD_DIR."$class.php")) { - require_once(WIZARD_DIR."$class.php"); - } elseif (file_exists(STEP_DIR."$class.php")) { - require_once(STEP_DIR."$class.php"); - } elseif (file_exists(WIZARD_LIB."$class.php")) { - require_once(WIZARD_LIB."$class.php"); } else { - return null; + if(file_exists(WIZARD_DIR."$class.php")) { + require_once(WIZARD_DIR."$class.php"); + } elseif (file_exists(STEP_DIR."$class.php")) { + require_once(STEP_DIR."$class.php"); + } elseif (file_exists(WIZARD_LIB."$class.php")) { + require_once(WIZARD_LIB."$class.php"); + } } + + return true; } class UpgradeWizard { @@ -191,26 +191,7 @@ class UpgradeWizard { * @return mixed */ public function systemChecks() { - // for now we don't write to any of these locations - return true; - - $res = $this->util->checkStructurePermissions(); - if($res === true) return $res; - switch ($res) { - case "wizard": - $this->util->error("Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)"); - return 'Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)'; - break; - case "/": - $this->util->error("System root is not writable (KT_Installation_Directory/)"); - return "System root is not writable (KT_Installation_Directory/)"; - break; - default: - return true; - break; - } - - return $res; + return true; // for now we don't write to any locations } /** diff --git a/setup/upgrade/upgrader.php b/setup/upgrade/upgrader.php index 30dedf9..55bdffb 100644 --- a/setup/upgrade/upgrader.php +++ b/setup/upgrade/upgrader.php @@ -157,7 +157,7 @@ class Upgrader { $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); } catch (Exception $e) { $util = new UpgradeUtil(); - $util->error("Error reading configuration file: $name"); + $util->error("Error reading configuration file: $e"); exit(); } } @@ -431,8 +431,7 @@ class Upgrader { if($class->runUpgrade()) { // Check if step needs to be upgraded $class->setDataFromSession($className); // Set Session Information $class->setPostConfig(); // Set any posted variables - $response = $class->upgradeStep(); // Run upgrade step - // TODO : Break on error response + $class->upgradeStep(); // Run upgrade step } } else { $util = new UpgradeUtil(); diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php index b036724..c9dc4fa 100644 --- a/setup/wizard/iniUtilities.php +++ b/setup/wizard/iniUtilities.php @@ -63,11 +63,12 @@ class iniUtilities { return false; } $date = date('YmdHis'); - $backupFile = $iniFile . '.' .$date; if (is_writeable($backupFile)) { file_put_contents($backupFile, $content); } + + return true; } function read($iniFile) { @@ -153,13 +154,20 @@ class iniUtilities { } function itemExists($checkSection, $checkItem) { - +/* + foreach ($items as $key => $value) { + if($key == $checkItem) { + return true; + } + } +*/ $this->exists = ''; foreach($this->cleanArray as $section => $items) { if($section == $checkSection) { $this->exists = 'section'; - foreach ($items as $key => $value) { - if($key == $checkItem) { + $items = array_flip($items); + foreach ($items as $value) { + if($value == $checkItem) { return true; } } diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php index 25452f5..2e59356 100644 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -70,15 +70,16 @@ class InstallUtil { public function error($error) { $template_vars['error'] = $error; $file = "templates/error.tpl"; - if (!file_exists($file)) { - return false; + if (file_exists($file)) { + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; } - extract($template_vars); // Extract the vars to local namespace - ob_start(); - include($file); - $contents = ob_get_contents(); - ob_end_clean(); - echo $contents; + + return false; } /** * Check if system needs to be installed @@ -165,7 +166,8 @@ class InstallUtil { return $url; } if (!empty($protocol)) { - $url = $protocol .':'. end($array = explode(':', $url, 2)); + $array = explode(':', $url, 2); + $url = $protocol .':'. end($array); } if (!empty($port)) { $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', @@ -321,13 +323,15 @@ class InstallUtil { while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..') { $fullpath = $path.'/'.$file; - if(is_link($fullpath)) + if(is_link($fullpath)) { return false; - elseif(!is_dir($fullpath)) { + } elseif(!is_dir($fullpath)) { $perms = substr(sprintf('%o', fileperms($fullpath)), -4); - if($perms != $filemode) - if (!chmod($fullpath, $filemode)) + if($perms != $filemode) { + if (!chmod($fullpath, $filemode)) { return false; + } + } } elseif(!$this->chmodRecursive($fullpath, $filemode)) return false; } @@ -354,7 +358,8 @@ class InstallUtil { */ public function canWriteFile($filename) { $fh = fopen($filename, "w+"); - if($fr = fwrite($fh, 'test') === false) { + $fr = fwrite($fh, 'test'); + if($fr === false) { return false; } @@ -372,9 +377,9 @@ class InstallUtil { */ public function javaBridge() { try { - $javaSystem = new Java('java.lang.System'); + new Java('java.lang.System'); } catch (JavaException $e) { - return false; + return $e; } return true; } @@ -763,6 +768,7 @@ class InstallUtil { * @return string */ public function installEnvironment() { + $matches = false; preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type if($matches) { return 'Zend'; @@ -792,7 +798,7 @@ class InstallUtil { array_pop($sysdir); array_pop($sysdir); $zendsys = ''; - foreach ($sysdir as $k=>$v) { + foreach ($sysdir as $v) { $zendsys .= $v.DS; } return $zendsys."ZendServer".DS."bin".DS; @@ -815,15 +821,16 @@ class InstallUtil { if(WINDOWS_OS) { // Mysql bin [Windows] $serverPaths = explode(';',$_SERVER['PATH']); foreach ($serverPaths as $apath) { + $matches = false; preg_match('/mysql/i', $apath, $matches); if($matches) { return $apath.DS; break; } } - } else { - return "mysql"; // Assume its linux and can be executed from command line } + + return "mysql"; // Assume its linux and can be executed from command line } public function sqlInstallDir() { diff --git a/setup/wizard/installWizard.php b/setup/wizard/installWizard.php index c48aac0..986d706 100644 --- a/setup/wizard/installWizard.php +++ b/setup/wizard/installWizard.php @@ -62,9 +62,13 @@ function __autoload($class) { // Attempt and autoload classes } else { if(preg_match('/Helper/', $class)) { require_once(HELPER_DIR."$class.php"); + } else if(preg_match('/Test/i', $class)) { + if($_GET['step'] != '') { + require_once(TEST_DIR."$class.php"); + } } - return null; } + return true; } class InstallWizard { @@ -96,6 +100,15 @@ class InstallWizard { protected $util = null; /** + * Step name + * + * @author KnowledgeTree Team + * @access protected + * @var mixed + */ + protected $stepName = ''; + + /** * Constructs installation wizard object * * @author KnowledgeTree Team @@ -183,15 +196,27 @@ class InstallWizard { } /** - * Bypass and force an install + * Is the step being accessed directly * * @author KnowledgeTree Team - * @access private + * @access public * @param none * @return boolean */ - private function bypass() { - + public function isActionOnStep() { + return $this->stepName; + } + + /** + * Set step being accessed directly + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + private function setStep($stepName) { + $this->stepName = $stepName; } /** @@ -231,6 +256,9 @@ class InstallWizard { if(isset($_GET['bypass'])) { $this->setBypass($_GET['bypass']); } + if(isset($_GET['step'])) { + $this->setStep($_GET['step']); + } if(isset($_GET['debug'])) { $this->setDebugLevel($_GET['debug']); } else { @@ -263,8 +291,6 @@ class InstallWizard { return true; break; } - - return $res; } /** @@ -278,10 +304,14 @@ class InstallWizard { public function dispatch() { $this->load(); if($this->getBypass() === "1") { // Helper to force install - $this->removeInstallFile(); // TODO: Remove + $this->removeInstallFile(); } elseif ($this->getBypass() === "0") { $this->createInstallFile(); } + if($this->isActionOnStep()) { // Testing purposes + $testStepClass = $this->stepName."Test"; + new $testStepClass(); + } if(!$this->isSystemInstalled()) { // Check if the systems not installed if($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed $this->util->redirect('../migrate'); diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php index e3ae105..aa4e06e 100644 --- a/setup/wizard/installer.php +++ b/setup/wizard/installer.php @@ -157,7 +157,7 @@ class Installer { $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); } catch (Exception $e) { $util = new InstallUtil(); - $util->error("Error reading configuration file: $name"); + $util->error("Error reading configuration file: $e"); exit(); } } @@ -431,8 +431,7 @@ class Installer { if($class->runInstall()) { // Check if step needs to be installed $class->setDataFromSession($className); // Set Session Information $class->setPostConfig(); // Set any posted variables - $response = $class->installStep(); // Run install step - // TODO : Break on error response + $class->installStep(); // Run install step } } else { $util = new InstallUtil(); diff --git a/setup/wizard/lib/helpers/htmlHelper.php b/setup/wizard/lib/helpers/htmlHelper.php index 50150b5..d2a6565 100644 --- a/setup/wizard/lib/helpers/htmlHelper.php +++ b/setup/wizard/lib/helpers/htmlHelper.php @@ -41,7 +41,7 @@ */ class htmlHelper { - var $tags = array( + private $tags = array( 'meta' => '', 'metalink' => '', 'link' => '%s', @@ -96,76 +96,76 @@ class htmlHelper { 'error' => '%s' ); - function __construct() { - } + public function __construct() { + } + + public function js($name) { + return ""; + } + + public function css($name) { + return ""; + } + + public function image($name, $options = array()) { + $path = "../wizard/resources/graphics/$name"; + $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); - function js($name) { - return ""; - } + return $image; + } + + public function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { + if (is_array($options)) { + $options = array_merge(array('escape' => true), $options); - function css($name) { - return ""; + if (!is_array($exclude)) { + $exclude = array(); } + $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape'))); + $values = array_intersect_key(array_values($options), $keys); + $escape = $options['escape']; + $attributes = array(); - function image($name, $options = array()) { - $path = "../wizard/resources/graphics/$name"; - $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); - - return $image; + foreach ($keys as $index => $key) { + $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); } - - function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { - if (is_array($options)) { - $options = array_merge(array('escape' => true), $options); - - if (!is_array($exclude)) { - $exclude = array(); - } - $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape'))); - $values = array_intersect_key(array_values($options), $keys); - $escape = $options['escape']; - $attributes = array(); - - foreach ($keys as $index => $key) { - $attributes[] = $this->__formatAttribute($key, $values[$index], $escape); - } - $out = implode(' ', $attributes); - } else { - $out = $options; - } - return $out ? $insertBefore . $out . $insertAfter : ''; + $out = implode(' ', $attributes); + } else { + $out = $options; } - - function __formatAttribute($key, $value, $escape = true) { + return $out ? $insertBefore . $out . $insertAfter : ''; + } + + public function __formatAttribute($key, $value, $escape = true) { $attribute = ''; $attributeFormat = '%s="%s"'; $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); if (is_array($value)) { - $value = ''; + $value = ''; } - + if (in_array($key, $minimizedAttributes)) { - if ($value === 1 || $value === true || $value === 'true' || $value == $key) { - $attribute = sprintf($attributeFormat, $key, $key); - } + if ($value === 1 || $value === true || $value === 'true' || $value == $key) { + $attribute = sprintf($attributeFormat, $key, $key); + } } else { - $attribute = sprintf($attributeFormat, $key, $this->ife($escape, $this->h($value), $value)); + $attribute = sprintf($attributeFormat, $key, $this->ife($escape, $this->h($value), $value)); } return $attribute; } - function ife($condition, $val1 = null, $val2 = null) { + public function ife($condition, $val1 = null, $val2 = null) { if (!empty($condition)) { - return $val1; + return $val1; } return $val2; } - function h($text, $charset = 'UTF-8') { + public function h($text, $charset = 'UTF-8') { if (is_array($text)) { - return array_map('h', $text); + return array_map('h', $text); } return htmlspecialchars($text, ENT_QUOTES, $charset); -} + } } ?> \ No newline at end of file diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php index ff574e1..b4b14f2 100644 --- a/setup/wizard/lib/services/unixLucene.php +++ b/setup/wizard/lib/services/unixLucene.php @@ -59,7 +59,7 @@ class unixLucene extends unixService { * @param string * @return void */ - public function load($options = null) { + public function load() { $this->setLuceneSource("ktlucene.jar"); $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); @@ -155,7 +155,8 @@ class unixLucene extends unixService { $response = $this->util->pexec($cmd); return $response; } - + + return $state; } public function install() { @@ -173,6 +174,7 @@ class unixLucene extends unixService { if(is_array($response['out'])) { if(count($response['out']) > 1) { foreach ($response['out'] as $r) { + $matches = false; preg_match('/grep/', $r, $matches); // Ignore grep if(!$matches) { return 'STARTED'; @@ -207,20 +209,14 @@ class unixLucene extends unixService { $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!"; if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } $response = $this->util->pexec($cmd); return $response; - } elseif ($state == '') { - // Start Service - return true; - } else { - // Service Running Already - return true; } - return false; + return true; } public function getName() { diff --git a/setup/wizard/lib/services/unixOpenOffice.php b/setup/wizard/lib/services/unixOpenOffice.php index 781e336..b476102 100644 --- a/setup/wizard/lib/services/unixOpenOffice.php +++ b/setup/wizard/lib/services/unixOpenOffice.php @@ -106,13 +106,14 @@ class unixOpenOffice extends unixService { } } - public function status($updrade = false) { + public function status() { sleep(1); $cmd = "ps ax | grep soffice"; $response = $this->util->pexec($cmd); if(is_array($response['out'])) { if(count($response['out']) > 1) { foreach ($response['out'] as $r) { + $matches = false; preg_match('/grep/', $r, $matches); // Ignore grep if(!$matches) { return 'STARTED'; @@ -138,29 +139,16 @@ class unixOpenOffice extends unixService { $state = $this->status(); if($state != 'STARTED') { $cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." &1> /dev/null &"; -// $cmd = "\"{$this->util->getJava()}\" -cp \"".SYS_DIR."\" openOffice ".$this->getBin(); - if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } -// $cmd = 'nohup /usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" &> /dev/null &'; -// $cmd = 'nohup /usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" &1> /dev/null &'; -// $cmd = '/usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"'; -// $cmd = '/usr/lib/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"'; -// $cmd = '/usr/lib/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"'; $response = $this->util->pexec($cmd); return $response; - } elseif ($state == '') { - // Start Service - return true; - } else { - // Service Running Already - return true; } - return false; + return true; } /** diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php index aae16f3..ba14d0a 100644 --- a/setup/wizard/lib/services/unixScheduler.php +++ b/setup/wizard/lib/services/unixScheduler.php @@ -57,7 +57,7 @@ class unixScheduler extends unixService { * @param string * @return void */ - public function load($options = null) { + public function load() { $this->setPhpCli(); $this->scheduler = 'scheduler'; $this->setSchedulerSource('schedulerTask.sh'); @@ -155,6 +155,7 @@ class unixScheduler extends unixService { if(is_array($response['out'])) { if(count($response['out']) > 1) { foreach ($response['out'] as $r) { + $matches = false; preg_match('/grep/', $r, $matches); // Ignore grep if(!$matches) { return 'STARTED'; @@ -190,7 +191,7 @@ class unixScheduler extends unixService { } if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } $response = $this->util->pexec($cmd); diff --git a/setup/wizard/lib/services/windowsLucene.php b/setup/wizard/lib/services/windowsLucene.php index ff7a231..2882794 100644 --- a/setup/wizard/lib/services/windowsLucene.php +++ b/setup/wizard/lib/services/windowsLucene.php @@ -140,8 +140,8 @@ class windowsLucene extends windowsService { * @param string * @return void */ - public function load($options = null) { - $this->setJavaBin(); + public function load() { + $this->findJavaBin(); $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver"); $this->setLuceneExe("KTLuceneService.exe"); $this->setJavaJVM(); @@ -172,14 +172,14 @@ class windowsLucene extends windowsService { } /** - * Set Java Directory path + * Dind Java Directory path * * @author KnowledgeTree Team * @access private * @param string * @return void */ - private function setJavaBin($javaBin = '') { + private function findJavaBin() { if($this->util->zendBridge()) { if($this->util->javaBridge()) { $this->javaSystem = new Java('java.lang.System'); @@ -379,6 +379,8 @@ class windowsLucene extends windowsService { } else { return false; } + + return true; } /** @@ -407,12 +409,11 @@ class windowsLucene extends windowsService { $luceneExe = $this->getLuceneExe(); $luceneSource = $this->getLuceneSource(); $luceneDir = $this->getluceneDir(); - $javaJVM = $this->getJavaJVM(); if($luceneExe && $luceneSource && $luceneDir) { $cmd = "\"{$luceneExe}\""." -install \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto"; if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/services/windowsOpenOffice.php b/setup/wizard/lib/services/windowsOpenOffice.php index 082b921..ae46c9f 100644 --- a/setup/wizard/lib/services/windowsOpenOffice.php +++ b/setup/wizard/lib/services/windowsOpenOffice.php @@ -183,10 +183,11 @@ class windowsOpenOffice extends windowsService { } private function setWinservice($winservice = "winserv.exe") { - if(file_exists(SYS_BIN_DIR . $winservice)) + if(file_exists(SYS_BIN_DIR . $winservice)) { $this->winservice = SYS_BIN_DIR . $winservice; - else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice)) + } else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice)) { $this->winservice = SYS_BIN_DIR . "win32" . DS. $winservice; + } } public function getWinservice() { @@ -206,7 +207,7 @@ class windowsOpenOffice extends windowsService { $cmd = "\"{$this->winservice}\" install $this->name "."-displayname {$this->name} -start auto \"".$binary."\" -headless -invisible -accept=socket,host={$this->host},port={$this->port};urp;";; if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/services/windowsScheduler.php b/setup/wizard/lib/services/windowsScheduler.php index e6d8a95..1e163e2 100644 --- a/setup/wizard/lib/services/windowsScheduler.php +++ b/setup/wizard/lib/services/windowsScheduler.php @@ -85,7 +85,7 @@ class windowsScheduler extends windowsService { * @param string * @return void */ - function load($options = null) { + function load() { $this->setSchedulerDIR($this->varDir."bin"); $this->setSchedulerScriptPath("taskrunner.bat"); $this->setSchedulerSource("schedulerService.php"); @@ -209,7 +209,7 @@ class windowsScheduler extends windowsService { echo '
';
             		print_r(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath()));
     	            echo '
'; - return ; + return true; } $response = win32_create_service(array( 'service' => $this->name, @@ -224,7 +224,7 @@ class windowsScheduler extends windowsService { $cmd = "\"{$this->winservice}\" install $this->name $this->options"; if(DEBUG) { echo "Command : $cmd
"; - return ; + return true; } $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/services/windowsService.php b/setup/wizard/lib/services/windowsService.php index 41e48bd..eebe002 100644 --- a/setup/wizard/lib/services/windowsService.php +++ b/setup/wizard/lib/services/windowsService.php @@ -163,7 +163,7 @@ class windowsService extends Service { * @return array */ public function restart() { - $response = $this->stop(); + $this->stop(); sleep(1); $this->start(); } diff --git a/setup/wizard/lib/validation/luceneValidation.php b/setup/wizard/lib/validation/luceneValidation.php index b35c72d..4e58d3c 100644 --- a/setup/wizard/lib/validation/luceneValidation.php +++ b/setup/wizard/lib/validation/luceneValidation.php @@ -264,7 +264,7 @@ class luceneValidation extends serviceValidation { public function binaryChecks() { if($this->util->javaSpecified()) { $this->disableExtension = true; // Disable the use of the php bridge extension - if($this->detSettings(true)) { // AutoDetect java settings + if($this->detSettings()) { // AutoDetect java settings return true; } else { $this->specifyJava(); // Ask for settings @@ -274,16 +274,16 @@ class luceneValidation extends serviceValidation { if($auto) { return $auto; } else { - $auto = $this->useDetected(); // Check if auto detected java works + $auto = $this->detSettings(); // Check if auto detected java works if($auto) { $this->disableExtension = true; // Disable the use of the php bridge extension - return $auto; } else { $this->specifyJava(); // Ask for settings } } return $auto; } + return false; } /** @@ -363,7 +363,7 @@ class luceneValidation extends serviceValidation { * @access private * @return boolean */ - private function detSettings($attempt = false) { + private function detSettings() { $javaExecutable = $this->util->javaSpecified();// Retrieve java bin if($javaExecutable == '') { if($this->java == '') { @@ -388,7 +388,7 @@ class luceneValidation extends serviceValidation { } function windowsReadJVFromFile($cmd) { - $response = $this->util->pexec($cmd); + $this->util->pexec($cmd); if(file_exists($this->outputDir.'outJV')) { $version = file_get_contents($this->outputDir.'outJV'); if($version != '') { @@ -409,21 +409,23 @@ class luceneValidation extends serviceValidation { } else { $this->javaVersionWarning(); $this->javaCheck = 'cross_orange'; - if($attempt) { +// if($attempt) { $this->javaExeMessage = "Incorrect java path specified"; $this->javaExeError = true; $this->error[] = "Requires Java 1.5+ to be installed"; - } +// } return false; } } + return false; } function unixReadJVFromFile($cmd) { - $response = $this->util->pexec($cmd); + $this->util->pexec($cmd); if(file_exists($this->outputDir.'outJV')) { $tmp = file_get_contents($this->outputDir.'outJV'); + $matches = false; preg_match('/"(.*)"/',$tmp, $matches); if($matches) { if($matches[1] < $this->javaVersion) { // Check Version of java @@ -443,27 +445,17 @@ class luceneValidation extends serviceValidation { } else { $this->javaVersionWarning(); $this->javaCheck = 'cross_orange'; - if($attempt) { +// if($attempt) { $this->javaExeMessage = "Incorrect java path specified"; $this->javaExeError = true; $this->error[] = "Requires Java 1.5+ to be installed"; - } +// } return false; } } - } - - /** - * Attempt detection without logging errors - * - * @author KnowledgeTree Team - * @param none - * @access private - * @return boolean - */ - private function useDetected() { - return $this->detSettings(); + + return false; } /** diff --git a/setup/wizard/lib/validation/openofficeValidation.php b/setup/wizard/lib/validation/openofficeValidation.php index f2d1b2b..bc3b052 100644 --- a/setup/wizard/lib/validation/openofficeValidation.php +++ b/setup/wizard/lib/validation/openofficeValidation.php @@ -92,7 +92,7 @@ class openofficeValidation extends serviceValidation { * @access private * @var mixed */ - private $windowsLocations = array("C:\Program Files\OpenOffice.org 3\program", "C:\OpenOffice.org 3\program"); + private $windowsLocations = array("\"C:\Program Files\OpenOffice.org 3\program\"", "\"C:\OpenOffice.org 3\program\""); /** * Open Office unix locations @@ -103,7 +103,7 @@ class openofficeValidation extends serviceValidation { */ private $unixLocations = array("/usr/bin/"); - public function preset($options = null) { + public function preset() { $this->specifyOpenOffice(); } diff --git a/setup/wizard/lib/validation/schedulerValidation.php b/setup/wizard/lib/validation/schedulerValidation.php index b39b9ad..752592b 100644 --- a/setup/wizard/lib/validation/schedulerValidation.php +++ b/setup/wizard/lib/validation/schedulerValidation.php @@ -92,36 +92,37 @@ class schedulerValidation extends serviceValidation { public function binaryChecks() { // TODO: Better detection return true; - $this->setPhp(); - if($this->util->phpSpecified()) { - return $this->detPhpSettings(); - } else { - $this->specifyPhp();// Ask for settings - return false; - } +// $this->setPhp(); +// if($this->util->phpSpecified()) { +// return $this->detPhpSettings(); +// } else { +// $this->specifyPhp();// Ask for settings +// return false; +// } } function detPhpSettings() { // TODO: Better php handling return true; - $phpExecutable = $this->util->phpSpecified();// Retrieve java bin - $cmd = "$phpExecutable -version > ".$this->outputDir."/outPHP 2>&1 echo $!"; - $response = $this->util->pexec($cmd); - if(file_exists($this->outputDir.'outPHP')) { - $tmp = file_get_contents($this->outputDir.'outPHP'); - preg_match('/PHP/',$tmp, $matches); - if($matches) { - $this->phpCheck = 'tick'; - - return true; - } else { - $this->phpCheck = 'cross_orange'; - $this->phpExeError = "PHP : Incorrect path specified"; - $this->error[] = "PHP executable required"; - - return false; - } - } +// $phpExecutable = $this->util->phpSpecified();// Retrieve java bin +// $cmd = "$phpExecutable -version > ".$this->outputDir."/outPHP 2>&1 echo $!"; +// $this->util->pexec($cmd); +// if(file_exists($this->outputDir.'outPHP')) { +// $tmp = file_get_contents($this->outputDir.'outPHP'); +// $matches = false; +// preg_match('/PHP/',$tmp, $matches); +// if($matches) { +// $this->phpCheck = 'tick'; +// +// return true; +// } else { +// $this->phpCheck = 'cross_orange'; +// $this->phpExeError = "PHP : Incorrect path specified"; +// $this->error[] = "PHP executable required"; +// +// return false; +// } +// } } /** @@ -137,13 +138,13 @@ class schedulerValidation extends serviceValidation { } private function setPhp() { + $phpDir = $this->util->useZendPhp(); if($this->php != '') { // PHP Found $this->phpCheck = 'tick'; - } elseif ($phpDir = $this->util->useZendPhp()) { // Use System Defined Settings + } elseif ($phpDir) { // Use System Defined Settings $this->php = $phpDir; - } else { - } + $this->temp_variables['php']['location'] = $this->php; } diff --git a/setup/wizard/lib/validation/steps/databaseTest.php b/setup/wizard/lib/validation/steps/databaseTest.php new file mode 100644 index 0000000..aa72af7 --- /dev/null +++ b/setup/wizard/lib/validation/steps/databaseTest.php @@ -0,0 +1,41 @@ +stepName.php"); + } + + /** + * Test database connectivity + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function doAjaxTest($host, $uname, $dname) { + echo "$host, $uname, $dname"; + die; + } + + public function doCreateSchema() { + $this->dhost = '127.0.0.1'; + $this->duname = 'root'; + $this->dpassword = 'root'; + $this->dname = 'dms_install'; + $this->dbbinary = 'mysql'; + $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); + $this->createSchema(); + echo 'Schema loaded
'; + } +} + + +?> \ No newline at end of file diff --git a/setup/wizard/lib/validation/steps/test.php b/setup/wizard/lib/validation/steps/test.php new file mode 100644 index 0000000..5d9cbed --- /dev/null +++ b/setup/wizard/lib/validation/steps/test.php @@ -0,0 +1,33 @@ +$v) { + if(in_array($k, $this->ignore)) { + $temp[] = $_GET[$k]; + unset($_GET[$k]); + } + } + $funcargs = array_slice($_GET,0); + require_once("$class.php"); + $Test = new $class(); + $func_call = strtoupper(substr($func,0,1)).substr($func,1); + $method = "do$func_call"; + call_user_func_array(array($Test, $method), $funcargs); + } + } + */ +// } +} + +?> \ No newline at end of file diff --git a/setup/wizard/path.php b/setup/wizard/path.php index 676230b..2bdb9a2 100644 --- a/setup/wizard/path.php +++ b/setup/wizard/path.php @@ -114,6 +114,7 @@ define('SYS_DIR', WIZARD_LIB."system".DS); define('HELPER_DIR', WIZARD_LIB."helpers".DS); define('VALID_DIR', WIZARD_LIB."validation".DS); + define('TEST_DIR', VALID_DIR."steps".DS); // Define paths to system webroot define('SYSTEM_DIR', $sys); define('SYS_VAR_DIR', SYSTEM_DIR."var".DS); diff --git a/setup/wizard/session.php b/setup/wizard/session.php index c7eecce..e0bf657 100644 --- a/setup/wizard/session.php +++ b/setup/wizard/session.php @@ -228,13 +228,4 @@ class Session } } - -if(isset($_GET['action'])) { - $func = $_GET['action']; - if($func != '') { - $ses = new Session(); - $method = "$func"; - $ses->$method(); - } -} ?> \ No newline at end of file diff --git a/setup/wizard/step.php b/setup/wizard/step.php index ff0acd0..472c082 100644 --- a/setup/wizard/step.php +++ b/setup/wizard/step.php @@ -42,6 +42,15 @@ class Step { /** + * Salt to use in session + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $salt = 'installers'; + + /** * List of variables to be loaded to template * * @author KnowledgeTree Team @@ -73,7 +82,7 @@ class Step * * @author KnowledgeTree Team * @access public - * @var array + * @var boolean */ protected $storeInSession = false; @@ -82,7 +91,7 @@ class Step * * @author KnowledgeTree Team * @access public - * @var array + * @var boolean */ protected $runInstall = false; @@ -91,7 +100,7 @@ class Step * * @author KnowledgeTree Team * @access public - * @var string + * @var boolean */ protected $order = false; @@ -104,10 +113,15 @@ class Step */ protected $silent = false; + /** + * Display the confirmation page first + * + * @author KnowledgeTree Team + * @access public + * @var boolean + */ public $displayFirst = false; - private $salt = 'installers'; - /** * Reference to utility object * @@ -115,7 +129,7 @@ class Step * @access protected * @var object */ - public $util; + public $util = null; /** * Reference to utility object @@ -124,12 +138,20 @@ class Step * @access protected * @var object */ - public $dbhandler; + public $dbhandler = null; + /** + * Constructs step object + * + * @author KnowledgeTree Team + * @access public + * @param none + */ public function __construct() { $this->dbhandler = new dbUtilities(); $this->util = new InstallUtil(); } + /** * Returns step state * @@ -142,6 +164,13 @@ class Step return ''; } + /** + * Returns display flag + * + * @author KnowledgeTree Team + * @access public + * @var boolean + */ public function displayFirst() { return $this->displayFirst; } @@ -183,30 +212,6 @@ class Step } /** - * Load default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return void - */ - public function loadDefaults() { - - } - - /** - * Return default step values - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return array - */ - public function getDefaults() { - return array(); - } - - /** * Checks if edit button has been clicked * * @author KnowledgeTree Team diff --git a/setup/wizard/stepAction.php b/setup/wizard/stepAction.php index 5fde474..9953437 100644 --- a/setup/wizard/stepAction.php +++ b/setup/wizard/stepAction.php @@ -472,7 +472,7 @@ class stepAction { * @access private * @return void */ - private function _loadValueToSession($class, $k, $v, $overwrite = false) { + private function _loadValueToSession($class, $k, $v) { if($this->session != null) { $this->session->setClass($class, $k, $v); } else { diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index c829a8b..3f8bf70 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -40,16 +40,6 @@ * @version Version 0.1 */ -if(isset($_GET['action'])) { - $func = $_GET['action']; - if($func != '') { - require_once("../step.php"); - require_once("../installUtil.php"); - require_once("../path.php"); - require_once("../dbUtilities.php"); - } -} - class database extends Step { /** @@ -719,9 +709,16 @@ class database extends Step * @return boolean */ private function createDmsUser() { - return $this->parse_mysql_dump($this->util->sqlInstallDir()."user.sql"); - } - + $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";"; + $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";"; + if ($this->dbhandler->execute($user1) && $this->dbhandler->execute($user2)) { + return true; + } else { + $this->error['con'] = "Could not create users for database: {$this->dname}"; + return false; + } + } + /** * Create schema * @@ -803,17 +800,7 @@ class database extends Step return $this->error; } - /** - * Test database connectivity - * - * @author KnowledgeTree Team - * @param none - * @access public - * @return boolean - */ - public function doAjaxTest($host, $uname, $dname) { - - } + /** * Initialize errors to false @@ -829,25 +816,8 @@ class database extends Step } } - public function doCreateSchema() { - $this->dhost = '127.0.0.1'; - $this->duname = 'root'; - $this->dpassword = 'root'; - $this->dname = 'dms_install'; - $this->dbbinary = 'mysql'; - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); - $this->createSchema(); - echo 'Schema loaded
'; - } -} -if(isset($_GET['action'])) { - $func = $_GET['action']; - if($func != '') { - $serv = new database(); - $func_call = strtoupper(substr($func,0,1)).substr($func,1); - $method = "do$func_call"; - $serv->$method(); - } } + + ?> \ No newline at end of file