+ * @static
+ * @access public
+ * @param string $url Absolute or relative URI the redirect should go to.
+ * @param string $protocol Protocol to use when redirecting URIs.
+ * @param integer $port A new port number.
+ * @return string The absolute URI.
+ */
+ public function absoluteURI($url = null, $protocol = null, $port = null)
+ {
+ // filter CR/LF
+ $url = str_replace(array("\r", "\n"), ' ', $url);
+
+ // Mess around with already absolute URIs
+ if (preg_match('!^([a-z0-9]+)://!i', $url)) {
+ if (empty($protocol) && empty($port)) {
+ return $url;
+ }
+ if (!empty($protocol)) {
+ $url = $protocol .':'. end($array = explode(':', $url, 2));
+ }
+ if (!empty($port)) {
+ $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
+ '\1:'. $port, $url);
+ }
+ return $url;
+ }
+
+ $host = 'localhost';
+ if (!empty($_SERVER['HTTP_HOST'])) {
+ list($host) = explode(':', $_SERVER['HTTP_HOST']);
+ } elseif (!empty($_SERVER['SERVER_NAME'])) {
+ list($host) = explode(':', $_SERVER['SERVER_NAME']);
+ }
+
+ if (empty($protocol)) {
+ if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) {
+ $protocol = 'https';
+ } else {
+ $protocol = 'http';
+ }
+ if (!isset($port) || $port != intval($port)) {
+ $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
+ }
+ }
+
+ if ($protocol == 'http' && $port == 80) {
+ unset($port);
+ }
+ if ($protocol == 'https' && $port == 443) {
+ unset($port);
+ }
+
+ $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : '');
+
+ if (!strlen($url)) {
+ $url = isset($_SERVER['REQUEST_URI']) ?
+ $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
+ }
+
+ if ($url{0} == '/') {
+ return $server . $url;
+ }
+
+ // Check for PATH_INFO
+ if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) &&
+ $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) {
+ $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])));
+ } else {
+ $path = dirname($_SERVER['PHP_SELF']);
+ }
+
+ if (substr($path = strtr($path, '\\', '/'), -1) != '/') {
+ $path .= '/';
+ }
+
+ return $server . $path . $url;
+ }
+
+ /**
+ * Check whether a given directory / file path exists and is writable
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param string $dir The directory / file to check
+ * @param boolean $create Whether to create the directory if it doesn't exist
+ * @return array The message and css class to use
+ */
+ private function _checkPermission($dir)
+ {
+ if(is_readable($dir) && is_writable($dir)) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * Check whether a given directory / file path exists and is writable
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param string $dir The directory / file to check
+ * @param boolean $create Whether to create the directory if it doesn't exist
+ * @return array The message and css class to use
+ */
+ public function checkPermission($dir, $create=false)
+ {
+ $exist = 'Directory doesn\'t exist';
+ $write = 'Directory not writable';
+ $ret = array('class' => 'cross');
+
+ if(!file_exists($dir)){
+ if($create === false){
+ $this->done = false;
+ $ret['msg'] = $exist;
+ return $ret;
+ }
+ $par_dir = dirname($dir);
+ if(!file_exists($par_dir)){
+ $this->done = false;
+ $ret['msg'] = $exist;
+ return $ret;
+ }
+ if(!is_writable($par_dir)){
+ $this->done = false;
+ $ret['msg'] = $exist;
+ return $ret;
+ }
+ mkdir($dir, '0755');
+ }
+
+ if(is_writable($dir)){
+ $ret['class'] = 'tick';
+
+ return $ret;
+ }
+
+ $this->done = false;
+ $ret['msg'] = $write;
+ return $ret;
+ }
+
+ /**
+ * Change permissions on a directory helper
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param string $folderPath The directory / file to check
+ * @return boolean
+ */
+ public function canChangePermissions($folderPath) {
+ return $this->_chmodRecursive($folderPath, 0755);
+ }
+
+ /**
+ * Change permissions on a directory (recursive)
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param string $folderPath The directory / file to check
+ * @param boolean $create Whether to create the directory if it doesn't exist
+ * @return boolean
+ */
+ private function _chmodRecursive($path, $filemode) {
+ if (!is_dir($path))
+ return chmod($path, $filemode);
+ $dh = opendir($path);
+ while (($file = readdir($dh)) !== false) {
+ if($file != '.' && $file != '..') {
+ $fullpath = $path.'/'.$file;
+ if(is_link($fullpath))
+ return false;
+ elseif(!is_dir($fullpath)) {
+ $perms = substr(sprintf('%o', fileperms($fullpath)), -4);
+ if($perms != $filemode)
+ if (!chmod($fullpath, $filemode))
+ return false;
+ } elseif(!$this->chmodRecursive($fullpath, $filemode))
+ return false;
+ }
+ }
+ closedir($dh);
+ $perms = substr(sprintf('%o', fileperms($path)), -4);
+ if($perms != $filemode) {
+ if(chmod($path, $filemode))
+ return true;
+ else
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Check if a file can be written to a folder
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param string $filename the path to the file to create
+ * @return boolean
+ */
+ public function canWriteFile($filename) {
+ $fh = fopen($filename, "w+");
+ if($fr = fwrite($fh, 'test') === false) {
+ return false;
+ }
+
+ fclose($fh);
+ return true;
+ }
+
+ /**
+ * Attempt using the php-java bridge
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return boolean
+ */
+ public function javaBridge() {
+ try {
+ $javaSystem = new Java('java.lang.System');
+ } catch (JavaException $e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if Zend Bridge is enabled
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function zendBridge() {
+ $mods = get_loaded_extensions();
+ if(in_array('Zend Java Bridge', $mods))
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * Attempt java detection
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return boolean
+ */
+ public function tryJava1() {
+ $response = $this->pexec("java -version"); // Java Runtime Check
+ if(empty($response['out'])) {
+ return '';
+ }
+
+ return 'java';
+ }
+
+ /**
+ * Attempt java detection
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return boolean
+ */
+ public function tryJava2() {
+ $response = $this->pexec("java"); // Java Runtime Check
+ if(empty($response['out'])) {
+ return '';
+ }
+
+ return 'java';
+ }
+
+ /**
+ * Attempt java detection
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return boolean
+ */
+ public function tryJava3() {
+ $response = $this->pexec("whereis java"); // Java Runtime Check
+ if(empty($response['out'])) {
+ return '';
+ }
+ $broke = explode(' ', $response['out'][0]);
+ foreach ($broke as $r) {
+ $match = preg_match('/bin/', $r);
+ if($match) {
+ return preg_replace('/java:/', '', $r);
+ }
+ }
+ }
+
+ /**
+ * Check if user entered location of JRE
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return mixed
+ */
+ public function javaSpecified() {
+ if(isset($_POST['java'])) {
+ if($_POST['java'] != '') {
+ return $_POST['java'];
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check if user entered location of PHP
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return mixed
+ */
+ public function phpSpecified() {
+ if(isset($_POST['php'])) {
+ if($_POST['php'] != '') {
+ return $_POST['php'];
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ public function openOfficeSpecified() {
+ if(isset($_POST['soffice'])) {
+ if($_POST['soffice'] != '') {
+ return $_POST['soffice'];
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get session data from post
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return boolean
+ */
+ public function getDataFromSession($class) {
+ if(empty($_SESSION[$this->salt][$class])) {
+ return false;
+ }
+
+ return $_SESSION[$this->salt][$class];
+ }
+
+ /**
+ * Determine the location of JAVA_HOME
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return mixed
+ */
+ function getJava() {
+ $response = $this->tryJava1();
+ if(!is_array($response)) {
+ $response = $this->tryJava2();
+ if(!is_array($response)) {
+ $response = $this->tryJava3();
+ }
+ }
+
+ return $response;
+ }
+
+ /**
+ * Determine the location of PHP
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return mixed
+ */
+ function getPhp() {
+ $cmd = "whereis php";
+ $res = $this->getPhpHelper($cmd);
+ if($res != '') {
+ return $res;
+ }
+ $cmd = "which php";
+ return $this->getPhpHelper($cmd);
+ }
+
+ function getPhpHelper($cmd) {
+ $response = $this->pexec($cmd);
+ if(is_array($response['out'])) {
+ if (isset($response['out'][0])) {
+ $broke = explode(' ', $response['out'][0]);
+ foreach ($broke as $r) {
+ $match = preg_match('/bin/', $r);
+ if($match) {
+ return preg_replace('/php:/', '', $r);
+ }
+ }
+ }
+ }
+
+ return '';
+ }
+
+ function getOpenOffice() {
+ $cmd = "whereis soffice";
+ $res = $this->getOpenOfficeHelper($cmd);
+ if($res != '') {
+ return $res;
+ }
+ $cmd = "which soffice";
+ return $this->getOpenOfficeHelper($cmd);
+ }
+
+ function getOpenOfficeHelper($cmd) {
+ $response = $this->pexec($cmd);
+ if(is_array($response['out'])) {
+ if (isset($response['out'][0])) {
+ $broke = explode(' ', $response['out'][0]);
+ foreach ($broke as $r) {
+ $match = preg_match('/bin/', $r);
+ if($match) {
+ return preg_replace('/soffice:/', '', $r);
+ }
+ }
+ }
+ }
+
+ return '';
+ }
+
+
+ /**
+ * Portably execute a command on any of the supported platforms.
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param string $aCmd
+ * @param array $aOptions
+ * @return array
+ */
+ public function pexec($aCmd, $aOptions = null) {
+ if (is_array($aCmd)) {
+ $sCmd = $this->safeShellString($aCmd);
+ } else {
+ $sCmd = $aCmd;
+ }
+ $sAppend = $this->arrayGet($aOptions, 'append');
+ if ($sAppend) {
+ $sCmd .= " >> " . escapeshellarg($sAppend);
+ }
+ $sPopen = $this->arrayGet($aOptions, 'popen');
+ if ($sPopen) {
+ if (WINDOWS_OS) {
+ $sCmd = "start /b \"kt\" " . $sCmd;
+ }
+ return popen($sCmd, $sPopen);
+ }
+ // for exec, check return code and output...
+ $aRet = array();
+ $aOutput = array();
+ $iRet = '';
+ if(WINDOWS_OS) {
+ $sCmd = 'call '.$sCmd;
+ }
+
+ exec($sCmd, $aOutput, $iRet);
+ $aRet['ret'] = $iRet;
+ $aRet['out'] = $aOutput;
+
+ return $aRet;
+ }
+
+ /**
+ *
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @return string
+ */
+ public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {
+ if (!is_array($aArray)) {
+ $aArray = (array) $aArray;
+ }
+
+ if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) {
+ return $mDefault;
+ }
+ if (array_key_exists($sKey, $aArray)) {
+ $mVal =& $aArray[$sKey];
+ if (empty($mVal) && $bDefaultIfEmpty) {
+ return $mDefault;
+ }
+ return $mVal;
+ }
+ return $mDefault;
+ }
+
+ /**
+ *
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @return string
+ */
+ public function safeShellString () {
+ $aArgs = func_get_args();
+ $aSafeArgs = array();
+ if (is_array($aArgs[0])) {
+ $aArgs = $aArgs[0];
+ }
+ $aSafeArgs[] = escapeshellarg(array_shift($aArgs));
+ if (is_array($aArgs[0])) {
+ $aArgs = $aArgs;
+ }
+ foreach ($aArgs as $sArg) {
+ if (empty($sArg)) {
+ $aSafeArgs[] = "''";
+ } else {
+ $aSafeArgs[] = escapeshellarg($sArg);
+ }
+ }
+ return join(" ", $aSafeArgs);
+ }
+
+}
?>
\ No newline at end of file
diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php
index 96cb136..b8ea171 100644
--- a/setup/wizard/installer.php
+++ b/setup/wizard/installer.php
@@ -1,673 +1,673 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-
-class Installer {
- /**
- * Reference to simple xml object
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var object SimpleXMLElement
- */
- protected $simpleXmlObj = null;
-
- /**
- * Reference to step action object
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var object StepAction
- */
- protected $stepAction = null;
-
- /**
- * Reference to session object
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var object Session
- */
- protected $session = null;
-
- /**
- * List of installation steps as strings
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array string
- */
- protected $stepClassNames = array();
-
- /**
- * List of installation steps as human readable strings
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array string
- */
- protected $stepNames = array();
-
- /**
- * List of installation steps as human readable strings
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array string
- */
- protected $stepObjects = array();
-
- /**
- * Order in which steps have to be installed
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array string
- */
- protected $installOrders = array();
-
- /**
- * List of installation properties
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array string
- */
- protected $installProperties = array();
-
- /**
- * Flag if a step object needs confirmation
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var boolean
- */
- protected $stepConfirmation = false;
-
- /**
- * Flag if a step object needs confirmation
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var boolean
- */
- protected $stepDisplayFirst = false;
-
- private $installerAction = '';
-
- /**
- * Constructs installation object
- *
- * @author KnowledgeTree Team
- * @access public
- * @param object Session $session Instance of the Session object
- */
- public function __construct($session = null) {
- $this->session = $session;
- }
-
- /**
- * Read xml configuration file
- *
- * @author KnowledgeTree Team
- * @param string $name of config file
- * @access private
- * @return object
- */
- private function _readXml($name = "config.xml") {
- try {
- $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
- } catch (Exception $e) {
- $iutil = new InstallUtil();
- $iutil->error("Error reading configuration file: $name");
- exit();
- }
- }
-
- /**
- * Checks if first step of installer
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function _firstStep() {
- if(isset($_GET['step_name'])) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Checks if first step of installer
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function _firstStepPeriod() {
- if(isset($_GET['step_name'])) {
- if($_GET['step_name'] != 'welcome')
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns next step
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return string
- */
- private function _getNextStep() {
- return $this->_getStepName(1);
- }
-
- /**
- * Returns previous step
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return string
- */
- private function _getPreviousStep() {
- return $this->_getStepName(-1);
- }
-
- /**
- * Returns the step name, given a position
- *
- * @author KnowledgeTree Team
- * @param integer $pos current position
- * @access private
- * @return string $name
- */
- private function _getStepName($pos = 0) {
- if($this->_firstStep()) {
- $step = (string) $this->simpleXmlObj->steps->step[0];
- } else {
- $pos += $this->getStepPosition();
- $step = (string) $this->simpleXmlObj->steps->step[$pos];
- }
-
- return $step;
- }
-
- /**
- * Executes next step
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return string
- */
- private function _proceed() {
- $step_name = $this->_getNextStep();
-
- return $this->_runStepAction($step_name);
- }
-
- /**
- * Executes previous step
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return string
- */
- private function _backward() {
- $step_name = $this->_getPreviousStep();
-
- return $this->_runStepAction($step_name);
- }
-
- /**
- * Executes step landing
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return string
- */
- private function _landing() {
- $step_name = $this->_getStepName();
-
- return $this->_runStepAction($step_name);
- }
-
- /**
- * Executes step based on step class name
- *
- * @author KnowledgeTree Team
- * @param string $step_name
- * @access private
- * @return string
- */
- private function _runStepAction($stepName) {
- $this->stepAction = new stepAction($stepName);
- $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getInstallProperties());
-
- return $this->stepAction->doAction();
- }
-
- private function stepDisplayFirst() {
- if($this->installerAction == 'edit')
- return false; //
- $class = $this->stepAction->createStep(); // Get step class
- return $class->displayFirst(); // Check if class needs to display first
- }
-
- /**
- * Set steps class names in string format
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return array
- */
- private function _getInstallOrders() {
- return $this->installOrders;
- }
-
- /**
- * Set steps as names
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _xmlStepsToArray() {
- if(isset($this->simpleXmlObj)) {
- foreach($this->simpleXmlObj->steps->step as $d_step) {
- $step_name = (string) $d_step[0];
- $this->stepClassNames[] = $step_name;
- }
- $this->_loadToSession('stepClassNames', $this->stepClassNames);
- }
- }
-
- /**
- * Set steps as human readable strings
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _xmlStepsNames() {
- if(isset($this->simpleXmlObj)) {
- foreach($this->simpleXmlObj->steps->step as $d_step) {
- $step_name = (string) $d_step[0];
- $this->stepNames[$step_name] = (string) $d_step['name'];
- }
- $this->_loadToSession('stepNames', $this->stepNames);
- }
- }
-
- /**
- * Set steps install order
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _xmlStepsOrders() {
- if(isset($this->simpleXmlObj)) {
- foreach($this->simpleXmlObj->steps->step as $d_step) {
- if(isset($d_step['order'])) {
- $step_name = (string) $d_step[0];
- $order = (string) $d_step['order'];
- $this->installOrders[$order] = $step_name; // Store step install order
- }
- }
- $this->_loadToSession('installOrders', $this->installOrders);
- }
- }
-
- /**
- * Set install properties
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _xmlInstallProperties() {
- if(isset($this->simpleXmlObj)) {
- $this->installProperties['install_version'] = (string) $this->simpleXmlObj['version'];
- $this->installProperties['install_type'] = (string) $this->simpleXmlObj['type'];
- $this->_loadToSession('installProperties', $this->installProperties);
- }
- }
-
- /**
- * Install steps
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _runStepsInstallers() {
- $steps = $this->_getInstallOrders();
- for ($i=1; $i< count($steps)+1; $i++) {
- $this->_installHelper($steps[$i]);
- }
-
- $this->_completeInstall();
- }
-
- /**
- * Complete install cleanup process
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _completeInstall() {
- @touch("install");
- }
-
- /**
- * Install steps helper
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _installHelper($className) {
- $stepAction = new stepAction($className); // Instantiate a step action
- $class = $stepAction->createStep(); // Get step class
- if($class) { // Check if class Exists
- 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
- }
- } else {
- $iutil = new InstallUtil();
- $iutil->error("Class File Missing in Step Directory: $className");
- exit();
- }
- }
-
- /**
- * Reset all session information on welcome landing
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function _resetSessions() {
- if($this->session) {
- if($this->_firstStepPeriod()) {
- foreach ($this->getSteps() as $class) {
- $this->session->un_setClass($class);
- }
- foreach ($this->getStepNames() as $class) {
- $this->session->un_setClass($class);
- }
- foreach ($this->_getInstallOrders() as $class) {
- $this->session->un_setClass($class);
- }
- }
- }
- }
-
- function _loadFromSessions() {
- $this->stepClassNames = $this->session->get('stepClassNames');
- if(!$this->stepClassNames) {
- $this->_xmlStepsToArray(); // String steps
- }
- $this->stepNames = $this->session->get('stepNames');
- if(!$this->stepNames) {
- $this->_xmlStepsNames();
- }
- $this->installOrders = $this->session->get('installOrders');
- if(!$this->installOrders) {
- $this->_xmlStepsOrders();
- }
- $this->installProperties = $this->session->get('installProperties');
- if(!$this->installProperties) {
- $this->_xmlInstallProperties();
- }
- }
-
- private function loadNeeded() {
- $this->_readXml(); // Xml steps
- // Make sure session is cleared
- $this->_resetSessions();
- $this->_loadFromSessions();
- if(isset($_POST['Next'])) {
- $this->installerAction = 'next';
- $this->response = 'next';
- } elseif (isset($_POST['Previous'])) {
- $this->installerAction = 'previous';
- $this->response = 'previous';
- } elseif (isset($_POST['Confirm'])) {
- $this->installerAction = 'confirm';
- $this->response = 'next';
- } elseif (isset($_POST['Install'])) {
- $this->installerAction = 'install';
- $this->response = 'next';
- } elseif (isset($_POST['Edit'])) {
- $this->installerAction = 'edit';
- $this->response = 'next';
- } else {
- $this->response = '';
- $this->installerAction = '';
- }
- }
-
- /**
- * Main control to handle the flow of install
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function step() {
- $this->loadNeeded();
- switch($this->response) {
- case 'next':
- $step_name = $this->_getStepName();
- $res = $this->_runStepAction($step_name);
- if($res == 'next')
- $this->_proceed(); // Load next window
- elseif ($res == 'install') {
- $this->_runStepsInstallers(); // Load landing
- $this->_proceed(); // Load next window
- } elseif ($res == 'confirm') {
- if(!$this->stepDisplayFirst())
- $this->stepConfirmation = true;
- $this->_landing();
- } elseif ($res == 'landing') {
- $this->_landing();
- } else {
- }
- break;
- case 'previous':
- $this->_backward(); // Load previous page
- break;
- default:
- // TODO : handle silent
- $this->_landing();
- break;
- }
- $this->stepAction->paintAction(); // Display step
- }
-
- /**
- * Returns the step number
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return integer $pos
- */
- public function getStepPosition() {
- $pos = 0;
- foreach($this->simpleXmlObj->steps->step as $d_step) {
- $step = (string) $d_step;
- if ($step == $_GET['step_name']) {
- break;
- }
- $pos++;
- }
- if(isset($_GET['step'])) {
- if($_GET['step'] == "next")
- $pos = $pos+1;
- else
- $pos = $pos-1;
- }
-
- return $pos;
- }
-
- /**
- * Returns the step names for classes
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getSteps() {
- return $this->stepClassNames;
- }
-
- /**
- * Returns the steps as human readable string
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getStepNames() {
- return $this->stepNames;
- }
-
- /**
- * Returns whether or not a confirmation step is needed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function getStepConfirmation() {
- return $this->stepConfirmation;
- }
-
- /**
- * Return install properties
- *
- * @author KnowledgeTree Team
- * @param string
- * @access public
- * @return string
- */
- public function getInstallProperties() {
- return $this->installProperties;
- }
-
- /**
- * Returns session
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function getSession() {
- return $this->session;
- }
-
- /**
- * Dump of SESSION
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function showSession() {
- echo '';
- print_r($_SESSION);
- echo '
';
- }
-
- /**
- * Display errors that are not allowing the installer to operate
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function resolveErrors($errors) {
- echo $errors;
- exit();
- }
-
- private function _loadToSession($type, $values) {
- if($values) {
- $this->session->set($type , $values);
- }
- }
-}
-
-?>
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+
+class Installer {
+ /**
+ * Reference to simple xml object
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var object SimpleXMLElement
+ */
+ protected $simpleXmlObj = null;
+
+ /**
+ * Reference to step action object
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var object StepAction
+ */
+ protected $stepAction = null;
+
+ /**
+ * Reference to session object
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var object Session
+ */
+ protected $session = null;
+
+ /**
+ * List of installation steps as strings
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array string
+ */
+ protected $stepClassNames = array();
+
+ /**
+ * List of installation steps as human readable strings
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array string
+ */
+ protected $stepNames = array();
+
+ /**
+ * List of installation steps as human readable strings
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array string
+ */
+ protected $stepObjects = array();
+
+ /**
+ * Order in which steps have to be installed
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array string
+ */
+ protected $installOrders = array();
+
+ /**
+ * List of installation properties
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array string
+ */
+ protected $installProperties = array();
+
+ /**
+ * Flag if a step object needs confirmation
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var boolean
+ */
+ protected $stepConfirmation = false;
+
+ /**
+ * Flag if a step object needs confirmation
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var boolean
+ */
+ protected $stepDisplayFirst = false;
+
+ private $installerAction = '';
+
+ /**
+ * Constructs installation object
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param object Session $session Instance of the Session object
+ */
+ public function __construct($session = null) {
+ $this->session = $session;
+ }
+
+ /**
+ * Read xml configuration file
+ *
+ * @author KnowledgeTree Team
+ * @param string $name of config file
+ * @access private
+ * @return object
+ */
+ private function _readXml($name = "config.xml") {
+ try {
+ $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
+ } catch (Exception $e) {
+ $iutil = new InstallUtil();
+ $iutil->error("Error reading configuration file: $name");
+ exit();
+ }
+ }
+
+ /**
+ * Checks if first step of installer
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function _firstStep() {
+ if(isset($_GET['step_name'])) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if first step of installer
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function _firstStepPeriod() {
+ if(isset($_GET['step_name'])) {
+ if($_GET['step_name'] != 'welcome')
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns next step
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return string
+ */
+ private function _getNextStep() {
+ return $this->_getStepName(1);
+ }
+
+ /**
+ * Returns previous step
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return string
+ */
+ private function _getPreviousStep() {
+ return $this->_getStepName(-1);
+ }
+
+ /**
+ * Returns the step name, given a position
+ *
+ * @author KnowledgeTree Team
+ * @param integer $pos current position
+ * @access private
+ * @return string $name
+ */
+ private function _getStepName($pos = 0) {
+ if($this->_firstStep()) {
+ $step = (string) $this->simpleXmlObj->steps->step[0];
+ } else {
+ $pos += $this->getStepPosition();
+ $step = (string) $this->simpleXmlObj->steps->step[$pos];
+ }
+
+ return $step;
+ }
+
+ /**
+ * Executes next step
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return string
+ */
+ private function _proceed() {
+ $step_name = $this->_getNextStep();
+
+ return $this->_runStepAction($step_name);
+ }
+
+ /**
+ * Executes previous step
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return string
+ */
+ private function _backward() {
+ $step_name = $this->_getPreviousStep();
+
+ return $this->_runStepAction($step_name);
+ }
+
+ /**
+ * Executes step landing
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return string
+ */
+ private function _landing() {
+ $step_name = $this->_getStepName();
+
+ return $this->_runStepAction($step_name);
+ }
+
+ /**
+ * Executes step based on step class name
+ *
+ * @author KnowledgeTree Team
+ * @param string $step_name
+ * @access private
+ * @return string
+ */
+ private function _runStepAction($stepName) {
+ $this->stepAction = new stepAction($stepName);
+ $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getInstallProperties());
+
+ return $this->stepAction->doAction();
+ }
+
+ private function stepDisplayFirst() {
+ if($this->installerAction == 'edit')
+ return false; //
+ $class = $this->stepAction->createStep(); // Get step class
+ return $class->displayFirst(); // Check if class needs to display first
+ }
+
+ /**
+ * Set steps class names in string format
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return array
+ */
+ private function _getInstallOrders() {
+ return $this->installOrders;
+ }
+
+ /**
+ * Set steps as names
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _xmlStepsToArray() {
+ if(isset($this->simpleXmlObj)) {
+ foreach($this->simpleXmlObj->steps->step as $d_step) {
+ $step_name = (string) $d_step[0];
+ $this->stepClassNames[] = $step_name;
+ }
+ $this->_loadToSession('stepClassNames', $this->stepClassNames);
+ }
+ }
+
+ /**
+ * Set steps as human readable strings
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _xmlStepsNames() {
+ if(isset($this->simpleXmlObj)) {
+ foreach($this->simpleXmlObj->steps->step as $d_step) {
+ $step_name = (string) $d_step[0];
+ $this->stepNames[$step_name] = (string) $d_step['name'];
+ }
+ $this->_loadToSession('stepNames', $this->stepNames);
+ }
+ }
+
+ /**
+ * Set steps install order
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _xmlStepsOrders() {
+ if(isset($this->simpleXmlObj)) {
+ foreach($this->simpleXmlObj->steps->step as $d_step) {
+ if(isset($d_step['order'])) {
+ $step_name = (string) $d_step[0];
+ $order = (string) $d_step['order'];
+ $this->installOrders[$order] = $step_name; // Store step install order
+ }
+ }
+ $this->_loadToSession('installOrders', $this->installOrders);
+ }
+ }
+
+ /**
+ * Set install properties
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _xmlInstallProperties() {
+ if(isset($this->simpleXmlObj)) {
+ $this->installProperties['install_version'] = (string) $this->simpleXmlObj['version'];
+ $this->installProperties['install_type'] = (string) $this->simpleXmlObj['type'];
+ $this->_loadToSession('installProperties', $this->installProperties);
+ }
+ }
+
+ /**
+ * Install steps
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _runStepsInstallers() {
+ $steps = $this->_getInstallOrders();
+ for ($i=1; $i< count($steps)+1; $i++) {
+ $this->_installHelper($steps[$i]);
+ }
+
+ $this->_completeInstall();
+ }
+
+ /**
+ * Complete install cleanup process
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _completeInstall() {
+ @touch("install");
+ }
+
+ /**
+ * Install steps helper
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _installHelper($className) {
+ $stepAction = new stepAction($className); // Instantiate a step action
+ $class = $stepAction->createStep(); // Get step class
+ if($class) { // Check if class Exists
+ 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
+ }
+ } else {
+ $iutil = new InstallUtil();
+ $iutil->error("Class File Missing in Step Directory: $className");
+ exit();
+ }
+ }
+
+ /**
+ * Reset all session information on welcome landing
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function _resetSessions() {
+ if($this->session) {
+ if($this->_firstStepPeriod()) {
+ foreach ($this->getSteps() as $class) {
+ $this->session->un_setClass($class);
+ }
+ foreach ($this->getStepNames() as $class) {
+ $this->session->un_setClass($class);
+ }
+ foreach ($this->_getInstallOrders() as $class) {
+ $this->session->un_setClass($class);
+ }
+ }
+ }
+ }
+
+ function _loadFromSessions() {
+ $this->stepClassNames = $this->session->get('stepClassNames');
+ if(!$this->stepClassNames) {
+ $this->_xmlStepsToArray(); // String steps
+ }
+ $this->stepNames = $this->session->get('stepNames');
+ if(!$this->stepNames) {
+ $this->_xmlStepsNames();
+ }
+ $this->installOrders = $this->session->get('installOrders');
+ if(!$this->installOrders) {
+ $this->_xmlStepsOrders();
+ }
+ $this->installProperties = $this->session->get('installProperties');
+ if(!$this->installProperties) {
+ $this->_xmlInstallProperties();
+ }
+ }
+
+ private function loadNeeded() {
+ $this->_readXml(); // Xml steps
+ // Make sure session is cleared
+ $this->_resetSessions();
+ $this->_loadFromSessions();
+ if(isset($_POST['Next'])) {
+ $this->installerAction = 'next';
+ $this->response = 'next';
+ } elseif (isset($_POST['Previous'])) {
+ $this->installerAction = 'previous';
+ $this->response = 'previous';
+ } elseif (isset($_POST['Confirm'])) {
+ $this->installerAction = 'confirm';
+ $this->response = 'next';
+ } elseif (isset($_POST['Install'])) {
+ $this->installerAction = 'install';
+ $this->response = 'next';
+ } elseif (isset($_POST['Edit'])) {
+ $this->installerAction = 'edit';
+ $this->response = 'next';
+ } else {
+ $this->response = '';
+ $this->installerAction = '';
+ }
+ }
+
+ /**
+ * Main control to handle the flow of install
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return void
+ */
+ public function step() {
+ $this->loadNeeded();
+ switch($this->response) {
+ case 'next':
+ $step_name = $this->_getStepName();
+ $res = $this->_runStepAction($step_name);
+ if($res == 'next')
+ $this->_proceed(); // Load next window
+ elseif ($res == 'install') {
+ $this->_runStepsInstallers(); // Load landing
+ $this->_proceed(); // Load next window
+ } elseif ($res == 'confirm') {
+ if(!$this->stepDisplayFirst())
+ $this->stepConfirmation = true;
+ $this->_landing();
+ } elseif ($res == 'landing') {
+ $this->_landing();
+ } else {
+ }
+ break;
+ case 'previous':
+ $this->_backward(); // Load previous page
+ break;
+ default:
+ // TODO : handle silent
+ $this->_landing();
+ break;
+ }
+ $this->stepAction->paintAction(); // Display step
+ }
+
+ /**
+ * Returns the step number
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return integer $pos
+ */
+ public function getStepPosition() {
+ $pos = 0;
+ foreach($this->simpleXmlObj->steps->step as $d_step) {
+ $step = (string) $d_step;
+ if ($step == $_GET['step_name']) {
+ break;
+ }
+ $pos++;
+ }
+ if(isset($_GET['step'])) {
+ if($_GET['step'] == "next")
+ $pos = $pos+1;
+ else
+ $pos = $pos-1;
+ }
+
+ return $pos;
+ }
+
+ /**
+ * Returns the step names for classes
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function getSteps() {
+ return $this->stepClassNames;
+ }
+
+ /**
+ * Returns the steps as human readable string
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function getStepNames() {
+ return $this->stepNames;
+ }
+
+ /**
+ * Returns whether or not a confirmation step is needed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function getStepConfirmation() {
+ return $this->stepConfirmation;
+ }
+
+ /**
+ * Return install properties
+ *
+ * @author KnowledgeTree Team
+ * @param string
+ * @access public
+ * @return string
+ */
+ public function getInstallProperties() {
+ return $this->installProperties;
+ }
+
+ /**
+ * Returns session
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function getSession() {
+ return $this->session;
+ }
+
+ /**
+ * Dump of SESSION
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function showSession() {
+ echo '';
+ print_r($_SESSION['install']);
+ echo '
';
+ }
+
+ /**
+ * Display errors that are not allowing the installer to operate
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return void
+ */
+ public function resolveErrors($errors) {
+ echo $errors;
+ exit();
+ }
+
+ private function _loadToSession($type, $values) {
+ if($values) {
+ $this->session->set($type , $values);
+ }
+ }
+}
+
+?>
diff --git a/setup/wizard/lib/services/windowsOpenOffice.php b/setup/wizard/lib/services/windowsOpenOffice.php
index 68cf981..b3fb4d0 100644
--- a/setup/wizard/lib/services/windowsOpenOffice.php
+++ b/setup/wizard/lib/services/windowsOpenOffice.php
@@ -1,241 +1,244 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-
-class windowsOpenOffice extends windowsService {
-
- /**
- * Reference to utility object
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- public $util;
-
- /**
- * Path to office executable
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $path;
-
- /**
- * Web server
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $host;
-
- /**
- * Path to temp pid file
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $pidFile;
-
- /**
- * Web server Port
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $port;
-
- /**
- * Web server
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $bin;
-
- /**
- * Office executable name
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $soffice;
-
- /**
- * Log file
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $log;
-
- /**
- * Open office options
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $options;
-
- /**
- * Path to win service
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $winservice;
-
- /**
- * Service name
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public $name = "KTOpenOfficeTest";
-
- public function load() {
- // hack for testing
- $this->setPort("8100");
- $this->setHost("127.0.0.1");
- $this->setLog("openoffice.log");
- $this->setWinservice("winserv.exe");
- $this->setOption();
- }
-
- private function setPort($port = "8100") {
- $this->port = $port;
- }
-
- public function getPort() {
- return $this->port;
- }
-
- private function setHost($host = "127.0.0.1") {
- $this->host = $host;
- }
-
- public function getHost() {
- return $this->host;
- }
-
- private function setLog($log = "openoffice.log") {
- $this->log = $log;
- }
-
- public function getLog() {
- return $this->log;
- }
-
- private function setBin($bin) {
- $this->bin = "\"".$bin."\"";
- }
-
- public function getBin() {
- return $this->bin;
- }
-
- private function setWinservice($winservice = "winserv.exe") {
- $this->winservice = SYS_BIN_DIR . $winservice;
- }
-
- public function getWinservice() {
- return $this->winservice;
- }
-
- private function setOption() {
- $this->options = "-displayname {$this->name} -start auto {$this->getBin()} -headless -invisible -nofirststartwizard"
- . "-accept=\"socket,host={$this->host},port={$this->port};urp;StarOffice.ServiceManager\"";
- }
-
- public function getOption() {
- return $this->options;
- }
-
- public function install() {
- $status = $this->status();
- if($status == '') {
- $services = $this->util->getDataFromSession('services');
- $this->setBin("{$services['openOfficeExe']}");
- $this->setOption();
- $cmd = "\"{$this->winservice}\" install $this->name {$this->getOption()}";
- if(DEBUG) {
- echo "$cmd
";
- return ;
- }
- $response = $this->util->pexec($cmd);
- return $response;
- }
- else {
- return $status;
- }
- }
-
- /**
- * Retrieve Status Service
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public function status() {
- $cmd = "sc query {$this->name}";
- $response = $this->util->pexec($cmd);
- if($response['out']) {
- $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
- return $state;
- }
-
- return '';
- }
-}
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+
+class windowsOpenOffice extends windowsService {
+
+ /**
+ * Reference to utility object
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ public $util;
+
+ /**
+ * Path to office executable
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $path;
+
+ /**
+ * Web server
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $host;
+
+ /**
+ * Path to temp pid file
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $pidFile;
+
+ /**
+ * Web server Port
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $port;
+
+ /**
+ * Web server
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $bin;
+
+ /**
+ * Office executable name
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $soffice;
+
+ /**
+ * Log file
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $log;
+
+ /**
+ * Open office options
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $options;
+
+ /**
+ * Path to win service
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $winservice;
+
+ /**
+ * Service name
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public $name = "KTOpenOfficeTest";
+
+ public function load() {
+ // hack for testing
+ $this->setPort("8100");
+ $this->setHost("127.0.0.1");
+ $this->setLog("openoffice.log");
+ $this->setWinservice("winserv.exe");
+ $this->setOption();
+ }
+
+ private function setPort($port = "8100") {
+ $this->port = $port;
+ }
+
+ public function getPort() {
+ return $this->port;
+ }
+
+ private function setHost($host = "127.0.0.1") {
+ $this->host = $host;
+ }
+
+ public function getHost() {
+ return $this->host;
+ }
+
+ private function setLog($log = "openoffice.log") {
+ $this->log = $log;
+ }
+
+ public function getLog() {
+ return $this->log;
+ }
+
+ private function setBin($bin) {
+ $this->bin = "\"".$bin."\"";
+ }
+
+ public function getBin() {
+ return $this->bin;
+ }
+
+ private function setWinservice($winservice = "winserv.exe") {
+ if(file_exists(SYS_BIN_DIR . $winservice))
+ $this->winservice = SYS_BIN_DIR . $winservice;
+ else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice))
+ $this->winservice = SYS_BIN_DIR . "win32" . DS. $winservice;
+ }
+
+ public function getWinservice() {
+ return $this->winservice;
+ }
+
+ private function setOption() {
+ $this->options = "-displayname {$this->name} -start auto {$this->getBin()} -headless -invisible -nofirststartwizard"
+ . "-accept=\"socket,host={$this->host},port={$this->port};urp;StarOffice.ServiceManager\"";
+ }
+
+ public function getOption() {
+ return $this->options;
+ }
+
+ public function install() {
+ $status = $this->status();
+ if($status == '') {
+ $services = $this->util->getDataFromSession('services');
+ $this->setBin("{$services['openOfficeExe']}");
+ $this->setOption();
+ $cmd = "\"{$this->winservice}\" install $this->name {$this->getOption()}";
+ if(DEBUG) {
+ echo "$cmd
";
+ return ;
+ }
+ $response = $this->util->pexec($cmd);
+ return $response;
+ }
+ else {
+ return $status;
+ }
+ }
+
+ /**
+ * Retrieve Status Service
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public function status() {
+ $cmd = "sc query {$this->name}";
+ $response = $this->util->pexec($cmd);
+ if($response['out']) {
+ $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
+ return $state;
+ }
+
+ return '';
+ }
+}
?>
\ No newline at end of file
diff --git a/setup/wizard/lib/services/windowsScheduler.php b/setup/wizard/lib/services/windowsScheduler.php
index 58c2f2a..ccd7be3 100644
--- a/setup/wizard/lib/services/windowsScheduler.php
+++ b/setup/wizard/lib/services/windowsScheduler.php
@@ -1,266 +1,266 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-class windowsScheduler extends windowsService {
- /**
- * Batch Script to execute
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $schedulerScriptPath;
-
- /**
- * Php Script to execute
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $schedulerSource;
-
- /**
- * Scheduler Directory
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $schedulerDir;
-
- /**
- * Service name
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public $name = "KTSchedulerTest";
-
- /**
- * Load defaults needed by service
- *
- * @author KnowledgeTree Team
- * @access public
- * @param string
- * @return void
- */
- function load() {
- $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
- $this->setSchedulerScriptPath("taskrunner.bat");
- $this->setSchedulerSource("schedulerService.php");
-
- }
-
- /**
- * Set Scheduler Directory path
- *
- * @author KnowledgeTree Team
- * @access private
- * @param none
- * @return string
- */
- private function setSchedulerDIR($schedulerDIR) {
- $this->schedulerDir = $schedulerDIR;
- }
-
- /**
- * Retrieve Scheduler Directory path
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public function getSchedulerDir() {
- if(file_exists($this->schedulerDir))
- return $this->schedulerDir;
- return false;
- }
-
- /**
- * Set Batch Script path
- *
- * @author KnowledgeTree Team
- * @access private
- * @param string
- * @return void
- */
- private function setSchedulerScriptPath($schedulerScriptPath) {
- $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath";
- }
-
- /**
- * Retrieve Batch Script path
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public function getSchedulerScriptPath() {
- if(file_exists($this->schedulerScriptPath))
- return $this->schedulerScriptPath;
- return false;
- }
-
- /**
- * Set Php Script path
- *
- * @author KnowledgeTree Team
- * @access private
- * @param none
- * @return string
- */
- private function setSchedulerSource($schedulerSource) {
- $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource;
- }
-
- /**
- * Retrieve Php Script path
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public function getSchedulerSource() {
- if(file_exists($this->schedulerSource))
- return $this->schedulerSource;
- return false;
- }
-
- /**
- * Retrieve Status Service
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return string
- */
- public function status() {
- $cmd = "sc query {$this->name}";
- $response = $this->util->pexec($cmd);
- if($response['out']) {
- $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
- return $state;
- }
-
- return '';
- }
-
- /**
- * Install Scheduler Service
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- * @return array
- */
- public function install() {
- $state = $this->status();
- if($state == '') {
- $this->writeSchedulerTask();
- $this->writeTaskRunner();
- // TODO what if it does not exist? check how the dmsctl.bat does this
- if (function_exists('win32_create_service')) {
- $response = win32_create_service(array(
- 'service' => $this->name,
- 'display' => $this->name,
- 'path' => $this->getSchedulerScriptPath()
- ));
- return $response;
- } else { // Attempt to use the winserv
- // TODO: Add service using winserv
- $this->setWinservice();
- $this->setOptions();
- $cmd = "\"{$this->winservice}\" install $this->name $this->options";
- if(DEBUG) {
- echo "$cmd
";
- return ;
- }
- $response = $this->util->pexec($cmd);
- return $response;
- }
- }
- return $state;
- }
-
- private function setWinservice($winservice = "winserv.exe") {
- $this->winservice = SYS_BIN_DIR . $winservice;
- }
-
- private function setOptions() {
- $this->options = "-displayname {$this->name} -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible "
- . "";
- }
-
- private function writeTaskRunner() {
- // Check if bin is readable and writable
- if(is_readable(SYS_BIN_DIR."win32") && is_writable(SYS_BIN_DIR."win32")) {
- $fp = fopen($this->getSchedulerDir().""."\\taskrunner.bat", "w+");
- $content = "@echo off \n";
- $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
- fwrite($fp, $content);
- fclose($fp);
- } else {
- // TODO: Should not reach this point
- }
- }
-
- private function writeSchedulerTask() {
- // Check if bin is readable and writable
- if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) {
- if(!$this->getSchedulerScriptPath()) {
- $fp = fopen($this->getSchedulerScriptPath(), "w+");
- $content = "@echo off\n";
- $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
- fwrite($fp, $content);
- fclose($fp);
- }
- } else {
- // TODO: Should not reach this point
- }
- }
-}
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+class windowsScheduler extends windowsService {
+ /**
+ * Batch Script to execute
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $schedulerScriptPath;
+
+ /**
+ * Php Script to execute
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $schedulerSource;
+
+ /**
+ * Scheduler Directory
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $schedulerDir;
+
+ /**
+ * Service name
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public $name = "KTSchedulerTest";
+
+ /**
+ * Load defaults needed by service
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param string
+ * @return void
+ */
+ function load() {
+ $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
+ $this->setSchedulerScriptPath("taskrunner.bat");
+ $this->setSchedulerSource("schedulerService.php");
+
+ }
+
+ /**
+ * Set Scheduler Directory path
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param none
+ * @return string
+ */
+ private function setSchedulerDIR($schedulerDIR) {
+ $this->schedulerDir = $schedulerDIR;
+ }
+
+ /**
+ * Retrieve Scheduler Directory path
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public function getSchedulerDir() {
+ if(file_exists($this->schedulerDir))
+ return $this->schedulerDir;
+ return false;
+ }
+
+ /**
+ * Set Batch Script path
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param string
+ * @return void
+ */
+ private function setSchedulerScriptPath($schedulerScriptPath) {
+ $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath";
+ }
+
+ /**
+ * Retrieve Batch Script path
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public function getSchedulerScriptPath() {
+ if(file_exists($this->schedulerScriptPath))
+ return $this->schedulerScriptPath;
+ return false;
+ }
+
+ /**
+ * Set Php Script path
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @param none
+ * @return string
+ */
+ private function setSchedulerSource($schedulerSource) {
+ $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource;
+ }
+
+ /**
+ * Retrieve Php Script path
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public function getSchedulerSource() {
+ if(file_exists($this->schedulerSource))
+ return $this->schedulerSource;
+ return false;
+ }
+
+ /**
+ * Retrieve Status Service
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return string
+ */
+ public function status() {
+ $cmd = "sc query {$this->name}";
+ $response = $this->util->pexec($cmd);
+ if($response['out']) {
+ $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
+ return $state;
+ }
+
+ return '';
+ }
+
+ /**
+ * Install Scheduler Service
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return array
+ */
+ public function install() {
+ $state = $this->status();
+ if($state == '') {
+ $this->writeSchedulerTask();
+ $this->writeTaskRunner();
+ // TODO what if it does not exist? check how the dmsctl.bat does this
+ if (function_exists('win32_create_service')) {
+ $response = win32_create_service(array(
+ 'service' => $this->name,
+ 'display' => $this->name,
+ 'path' => $this->getSchedulerScriptPath()
+ ));
+ return $response;
+ } else { // Attempt to use the winserv
+ // TODO: Add service using winserv
+ $this->setWinservice();
+ $this->setOptions();
+ $cmd = "\"{$this->winservice}\" install $this->name $this->options";
+ if(DEBUG) {
+ echo "$cmd
";
+ return ;
+ }
+ $response = $this->util->pexec($cmd);
+ return $response;
+ }
+ }
+ return $state;
+ }
+
+ private function setWinservice($winservice = "winserv.exe") {
+ $this->winservice = SYS_BIN_DIR . $winservice;
+ }
+
+ private function setOptions() {
+ $this->options = "-displayname {$this->name} -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible "
+ . "";
+ }
+
+ private function writeTaskRunner() {
+ // Check if bin is readable and writable
+ if(is_readable(SYS_BIN_DIR."win32") && is_writable(SYS_BIN_DIR."win32")) {
+ $fp = fopen($this->getSchedulerDir().""."\\taskrunner.bat", "w+");
+ $content = "@echo off \n";
+ $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
+ fwrite($fp, $content);
+ fclose($fp);
+ } else {
+ // TODO: Should not reach this point
+ }
+ }
+
+ private function writeSchedulerTask() {
+ // Check if bin is readable and writable
+ if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) {
+ if(!$this->getSchedulerScriptPath()) {
+ $fp = fopen($this->getSchedulerScriptPath(), "w+");
+ $content = "@echo off\n";
+ $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
+ fwrite($fp, $content);
+ fclose($fp);
+ }
+ } else {
+ // TODO: Should not reach this point
+ }
+ }
+}
?>
\ No newline at end of file
diff --git a/setup/wizard/path.php b/setup/wizard/path.php
index 9f13359..2442d84 100644
--- a/setup/wizard/path.php
+++ b/setup/wizard/path.php
@@ -1,131 +1,131 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
- // Define installer environment
- define('DEBUG', 1);
- define('AJAX', 0);
- if (substr(php_uname(), 0, 7) == "Windows"){
- define('WINDOWS_OS', true);
- define('UNIX_OS', false);
- define('OS', 'windows');
- } else {
- define('WINDOWS_OS', false);
- define('UNIX_OS', true);
- define('OS', 'unix');
- }
- if(WINDOWS_OS) {
- define('DS', '\\');
- } else {
- define('DS', '/');
- }
- // Define environment root
- $wizard = realpath(dirname(__FILE__));
- $xdir = explode(DS, $wizard);
- array_pop($xdir);
- array_pop($xdir);
- $sys = '';
- foreach ($xdir as $k=>$v) {
- $sys .= $v.DS;
- }
- // Define paths to wizard
- define('WIZARD_DIR', $wizard.DS);
- define('WIZARD_LIB', WIZARD_DIR."lib".DS);
- define('SERVICE_LIB', WIZARD_LIB."services".DS);
- define('SQL_DIR', WIZARD_DIR."sql".DS);
- define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS);
- define('CONF_DIR', WIZARD_DIR."config".DS);
- define('RES_DIR', WIZARD_DIR."resources".DS);
- define('STEP_DIR', WIZARD_DIR."steps".DS);
- define('TEMP_DIR', WIZARD_DIR."templates".DS);
- define('SHELL_DIR', WIZARD_DIR."shells".DS);
- define('OUTPUT_DIR', WIZARD_DIR."output".DS);
- // Define paths to system webroot
- define('SYSTEM_DIR', $sys);
- define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
- define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS);
- // Define paths to system
- array_pop($xdir);
- $asys = '';
- foreach ($xdir as $k=>$v) {
- $asys .= $v.DS;
- }
- define('SYSTEM_ROOT', $asys);
- // Install Type
- preg_match('/Zend/', $sys, $matches); // TODO: Dirty
- if($matches) {
- $sysdir = explode(DS, $sys);
- array_pop($sysdir);
- array_pop($sysdir);
- array_pop($sysdir);
- array_pop($sysdir);
- $zendsys = '';
- foreach ($sysdir as $k=>$v) {
- $zendsys .= $v.DS;
- }
- define('INSTALL_TYPE', 'Zend');
- define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);
- } else {
- $modules = get_loaded_extensions();
- // TODO: Dirty
- if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) {
- define('INSTALL_TYPE', 'Zend');
- define('PHP_DIR', '');
- } else {
- define('INSTALL_TYPE', '');
- define('PHP_DIR', '');
- }
- }
- // Other
- date_default_timezone_set('Africa/Johannesburg');
- if(WINDOWS_OS) { // Mysql bin [Windows]
- $serverPaths = explode(';',$_SERVER['PATH']);
- foreach ($serverPaths as $apath) {
- preg_match('/mysql/i', $apath, $matches);
- if($matches) {
- define('MYSQL_BIN', $apath.DS);
- break;
- }
- }
- } else {
- define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line
- }
-
-?>
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+ // Define installer environment
+ define('DEBUG', 0);
+ define('AJAX', 0);
+ if (substr(php_uname(), 0, 7) == "Windows"){
+ define('WINDOWS_OS', true);
+ define('UNIX_OS', false);
+ define('OS', 'windows');
+ } else {
+ define('WINDOWS_OS', false);
+ define('UNIX_OS', true);
+ define('OS', 'unix');
+ }
+ if(WINDOWS_OS) {
+ define('DS', '\\');
+ } else {
+ define('DS', '/');
+ }
+ // Define environment root
+ $wizard = realpath(dirname(__FILE__));
+ $xdir = explode(DS, $wizard);
+ array_pop($xdir);
+ array_pop($xdir);
+ $sys = '';
+ foreach ($xdir as $k=>$v) {
+ $sys .= $v.DS;
+ }
+ // Define paths to wizard
+ define('WIZARD_DIR', $wizard.DS);
+ define('WIZARD_LIB', WIZARD_DIR."lib".DS);
+ define('SERVICE_LIB', WIZARD_LIB."services".DS);
+ define('SQL_DIR', WIZARD_DIR."sql".DS);
+ define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS);
+ define('CONF_DIR', WIZARD_DIR."config".DS);
+ define('RES_DIR', WIZARD_DIR."resources".DS);
+ define('STEP_DIR', WIZARD_DIR."steps".DS);
+ define('TEMP_DIR', WIZARD_DIR."templates".DS);
+ define('SHELL_DIR', WIZARD_DIR."shells".DS);
+ define('OUTPUT_DIR', WIZARD_DIR."output".DS);
+ // Define paths to system webroot
+ define('SYSTEM_DIR', $sys);
+ define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
+ define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS);
+ // Define paths to system
+ array_pop($xdir);
+ $asys = '';
+ foreach ($xdir as $k=>$v) {
+ $asys .= $v.DS;
+ }
+ define('SYSTEM_ROOT', $asys);
+ // Install Type
+ preg_match('/Zend/', $sys, $matches); // TODO: Dirty
+ if($matches) {
+ $sysdir = explode(DS, $sys);
+ array_pop($sysdir);
+ array_pop($sysdir);
+ array_pop($sysdir);
+ array_pop($sysdir);
+ $zendsys = '';
+ foreach ($sysdir as $k=>$v) {
+ $zendsys .= $v.DS;
+ }
+ define('INSTALL_TYPE', 'Zend');
+ define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);
+ } else {
+ $modules = get_loaded_extensions();
+ // TODO: Dirty
+ if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) {
+ define('INSTALL_TYPE', 'Zend');
+ define('PHP_DIR', '');
+ } else {
+ define('INSTALL_TYPE', '');
+ define('PHP_DIR', '');
+ }
+ }
+ // Other
+ date_default_timezone_set('Africa/Johannesburg');
+ if(WINDOWS_OS) { // Mysql bin [Windows]
+ $serverPaths = explode(';',$_SERVER['PATH']);
+ foreach ($serverPaths as $apath) {
+ preg_match('/mysql/i', $apath, $matches);
+ if($matches) {
+ define('MYSQL_BIN', $apath.DS);
+ break;
+ }
+ }
+ } else {
+ define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line
+ }
+
+?>
diff --git a/setup/wizard/resources/form.js b/setup/wizard/resources/form.js
index 7e1815b..b88c521 100644
--- a/setup/wizard/resources/form.js
+++ b/setup/wizard/resources/form.js
@@ -9,5 +9,4 @@ $(document).ready(function() {
var options = {target: '#content_container', beforeSubmit: w.validateRegistration, success: w.adjustMenu($('form').attr('id'))};
$('form').ajaxForm(options);
}
-});
-
+});
\ No newline at end of file
diff --git a/setup/wizard/resources/wizard.js b/setup/wizard/resources/wizard.js
index 1694539..ba60308 100644
--- a/setup/wizard/resources/wizard.js
+++ b/setup/wizard/resources/wizard.js
@@ -1,218 +1,228 @@
-// Class Wizard
-function wizard() {
-}
-
-// Toggle Advance Database options
-wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details
- if($('.'+ele).attr('style') == 'display: none;') {
- $('.'+ele).attr('style', 'display: block;');
- if($('#'+option).attr('innerHTML') != ' Advanced Options')
- $('#'+option).attr('innerHTML', 'Hide Details');
- } else {
- $('.'+ele).attr('style', 'display: none;');
- if($('#'+option).attr('innerHTML') != ' Advanced Options')
- $('#'+option).attr('innerHTML', 'Show Details');
- }
-}
-
-// Focus on element
-wizard.prototype.focusElement = function(el) {
- el.focus();
-}
-
-// Force previous click
-wizard.prototype.pClick = function() {
- var state = $('#state');
- if(state != undefined) {
- state.attr('name', 'previous');
- }
-}
-
-// Force next click
-wizard.prototype.nClick = function() {
- var state = $('#state');;
- if(state != undefined) {
- state.attr('name', 'next');
- }
-}
-
-// Validate Registration Page
-wizard.prototype.validateRegistration = function() {
- // See if next or previous is clicked.
- var state = $('#state').attr('name');
- if(state == 'next') {
- if(w.valRegHelper()) {
- $('#sendAll').attr('name', 'Next'); // Force the next step
- $('#sendAll').attr('value', 'next');
- return true;
- }
- } else if(state == 'previous') {
- $('#sendAll').attr('name', 'Previous'); // Force the previous step
- $('#sendAll').attr('value', 'previous');
- return true;
- }
-
- return false;
-}
-
-wizard.prototype.valRegHelper = function() {
- var first = document.getElementById('first');
- var last = document.getElementById('last');
- var email = document.getElementById('email');
- if(first.value.length < 1) {
- document.getElementById("reg_error").innerHTML = "Please enter a First Name";
- w.focusElement(first);
- return false;
- }
- if(!w.nameCheck(first.value)) {
- document.getElementById("reg_error").innerHTML = "Please enter a valid First Name";
- w.focusElement(first);
- return false;
- }
- if(last.value.length < 1) {
- document.getElementById("reg_error").innerHTML = "Please enter a Last Name";
- w.focusElement(last);
- return false;
- }
- if(!w.nameCheck(last.value)) {
- document.getElementById("reg_error").innerHTML = "Please enter a valid Last Name";
- w.focusElement(last);
- return false;
- }
- if(!w.emailCheck(email.value)) {
- document.getElementById("reg_error").innerHTML = "Please enter a valid email address";
- w.focusElement(email);
- return false;
- }
-
- return true;
-}
-
-wizard.prototype.nameCheck = function(str) {
- var nameRegxp = /^([a-zA-Z]+)$/;
- if(str.match(nameRegxp)) {
- return true;
- } else {
- return false;
- }
-}
-
-// Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
-wizard.prototype.emailCheck = function(str) {
- str = w.trim(str);
- var at="@";
- var dot=".";
- var lat=str.indexOf(at);
- var lstr=str.length;
- var ldot=str.indexOf(dot);
- if (str.indexOf(at)==-1) {
- return false;
- }
- if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
- return false;
- }
- if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
- return false;
- }
- if (str.indexOf(at,(lat+1))!=-1) {
- return false;
- }
- if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
- return false;
- }
- if (str.indexOf(dot,(lat+2))==-1){
- return false;
- }
- if (str.indexOf(" ")!=-1){
- return false;
- }
- return true;
-}
-
-wizard.prototype.trim = function (str, chars) {
- return w.ltrim(w.rtrim(str, chars), chars);
-}
-
-wizard.prototype.ltrim = function (str, chars) {
- chars = chars || "\\s";
- return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
-}
-
-wizard.prototype.rtrim = function (str, chars) {
- chars = chars || "\\s";
- return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
-}
-
-wizard.prototype.adjustMenu = function (form_id, previous) {
- form_name = form_id.split('_');
- if(form_name.length == 2) {
- current_step = form_name[0];
- next_step = form_name[1];
- $('#'+current_step).attr('class', 'current');
- $('#'+next_step).attr('class', 'inactive');
- } else if(form_name.length == 3) {
- previous_step = form_name[0];
- current_step = form_name[1];
- next_step = form_name[2];
- $('#'+previous_step).attr('class', 'active');
- $('#'+current_step).attr('class', 'current');
- $('#'+next_step).attr('class', 'inactive');
- }
-}
-
-wizard.prototype.dummy = function () {
-
-}
-
-// pre-submit callback
-wizard.prototype.showRequest = function (formData, jqForm, options) {
- $.blockUI({message:''});
- $('#loading').attr('style', 'display:block;');
-}
-
-// post-submit callback
-wizard.prototype.showResponse = function (responseText, statusText) {
- $.unblockUI();
- $('#loading').attr('style', 'display:none;');
-}
-
-wizard.prototype.refresh = function (page) {
- var address = "index.php?step_name="+page;
- var div = 'content_container';
- $.ajax({
- url: address,
- dataType: "html",
- type: "GET",
- cache: false,
- beforeSubmit: w.showRequest,
- success: function(data){
- $("#"+div).empty();
- $("#"+div).append(data);
- w.showResponse;
- return;
- }
- });
-}
-
-wizard.prototype.getUrl = function (address, div) {
- $("#"+div).empty();
- $.ajax({
- url: address,
- dataType: "html",
- type: "GET",
- cache: false,
- success: function(data){
- $("#"+div).empty();
- $("#"+div).append(data);
- return;
- }
- });
-}
-
-wizard.prototype.sendJavaLocation = function () {
- $('form').submit();
-}
-
-wizard.prototype.sendRegistration = function () {
- $('form').submit();
+// Class Wizard
+function wizard() {
+}
+
+// Toggle Advance Database options
+wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details
+ if($('.'+ele).attr('style') == 'display: none;') {
+ $('.'+ele).attr('style', 'display: block;');
+ if($('#'+option).attr('innerHTML') != ' Advanced Options')
+ $('#'+option).attr('innerHTML', 'Hide Details');
+ } else {
+ $('.'+ele).attr('style', 'display: none;');
+ if($('#'+option).attr('innerHTML') != ' Advanced Options')
+ $('#'+option).attr('innerHTML', 'Show Details');
+ }
+}
+
+// Focus on element
+wizard.prototype.focusElement = function(el) {
+ el.focus();
+}
+
+// Force previous click
+wizard.prototype.pClick = function() {
+ var state = $('#state');
+ if(state != undefined) {
+ state.attr('name', 'previous');
+ }
+}
+
+// Force next click
+wizard.prototype.nClick = function() {
+ var state = $('#state');;
+ if(state != undefined) {
+ state.attr('name', 'next');
+ }
+}
+
+// Validate Registration Page
+wizard.prototype.validateRegistration = function() {
+ // See if next or previous is clicked.
+ var state = $('#state').attr('name');
+ if(state == 'next') {
+ if(w.valRegHelper()) {
+ $('#sendAll').attr('name', 'Next'); // Force the next step
+ $('#sendAll').attr('value', 'next');
+ return true;
+ }
+ } else if(state == 'previous') {
+ $('#sendAll').attr('name', 'Previous'); // Force the previous step
+ $('#sendAll').attr('value', 'previous');
+ return true;
+ }
+
+ return false;
+}
+
+wizard.prototype.valRegHelper = function() {
+ var first = document.getElementById('first');
+ var last = document.getElementById('last');
+ var email = document.getElementById('email');
+ if(first.value.length < 1) {
+ document.getElementById("reg_error").innerHTML = "Please enter a First Name";
+ w.focusElement(first);
+ return false;
+ }
+ if(!w.nameCheck(first.value)) {
+ document.getElementById("reg_error").innerHTML = "Please enter a valid First Name";
+ w.focusElement(first);
+ return false;
+ }
+ if(last.value.length < 1) {
+ document.getElementById("reg_error").innerHTML = "Please enter a Last Name";
+ w.focusElement(last);
+ return false;
+ }
+ if(!w.nameCheck(last.value)) {
+ document.getElementById("reg_error").innerHTML = "Please enter a valid Last Name";
+ w.focusElement(last);
+ return false;
+ }
+ if(!w.emailCheck(email.value)) {
+ document.getElementById("reg_error").innerHTML = "Please enter a valid email address";
+ w.focusElement(email);
+ return false;
+ }
+
+ return true;
+}
+
+wizard.prototype.nameCheck = function(str) {
+ var nameRegxp = /^([a-zA-Z]+)$/;
+ if(str.match(nameRegxp)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
+wizard.prototype.emailCheck = function(str) {
+ str = w.trim(str);
+ var at="@";
+ var dot=".";
+ var lat=str.indexOf(at);
+ var lstr=str.length;
+ var ldot=str.indexOf(dot);
+ if (str.indexOf(at)==-1) {
+ return false;
+ }
+ if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
+ return false;
+ }
+ if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
+ return false;
+ }
+ if (str.indexOf(at,(lat+1))!=-1) {
+ return false;
+ }
+ if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
+ return false;
+ }
+ if (str.indexOf(dot,(lat+2))==-1){
+ return false;
+ }
+ if (str.indexOf(" ")!=-1){
+ return false;
+ }
+ return true;
+}
+
+wizard.prototype.trim = function (str, chars) {
+ return w.ltrim(w.rtrim(str, chars), chars);
+}
+
+wizard.prototype.ltrim = function (str, chars) {
+ chars = chars || "\\s";
+ return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
+}
+
+wizard.prototype.rtrim = function (str, chars) {
+ chars = chars || "\\s";
+ return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
+}
+
+wizard.prototype.adjustMenu = function (form_id, previous) {
+ form_name = form_id.split('_');
+ if(form_name.length == 2) {
+ current_step = form_name[0];
+ next_step = form_name[1];
+ $('#'+current_step).attr('class', 'current');
+ $('#'+next_step).attr('class', 'inactive');
+ } else if(form_name.length == 3) {
+ previous_step = form_name[0];
+ current_step = form_name[1];
+ next_step = form_name[2];
+ $('#'+previous_step).attr('class', 'active');
+ $('#'+current_step).attr('class', 'current');
+ $('#'+next_step).attr('class', 'inactive');
+ }
+}
+
+wizard.prototype.dummy = function () {
+
+}
+
+// pre-submit callback
+wizard.prototype.showRequest = function (formData, jqForm, options) {
+ $.blockUI({message:''});
+ $('#loading').attr('style', 'display:block;');
+}
+
+// post-submit callback
+wizard.prototype.showResponse = function (responseText, statusText) {
+ $.unblockUI();
+ $('#loading').attr('style', 'display:none;');
+}
+
+wizard.prototype.refresh = function (page) {
+ var address = "index.php?step_name="+page;
+ var div = 'content_container';
+ $.ajax({
+ url: address,
+ dataType: "html",
+ type: "GET",
+ cache: false,
+ beforeSubmit: w.showRequest,
+ success: function(data){
+ $("#"+div).empty();
+ $("#"+div).append(data);
+ w.showResponse;
+ return;
+ }
+ });
+}
+
+wizard.prototype.getUrl = function (address, div) {
+ $("#"+div).empty();
+ $.ajax({
+ url: address,
+ dataType: "html",
+ type: "GET",
+ cache: false,
+ success: function(data){
+ $("#"+div).empty();
+ $("#"+div).append(data);
+ return;
+ }
+ });
+}
+
+wizard.prototype.sendJavaLocation = function () {
+ $('form').submit();
+}
+
+wizard.prototype.sendRegistration = function () {
+ $('form').submit();
+}
+
+wizard.prototype.clearSessions = function () {
+ var address = 'session.php?action=destroyInstall';
+ $.ajax({
+ url: address,
+ dataType: "html",
+ type: "POST",
+ cache: false,
+ });
}
\ No newline at end of file
diff --git a/setup/wizard/session.php b/setup/wizard/session.php
index 0147aa8..a1ebd39 100644
--- a/setup/wizard/session.php
+++ b/setup/wizard/session.php
@@ -1,223 +1,238 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-class Session
-{
- /**
- * 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['ready'])) {
- session_start();
- $_SESSION ['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 [$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 [ $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 [ $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 [ $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 [$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 [$class]))
- unset($_SESSION [$class]);
- }
-
- /**
- * Destroy the session
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function destroy() {
- $this->startSession();
- unset($_SESSION);
- 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 [$fld]))
- return $_SESSION [$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 [$fld]);
- }
-
- /**
- * Return a class from session
- *
- * @author KnowledgeTree Team
- * @param string $fld
- * @access public
- * @return string
- */
- public function getClass($class) {
- return $_SESSION[$class];
- }
-}
+.
+*
+* 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 Migrater
+* @version Version 0.1
+*/
+class Session
+{
+ private $salt = 'install';
+ /**
+ * 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];
+ }
+
+ public function destroyInstall() {
+ $_SESSION[$this->salt] = '';
+ $this->destroy();
+ }
+}
+
+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 64659a5..d8b5bf4 100644
--- a/setup/wizard/step.php
+++ b/setup/wizard/step.php
@@ -1,402 +1,404 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-class Step
-{
- /**
- * List of variables to be loaded to template
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $temp_variables = array();
-
- /**
- * List of errors encountered by step
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $error = array();
-
- /**
- * List of warnings encountered by step
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $warnings = array();
-
- /**
- * Flag to store class information in session
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $storeInSession = false;
-
- /**
- * Flag if step needs to be installed
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $runInstall = false;
-
- /**
- * Step order
- *
- * @author KnowledgeTree Team
- * @access public
- * @var string
- */
- protected $order = false;
-
- /**
- * Flag if step needs to run silently
- *
- * @author KnowledgeTree Team
- * @access public
- * @var boolean
- */
- protected $silent = false;
-
- public $displayFirst = false;
- /**
- * Returns step state
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return string
- */
- public function doStep()
- {
- return '';
- }
-
- public function displayFirst() {
- return $this->displayFirst;
- }
-
- /**
- * Returns step variables
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getStepVars()
- {
- return $this->temp_variables;
- }
-
- /**
- * Returns step errors
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getErrors() {
- return $this->error;
- }
-
- /**
- * Returns step errors
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- 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
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function edit() {
- if(isset($_POST['Edit'])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if next button has been clicked
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function next() {
- if(isset($_POST['Next'])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if previous button has been clicked
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function previous() {
- if(isset($_POST['Previous'])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if Confirm button has been clicked
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- function confirm() {
- if(isset($_POST['Confirm'])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if Confirm button has been clicked
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- function install() {
- if(isset($_POST['Install'])) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks if we are currently in this class step
- *
- * @author KnowledgeTree Team
- * @param string
- * @access public
- * @return boolean
- */
- public function inStep($name) {
- if($_GET['step_name'] == $name)
- return true;
- return false;
- }
-
- /**
- * Load session data to post
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return boolean
- */
- public function setDataFromSession($class) {
- if(empty($_SESSION[$class])) {
- return false;
- }
- $_POST = $_SESSION[$class];
-
- return true;
- }
-
- /**
- * Get session data from post
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return boolean
- */
- public function getDataFromSession($class) {
- if(empty($_SESSION[$class])) {
- return false;
- }
-
- return $_SESSION[$class];
- }
-
- /**
- * Safer way to return post data
- *
- * @author KnowledgeTree Team
- * @params SimpleXmlObject $simplexml
- * @access public
- * @return void
- */
- public function getPostSafe($key) {
- return isset($_POST[$key]) ? $_POST[$key] : "";
- }
-
- /**
- * Safer way to return post data
- *
- * @author KnowledgeTree Team
- * @params SimpleXmlObject $simplexml
- * @access public
- * @return void
- */
- public function getPostBoolean($key) {
- return isset($_POST[$key]) ? $_POST[$key] : false;
- }
-
- /**
- * Runs step install if required
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function installStep() {
- return '';
- }
-
- /**
- * Return whether or not to store a step information in session
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function storeInSession() {
- return $this->storeInSession;
- }
-
- /**
- * Return whether or not to a step has to be installed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function runInstall() {
- return $this->runInstall;
- }
-
- public function setPostConfig() {
- return '';
- }
-
- /**
- * Return whether or not to a step has to be in silent mode
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function silentMode() {
- return $this->silent;
- }
-
- /**
- * Set step errors
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function setErrors($error) {
- $this->error = $error;
- }
-}
-
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+class Step
+{
+ /**
+ * List of variables to be loaded to template
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array
+ */
+ protected $temp_variables = array();
+
+ /**
+ * List of errors encountered by step
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array
+ */
+ protected $error = array();
+
+ /**
+ * List of warnings encountered by step
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array
+ */
+ protected $warnings = array();
+
+ /**
+ * Flag to store class information in session
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $storeInSession = false;
+
+ /**
+ * Flag if step needs to be installed
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $runInstall = false;
+
+ /**
+ * Step order
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var string
+ */
+ protected $order = false;
+
+ /**
+ * Flag if step needs to run silently
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var boolean
+ */
+ protected $silent = false;
+
+ public $displayFirst = false;
+
+ private $salt = 'install';
+ /**
+ * Returns step state
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return string
+ */
+ public function doStep()
+ {
+ return '';
+ }
+
+ public function displayFirst() {
+ return $this->displayFirst;
+ }
+
+ /**
+ * Returns step variables
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function getStepVars()
+ {
+ return $this->temp_variables;
+ }
+
+ /**
+ * Returns step errors
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function getErrors() {
+ return $this->error;
+ }
+
+ /**
+ * Returns step errors
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ 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
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function edit() {
+ if(isset($_POST['Edit'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if next button has been clicked
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function next() {
+ if(isset($_POST['Next'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if previous button has been clicked
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function previous() {
+ if(isset($_POST['Previous'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if Confirm button has been clicked
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ function confirm() {
+ if(isset($_POST['Confirm'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if Confirm button has been clicked
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ function install() {
+ if(isset($_POST['Install'])) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if we are currently in this class step
+ *
+ * @author KnowledgeTree Team
+ * @param string
+ * @access public
+ * @return boolean
+ */
+ public function inStep($name) {
+ if($_GET['step_name'] == $name)
+ return true;
+ return false;
+ }
+
+ /**
+ * Load session data to post
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return boolean
+ */
+ public function setDataFromSession($class) {
+ if(empty($_SESSION[$this->salt][$class])) {
+ return false;
+ }
+ $_POST = $_SESSION[$this->salt][$class];
+
+ return true;
+ }
+
+ /**
+ * Get session data from post
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return boolean
+ */
+ public function getDataFromSession($class) {
+ if(empty($_SESSION[$this->salt][$class])) {
+ return false;
+ }
+
+ return $_SESSION[$this->salt][$class];
+ }
+
+ /**
+ * Safer way to return post data
+ *
+ * @author KnowledgeTree Team
+ * @params SimpleXmlObject $simplexml
+ * @access public
+ * @return void
+ */
+ public function getPostSafe($key) {
+ return isset($_POST[$key]) ? $_POST[$key] : "";
+ }
+
+ /**
+ * Safer way to return post data
+ *
+ * @author KnowledgeTree Team
+ * @params SimpleXmlObject $simplexml
+ * @access public
+ * @return void
+ */
+ public function getPostBoolean($key) {
+ return isset($_POST[$key]) ? $_POST[$key] : false;
+ }
+
+ /**
+ * Runs step install if required
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return void
+ */
+ public function installStep() {
+ return '';
+ }
+
+ /**
+ * Return whether or not to store a step information in session
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function storeInSession() {
+ return $this->storeInSession;
+ }
+
+ /**
+ * Return whether or not to a step has to be installed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function runInstall() {
+ return $this->runInstall;
+ }
+
+ public function setPostConfig() {
+ return '';
+ }
+
+ /**
+ * Return whether or not to a step has to be in silent mode
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function silentMode() {
+ return $this->silent;
+ }
+
+ /**
+ * Set step errors
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function setErrors($error) {
+ $this->error = $error;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php
index 7f11b25..c4f3306 100644
--- a/setup/wizard/steps/database.php
+++ b/setup/wizard/steps/database.php
@@ -1,829 +1,831 @@
-.
-*
-* 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 Installer
-* @version Version 0.1
-*/
-
-class database extends Step
-{
- /**
- * Reference to Database object
- *
- * @author KnowledgeTree Team
- * @access public
- * @var object
- */
- public $_dbhandler = null;
-
- /**
- * Reference to Database object
- *
- * @author KnowledgeTree Team
- * @access public
- * @var object
- */
- public $_util = null;
-
- /**
- * Database type
- *
- * @author KnowledgeTree Team
- * @access private
- * @var array
- */
- private $dtype = '';
-
- /**
- * Database types
- *
- * @author KnowledgeTree Team
- * @access private
- * @var array
- */
- private $dtypes = array();
-
- /**
- * Database host
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dhost = '';
-
- /**
- * Database port
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dport = '';
-
- /**
- * Database name
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dname = '';
-
- /**
- * Database root username
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $duname = '';
-
- /**
- * Database root password
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dpassword = '';
-
- /**
- * Database dms username
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dmsname = '';
-
- /**
- * Database dms password
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dmspassword = '';
-
- /**
- * Default dms user username
- *
- * @author KnowledgeTree Team
- * @access private
- * @var boolean
- */
- private $dmsusername = '';
-
- /**
- * Default dms user password
- *
- * @author KnowledgeTree Team
- * @access private
- * @var boolean
- */
- private $dmsuserpassword = '';
-
- /**
- * Location of database binaries.
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $mysqlDir; // TODO:multiple databases
-
- /**
- * Name of database binary.
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $dbbinary = ''; // TODO:multiple databases
-
- /**
- * Database table prefix
- *
- * @author KnowledgeTree Team
- * @access private
- * @var string
- */
- private $tprefix = '';
-
- /**
- * Flag to drop database
- *
- * @author KnowledgeTree Team
- * @access private
- * @var boolean
- */
- private $ddrop = false;
-
- /**
- * List of errors encountered
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- public $error = array();
-
- /**
- * List of errors used in template
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');
-
- /**
- * Flag to store class information in session
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- public $storeInSession = true;
-
- /**
- * Flag if step needs to be installed
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $runInstall = true;
-
- /**
- * Flag if step needs to run silently
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $silent = true;
-
- /**
- * Constructs database object
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- */
- public function __construct() {
- $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent);
- $this->_dbhandler = new dbUtil();
- $this->_util = new InstallUtil();
- if(WINDOWS_OS)
- $this->mysqlDir = MYSQL_BIN;
- }
-
- /**
- * Main control of database setup
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return string
- */
- public function doStep() {
- $this->setErrorsFromSession();
- $this->initErrors(); // Load template errors
- if($this->inStep("database")) {
- $res = $this->doProcess();
- if($res) { // If theres a response, return it
- return $res;
- }
- }
- if($this->setDataFromSession("database")) { // Attempt to set values from session
- $this->setDetails(); // Set any posted variables
- } else {
- $this->temp_variables['state'] = '';
- $this->loadDefaults($this->readXml()); // Load default variables from file
- }
-
- return 'landing';
- }
-
- /**
- * Controls setup helper
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return string
- */
- public function doProcess() {
- if($this->next()) {
- $this->setPostConfig(); // Set any posted variables
- $this->setDetails();
- if($this->doTest()) { // Test
- return 'confirm';
- } else {
- return 'error';
- }
- } else if($this->previous()) {
- return 'previous';
- } else if($this->confirm()) {
- $this->setDataFromSession("database"); // Set Session Information
- $this->setPostConfig(); // Set any posted variables
- return 'next';
- } else if($this->edit()) {
- $this->setDataFromSession("database"); // Set Session Information, since its an edit
- $this->temp_variables['state'] = 'edit';
-
- return 'landing';
- }
- }
-
- /**
- * Test database connectivity
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function doTest() {
- if($this->match($this->dmspassword, $this->getPassword1()) != 0) {
- $this->error['dmspassword'] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();
- return false;
- }
- if($this->match($this->dmsuserpassword, $this->getPassword2()) != 0) {
- $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
- return false;
- }
- if($this->dport == '') {
- $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
- } else {
- $con = $this->_dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
- }
- if (!$con) {
- $this->error['con'] = "Could not connect to the database, please check username and password";
- return false;
- } else {
- if ($this->dbExists()) { // Check if database Exists
- $this->error['dname'] = 'Database Already Exists, please specify a different name'; // Reset usage errors
- return false;
- } else {
- $this->error = array(); // Reset usage errors
- return true;
- }
- }
- }
-
- public function dbExists() {
- return $this->_dbhandler->useDb();
- }
-
- public function match($str1, $str2) {
- return strcmp($str1, $str2);
- }
-
- public function getPassword1() {
- return $_POST['dmspassword2'];
- }
-
- public function getPassword2() {
- return $_POST['dmsuserpassword2'];
- }
- /**
- * Check if theres a database type
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return boolean database type or false
- */
- private function getType() {
- if(isset($_POST['dtype'])) {
- return $_POST['dtype'];
- }
-
- return false;
- }
-
- /**
- * Set Errors if any were encountered
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return boolean
- */
- private function setErrorsFromSession() {
- if(isset($_SESSION['database']['errors'])) {
- $this->error[] = $_SESSION['database']['errors'];
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Set POST information
- *
- * @author KnowledgeTree Team
- * @params none
- * @access public
- * @return void
- */
- public function setPostConfig() {
- $this->dtype = $this->getPostSafe("dtype");
- $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases
- $this->dhost = $this->getPostSafe("dhost");
- $this->dport = $this->getPostSafe("dport");
- $this->dname = $this->getPostSafe("dname");
- $this->duname = $this->getPostSafe("duname");
- $this->dpassword = $this->getPostSafe("dpassword");
- $this->dmsname = $this->getPostSafe("dmsname");
- $this->dmsusername = $this->getPostSafe("dmsusername");
- $this->dmspassword = $this->getPostSafe("dmspassword");
- $this->dmsuserpassword = $this->getPostSafe("dmsuserpassword");
- $this->dbbinary = $this->getPostSafe("dbbinary");
- $this->tprefix = $this->getPostSafe("tprefix");
- $this->ddrop = $this->getPostBoolean("ddrop");
- }
-
- /**
- * Load default options on template from xml file
- *
- * @author KnowledgeTree Team
- * @params object SimpleXmlObject
- * @access public
- * @return void
- */
- public function loadDefaults($simplexml) {
- if($simplexml) {
- $this->temp_variables['dtype'] = "";
- $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases
- $this->temp_variables['dname'] = (string) $simplexml->dname;
- $this->temp_variables['duname'] = (string) $simplexml->duname;
- $this->temp_variables['dhost'] = (string) $simplexml->dhost;
- $this->temp_variables['dport'] = (string) $simplexml->dport;
- $this->temp_variables['dpassword'] = '';
- $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;
- $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser;
- $this->temp_variables['dmspassword'] = (string) $simplexml->dmsaupass;
- $this->temp_variables['dmsuserpassword'] = (string) $simplexml->dmsupass;
- if(WINDOWS_OS) {
- $this->temp_variables['dbbinary'] = 'mysql.exe';
- } else {
- $this->temp_variables['dbbinary'] = 'mysql';
- }
- $this->temp_variables['tprefix'] = '';
- $this->temp_variables['ddrop'] = false;
- }
- }
-
- /**
- * Store options
- *
- * @author KnowledgeTree Team
- * @params object SimpleXmlObject
- * @access private
- * @return void
- */
- private function setDetails() {
- if($this->edit()) {
- $this->temp_variables['state'] = 'edit';
- } else {
- $this->temp_variables['state'] = '';
- }
- $this->temp_variables['dtype'] = $this->getPostSafe('dtype');
- $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;
- $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
- $this->temp_variables['dport'] = $this->getPostSafe('dport');
- $this->temp_variables['dname'] = $this->getPostSafe('dname');
- $this->temp_variables['duname'] = $this->getPostSafe('duname');
- $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');
- $this->temp_variables['dmsname'] = $this->getPostSafe('dmsname');
- $this->temp_variables['dmsusername'] = $this->getPostSafe('dmsusername');
- $this->temp_variables['dmspassword'] = $this->getPostSafe('dmspassword');
- $this->temp_variables['dmsuserpassword'] = $this->getPostSafe('dmsuserpassword');;
- $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary');
- $this->temp_variables['tprefix'] = $this->getPostSafe('tprefix');
- $this->temp_variables['ddrop'] = $this->getPostBoolean('ddrop');
- }
-
- /**
- * Extract database types
- *
- * @author KnowledgeTree Team
- * @access private
- * @params object SimpleXmlObject
- * @return array
- */
- private function getTypes($xmlTypes) {
- $t = array();
- foreach ($xmlTypes->dtype as $key=>$val) {
- $t[] = (string) $val;
- }
- return $t;
- }
-
- /**
- * Read xml config file
- *
- * @author KnowledgeTree Team
- * @access private
- * @params none
- * @return object SimpleXmlObject
- */
- private function readXml() {
- $simplexml = simplexml_load_file(CONF_DIR."databases.xml");
-
- return $simplexml;
- }
-
- /**
- * Stores varibles used by template
- *
- * @author KnowledgeTree Team
- * @params none
- * @access public
- * @return array
- */
- public function getStepVars() {
- return $this->temp_variables;
- }
-
- /**
- * Runs step install if required
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function installStep() {
- return $this->installDatabase();
- }
-
- /**
- * Helper
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return void
- */
- private function installDatabase() {
- if($this->dtype == '') {
- $this->error['dtype'] = 'No database type selected';
- return 'error';
- }
- if(!$this->{$this->dtype}()) {
- return 'error';
- }
- }
-
- /**
- * Helper
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return void
- */
- private function mysql() {
- $con = $this->connectMysql();
- if($con) {
- if(!$this->createDB($con)) {
- $this->error['con'] = "Could not Create Database: ";
- return false;
- }
- $this->closeMysql($con);
- }
- }
-
- /**
- * Connect to mysql
- *
- * @author KnowledgeTree Team
- * @params none
- * @access private
- * @return object mysql connection
- */
- private function connectMysql() {
- $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
- if (!$con) {
- $this->error['con'] = "Could not connect: ";
-
- return false;
- }
-
- return $con;
- }
-
- /**
- * Helper
- *
- * @author KnowledgeTree Team
- * @params object mysql connection object $con
- * @access private
- * @return object mysql connection
- */
- private function createDB($con) {
- if($this->usedb($con)) { // attempt to use the db
- if($this->dropdb($con)) { // attempt to drop the db
- if(!$this->create($con)) { // attempt to create the db
- $this->error['con'] = "Could not create database: ";
- return false;// cannot overwrite database
- }
- } else {
- $this->error['con'] = "Could not drop database: ";
- return false;// cannot overwrite database
- }
- } else {
- if(!$this->create($con)) { // attempt to create the db
- $this->error['con'] = "Could not create database: ";
- return false;// cannot overwrite database
- }
- }
- if(!$this->createDmsUser($con)) {
-
- }
- if(!$this->createSchema($con)) {
- $this->error['con'] = "Could not create schema ";
- }
- if(!$this->populateSchema($con)) {
- $this->error['con'] = "Could not populate schema ";
- }
- if(!$this->applyUpgrades($con)) {
- $this->error['con'] = "Could not apply updates ";
- }
-
- return true;
- }
-
- /**
- * Create database
- *
- * @author KnowledgeTree Team
- * @params object mysql connection object $con
- * @access private
- * @return boolean
- */
- private function create($con) {
- $sql = "CREATE DATABASE {$this->dname}";
- if ($this->_dbhandler->query($sql, $con)) {
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Attempts to use a db
- *
- * @author KnowledgeTree Team
- * @params mysql connection object $con
- * @access private
- * @return boolean
- */
- private function usedb($con) {
- if($this->_dbhandler->useDb($this->dname)) {
- return true;
- } else {
- $this->error['con'] = "Error using database: {$this->dname}";
- return false;
- }
- }
-
- /**
- * Attempts to drop table
- *
- * @author KnowledgeTree Team
- * @access private
- * @params mysql connection object $con
- * @return boolean
- */
- private function dropdb($con) {
- if($this->ddrop) {
- $sql = "DROP DATABASE {$this->dname};";
- if(!$this->_dbhandler->query($sql)) {
- $this->error['con'] = "Cannot drop database: {$this->dname}";
- return false;
- }
- } else {
- $this->error['con'] = "Cannot drop database: {$this->dname}";
- return false;
- }
- return true;
- }
-
- /**
- * Create dms user
- *
- * @author KnowledgeTree Team
- * @access private
- * @params none
- * @return boolean
- */
- private function createDmsUser($con) {
- if($this->dmsname == '' || $this->dmspassword == '') {
- if($this->dpassword == '') {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."user.sql\"";
- } else {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."user.sql\"";
- }
- $response = $this->_util->pexec($command);
- return $response;
- } else {
- $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
- *
- * @author KnowledgeTree Team
- * @access private
- * @params none
- * @return boolean
- */
- private function createSchema($con) {
- if($this->dpassword == '') {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."structure.sql\"";
- } else {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."structure.sql\"";
- }
- $response = $this->_util->pexec($command);
- return $response;
- }
-
- /**
- * Populate database
- *
- * @author KnowledgeTree Team
- * @access private
- * @params none
- * @return boolean
- */
- private function populateSchema($con) {
- if($this->dpassword == '') {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."data.sql\"";
- } else {
- $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."data.sql\"";
- }
- $response = $this->_util->pexec($command);
- return $response;
- }
-
- /**
- * Ammend any known database upgrades
- *
- * @author KnowledgeTree Team
- * @access private
- * @params none
- * @return boolean
- */
- private function applyUpgrades($con) {
- // Database upgrade to version 3.6.1: Search ranking
- return true;
- }
-
- /**
- * Close connection if it exists
- *
- * @author KnowledgeTree Team
- * @access private
- * @params mysql connection object $con
- * @return void
- */
- private function closeMysql($con) {
- try {
- $this->_dbhandler->close();
- } catch (Exeption $e) {
- $this->error['con'] = "Could not close: " . $e;
- }
- }
-
- /**
- * Returns database errors
- *
- * @author KnowledgeTree Team
- * @access public
- * @params none
- * @return array
- */
- public function getErrors() {
-
- 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
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function initErrors() {
- foreach ($this->templateErrors as $e) {
- $this->error[$e] = false;
- }
- }
-}
+.
+*
+* 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 Installer
+* @version Version 0.1
+*/
+
+class database extends Step
+{
+ /**
+ * Reference to Database object
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var object
+ */
+ public $_dbhandler = null;
+
+ /**
+ * Reference to Database object
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var object
+ */
+ public $_util = null;
+
+ /**
+ * Database type
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var array
+ */
+ private $dtype = '';
+
+ /**
+ * Database types
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var array
+ */
+ private $dtypes = array();
+
+ /**
+ * Database host
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dhost = '';
+
+ /**
+ * Database port
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dport = '';
+
+ /**
+ * Database name
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dname = '';
+
+ /**
+ * Database root username
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $duname = '';
+
+ /**
+ * Database root password
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dpassword = '';
+
+ /**
+ * Database dms username
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dmsname = '';
+
+ /**
+ * Database dms password
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dmspassword = '';
+
+ /**
+ * Default dms user username
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var boolean
+ */
+ private $dmsusername = '';
+
+ /**
+ * Default dms user password
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var boolean
+ */
+ private $dmsuserpassword = '';
+
+ /**
+ * Location of database binaries.
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $mysqlDir; // TODO:multiple databases
+
+ /**
+ * Name of database binary.
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $dbbinary = ''; // TODO:multiple databases
+
+ /**
+ * Database table prefix
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var string
+ */
+ private $tprefix = '';
+
+ /**
+ * Flag to drop database
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var boolean
+ */
+ private $ddrop = false;
+
+ /**
+ * List of errors encountered
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ public $error = array();
+
+ /**
+ * List of errors used in template
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');
+
+ /**
+ * Flag to store class information in session
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ public $storeInSession = true;
+
+ /**
+ * Flag if step needs to be installed
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $runInstall = true;
+
+ /**
+ * Flag if step needs to run silently
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $silent = true;
+
+ private $salt = 'install';
+
+ /**
+ * Constructs database object
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ */
+ public function __construct() {
+ $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent);
+ $this->_dbhandler = new dbUtil();
+ $this->_util = new InstallUtil();
+ if(WINDOWS_OS)
+ $this->mysqlDir = MYSQL_BIN;
+ }
+
+ /**
+ * Main control of database setup
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return string
+ */
+ public function doStep() {
+ $this->setErrorsFromSession();
+ $this->initErrors(); // Load template errors
+ if($this->inStep("database")) {
+ $res = $this->doProcess();
+ if($res) { // If theres a response, return it
+ return $res;
+ }
+ }
+ if($this->setDataFromSession("database")) { // Attempt to set values from session
+ $this->setDetails(); // Set any posted variables
+ } else {
+ $this->temp_variables['state'] = '';
+ $this->loadDefaults($this->readXml()); // Load default variables from file
+ }
+
+ return 'landing';
+ }
+
+ /**
+ * Controls setup helper
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return string
+ */
+ public function doProcess() {
+ if($this->next()) {
+ $this->setPostConfig(); // Set any posted variables
+ $this->setDetails();
+ if($this->doTest()) { // Test
+ return 'confirm';
+ } else {
+ return 'error';
+ }
+ } else if($this->previous()) {
+ return 'previous';
+ } else if($this->confirm()) {
+ $this->setDataFromSession("database"); // Set Session Information
+ $this->setPostConfig(); // Set any posted variables
+ return 'next';
+ } else if($this->edit()) {
+ $this->setDataFromSession("database"); // Set Session Information, since its an edit
+ $this->temp_variables['state'] = 'edit';
+
+ return 'landing';
+ }
+ }
+
+ /**
+ * Test database connectivity
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function doTest() {
+ if($this->match($this->dmspassword, $this->getPassword1()) != 0) {
+ $this->error['dmspassword'] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();
+ return false;
+ }
+ if($this->match($this->dmsuserpassword, $this->getPassword2()) != 0) {
+ $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
+ return false;
+ }
+ if($this->dport == '') {
+ $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
+ } else {
+ $con = $this->_dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
+ }
+ if (!$con) {
+ $this->error['con'] = "Could not connect to the database, please check username and password";
+ return false;
+ } else {
+ if ($this->dbExists()) { // Check if database Exists
+ $this->error['dname'] = 'Database Already Exists, please specify a different name'; // Reset usage errors
+ return false;
+ } else {
+ $this->error = array(); // Reset usage errors
+ return true;
+ }
+ }
+ }
+
+ public function dbExists() {
+ return $this->_dbhandler->useDb();
+ }
+
+ public function match($str1, $str2) {
+ return strcmp($str1, $str2);
+ }
+
+ public function getPassword1() {
+ return $_POST['dmspassword2'];
+ }
+
+ public function getPassword2() {
+ return $_POST['dmsuserpassword2'];
+ }
+ /**
+ * Check if theres a database type
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return boolean database type or false
+ */
+ private function getType() {
+ if(isset($_POST['dtype'])) {
+ return $_POST['dtype'];
+ }
+
+ return false;
+ }
+
+ /**
+ * Set Errors if any were encountered
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return boolean
+ */
+ private function setErrorsFromSession() {
+ if(isset($_SESSION[$this->salt]['database']['errors'])) {
+ $this->error[] = $_SESSION[$this->salt]['database']['errors'];
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Set POST information
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access public
+ * @return void
+ */
+ public function setPostConfig() {
+ $this->dtype = $this->getPostSafe("dtype");
+ $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases
+ $this->dhost = $this->getPostSafe("dhost");
+ $this->dport = $this->getPostSafe("dport");
+ $this->dname = $this->getPostSafe("dname");
+ $this->duname = $this->getPostSafe("duname");
+ $this->dpassword = $this->getPostSafe("dpassword");
+ $this->dmsname = $this->getPostSafe("dmsname");
+ $this->dmsusername = $this->getPostSafe("dmsusername");
+ $this->dmspassword = $this->getPostSafe("dmspassword");
+ $this->dmsuserpassword = $this->getPostSafe("dmsuserpassword");
+ $this->dbbinary = $this->getPostSafe("dbbinary");
+ $this->tprefix = $this->getPostSafe("tprefix");
+ $this->ddrop = $this->getPostBoolean("ddrop");
+ }
+
+ /**
+ * Load default options on template from xml file
+ *
+ * @author KnowledgeTree Team
+ * @params object SimpleXmlObject
+ * @access public
+ * @return void
+ */
+ public function loadDefaults($simplexml) {
+ if($simplexml) {
+ $this->temp_variables['dtype'] = "";
+ $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases
+ $this->temp_variables['dname'] = (string) $simplexml->dname;
+ $this->temp_variables['duname'] = (string) $simplexml->duname;
+ $this->temp_variables['dhost'] = (string) $simplexml->dhost;
+ $this->temp_variables['dport'] = (string) $simplexml->dport;
+ $this->temp_variables['dpassword'] = '';
+ $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;
+ $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser;
+ $this->temp_variables['dmspassword'] = (string) $simplexml->dmsaupass;
+ $this->temp_variables['dmsuserpassword'] = (string) $simplexml->dmsupass;
+ if(WINDOWS_OS) {
+ $this->temp_variables['dbbinary'] = 'mysql.exe';
+ } else {
+ $this->temp_variables['dbbinary'] = 'mysql';
+ }
+ $this->temp_variables['tprefix'] = '';
+ $this->temp_variables['ddrop'] = false;
+ }
+ }
+
+ /**
+ * Store options
+ *
+ * @author KnowledgeTree Team
+ * @params object SimpleXmlObject
+ * @access private
+ * @return void
+ */
+ private function setDetails() {
+ if($this->edit()) {
+ $this->temp_variables['state'] = 'edit';
+ } else {
+ $this->temp_variables['state'] = '';
+ }
+ $this->temp_variables['dtype'] = $this->getPostSafe('dtype');
+ $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;
+ $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
+ $this->temp_variables['dport'] = $this->getPostSafe('dport');
+ $this->temp_variables['dname'] = $this->getPostSafe('dname');
+ $this->temp_variables['duname'] = $this->getPostSafe('duname');
+ $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');
+ $this->temp_variables['dmsname'] = $this->getPostSafe('dmsname');
+ $this->temp_variables['dmsusername'] = $this->getPostSafe('dmsusername');
+ $this->temp_variables['dmspassword'] = $this->getPostSafe('dmspassword');
+ $this->temp_variables['dmsuserpassword'] = $this->getPostSafe('dmsuserpassword');;
+ $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary');
+ $this->temp_variables['tprefix'] = $this->getPostSafe('tprefix');
+ $this->temp_variables['ddrop'] = $this->getPostBoolean('ddrop');
+ }
+
+ /**
+ * Extract database types
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params object SimpleXmlObject
+ * @return array
+ */
+ private function getTypes($xmlTypes) {
+ $t = array();
+ foreach ($xmlTypes->dtype as $key=>$val) {
+ $t[] = (string) $val;
+ }
+ return $t;
+ }
+
+ /**
+ * Read xml config file
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params none
+ * @return object SimpleXmlObject
+ */
+ private function readXml() {
+ $simplexml = simplexml_load_file(CONF_DIR."databases.xml");
+
+ return $simplexml;
+ }
+
+ /**
+ * Stores varibles used by template
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access public
+ * @return array
+ */
+ public function getStepVars() {
+ return $this->temp_variables;
+ }
+
+ /**
+ * Runs step install if required
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return void
+ */
+ public function installStep() {
+ return $this->installDatabase();
+ }
+
+ /**
+ * Helper
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return void
+ */
+ private function installDatabase() {
+ if($this->dtype == '') {
+ $this->error['dtype'] = 'No database type selected';
+ return 'error';
+ }
+ if(!$this->{$this->dtype}()) {
+ return 'error';
+ }
+ }
+
+ /**
+ * Helper
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return void
+ */
+ private function mysql() {
+ $con = $this->connectMysql();
+ if($con) {
+ if(!$this->createDB($con)) {
+ $this->error['con'] = "Could not Create Database: ";
+ return false;
+ }
+ $this->closeMysql($con);
+ }
+ }
+
+ /**
+ * Connect to mysql
+ *
+ * @author KnowledgeTree Team
+ * @params none
+ * @access private
+ * @return object mysql connection
+ */
+ private function connectMysql() {
+ $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
+ if (!$con) {
+ $this->error['con'] = "Could not connect: ";
+
+ return false;
+ }
+
+ return $con;
+ }
+
+ /**
+ * Helper
+ *
+ * @author KnowledgeTree Team
+ * @params object mysql connection object $con
+ * @access private
+ * @return object mysql connection
+ */
+ private function createDB($con) {
+ if($this->usedb($con)) { // attempt to use the db
+ if($this->dropdb($con)) { // attempt to drop the db
+ if(!$this->create($con)) { // attempt to create the db
+ $this->error['con'] = "Could not create database: ";
+ return false;// cannot overwrite database
+ }
+ } else {
+ $this->error['con'] = "Could not drop database: ";
+ return false;// cannot overwrite database
+ }
+ } else {
+ if(!$this->create($con)) { // attempt to create the db
+ $this->error['con'] = "Could not create database: ";
+ return false;// cannot overwrite database
+ }
+ }
+ if(!$this->createDmsUser($con)) {
+
+ }
+ if(!$this->createSchema($con)) {
+ $this->error['con'] = "Could not create schema ";
+ }
+ if(!$this->populateSchema($con)) {
+ $this->error['con'] = "Could not populate schema ";
+ }
+ if(!$this->applyUpgrades($con)) {
+ $this->error['con'] = "Could not apply updates ";
+ }
+
+ return true;
+ }
+
+ /**
+ * Create database
+ *
+ * @author KnowledgeTree Team
+ * @params object mysql connection object $con
+ * @access private
+ * @return boolean
+ */
+ private function create($con) {
+ $sql = "CREATE DATABASE {$this->dname}";
+ if ($this->_dbhandler->query($sql, $con)) {
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Attempts to use a db
+ *
+ * @author KnowledgeTree Team
+ * @params mysql connection object $con
+ * @access private
+ * @return boolean
+ */
+ private function usedb($con) {
+ if($this->_dbhandler->useDb($this->dname)) {
+ return true;
+ } else {
+ $this->error['con'] = "Error using database: {$this->dname}";
+ return false;
+ }
+ }
+
+ /**
+ * Attempts to drop table
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params mysql connection object $con
+ * @return boolean
+ */
+ private function dropdb($con) {
+ if($this->ddrop) {
+ $sql = "DROP DATABASE {$this->dname};";
+ if(!$this->_dbhandler->query($sql)) {
+ $this->error['con'] = "Cannot drop database: {$this->dname}";
+ return false;
+ }
+ } else {
+ $this->error['con'] = "Cannot drop database: {$this->dname}";
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Create dms user
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params none
+ * @return boolean
+ */
+ private function createDmsUser($con) {
+ if($this->dmsname == '' || $this->dmspassword == '') {
+ if($this->dpassword == '') {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."user.sql\"";
+ } else {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."user.sql\"";
+ }
+ $response = $this->_util->pexec($command);
+ return $response;
+ } else {
+ $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
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params none
+ * @return boolean
+ */
+ private function createSchema($con) {
+ if($this->dpassword == '') {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."structure.sql\"";
+ } else {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."structure.sql\"";
+ }
+ $response = $this->_util->pexec($command);
+ return $response;
+ }
+
+ /**
+ * Populate database
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params none
+ * @return boolean
+ */
+ private function populateSchema($con) {
+ if($this->dpassword == '') {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."data.sql\"";
+ } else {
+ $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."data.sql\"";
+ }
+ $response = $this->_util->pexec($command);
+ return $response;
+ }
+
+ /**
+ * Ammend any known database upgrades
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params none
+ * @return boolean
+ */
+ private function applyUpgrades($con) {
+ // Database upgrade to version 3.6.1: Search ranking
+ return true;
+ }
+
+ /**
+ * Close connection if it exists
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @params mysql connection object $con
+ * @return void
+ */
+ private function closeMysql($con) {
+ try {
+ $this->_dbhandler->close();
+ } catch (Exeption $e) {
+ $this->error['con'] = "Could not close: " . $e;
+ }
+ }
+
+ /**
+ * Returns database errors
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @params none
+ * @return array
+ */
+ public function getErrors() {
+
+ 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
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function initErrors() {
+ foreach ($this->templateErrors as $e) {
+ $this->error[$e] = false;
+ }
+ }
+}
?>
\ No newline at end of file
diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php
index c17adee..1d9cd3e 100644
--- a/setup/wizard/steps/services.php
+++ b/setup/wizard/steps/services.php
@@ -1,1184 +1,1190 @@
-.
-*
-* 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 Installer
-* @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");
- }
-}
-
-class services extends Step
-{
- /**
- * List of errors encountered
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $error = array();
-
- /**
- * Flag if step needs to be installed
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $runInstall = true;
-
- /**
- * List of services to be installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var array
- */
- private $services = array('Lucene', 'Scheduler', 'OpenOffice');
-
- /**
- * Path to php executable
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $php;
-
- /**
- * Flag if php already provided
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- public $providedPhp = false;
-
- /**
- * PHP Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $phpCheck = 'cross_orange';
-
- /**
- * Flag, if php is specified and an error has been encountered
- *
- * @author KnowledgeTree Team
- * @access public
- * @var boolean
- */
- private $phpExeError = false;
-
- /**
- * Holds path error, if php is specified
- *
- * @author KnowledgeTree Team
- * @access public
- * @var string
- */
- private $phpExeMessage = '';
-
- /**
- * Path to open office executable
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $soffice;
-
- /**
- * Flag if open office already provided
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- public $providedOpenOffice = false;
-
- /**
- * Flag, if open office is specified and an error has been encountered
- *
- * @author KnowledgeTree Team
- * @access public
- * @var boolean
- */
- private $openOfficeExeError = false;
-
- /**
- * Holds path error, if open office is specified
- *
- * @author KnowledgeTree Team
- * @access public
- * @var string
- */
- private $openOfficeExeMessage = '';
-
- /**
- * Path to java executable
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $java = "";
-
- /**
- * Minumum Java Version
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $javaVersion = '1.5';
-
- /**
- * Java Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $javaCheck = 'cross';
-
- /**
- * Open Office Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $openOfficeCheck = 'cross';
-
- /**
- * Flag if java already provided
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- public $providedJava = false;
-
- /**
- * Java Bridge Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $javaExtCheck = 'cross_orange';
-
- /**
- * Flag if bridge extension needs to be disabled
- *
- * @author KnowledgeTree Team
- * @access public
- * @var boolean
- */
- private $disableExtension = false;
-
- /**
- * Flag, if java is specified and an error has been encountered
- *
- * @author KnowledgeTree Team
- * @access public
- * @var booelean
- */
- private $javaExeError = false;
-
- /**
- * Holds path error, if java is specified
- *
- * @author KnowledgeTree Team
- * @access public
- * @var string
- */
- private $javaExeMessage = '';
-
- /**
- * Flag if services are already Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $alreadyInstalled = false;
-
- /**
- * Flag if services are already Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $luceneInstalled = false;
-
- /**
- * Flag if services are already Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var mixed
- */
- private $schedulerInstalled = false;
-
- /**
- * Path to php executable
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- private $openOfficeInstalled;
-
- /**
- * Service Installed
- *
- * @author KnowledgeTree Team
- * @access private
- * @var array
- */
- private $serviceCheck = 'tick';
-
- /**
- * Flag to store class information in session
- *
- * @author KnowledgeTree Team
- * @access public
- * @var boolean
- */
- protected $storeInSession = true;
-
- /**
- * List of variables to be loaded to template
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $temp_variables;
-
- /**
- * Flag if step needs to run silently
- *
- * @author KnowledgeTree Team
- * @access public
- * @var array
- */
- protected $silent = true;
-
- /**
- * Reference to utility object
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $util;
-
- /**
- * Constructs services object
- *
- * @author KnowledgeTree Team
- * @access public
- * @param none
- */
- public function __construct() {
- $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent);
- $this->util = new InstallUtil();
- }
-
- /**
- * Main control of services setup
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return string
- */
- public function doStep()
- {
- if(!$this->inStep("services")) {
- $this->doRun();
- return 'landing';
- }
- if($this->next()) {
- // Check dependencies
- $passed = $this->doRun();
- $serv = $this->getDataFromSession("services");
- if($passed || $serv['providedJava'])
- return 'next';
- else
- return 'error';
- } else if($this->previous()) {
- return 'previous';
- }
- $passed = $this->doRun();
- return 'landing';
- }
-
- /**
- * Get service names
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getServices() {
- return $this->services;
- }
-
- /**
- * Check if java executable was found
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return array
- */
- private function setJava() {
- if($this->java != '') { // Java JRE Found
- $this->javaCheck = 'tick';
- $this->javaInstalled();
- $this->temp_variables['java']['location'] = $this->java;
- }
- }
-
- /**
- * Run step
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function doRun() {
- if($this->alreadyInstalled()) {
- $this->alreadyInstalled = true;
- $this->serviceCheck = 'tick';
- } else {
- $this->presetJava();
- $this->presetOpenOffice();
- if(!$this->schedulerInstalled) {
- $this->php = $this->util->getPhp(); // Get java, if it exists
- $passedPhp = $this->phpChecks(); // Run Java Pre Checks
- if ($passedPhp) { // Install Scheduler
- $this->installService('Scheduler');
- }
- } else {
- $this->schedulerInstalled();
- }
- if(!$this->luceneInstalled) {
- $this->java = $this->util->getJava(); // Get java, if it exists
- $passedJava = $this->javaChecks(); // Run Java Pre Checks
- if ($passedJava) { // Install Lucene
- $this->installService('Lucene');
- }
- } else {
- $this->luceneInstalled();
- }
- if(!$this->openOfficeInstalled) {
- $this->soffice = $this->util->getOpenOffice(); // Get java, if it exists
- $passedOpenOffice = $this->openOfficeChecks(); // Run Java Pre Checks
- if ($passedOpenOffice) { //Install OpenOffice
-// $this->temp_variables['openOfficeExe'] = $this->soffice;
- // TODO : Why, O, why?
- $this->openOfficeExeError = false;
- $_SESSION['services']['openOfficeExe'] = $this->soffice;
- $this->installService('OpenOffice');
- }
- } else {
- $this->openOfficeInstalled();
- }
- }
- $this->checkServiceStatus();
- $this->storeSilent(); // Store info needed for silent mode
- if(!empty($errors))
- return false;
- return true;
- }
-
- private function openOfficeInstalled() {
-
- }
-
- private function schedulerInstalled() {
-
- }
-
- private function luceneInstalled() {
- $this->disableExtension = true; // Disable the use of the php bridge extension
- $this->javaVersionCorrect();
- $this->javaInstalled();
- $this->javaCheck = 'tick';
- }
-
- /**
- * A final check to see if services are still running,
- * incase they switched on and turned off.
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function checkServiceStatus() {
- $serverDetails = $this->getServices();
- foreach ($serverDetails as $serviceName) {
- $className = OS.$serviceName;
- $service = new $className();
- $service->load();
- $status = $this->serviceInstalled($service);
- if($status != 'STARTED') {
- $msg = $service->getName()." Could not be added as a Service";
- $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$msg);
- $this->serviceCheck = 'cross_orange';
- $this->warnings[] = $msg;
- } else {
- if(WINDOWS_OS) {
- $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); }
- else {
- $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added and Started as a Service");
- }
- }
- }
- }
-
- /**
- * Checks if all services have been started already,
- * incase the user lands on service page multiple times
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function alreadyInstalled() {
- $allInstalled = true;
- $serverDetails = $this->getServices();
- foreach ($serverDetails as $serviceName) {
- $className = OS.$serviceName;
- $service = new $className();
- $status = $this->serviceInstalled($service);
- $flag = strtolower(substr($serviceName,0,1)).substr($serviceName,1)."Installed";
- if(!$status) {
- $allInstalled = false;
- $this->$flag = false;
- } else {
- $this->$flag = true;
- }
- }
-
- return $allInstalled;
- }
-
- private function presetJava() {
- $this->zendBridgeNotInstalled(); // Set bridge not installed
- $this->javaVersionInCorrect(); // Set version to incorrect
- $this->javaNotInstalled(); // Set java to not installed
- $this->setJava(); // Check if java has been auto detected
- }
-
- private function presetOpenOffice() {
- $this->specifyOpenOffice();
- }
-
- private function setOpenOffice() {
-
- }
- /**
- * Do some basic checks to help the user overcome java problems
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function javaChecks() {
- if($this->util->javaSpecified()) {
- $this->disableExtension = true; // Disable the use of the php bridge extension
- if($this->detSettings(true)) { // AutoDetect java settings
- return true;
- } else {
- $this->specifyJava(); // Ask for settings
- }
- } else {
- $auto = $this->useBridge(); // Use Bridge to get java settings
- if($auto) {
- return $auto;
- } else {
- $auto = $this->useDetected(); // 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;
- }
- }
-
- private function openOfficeChecks() {
- if($this->util->openOfficeSpecified()) {
- $this->soffice = $this->util->openOfficeSpecified();
-
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Attempt detection without logging errors
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function useDetected() {
- return $this->detSettings();
- }
-
- /**
- * Set template view to specify java
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function specifyJava() {
- $this->javaExeError = true;
- }
-
- /**
- * Set template view to specify php
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function specifyPhp() {
- $this->phpExeError = true;
- }
-
- /**
- * Set template view to specify open office
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function specifyOpenOffice() {
- $this->openOfficeExeError = true;
- }
-
- private function phpChecks() {
- // TODO: Better detection
- return true;
- $this->setPhp();
- if($this->util->phpSpecified()) {
- return $this->detPhpSettings();
- } else {
- $this->specifyPhp();// Ask for settings
- return false;
- }
- }
-
-
-
- /**
- * Attempts to use user input and configure java settings
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function detSettings($attempt = false) {
- $javaExecutable = $this->util->javaSpecified();// Retrieve java bin
- if($javaExecutable == '') {
- if($this->java == '') {
- return false;
- }
- $javaExecutable = $this->java;
- }
- $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!";
- $response = $this->util->pexec($cmd);
- if(file_exists(OUTPUT_DIR.'outJV')) {
- $tmp = file_get_contents(OUTPUT_DIR.'outJV');
- preg_match('/"(.*)"/',$tmp, $matches);
- if($matches) {
- if($matches[1] < $this->javaVersion) { // Check Version of java
- $this->javaVersionInCorrect();
- $this->javaCheck = 'cross';
- $this->error[] = "Requires Java 1.5+ to be installed";
-
- return false;
- } else {
- $this->javaVersionCorrect();
- $this->javaInstalled();
- $this->javaCheck = 'tick';
- $this->providedJava = true;
-
- return true;
- }
- } else {
- $this->javaVersionWarning();
- $this->javaCheck = 'cross_orange';
- if($attempt) {
- $this->javaExeMessage = "Incorrect java path specified";
- $this->javaExeError = true;
- $this->error[] = "Requires Java 1.5+ to be installed";
- }
-
-
- return false;
- }
- }
-
- $this->javaVersionInCorrect();
- $this->javaCheck = 'cross';
- $this->error[] = "Requires Java 1.5+ to be installed";
- return false;
- }
-
- function detPhpSettings() {
- // TODO: Better php handling
- return true;
- $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
- $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!";
- $response = $this->util->pexec($cmd);
- if(file_exists(OUTPUT_DIR.'outPHP')) {
- $tmp = file_get_contents(OUTPUT_DIR.'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;
- }
- }
- }
- /**
- * Attempts to use bridge and configure java settings
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function useBridge() {
- $zendBridge = $this->util->zendBridge(); // Find Zend Bridge
- if($zendBridge) { // Bridge installed implies java exists
- $this->zendBridgeInstalled();
- if($this->checkZendBridge()) { // Make sure the Zend Bridge is functional
- $this->javaExtCheck = 'tick'; // Set bridge to functional
- $this->javaInstalled(); // Set java to installed
- $javaSystem = new Java('java.lang.System');
- $version = $javaSystem->getProperty('java.version');
- $ver = substr($version, 0, 3);
- if($ver < $this->javaVersion) {
- $this->javaVersionInCorrect();
- $this->error[] = "Requires Java 1.5+ to be installed";
- return false;
- } else {
- $this->javaVersionCorrect(); // Set version to correct
- $this->javaCheck = 'tick';
- return true;
- }
- } else {
- $this->javaCheck = 'cross_orange';
- $this->javaVersionWarning();
- $this->zendBridgeWarning();
- $this->warnings[] = "Zend Java Bridge Not Functional";
- $this->javaExtCheck = 'cross_orange';
- return false;
- }
- } else {
- $this->warnings[] = "Zend Java Bridge Not Found";
- return false;
- }
- }
-
- /**
- * Check if Zend Bridge is functional
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return boolean
- */
- public function checkZendBridge() {
- if($this->util->javaBridge()) { // Check if java bridge is functional
- return true;
- } else {
- return false;
- }
- }
-
-
- /**
- * Installs services
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function installServices() {
- foreach ($this->getServices() as $serviceName) {
- $this->installService($serviceName);
- }
-
- return true;
- }
-
- /**
- * Installs services helper
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return boolean
- */
- private function installService($serviceName) {
- $className = OS.$serviceName;
- $service = new $className();
- $status = $this->serviceHelper($service);
- if (!$status) {
- $this->serviceCheck = 'cross_orange';
- }
- }
-
- /**
- * Installs services
- *
- * @author KnowledgeTree Team
- * @param object
- * @access private
- * @return string
- */
- private function serviceHelper($service) {
- $service->load(); // Load Defaults
- $response = $service->install(); // Install service
- $statusCheck = OS."ServiceInstalled";
- return $this->$statusCheck($service);
- }
-
- /**
- * Helper to check if service is installed
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return string
- */
- public function serviceInstalled($service) {
- $statusCheck = OS."ServiceInstalled";
- return $this->$statusCheck($service);
- }
-
- /**
- * Helper to check if service is started
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return string
- */
- public function serviceStarted($service) {
- $statusCheck = OS."ServiceStarted";
- return $this->$statusCheck($service);
- }
-
- /**
- * Check if windows service installed
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return boolean
- */
- public function windowsServiceStarted($service) {
- $status = $service->status(); // Check if service has been installed
- if($status != 'RUNNING') { // Check service status
- return false;
- }
- return true;
- }
-
- /**
- * Check if unix service installed
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return boolean
- */
- public function unixServiceStarted($service) {
- $status = $service->status(); // Check if service has been installed
- if($status != 'STARTED') { // Check service status
- return false;
- }
- return true;
- }
-
- /**
- * Check if windows service installed
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return boolean
- */
- public function windowsServiceInstalled($service) {
- $status = $service->status(); // Check if service has been installed
- if($status == '') { // Check service status
- return false;
- }
- return true;
- }
-
- /**
- * Check if unix service installed
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return boolean
- */
- public function unixServiceInstalled($service) {
- $status = $service->status(); // Check if service has been installed
- if($status != 'STARTED') { // Check service status
- return false;
- }
- return true;
- }
-
- /**
- * Starts all services
- *
- * @author KnowledgeTree Team
- * @param object
- * @access public
- * @return mixed
- */
- public function installStep() {
- foreach ($this->getServices() as $serviceName) {
- $className = OS.$serviceName;
- $service = new $className();
- $status = $this->serviceStart($service);
- }
- return true;
- }
-
- /**
- * Starts service
- *
- * @author KnowledgeTree Team
- * @param object
- * @access private
- * @return string
- */
- private function serviceStart($service) {
- if(OS == 'windows') {
- $service->load(); // Load Defaults
- $service->start(); // Start Service
- return $service->status(); // Get service status
- }
- }
-
- /**
- * Returns services errors
- *
- * @author KnowledgeTree Team
- * @access public
- * @params none
- * @return array
- */
- public function getErrors() {
- return $this->error;
- }
-
- /**
- * Returns services warnings
- *
- * @author KnowledgeTree Team
- * @access public
- * @params none
- * @return array
- */
- public function getWarnings() {
- return $this->warnings;
- }
-
- /**
- * Get the variables to be passed to the template
- *
- * @author KnowledgeTree Team
- * @access public
- * @return array
- */
- public function getStepVars()
- {
- return $this->temp_variables;
- }
-
- /**
- * Store Java state as installed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function javaInstalled() {
- $this->temp_variables['java']['class'] = 'tick';
- $this->temp_variables['java']['found'] = "Java Runtime Installed";
- }
-
- /**
- * Store Java state as not installed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function javaNotInstalled() {
- $this->temp_variables['java']['class'] = 'cross';
- $this->temp_variables['java']['found'] = "Java runtime environment required";
- }
-
- /**
- * Store Java version state as correct
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function javaVersionCorrect() {
- $this->temp_variables['version']['class'] = 'tick';
- $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
- }
-
- /**
- * Store Java version state as warning
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function javaVersionWarning() {
- $this->temp_variables['version']['class'] = 'cross_orange';
- $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";
- }
-
- /**
- * Store Java version as state incorrect
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function javaVersionInCorrect() {
- $this->temp_variables['version']['class'] = 'cross';
- $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
- }
-
- /**
- * Store Zend Bridge state as installed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function zendBridgeInstalled() {
- $this->temp_variables['extensions']['class'] = 'tick';
- $this->temp_variables['extensions']['found'] = "Java Bridge Installed";
- }
-
- /**
- * Store Zend Bridge state as not installed
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function zendBridgeNotInstalled() {
- $this->temp_variables['extensions']['class'] = 'cross_orange';
- $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Installed";
- }
-
- /**
- * Store Zend Bridge state as warning
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function zendBridgeWarning() {
- $this->temp_variables['extensions']['class'] = 'cross_orange';
- $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Functional";
- }
-
- /**
- * Set all silent mode varibles
- *
- * @author KnowledgeTree Team
- * @param none
- * @access private
- * @return void
- */
- private function storeSilent() {
- // Servics
- $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled;
- $this->temp_variables['luceneInstalled'] = $this->luceneInstalled;
- $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled;
- $this->temp_variables['openOfficeInstalled'] = $this->openOfficeInstalled;
- // Java
- $this->temp_variables['javaExeError'] = $this->javaExeError;
- $this->temp_variables['javaExeMessage'] = $this->javaExeMessage;
- $this->temp_variables['javaCheck'] = $this->javaCheck;
- $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
- // Open Office
- $this->temp_variables['openOfficeExeError'] = $this->openOfficeExeError;
- $this->temp_variables['openOfficeExeMessage'] = $this->openOfficeExeMessage;
- // TODO : PHP detection
- $this->temp_variables['phpCheck'] = 'tick';//$this->phpCheck;
- $this->temp_variables['phpExeError'] = '';//$this->phpExeError;
- $this->temp_variables['serviceCheck'] = $this->serviceCheck;
- $this->temp_variables['disableExtension'] = $this->disableExtension;
- // TODO: Java checks are gettign intense
- $this->temp_variables['providedJava'] = $this->providedJava;
- }
-
- private function setPhp() {
- if($this->php != '') { // PHP Found
- $this->phpCheck = 'tick';
- } elseif (PHP_DIR != '') { // Use System Defined Settings
- $this->php = PHP_DIR;
- } else {
-
- }
- $this->temp_variables['php']['location'] = $this->php;
- }
-
- public function getPhpDir() {
- return $this->php;
- }
-
- public function doDeleteAll() {
- $serverDetails = $this->getServices();
- foreach ($serverDetails as $serviceName) {
- $className = OS.$serviceName;
- require_once("../lib/services/service.php");
- require_once("../lib/services/".OS."Service.php");
- require_once("../lib/services/$className.php");
- $service = new $className();
- $service->uninstall();
- echo "Delete Service {$service->getName()}
";
- echo "Status of service ".$service->status()."
";
- }
- }
-
- public function doInstallAll() {
- $serverDetails = $this->getServices();
- foreach ($serverDetails as $serviceName) {
- $className = OS.$serviceName;
- require_once("../lib/services/service.php");
- require_once("../lib/services/".OS."Service.php");
- require_once("../lib/services/$className.php");
- $service = new $className();
- $service->load();
- $service->install();
- echo "Install Service {$service->getName()}
";
- echo "Status of service ".$service->status()."
";
- }
- }
-
- public function doStatusAll() {
- $serverDetails = $this->getServices();
- foreach ($serverDetails as $serviceName) {
- $className = OS.$serviceName;
- require_once("../lib/services/service.php");
- require_once("../lib/services/".OS."Service.php");
- require_once("../lib/services/$className.php");
- $service = new $className();
- $service->load();
- echo "{$service->getName()} : Status of service = ".$service->status()."
";
- }
- }
-}
-
-if(isset($_GET['action'])) {
- $func = $_GET['action'];
- if($func != '') {
- $serv = new services();
- $func_call = strtoupper(substr($func,0,1)).substr($func,1);
- $method = "do$func";
- $serv->$method();
- }
-}
+.
+*
+* 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 Installer
+* @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");
+ }
+}
+
+class services extends Step
+{
+ /**
+ * List of errors encountered
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array
+ */
+ protected $error = array();
+
+ /**
+ * Flag if step needs to be installed
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var array
+ */
+ protected $runInstall = true;
+
+ /**
+ * List of services to be installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var array
+ */
+ private $services = array('Lucene', 'Scheduler', 'OpenOffice');
+
+ /**
+ * Path to php executable
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ protected $php;
+
+ /**
+ * Flag if php already provided
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ public $providedPhp = false;
+
+ /**
+ * PHP Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $phpCheck = 'cross_orange';
+
+ /**
+ * Flag, if php is specified and an error has been encountered
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var boolean
+ */
+ private $phpExeError = false;
+
+ /**
+ * Holds path error, if php is specified
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var string
+ */
+ private $phpExeMessage = '';
+
+ /**
+ * Path to open office executable
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ protected $soffice;
+
+ /**
+ * Flag if open office already provided
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ public $providedOpenOffice = false;
+
+ /**
+ * Flag, if open office is specified and an error has been encountered
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var boolean
+ */
+ private $openOfficeExeError = false;
+
+ /**
+ * Holds path error, if open office is specified
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var string
+ */
+ private $openOfficeExeMessage = '';
+
+ /**
+ * Path to java executable
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ protected $java = "";
+
+ /**
+ * Minumum Java Version
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $javaVersion = '1.5';
+
+ /**
+ * Java Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $javaCheck = 'cross';
+
+ /**
+ * Open Office Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $openOfficeCheck = 'cross';
+
+ /**
+ * Flag if java already provided
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ public $providedJava = false;
+
+ /**
+ * Java Bridge Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $javaExtCheck = 'cross_orange';
+
+ /**
+ * Flag if bridge extension needs to be disabled
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var boolean
+ */
+ private $disableExtension = false;
+
+ /**
+ * Flag, if java is specified and an error has been encountered
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var booelean
+ */
+ private $javaExeError = false;
+
+ /**
+ * Holds path error, if java is specified
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var string
+ */
+ private $javaExeMessage = '';
+
+ /**
+ * Flag if services are already Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $alreadyInstalled = false;
+
+ /**
+ * Flag if services are already Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $luceneInstalled = false;
+
+ /**
+ * Flag if services are already Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $schedulerInstalled = false;
+
+ /**
+ * Path to php executable
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ private $openOfficeInstalled;
+
+ /**
+ * Service Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var array
+ */
+ private $serviceCheck = 'tick';
+
+ /**
+ * Flag to store class information in session
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var boolean
+ */
+ protected $storeInSession = true;
+
+ /**
+ * List of variables to be loaded to template
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $temp_variables;
+
+ /**
+ * Flag if step needs to run silently
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var array
+ */
+ protected $silent = true;
+
+ /**
+ * Reference to utility object
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var string
+ */
+ protected $util;
+ private $salt = 'install';
+
+ /**
+ * Constructs services object
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ */
+ public function __construct() {
+ $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent);
+ $this->util = new InstallUtil();
+ }
+
+ /**
+ * Main control of services setup
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return string
+ */
+ public function doStep()
+ {
+ if(!$this->inStep("services")) {
+ $this->doRun();
+ return 'landing';
+ }
+ if($this->next()) {
+ // Check dependencies
+ $passed = $this->doRun();
+ $serv = $this->getDataFromSession("services");
+ if($passed || $serv['providedJava'])
+ return 'next';
+ else
+ return 'error';
+ } else if($this->previous()) {
+ return 'previous';
+ }
+ $passed = $this->doRun();
+ return 'landing';
+ }
+
+ /**
+ * Get service names
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return array
+ */
+ public function getServices() {
+ return $this->services;
+ }
+
+ /**
+ * Check if java executable was found
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return array
+ */
+ private function setJava() {
+ if($this->java != '') { // Java JRE Found
+ $this->javaCheck = 'tick';
+ $this->javaInstalled();
+ $this->temp_variables['java']['location'] = $this->java;
+ return ;
+ }
+
+ $this->temp_variables['java']['location'] = $this->java;
+ }
+
+ /**
+ * Run step
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function doRun() {
+ if($this->alreadyInstalled()) {
+ $this->alreadyInstalled = true;
+ $this->serviceCheck = 'tick';
+ } else {
+ $this->presetJava();
+ $this->presetOpenOffice();
+ if(!$this->schedulerInstalled) {
+ $this->php = $this->util->getPhp(); // Get java, if it exists
+ $passedPhp = $this->phpChecks(); // Run Java Pre Checks
+ if ($passedPhp) { // Install Scheduler
+ $this->installService('Scheduler');
+ }
+ } else {
+ $this->schedulerInstalled();
+ }
+ if(!$this->luceneInstalled) {
+ $this->java = $this->util->getJava(); // Get java, if it exists
+ $passedJava = $this->javaChecks(); // Run Java Pre Checks
+ if ($passedJava) { // Install Lucene
+ $this->installService('Lucene');
+ }
+ } else {
+ $this->luceneInstalled();
+ }
+ if(!$this->openOfficeInstalled) {
+ $this->soffice = $this->util->getOpenOffice(); // Get java, if it exists
+ $passedOpenOffice = $this->openOfficeChecks(); // Run Java Pre Checks
+ if ($passedOpenOffice) { //Install OpenOffice
+// $this->temp_variables['openOfficeExe'] = $this->soffice;
+ // TODO : Why, O, why?
+ $this->openOfficeExeError = false;
+ $_SESSION[$this->salt]['services']['openOfficeExe'] = $this->soffice;
+ $this->installService('OpenOffice');
+ }
+ } else {
+ $this->openOfficeInstalled();
+ }
+ }
+ $this->checkServiceStatus();
+ $this->storeSilent(); // Store info needed for silent mode
+ if(!empty($errors))
+ return false;
+ return true;
+ }
+
+ private function openOfficeInstalled() {
+
+ }
+
+ private function schedulerInstalled() {
+
+ }
+
+ private function luceneInstalled() {
+ $this->disableExtension = true; // Disable the use of the php bridge extension
+ $this->javaVersionCorrect();
+ $this->javaInstalled();
+ $this->javaCheck = 'tick';
+ }
+
+ /**
+ * A final check to see if services are still running,
+ * incase they switched on and turned off.
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function checkServiceStatus() {
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $service->load();
+ $status = $this->serviceInstalled($service);
+ if($status != 'STARTED') {
+ $msg = $service->getName()." Could not be added as a Service";
+ $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$msg);
+ $this->serviceCheck = 'cross_orange';
+ $this->warnings[] = $msg;
+ } else {
+ if(WINDOWS_OS) {
+ $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); }
+ else {
+ $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added and Started as a Service");
+ }
+ }
+ }
+ }
+
+ /**
+ * Checks if all services have been started already,
+ * incase the user lands on service page multiple times
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function alreadyInstalled() {
+ $allInstalled = true;
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $status = $this->serviceInstalled($service);
+ $flag = strtolower(substr($serviceName,0,1)).substr($serviceName,1)."Installed";
+ if(!$status) {
+ $allInstalled = false;
+ $this->$flag = false;
+ } else {
+ $this->$flag = true;
+ }
+ }
+
+ return $allInstalled;
+ }
+
+ private function presetJava() {
+ $this->zendBridgeNotInstalled(); // Set bridge not installed
+ $this->javaVersionInCorrect(); // Set version to incorrect
+ $this->javaNotInstalled(); // Set java to not installed
+ $this->setJava(); // Check if java has been auto detected
+ }
+
+ private function presetOpenOffice() {
+ $this->specifyOpenOffice();
+ }
+
+ private function setOpenOffice() {
+
+ }
+ /**
+ * Do some basic checks to help the user overcome java problems
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function javaChecks() {
+ if($this->util->javaSpecified()) {
+ $this->disableExtension = true; // Disable the use of the php bridge extension
+ if($this->detSettings(true)) { // AutoDetect java settings
+ return true;
+ } else {
+ $this->specifyJava(); // Ask for settings
+ }
+ } else {
+ $auto = $this->useBridge(); // Use Bridge to get java settings
+ if($auto) {
+ return $auto;
+ } else {
+ $auto = $this->useDetected(); // 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;
+ }
+ }
+
+ private function openOfficeChecks() {
+ if($this->util->openOfficeSpecified()) {
+ $this->soffice = $this->util->openOfficeSpecified();
+ if(file_exists($this->soffice))
+ return true;
+ else
+ return false;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Attempt detection without logging errors
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function useDetected() {
+ return $this->detSettings();
+ }
+
+ /**
+ * Set template view to specify java
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function specifyJava() {
+ $this->javaExeError = true;
+ }
+
+ /**
+ * Set template view to specify php
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function specifyPhp() {
+ $this->phpExeError = true;
+ }
+
+ /**
+ * Set template view to specify open office
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function specifyOpenOffice() {
+ $this->openOfficeExeError = true;
+ }
+
+ private function phpChecks() {
+ // TODO: Better detection
+ return true;
+ $this->setPhp();
+ if($this->util->phpSpecified()) {
+ return $this->detPhpSettings();
+ } else {
+ $this->specifyPhp();// Ask for settings
+ return false;
+ }
+ }
+
+
+
+ /**
+ * Attempts to use user input and configure java settings
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function detSettings($attempt = false) {
+ $javaExecutable = $this->util->javaSpecified();// Retrieve java bin
+ if($javaExecutable == '') {
+ if($this->java == '') {
+ return false;
+ }
+ $javaExecutable = $this->java;
+ }
+ $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!";
+ $response = $this->util->pexec($cmd);
+ if(file_exists(OUTPUT_DIR.'outJV')) {
+ $tmp = file_get_contents(OUTPUT_DIR.'outJV');
+ preg_match('/"(.*)"/',$tmp, $matches);
+ if($matches) {
+ if($matches[1] < $this->javaVersion) { // Check Version of java
+ $this->javaVersionInCorrect();
+ $this->javaCheck = 'cross';
+ $this->error[] = "Requires Java 1.5+ to be installed";
+
+ return false;
+ } else {
+ $this->javaVersionCorrect();
+ $this->javaInstalled();
+ $this->javaCheck = 'tick';
+ $this->providedJava = true;
+
+ return true;
+ }
+ } else {
+ $this->javaVersionWarning();
+ $this->javaCheck = 'cross_orange';
+ if($attempt) {
+ $this->javaExeMessage = "Incorrect java path specified";
+ $this->javaExeError = true;
+ $this->error[] = "Requires Java 1.5+ to be installed";
+ }
+
+
+ return false;
+ }
+ }
+
+ $this->javaVersionInCorrect();
+ $this->javaCheck = 'cross';
+ $this->error[] = "Requires Java 1.5+ to be installed";
+ return false;
+ }
+
+ function detPhpSettings() {
+ // TODO: Better php handling
+ return true;
+ $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
+ $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!";
+ $response = $this->util->pexec($cmd);
+ if(file_exists(OUTPUT_DIR.'outPHP')) {
+ $tmp = file_get_contents(OUTPUT_DIR.'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;
+ }
+ }
+ }
+ /**
+ * Attempts to use bridge and configure java settings
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function useBridge() {
+ $zendBridge = $this->util->zendBridge(); // Find Zend Bridge
+ if($zendBridge) { // Bridge installed implies java exists
+ $this->zendBridgeInstalled();
+ if($this->checkZendBridge()) { // Make sure the Zend Bridge is functional
+ $this->javaExtCheck = 'tick'; // Set bridge to functional
+ $this->javaInstalled(); // Set java to installed
+ $javaSystem = new Java('java.lang.System');
+ $version = $javaSystem->getProperty('java.version');
+ $ver = substr($version, 0, 3);
+ if($ver < $this->javaVersion) {
+ $this->javaVersionInCorrect();
+ $this->error[] = "Requires Java 1.5+ to be installed";
+ return false;
+ } else {
+ $this->javaVersionCorrect(); // Set version to correct
+ $this->javaCheck = 'tick';
+ return true;
+ }
+ } else {
+ $this->javaCheck = 'cross_orange';
+ $this->javaVersionWarning();
+ $this->zendBridgeWarning();
+ $this->warnings[] = "Zend Java Bridge Not Functional";
+ $this->javaExtCheck = 'cross_orange';
+ return false;
+ }
+ } else {
+ $this->warnings[] = "Zend Java Bridge Not Found";
+ return false;
+ }
+ }
+
+ /**
+ * Check if Zend Bridge is functional
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function checkZendBridge() {
+ if($this->util->javaBridge()) { // Check if java bridge is functional
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * Installs services
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function installServices() {
+ foreach ($this->getServices() as $serviceName) {
+ $this->installService($serviceName);
+ }
+
+ return true;
+ }
+
+ /**
+ * Installs services helper
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return boolean
+ */
+ private function installService($serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $status = $this->serviceHelper($service);
+ if (!$status) {
+ $this->serviceCheck = 'cross_orange';
+ }
+ }
+
+ /**
+ * Installs services
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access private
+ * @return string
+ */
+ private function serviceHelper($service) {
+ $service->load(); // Load Defaults
+ $response = $service->install(); // Install service
+ $statusCheck = OS."ServiceInstalled";
+ return $this->$statusCheck($service);
+ }
+
+ /**
+ * Helper to check if service is installed
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return string
+ */
+ public function serviceInstalled($service) {
+ $statusCheck = OS."ServiceInstalled";
+ return $this->$statusCheck($service);
+ }
+
+ /**
+ * Helper to check if service is started
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return string
+ */
+ public function serviceStarted($service) {
+ $statusCheck = OS."ServiceStarted";
+ return $this->$statusCheck($service);
+ }
+
+ /**
+ * Check if windows service installed
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return boolean
+ */
+ public function windowsServiceStarted($service) {
+ $status = $service->status(); // Check if service has been installed
+ if($status != 'RUNNING') { // Check service status
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if unix service installed
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return boolean
+ */
+ public function unixServiceStarted($service) {
+ $status = $service->status(); // Check if service has been installed
+ if($status != 'STARTED') { // Check service status
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if windows service installed
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return boolean
+ */
+ public function windowsServiceInstalled($service) {
+ $status = $service->status(); // Check if service has been installed
+ if($status == '') { // Check service status
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if unix service installed
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return boolean
+ */
+ public function unixServiceInstalled($service) {
+ $status = $service->status(); // Check if service has been installed
+ if($status != 'STARTED') { // Check service status
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts all services
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access public
+ * @return mixed
+ */
+ public function installStep() {
+ foreach ($this->getServices() as $serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $status = $this->serviceStart($service);
+ }
+ return true;
+ }
+
+ /**
+ * Starts service
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access private
+ * @return string
+ */
+ private function serviceStart($service) {
+ if(OS == 'windows') {
+ $service->load(); // Load Defaults
+ $service->start(); // Start Service
+ return $service->status(); // Get service status
+ }
+ }
+
+ /**
+ * Returns services errors
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @params none
+ * @return array
+ */
+ public function getErrors() {
+ return $this->error;
+ }
+
+ /**
+ * Returns services warnings
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @params none
+ * @return array
+ */
+ public function getWarnings() {
+ return $this->warnings;
+ }
+
+ /**
+ * Get the variables to be passed to the template
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @return array
+ */
+ public function getStepVars()
+ {
+ return $this->temp_variables;
+ }
+
+ /**
+ * Store Java state as installed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function javaInstalled() {
+ $this->temp_variables['java']['class'] = 'tick';
+ $this->temp_variables['java']['found'] = "Java Runtime Installed";
+ }
+
+ /**
+ * Store Java state as not installed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function javaNotInstalled() {
+ $this->temp_variables['java']['class'] = 'cross';
+ $this->temp_variables['java']['found'] = "Java runtime environment required";
+ }
+
+ /**
+ * Store Java version state as correct
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function javaVersionCorrect() {
+ $this->temp_variables['version']['class'] = 'tick';
+ $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
+ }
+
+ /**
+ * Store Java version state as warning
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function javaVersionWarning() {
+ $this->temp_variables['version']['class'] = 'cross_orange';
+ $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";
+ }
+
+ /**
+ * Store Java version as state incorrect
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function javaVersionInCorrect() {
+ $this->temp_variables['version']['class'] = 'cross';
+ $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
+ }
+
+ /**
+ * Store Zend Bridge state as installed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function zendBridgeInstalled() {
+ $this->temp_variables['extensions']['class'] = 'tick';
+ $this->temp_variables['extensions']['found'] = "Java Bridge Installed";
+ }
+
+ /**
+ * Store Zend Bridge state as not installed
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function zendBridgeNotInstalled() {
+ $this->temp_variables['extensions']['class'] = 'cross_orange';
+ $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Installed";
+ }
+
+ /**
+ * Store Zend Bridge state as warning
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function zendBridgeWarning() {
+ $this->temp_variables['extensions']['class'] = 'cross_orange';
+ $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Functional";
+ }
+
+ /**
+ * Set all silent mode varibles
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return void
+ */
+ private function storeSilent() {
+ // Servics
+ $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled;
+ $this->temp_variables['luceneInstalled'] = $this->luceneInstalled;
+ $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled;
+ $this->temp_variables['openOfficeInstalled'] = $this->openOfficeInstalled;
+ // Java
+ $this->temp_variables['javaExeError'] = $this->javaExeError;
+ $this->temp_variables['javaExeMessage'] = $this->javaExeMessage;
+ $this->temp_variables['javaCheck'] = $this->javaCheck;
+ $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
+ // Open Office
+ $this->temp_variables['openOfficeExeError'] = $this->openOfficeExeError;
+ $this->temp_variables['openOfficeExeMessage'] = $this->openOfficeExeMessage;
+ // TODO : PHP detection
+ $this->temp_variables['phpCheck'] = 'tick';//$this->phpCheck;
+ $this->temp_variables['phpExeError'] = '';//$this->phpExeError;
+ $this->temp_variables['serviceCheck'] = $this->serviceCheck;
+ $this->temp_variables['disableExtension'] = $this->disableExtension;
+ // TODO: Java checks are gettign intense
+ $this->temp_variables['providedJava'] = $this->providedJava;
+ }
+
+ private function setPhp() {
+ if($this->php != '') { // PHP Found
+ $this->phpCheck = 'tick';
+ } elseif (PHP_DIR != '') { // Use System Defined Settings
+ $this->php = PHP_DIR;
+ } else {
+
+ }
+ $this->temp_variables['php']['location'] = $this->php;
+ }
+
+ public function getPhpDir() {
+ return $this->php;
+ }
+
+ public function doDeleteAll() {
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ require_once("../lib/services/service.php");
+ require_once("../lib/services/".OS."Service.php");
+ require_once("../lib/services/$className.php");
+ $service = new $className();
+ $service->uninstall();
+ echo "Delete Service {$service->getName()}
";
+ echo "Status of service ".$service->status()."
";
+ }
+ }
+
+ public function doInstallAll() {
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ require_once("../lib/services/service.php");
+ require_once("../lib/services/".OS."Service.php");
+ require_once("../lib/services/$className.php");
+ $service = new $className();
+ $service->load();
+ $service->install();
+ echo "Install Service {$service->getName()}
";
+ echo "Status of service ".$service->status()."
";
+ }
+ }
+
+ public function doStatusAll() {
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ require_once("../lib/services/service.php");
+ require_once("../lib/services/".OS."Service.php");
+ require_once("../lib/services/$className.php");
+ $service = new $className();
+ $service->load();
+ echo "{$service->getName()} : Status of service = ".$service->status()."
";
+ }
+ }
+}
+
+if(isset($_GET['action'])) {
+ $func = $_GET['action'];
+ if($func != '') {
+ $serv = new services();
+ $func_call = strtoupper(substr($func,0,1)).substr($func,1);
+ $method = "do$func";
+ $serv->$method();
+ }
+}
?>
\ No newline at end of file
diff --git a/setup/wizard/templates/complete.tpl b/setup/wizard/templates/complete.tpl
index cf1a452..881a470 100644
--- a/setup/wizard/templates/complete.tpl
+++ b/setup/wizard/templates/complete.tpl
@@ -1,129 +1,129 @@
-
+
\ No newline at end of file
diff --git a/setup/wizard/templates/configuration.tpl b/setup/wizard/templates/configuration.tpl
index dfd61dc..233879f 100644
--- a/setup/wizard/templates/configuration.tpl
+++ b/setup/wizard/templates/configuration.tpl
@@ -118,4 +118,4 @@
-
\ No newline at end of file
+
diff --git a/setup/wizard/templates/configuration_confirm.tpl b/setup/wizard/templates/configuration_confirm.tpl
index 5de48f2..ac24285 100644
--- a/setup/wizard/templates/configuration_confirm.tpl
+++ b/setup/wizard/templates/configuration_confirm.tpl
@@ -94,4 +94,4 @@
-
\ No newline at end of file
+
diff --git a/setup/wizard/templates/registration.tpl b/setup/wizard/templates/registration.tpl
index 0288c30..f79185c 100644
--- a/setup/wizard/templates/registration.tpl
+++ b/setup/wizard/templates/registration.tpl
@@ -3,6 +3,7 @@