diff --git a/setup/upgrade/config/databases.xml b/setup/upgrade/config/databases.xml new file mode 100644 index 0000000..24a818b --- /dev/null +++ b/setup/upgrade/config/databases.xml @@ -0,0 +1,22 @@ + + + + + + + mysql + + localhost + 3306 + dms + root + dmsadmin + js9281djw + dms + djw9281js + diff --git a/setup/upgrade/session.php b/setup/upgrade/session.php new file mode 100644 index 0000000..3942b4f --- /dev/null +++ b/setup/upgrade/session.php @@ -0,0 +1,224 @@ +. +* +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, +* California 94120-7775, or email info@knowledgetree.com. +* +* The interactive user interfaces in modified source and object code versions +* of this program must display Appropriate Legal Notices, as required under +* Section 5 of the GNU General Public License version 3. +* +* In accordance with Section 7(b) of the GNU General Public License version 3, +* these Appropriate Legal Notices must retain the display of the "Powered by +* KnowledgeTree" logo and retain the original copyright notice. If the display of the +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices +* must display the words "Powered by KnowledgeTree" and retain the original +* copyright notice. +* +* @copyright 2008-2009, KnowledgeTree Inc. +* @license GNU General Public License version 3 +* @author KnowledgeTree Team +* @package Upgrader +* @version Version 0.1 +*/ +class session +{ + private $salt = 'upgrade'; + /** + * Constructs session object + * + * @author KnowledgeTree Team + * @access public + * @param none + */ + public function __construct() { + $this->startSession(); + } + + /** + * Starts a session if one does not exist + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function startSession() { + if(!isset($_SESSION[$this->salt]['ready'])) { +// session_start(); + $_SESSION[$this->salt] ['ready'] = TRUE; + } + } + + /** + * Sets a value key pair in session + * + * @author KnowledgeTree Team + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function set($fld, $val) { + $this->startSession(); + $_SESSION[$this->salt] [$fld] = $val; + } + + /** + * Sets a value key pair in a class in session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function setClass($class , $k, $v) { + $this->startSession(); + $classArray = $this->get($class); + if(isset($classArray[$k])) { + $classArray[$k] = $v; + } else { + $classArray[$k] = $v; + } + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Sets a error value key pair in a class in session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function setClassError($class, $k, $v) { + $this->startSession(); + $classArray = $this->get($class); + if(isset($classArray[$k])) { + $classArray[$k] = $v; + } else { + $classArray[$k] = $v; + } + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Clear error values in a class session + * + * @author KnowledgeTree Team + * @param string $class + * @param string $fld + * @param string $val + * @access public + * @return void + */ + public function clearErrors($class) { + $classArray = $this->get($class); + unset($classArray['errors']); + $_SESSION[$this->salt] [ $class] = $classArray; + } + + /** + * Unset a value in session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return void + */ + public function un_set($fld) { + $this->startSession(); + unset($_SESSION[$this->salt] [$fld]); + } + + /** + * Unset a class value in session + * + * @author KnowledgeTree Team + * @param string $class + * @access public + * @return void + */ + public function un_setClass($class) { + $this->startSession(); + if(isset($_SESSION[$this->salt] [$class])) + unset($_SESSION[$this->salt] [$class]); + } + + /** + * Destroy the session + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function destroy() { + $this->startSession(); + unset($_SESSION[$this->salt]); + session_destroy(); + } + + /** + * Get a session value + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function get($fld) { + $this->startSession(); + if(isset($_SESSION[$this->salt] [$fld])) + return $_SESSION[$this->salt] [$fld]; + return false; + } + + /** + * Check if a field exists in session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function is_set($fld) { + $this->startSession(); + return isset($_SESSION[$this->salt] [$fld]); + } + + /** + * Return a class from session + * + * @author KnowledgeTree Team + * @param string $fld + * @access public + * @return string + */ + public function getClass($class) { + return $_SESSION[$this->salt][$class]; + } +} +?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeBackup.php b/setup/upgrade/steps/upgradeBackup.php index 6977416..8ce6505 100644 --- a/setup/upgrade/steps/upgradeBackup.php +++ b/setup/upgrade/steps/upgradeBackup.php @@ -40,7 +40,7 @@ * @version Version 0.1 */ -require_once('../../config/dmsDefaults.php'); +//require_once('../../config/dmsDefaults.php'); class upgradeBackup extends Step { protected $silent = false; diff --git a/setup/upgrade/steps/upgradeComplete.php b/setup/upgrade/steps/upgradeComplete.php index 7e8a08a..e8e6857 100644 --- a/setup/upgrade/steps/upgradeComplete.php +++ b/setup/upgrade/steps/upgradeComplete.php @@ -40,7 +40,7 @@ * @version Version 0.1 */ -require_once('../../config/dmsDefaults.php'); +//require_once('../../config/dmsDefaults.php'); class upgradeComplete extends Step { diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index f58f571..8987695 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -40,10 +40,10 @@ * @version Version 0.1 */ -require_once('../../config/dmsDefaults.php'); -require_once(KT_LIB_DIR . '/config/config.inc.php'); -require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); -require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); +//require_once('../../config/dmsDefaults.php'); +//require_once(KT_LIB_DIR . '/config/config.inc.php'); +//require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); +//require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); class upgradeDatabase extends Step { diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php index 270978f..0d3f503 100644 --- a/setup/upgrade/steps/upgradeRestore.php +++ b/setup/upgrade/steps/upgradeRestore.php @@ -40,7 +40,7 @@ * @version Version 0.1 */ -require_once('../../config/dmsDefaults.php'); +//require_once('../../config/dmsDefaults.php'); class upgradeRestore extends Step { diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php index dca3a25..c3df258 100644 --- a/setup/upgrade/steps/upgradeWelcome.php +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -40,14 +40,12 @@ * @version Version 0.1 */ -require_once('../../config/dmsDefaults.php'); -require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; - class upgradeWelcome extends step { protected $silent = false; protected $temp_variables = array(); - + protected $error = array() ; + public function doStep() { $this->temp_variables = array("step_name"=>"welcome"); if($this->next()) { @@ -81,9 +79,18 @@ class upgradeWelcome extends step { } private function checkPassword($username, $password) { -/* - $dconf = $this->getDataFromPackage('installers', 'database'); - $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); + $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install + if($dconf) { + $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); + } else { + require_once("../wizard/iniUtilities.php"); // ini to read the ini content + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path + $wizConfigHandler = new configuration(); + $configPath = $wizConfigHandler->readConfigPathIni(); + $ini = new iniUtilities($configPath); + $dconf = $ini->getSection('db'); + $this->dbhandler->load($dconf['dbHost'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); + } $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; $res = $this->dbhandler->query($sQuery); $ass = $this->dbhandler->fetchAssoc($res); @@ -91,28 +98,15 @@ class upgradeWelcome extends step { if($ass[0]['match_count']) return true; } + $this->error[] = 'Could Not Authenticate User'; return false; - */ - - global $default; - - $sTable = KTUtil::getTableName('users'); - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; - $aParams = array($username, md5($password)); - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); - if (PEAR::isError($res)) { return false; } - else { - $sTable = KTUtil::getTableName('users_groups_link'); - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1"; - $aParams = array($res); - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); - if (PEAR::isError($res)) { return false; } - else { - return ($res == 1); - } - } } + public function getErrors() { + return $this->error; + } + + } ?> \ No newline at end of file diff --git a/setup/upgrade/templates/welcome.tpl b/setup/upgrade/templates/welcome.tpl index 406578d..0625573 100644 --- a/setup/upgrade/templates/welcome.tpl +++ b/setup/upgrade/templates/welcome.tpl @@ -9,9 +9,14 @@

Only administrator users may access the upgrade wizard.

- + + +
Username -
Password +
Username
Password
Could Not Authenticate User
+
resolveErrors($response); // Run step } else { - $ins = new Upgrader(new UpgradeSession()); // Instantiate the upgrader and pass the session class + $ins = new Upgrader(new session()); // Instantiate the upgrader and pass the session class $ins->step(); // Run step } } diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index 9d7e4ed..56abe58 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -576,7 +576,7 @@ class configuration extends Step return true; } - private function readConfigPathIni() { + public function readConfigPathIni() { if(isset($this->temp_variables['paths']['configFile']['path'])) { return $this->temp_variables['paths']['configFile']['path']; } diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 2fa45af..8c3f3dc 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -441,6 +441,8 @@ class database extends Step $this->temp_variables['tprefix'] = ''; $this->temp_variables['ddrop'] = false; } + + return $this->temp_variables; } /** @@ -493,11 +495,12 @@ class database extends Step * Read xml config file * * @author KnowledgeTree Team - * @access private + * @access public * @params none * @return object SimpleXmlObject */ - private function readXml() { + public function readXml() { +// echo CONF_DIR."databases.xml"; $simplexml = simplexml_load_file(CONF_DIR."databases.xml"); return $simplexml;