diff --git a/setup/wizard/config/databases.xml b/setup/wizard/config/databases.xml
index df6ec5e..cd2e9a5 100644
--- a/setup/wizard/config/databases.xml
+++ b/setup/wizard/config/databases.xml
@@ -15,4 +15,8 @@
3306
dms
root
+ dmsadminuser
+ js9281djw
+ dmsuser
+ djw9281js
diff --git a/setup/wizard/dbUtil.php b/setup/wizard/dbUtil.php
index 2977855..8a6fbf3 100644
--- a/setup/wizard/dbUtil.php
+++ b/setup/wizard/dbUtil.php
@@ -108,7 +108,7 @@ class dbUtil {
$this->dbhost = $dhost;
$this->dbuname = $duname;
$this->dbpassword = $dpassword;
- $this->dbconnection = mysql_connect($dhost, $duname, $dpassword);
+ $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword);
if($dbname != '') {
$this->setDb($dbname);
$this->useDb($dbname);
@@ -116,7 +116,7 @@ class dbUtil {
if($this->dbconnection)
return $this->dbconnection;
else {
- $this->error[] = mysql_error($this->dbconnection);
+ $this->error[] = @mysql_error($this->dbconnection);
return false;
}
}
@@ -128,15 +128,15 @@ class dbUtil {
* @access public
* @return boolean
*/
- public function useDb($dbname) {
+ public function useDb($dbname = '') {
if($dbname != '') {
$this->setDb($dbname);
}
- if(mysql_select_db($this->dbname, $this->dbconnection))
+ if(@mysql_select_db($this->dbname, $this->dbconnection))
return true;
else {
- $this->error[] = mysql_error($this->dbconnection);
+ $this->error[] = @mysql_error($this->dbconnection);
return false;
}
}
@@ -153,11 +153,11 @@ class dbUtil {
* @return object The result of the query.
*/
public function query($query) {
- $result = mysql_query($query, $this->dbconnection);
+ $result = @mysql_query($query, $this->dbconnection);
if($result) {
return $result;
} else {
- $this->error[] = mysql_error($this->dbconnection);
+ $this->error[] = @mysql_error($this->dbconnection);
return false;
}
}
@@ -170,11 +170,11 @@ class dbUtil {
* @return boolean
*/
public function execute($query) {
- $result = mysql_query($query, $this->dbconnection);
+ $result = @mysql_query($query, $this->dbconnection);
if($result) {
return true;
} else {
- $this->error[] = mysql_error($this->dbconnection);
+ $this->error[] = @mysql_error($this->dbconnection);
return false;
}
}
@@ -187,10 +187,10 @@ class dbUtil {
* @return object An object representing a data row.
*/
public function fetchNextObject($result = NULL) {
- if ($result == NULL || mysql_num_rows($result) < 1)
+ if ($result == NULL || @mysql_num_rows($result) < 1)
return NULL;
else
- return mysql_fetch_object($result);
+ return @mysql_fetch_object($result);
}
/**
@@ -202,10 +202,10 @@ class dbUtil {
*/
public function fetchAssoc($result = NULL) {
$r = array();
- if ($result == NULL || mysql_num_rows($result) < 1)
+ if ($result == NULL || @mysql_num_rows($result) < 1)
return NULL;
else {
- $row = mysql_fetch_assoc($result);
+ $row = @mysql_fetch_assoc($result);
while ($row) {
$r[] = $row;
}
@@ -221,7 +221,7 @@ class dbUtil {
* @return void.
*/
public function close() {
- mysql_close($this->dbconnection);
+ @mysql_close($this->dbconnection);
}
/**
diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php
index a8b98ff..60f7dfd 100644
--- a/setup/wizard/installUtil.php
+++ b/setup/wizard/installUtil.php
@@ -373,7 +373,6 @@ class InstallUtil {
}
return 'java';
-// return array('response'=>$response, 'java'=>'java');
}
function tryJava2() {
@@ -383,7 +382,6 @@ class InstallUtil {
}
return 'java';
-// return array('response'=>$response, 'java'=>'java');
}
function tryJava3() {
@@ -396,7 +394,6 @@ class InstallUtil {
$match = preg_match('/bin/', $r);
if($match) {
return preg_replace('/java:/', '', $r);
-// return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r));
}
}
}
@@ -422,6 +419,26 @@ class InstallUtil {
}
/**
+ * 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;
+ }
+ }
+
+ /**
* Determine the location of JAVA_HOME
*
* @author KnowledgeTree Team
@@ -441,6 +458,32 @@ class InstallUtil {
return $response;
}
+ /**
+ * Determine the location of PHP
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access private
+ * @return mixed
+ */
+ function getPhp() {
+ $cmd = "whereis php";
+ $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 '';
+ }
+
/**
* Portably execute a command on any of the supported platforms.
*
diff --git a/setup/wizard/installWizard.php b/setup/wizard/installWizard.php
index b3db225..0d696b9 100644
--- a/setup/wizard/installWizard.php
+++ b/setup/wizard/installWizard.php
@@ -176,7 +176,7 @@ class InstallWizard {
* @return void
*/
private function createInstallFile() {
- touch("install");
+ @touch("install");
}
/**
@@ -188,7 +188,7 @@ class InstallWizard {
* @return void
*/
private function removeInstallFile() {
- unlink("install");
+ @unlink("install");
}
/**
diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php
index 3ebd069..5552708 100644
--- a/setup/wizard/installer.php
+++ b/setup/wizard/installer.php
@@ -114,6 +114,17 @@ class Installer {
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
@@ -273,11 +284,19 @@ class Installer {
$this->stepAction->setSteps($this->getSteps());
$this->stepAction->setStepNames($this->getStepNames());
$this->stepAction->setDisplayConfirm($this->stepConfirmation);
+ $this->stepAction->setDisplayFirst($this->stepDisplayFirst());
$this->stepAction->loadSession($this->session);
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
*
@@ -373,7 +392,7 @@ class Installer {
* @return void
*/
private function _completeInstall() {
- touch("install");
+ @touch("install");
}
/**
@@ -443,20 +462,26 @@ class Installer {
private function loadNeeded() {
$this->_readXml(); // Xml steps
// Make sure session is cleared
- $this->_resetSessions();
+ $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 = '';
}
}
@@ -480,7 +505,8 @@ class Installer {
$this->_runStepsInstallers(); // Load landing
$this->_proceed(); // Load next window
} elseif ($res == 'confirm') {
- $this->stepConfirmation = true;
+ if(!$this->stepDisplayFirst())
+ $this->stepConfirmation = true;
$this->_landing();
} elseif ($res == 'landing') {
$this->_landing();
diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php
index da84b5c..b2fc53f 100644
--- a/setup/wizard/lib/services/unixLucene.php
+++ b/setup/wizard/lib/services/unixLucene.php
@@ -42,7 +42,6 @@
class unixLucene extends unixService {
public $util;
- private $phpDir;
private $shutdownScript;
private $indexerDir;
private $lucenePidFile;
@@ -65,7 +64,6 @@ class unixLucene extends unixService {
$this->setJavaXmx(512);
$this->setLuceneSource("ktlucene.jar");
$this->setLuceneSourceLoc("ktlucene.jar");
-// $this->setPhpDir();
$this->setShutdownScript("shutdown.php");
}
@@ -85,29 +83,6 @@ class unixLucene extends unixService {
return $this->shutdownScript;
}
- private function setPhpDir($phpdir = '') {
- if($phpdir == '') {
- $cmd = "whereis php";
- $response = $this->util->pexec($cmd);
- if(is_array($response['out'])) {
- $broke = explode(' ', $response['out'][0]);
- foreach ($broke as $r) {
- $match = preg_match('/bin/', $r);
- if($match) {
- $this->phpDir = preg_replace('/php:/', '', $r);
- }
- }
- }
- return ;
- } else {
- $this->phpDir = $phpdir;
- }
- }
-
- public function getPhpDir() {
- return $this->phpDir;
- }
-
private function setLucenePidFile($lucenePidFile) {
$this->lucenePidFile = $lucenePidFile;
}
@@ -172,7 +147,12 @@ class unixLucene extends unixService {
}
public function install() {
- $this->start();
+ $status = $this->status();
+ if($status == '') {
+ return $this->start();
+ } else {
+ return $status;
+ }
}
public function status() {
@@ -187,11 +167,11 @@ class unixLucene extends unixService {
}
}
} else {
- return 'STOPPED';
+ return '';
}
}
- return 'STOPPED';
+ return '';
}
public function uninstall() {
diff --git a/setup/wizard/lib/services/unixScheduler.php b/setup/wizard/lib/services/unixScheduler.php
index e1840b0..f385ac3 100644
--- a/setup/wizard/lib/services/unixScheduler.php
+++ b/setup/wizard/lib/services/unixScheduler.php
@@ -41,7 +41,6 @@
*/
class unixScheduler extends unixService {
- private $phpDir;
private $schedulerDir;
private $schedulerSource;
private $schedulerSourceLoc;
@@ -109,7 +108,12 @@ class unixScheduler extends unixService {
}
function install() {
- $this->start();
+ $status = $this->status();
+ if($status == '') {
+ return $this->start();
+ } else {
+ return $status;
+ }
}
function uninstall() {
@@ -134,7 +138,7 @@ class unixScheduler extends unixService {
}
}
} else {
- return 'STOPPED';
+ return '';
}
}
@@ -162,6 +166,7 @@ class unixScheduler extends unixService {
return false;
}
+
}
?>
\ No newline at end of file
diff --git a/setup/wizard/lib/services/unixService.php b/setup/wizard/lib/services/unixService.php
index 02ddce4..c4c42c8 100644
--- a/setup/wizard/lib/services/unixService.php
+++ b/setup/wizard/lib/services/unixService.php
@@ -140,5 +140,7 @@ class unixService extends Service {
public function cont() {
}
+
+
}
?>
\ No newline at end of file
diff --git a/setup/wizard/lib/services/windowsScheduler.php b/setup/wizard/lib/services/windowsScheduler.php
index c88b0e0..a40f00c 100644
--- a/setup/wizard/lib/services/windowsScheduler.php
+++ b/setup/wizard/lib/services/windowsScheduler.php
@@ -78,7 +78,8 @@ class windowsScheduler extends windowsService {
function load() {
$this->name = "KTSchedulerTest";
$this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
- $this->setSchedulerScriptPath("taskrunner_test.bat");
+// $this->setSchedulerScriptPath("taskrunner_test.bat");
+ $this->setSchedulerScriptPath("taskrunner.bat");
$this->setSchedulerSource("schedulerService.php");
}
@@ -171,11 +172,15 @@ class windowsScheduler extends windowsService {
public function install() {
$state = $this->status();
if($state == '') {
- $fp = fopen($this->getSchedulerScriptPath(), "w+");
- $content = "@echo off\n";
- $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
- fwrite($fp, $content);
- fclose($fp);
+ if(is_readable(SYS_BIN_DIR)) {
+ if(!file_exists($this->getSchedulerScriptPath())) {
+ $fp = fopen($this->getSchedulerScriptPath(), "w+");
+ $content = "@echo off\n";
+ $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
+ fwrite($fp, $content);
+ fclose($fp);
+ }
+ }
$response = win32_create_service(array(
'service' => $this->name,
'display' => $this->name,
diff --git a/setup/wizard/lib/services/windowsService.php b/setup/wizard/lib/services/windowsService.php
index b3bd5e3..bca2f15 100644
--- a/setup/wizard/lib/services/windowsService.php
+++ b/setup/wizard/lib/services/windowsService.php
@@ -69,10 +69,13 @@ class windowsService extends Service {
* @return array
*/
public function start() {
- $cmd = "sc start {$this->name}";
- $response = $this->util->pexec($cmd);
-
- return $response;
+ $status = $this->status();
+ if ($status != 'RUNNING') {
+ $cmd = "sc start {$this->name}";
+ $response = $this->util->pexec($cmd);
+ return $response;
+ }
+ return $status;
}
/**
@@ -84,9 +87,13 @@ class windowsService extends Service {
* @return array
*/
public function stop() {
- $cmd = "sc stop {$this->name}";
- $response = $this->util->pexec($cmd);
- return $response;
+ $status = $this->status();
+ if ($status != 'STOPPED') {
+ $cmd = "sc stop {$this->name}";
+ $response = $this->util->pexec($cmd);
+ return $response;
+ }
+ return $status;
}
public function install() {}
@@ -101,7 +108,7 @@ class windowsService extends Service {
*/
public function restart() {
$response = $this->stop();
- sleep(1);
+ sleep(10);
$this->start();
}
@@ -114,10 +121,14 @@ class windowsService extends Service {
* @return array
*/
public function uninstall() {
- $cmd = "sc delete {$this->name}";
- $response = $this->util->pexec($cmd);
- sleep(1);
- return $response;
+ $status = $this->status();
+ if ($status != '') {
+ $cmd = "sc delete {$this->name}";
+ $response = $this->util->pexec($cmd);
+ sleep(10);
+ return $response;
+ }
+ return $status;
}
/**
diff --git a/setup/wizard/path.php b/setup/wizard/path.php
index 3bb3a1f..844145d 100644
--- a/setup/wizard/path.php
+++ b/setup/wizard/path.php
@@ -87,7 +87,7 @@
}
define('SYSTEM_ROOT', $asys);
// Install Type
- preg_match('/Zend/', $sys, $matches);
+ preg_match('/Zend/', $sys, $matches); // TODO: Dirty
if($matches) {
$sysdir = explode(DS, $sys);
array_pop($sysdir);
@@ -101,12 +101,18 @@
define('INSTALL_TYPE', 'Zend');
define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);
} else {
- // TODO: Other types
+ $modules = get_loaded_extensions();
+ if(in_array('Zend Monitor', $modules)) { // TODO: Dirty
+ define('INSTALL_TYPE', 'Zend');
+ define('PHP_DIR', '');
+ } else {
+ define('INSTALL_TYPE', '');
+ define('PHP_DIR', '');
+ }
}
// Other
date_default_timezone_set('Africa/Johannesburg');
- // Mysql bin [Windows]
- if(WINDOWS_OS) {
+ if(WINDOWS_OS) { // Mysql bin [Windows]
$serverPaths = explode(';',$_SERVER['PATH']);
foreach ($serverPaths as $apath) {
preg_match('/mysql/i', $apath, $matches);
@@ -115,6 +121,8 @@
break;
}
}
+ } else {
+ define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line
}
?>
diff --git a/setup/wizard/resources/wizard.js b/setup/wizard/resources/wizard.js
index d371273..c581ddd 100644
--- a/setup/wizard/resources/wizard.js
+++ b/setup/wizard/resources/wizard.js
@@ -133,9 +133,9 @@ wizard.prototype.focusElement = function(el) {
}
// Catch form submit and validate
-wizard.prototype.onSubmitValidate = function() {
+wizard.prototype.onSubmitValidate = function(silent) {
var response = w.showStep(3, 'n');
- if(response == true) {
+ if(response == true || silent == true) {
document.getElementById('sendAll').name = 'Next'; // Force the next step
document.getElementById('sendAll').value = 'next';
document.getElementById('dbsettings').submit();
diff --git a/setup/wizard/step.php b/setup/wizard/step.php
index 45f118a..029b9da 100644
--- a/setup/wizard/step.php
+++ b/setup/wizard/step.php
@@ -104,6 +104,7 @@ class Step
*/
protected $silent = false;
+ public $displayFirst = false;
/**
* Returns step state
*
@@ -117,6 +118,9 @@ class Step
return '';
}
+ public function displayFirst() {
+ return $this->displayFirst;
+ }
/**
* Returns step variables
diff --git a/setup/wizard/stepAction.php b/setup/wizard/stepAction.php
index 76ce22b..45eb081 100644
--- a/setup/wizard/stepAction.php
+++ b/setup/wizard/stepAction.php
@@ -69,6 +69,15 @@ class stepAction {
protected $displayConfirm = false;
/**
+ * Returns whether or not to display the confirmation page first
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var boolean
+ */
+ protected $displayFirst = false;
+
+ /**
* Reference to session object
*
* @author KnowledgeTree Team
@@ -122,9 +131,6 @@ class stepAction {
} else {
$this->_clearErrors($this->stepName); // Send Errors to session
}
-// if($this->action->silentMode()) {
-// return 'silent';
-// }
return $response;
} else {
$this->stepName = 'errors';
@@ -278,6 +284,18 @@ class stepAction {
}
/**
+ * Returns whether or not to display the confirmation page first
+ *
+ * @author KnowledgeTree Team
+ * @param none
+ * @access public
+ * @return boolean
+ */
+ public function displayFirst() {
+ return $this->displayFirst;
+ }
+
+ /**
* Sets confirmation page flag
*
* @author KnowledgeTree Team
@@ -290,6 +308,18 @@ class stepAction {
}
/**
+ * Sets confirmation page first flag
+ *
+ * @author KnowledgeTree Team
+ * @param boolean
+ * @access public
+ * @return void
+ */
+ public function setDisplayFirst($displayFirst) {
+ $this->displayFirst = $displayFirst;
+ }
+
+ /**
* Sets session object
*
* @author KnowledgeTree Team
@@ -326,10 +356,15 @@ class stepAction {
$top = $this->getTop();
$step_errors = $this->action->getErrors(); // Get errors
$step_warnings = $this->action->getWarnings(); // Get warnings
- if($this->displayConfirm()) // Check if theres a confirm step
+ if($this->displayConfirm()) { // Check if theres a confirm step
$template = "templates/{$this->stepName}_confirm.tpl";
- else
- $template = "templates/{$this->stepName}.tpl";
+ } else {
+ if($this->displayFirst()) {
+ $template = "templates/{$this->stepName}_confirm.tpl";
+ } else {
+ $template = "templates/{$this->stepName}.tpl";
+ }
+ }
$step_tpl = new Template($template);
$step_tpl->set("errors", $step_errors); // Set template errors
$step_tpl->set("warnings", $step_warnings); // Set template warnings
diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php
index 57080b6..84d0869 100644
--- a/setup/wizard/steps/complete.php
+++ b/setup/wizard/steps/complete.php
@@ -50,10 +50,16 @@ class complete extends Step {
* @var object
*/
private $_dbhandler = null;
-
- private $services_check = 'cross_orange';
+
+ /**
+ * List of services to check
+ *
+ * @access private
+ * @var array
+ */
+ private $services_check = 'tick';
private $paths_check = 'tick';
- private $privileges_check = 'cross';
+ private $privileges_check = 'tick';
private $database_check = 'tick';
protected $silent = true;
@@ -108,18 +114,15 @@ class complete extends Step {
$pathhtml = '
| '
. '%s | '
. '%s | ';
-
// check paths are writeable
if(is_array($paths)) {
foreach ($paths as $path)
{
$output = '';
$result = $this->util->checkPermission($path['path']);
- $output = sprintf($html, $result['class'],
- $path['path'],
- (($result['class'] == 'tick') ? '' : 'error' ),
- (($result['class'] == 'tick') ? 'Writeable' : 'Not Writeable' ));
-
+ $output = sprintf($pathhtml, $result['class'], $path['path'],
+ (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ),
+ (($result['class'] == 'tick') ? 'Writeable' : 'Not Writeable' ));
$this->temp_variables[($path['setting'] != '') ? $path['setting'] : 'config'] = $output;
if($result['class'] != 'tick') {
$this->paths_check = $result['class'];
@@ -129,7 +132,6 @@ class complete extends Step {
$docRoot = $path['path'];
}
}
-
}
// check document path internal/external to web root
@@ -198,10 +200,12 @@ class complete extends Step {
$this->database_check = 'cross';
$this->temp_variables['dbPrivileges'] .= sprintf($html, 'cross', 'class="error"', 'Unable to do a basic database query
Error: '
. $this->_dbhandler->getLastError());
+ $this->privileges_check = 'cross';
}
else
{
$this->temp_variables['dbPrivileges'] .= sprintf($html, 'tick', '', 'Basic database query successful');
+
}
// check transaction support
@@ -228,19 +232,15 @@ class complete extends Step {
private function checkServices()
{
-
- // defaults
-// $this->temp_variables['LuceneServiceStatus'] = 'cross';
-// $this->temp_variables['SchedulerServiceStatus'] = 'cross';
$services = new services();
foreach ($services->getServices() as $serviceName) {
$className = OS.$serviceName;
$service = new $className();
$service->load();
- if($service->status() != 'RUNNING') {
- $this->temp_variables[$serviceName."ServiceStatus"] = 'tick';
+ if($service->status() == 'RUNNING' || $service->status() == 'STARTED') {
+ $this->temp_variables[$serviceName."Status"] = 'tick';
} else {
- $this->temp_variables[$serviceName."ServiceStatus"] = 'cross_orange';
+ $this->temp_variables[$serviceName."Status"] = 'cross_orange';
$this->services_check = 'cross_orange';
}
}
diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php
index 34c8686..211f06c 100644
--- a/setup/wizard/steps/configuration.php
+++ b/setup/wizard/steps/configuration.php
@@ -57,6 +57,7 @@ class configuration extends Step
private $ssl_enabled;
private $done;
public $temp_variables = array("step_name"=>"configuration");
+ public $displayFirst = true;
/**
* Flag to store class information in session
*
@@ -125,6 +126,7 @@ class configuration extends Step
$this->doRun();
return 'landing';
}
+ $this->loadTemplateDefaults();
if($this->next()) {
if($this->doRun()) {
return 'confirm';
@@ -134,9 +136,15 @@ class configuration extends Step
$this->setDetails();
return 'previous';
} else if($this->confirm()) {
- return 'next';
+ if($this->doRun()) {
+ return 'next';
+ }
+ return 'error';
} else if($this->edit()) {
$this->setDetails();
+ if($this->doRun()) {
+
+ }
return 'landing';
}
@@ -144,6 +152,10 @@ class configuration extends Step
return 'landing';
}
+ public function loadTemplateDefaults() {
+ $this->temp_variables['paths_perms'] = 'tick';
+ }
+
/**
* Execute the step
*
@@ -326,19 +338,22 @@ class configuration extends Step
private function getPathInfo($fileSystemRoot)
{
$dirs = $this->getDirectories();
- $varDirectory = $fileSystemRoot . DIRECTORY_SEPARATOR . 'var';
- $this->temp_variables['paths_perms'] = 'tick';
+ $varDirectory = $fileSystemRoot . DS . 'var';
foreach ($dirs as $key => $dir){
$path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path'];
while(preg_match('/\$\{([^}]+)\}/', $path, $matches)){
$path = str_replace($matches[0], $$matches[1], $path);
}
+ if(WINDOWS_OS)
+ $path = preg_replace('/\//', '\\',$path);
- $dirs[$key]['path'] = $path;
+ $dirs[$key]['path'] = $path;
$class = $this->util->checkPermission($path, $dir['create']);
+
if($class['class'] != 'tick') {
$this->temp_variables['paths_perms'] = $class['class'];
+ $this->done = false;
}
$dirs[$key] = array_merge($dirs[$key], $class);
}
@@ -363,8 +378,9 @@ class configuration extends Step
array('name' => 'Log Directory', 'setting' => 'logDirectory', 'path' => '${varDirectory}/log', 'create' => true),
array('name' => 'Temporary Directory', 'setting' => 'tmpDirectory', 'path' => '${varDirectory}/tmp', 'create' => true),
array('name' => 'Uploads Directory', 'setting' => 'uploadDirectory', 'path' => '${varDirectory}/uploads', 'create' => true),
+ array('name' => 'Executables Directory', 'setting' => 'binDirectory', 'path' => '${fileSystemRoot}/bin', 'create' => false),
array('name' => 'Configuration File', 'setting' => '', 'path' => '${fileSystemRoot}/config/config.ini', 'create' => false),
- );
+ );
}
}
?>
\ No newline at end of file
diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php
index d73bb68..29cacc2 100644
--- a/setup/wizard/steps/database.php
+++ b/setup/wizard/steps/database.php
@@ -214,6 +214,15 @@ class database extends Step
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
@@ -232,6 +241,15 @@ class database extends Step
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
@@ -239,6 +257,7 @@ class database extends Step
* @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)
@@ -255,6 +274,7 @@ class database extends Step
*/
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
@@ -262,10 +282,8 @@ class database extends Step
}
}
if($this->setDataFromSession("database")) { // Attempt to set values from session
-
$this->setDetails(); // Set any posted variables
} else {
-
$this->loadDefaults($this->readXml()); // Load default variables from file
}
@@ -311,26 +329,36 @@ class database extends Step
*/
public function doTest() {
if($this->match($this->dmspassword, $this->getPassword1()) != 0) {
- $this->error[] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();
+ $this->error['dmspassword'] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();
return false;
}
if($this->match($this->dmsuserpassword, $this->getPassword2()) != 0) {
- $this->error[] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
+ $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
return false;
}
- if($this->dport == '')
+ if($this->dport == '') {
$con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
- else
+ } else {
$con = $this->_dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
+ }
if (!$con) {
- $this->error[] = "Could not connect";
+ $this->error['con'] = "Could not connect, please check username and password";
return false;
} else {
- $this->error = array(); // Reset usage errors
- return true;
+ 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);
}
@@ -418,10 +446,10 @@ class database extends Step
$this->temp_variables['dhost'] = (string) $simplexml->dhost;
$this->temp_variables['dport'] = (string) $simplexml->dport;
$this->temp_variables['dpassword'] = '';
- $this->temp_variables['dmsname'] = '';
- $this->temp_variables['dmsusername'] = '';
- $this->temp_variables['dmspassword'] = '';
- $this->temp_variables['dmsuserpassword'] = '';
+ $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 {
@@ -521,7 +549,7 @@ class database extends Step
*/
private function installDatabase() {
if($this->dtype == '') {
- $this->error[] = 'No database type selected';
+ $this->error['dtype'] = 'No database type selected';
return 'error';
}
if(!$this->{$this->dtype}()) {
@@ -541,7 +569,7 @@ class database extends Step
$con = $this->connectMysql();
if($con) {
if(!$this->createDB($con)) {
- $this->error[] = "Could not Create Database: ";
+ $this->error['con'] = "Could not Create Database: ";
return false;
}
$this->closeMysql($con);
@@ -559,7 +587,7 @@ class database extends Step
private function connectMysql() {
$con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
if (!$con) {
- $this->error[] = "Could not connect: ";
+ $this->error['con'] = "Could not connect: ";
return false;
}
@@ -579,16 +607,16 @@ class database extends Step
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[] = "Could create database: ";
+ $this->error['con'] = "Could not create database: ";
return false;// cannot overwrite database
}
} else {
- $this->error[] = "Could not drop database: ";
+ $this->error['con'] = "Could not drop database: ";
return false;// cannot overwrite database
}
} else {
if(!$this->create($con)) { // attempt to create the db
- $this->error[] = "Could not create database: ";
+ $this->error['con'] = "Could not create database: ";
return false;// cannot overwrite database
}
}
@@ -596,13 +624,13 @@ class database extends Step
}
if(!$this->createSchema($con)) {
- $this->error[] = "Could not create schema ";
+ $this->error['con'] = "Could not create schema ";
}
if(!$this->populateSchema($con)) {
- $this->error[] = "Could not populate schema ";
+ $this->error['con'] = "Could not populate schema ";
}
if(!$this->applyUpgrades($con)) {
- $this->error[] = "Could not apply updates ";
+ $this->error['con'] = "Could not apply updates ";
}
return true;
@@ -638,7 +666,7 @@ class database extends Step
if($this->_dbhandler->useDb($this->dname)) {
return true;
} else {
- $this->error[] = "Error using database: ";
+ $this->error['con'] = "Error using database: {$this->dname}";
return false;
}
}
@@ -655,11 +683,11 @@ class database extends Step
if($this->ddrop) {
$sql = "DROP DATABASE {$this->dname};";
if(!$this->_dbhandler->query($sql)) {
- $this->error[] = "Cannot drop database: ";
+ $this->error['con'] = "Cannot drop database: {$this->dname}";
return false;
}
} else {
- $this->error[] = "Cannot drop database: ";
+ $this->error['con'] = "Cannot drop database: {$this->dname}";
return false;
}
return true;
@@ -688,7 +716,7 @@ class database extends Step
if ($this->_dbhandler->execute($user1) && $this->_dbhandler->execute($user2)) {
return true;
} else {
- $this->error[] = "Could not create users in database: ";
+ $this->error['con'] = "Could not create users for database: {$this->dname}";
return false;
}
}
@@ -756,7 +784,7 @@ class database extends Step
try {
$this->_dbhandler->close();
} catch (Exeption $e) {
- $this->error[] = "Could not close: " . $e;
+ $this->error['con'] = "Could not close: " . $e;
}
}
@@ -784,5 +812,19 @@ class database extends Step
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/registration.php b/setup/wizard/steps/registration.php
index 6f636b6..207913f 100644
--- a/setup/wizard/steps/registration.php
+++ b/setup/wizard/steps/registration.php
@@ -430,7 +430,7 @@ class registration extends Step
'RO' => 'ROMANIA',
'RU' => 'RUSSIAN FEDERATION',
'RW' => 'RWANDA',
- 'BL' => 'SAINT BARTHƒLEMY',
+ 'BL' => 'SAINT BARTH�LEMY',
'SH' => 'SAINT HELENA',
'KN' => 'SAINT KITTS AND NEVIS',
'LC' => 'SAINT LUCIA',
diff --git a/setup/wizard/steps/services.php b/setup/wizard/steps/services.php
index b792e66..8884a42 100644
--- a/setup/wizard/steps/services.php
+++ b/setup/wizard/steps/services.php
@@ -80,6 +80,24 @@ class services extends Step
private $javaCheck = 'cross';
/**
+ * Flag if services are already Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $alreadyInstalled = false;
+
+ /**
+ * PHP Installed
+ *
+ * @author KnowledgeTree Team
+ * @access private
+ * @var mixed
+ */
+ private $phpCheck = 'cross_orange';
+
+ /**
* Java Bridge Installed
*
* @author KnowledgeTree Team
@@ -104,7 +122,7 @@ class services extends Step
* @access public
* @var boolean
*/
- protected $storeInSession = false;
+ protected $storeInSession = true;
/**
* List of variables to be loaded to template
@@ -140,9 +158,17 @@ class services extends Step
* @access public
* @var mixed
*/
- private $javaExeError = false;
+ private $javaExeError = '';
/**
+ * Holds path error, if php is specified
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @var mixed
+ */
+ private $phpExeError = '';
+ /**
* Constructs services object
*
* @author KnowledgeTree Team
@@ -205,6 +231,7 @@ class services extends Step
if($this->java != '') { // Java JRE Found
$this->javaCheck = 'tick';
$this->javaInstalled();
+ $this->temp_variables['java']['location'] = $this->java;
}
}
@@ -217,23 +244,64 @@ class services extends Step
* @return boolean
*/
private function doRun() {
- $this->java = $this->util->getJava(); // Get java, if it exists
- $this->javaChecks(); // Run Pre Checks
- $errors = $this->getErrors(); // Get errors
- if(empty($errors)) { // Install Service if there is no errors
- $this->installService();
- } else { // Services not installed
- foreach ($this->getServices() as $serviceName) {
- $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$serviceName." Could not be added as a Service");
+ if($this->alreadyInstalled()) {
+ $this->alreadyInstalled = true;
+ $this->serviceCheck = 'tick';
+ } else {
+ $this->php = $this->util->getPhp(); // Get java, if it exists
+ $this->java = $this->util->getJava(); // Get java, if it exists
+ $passedPhp = $this->phpChecks(); // Run Java Pre Checks
+ $passedJava = $this->javaChecks(); // Run Java Pre Checks
+ $errors = $this->getErrors(); // Get errors
+ if(empty($errors) && $passedJava && $passedPhp) { // Install Service if there is no errors
+ $this->installServices();
+ } elseif ($passedPhp) { // Install Scheduler
+ $this->installService('Scheduler');
+ } elseif ($passedJava) { // Install Lucene
+ $this->installService('Lucene');
+ } else { // All Services not installed
}
- $this->serviceCheck = 'cross_orange';
- }
+ }
+ $this->checkServiceStatus();
$this->storeSilent(); // Store info needed for silent mode
if(!empty($errors))
return false;
return true;
}
+ function checkServiceStatus() {
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $status = $this->serviceStatus($service);
+ if($status != 'STARTED') {
+ $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$service->getName()." Could not be added as a Service");
+ $this->serviceCheck = 'cross_orange';
+ } 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");
+ }
+ }
+ }
+ }
+
+ function alreadyInstalled() {
+ $installed = true;
+ $serverDetails = $this->getServices();
+ foreach ($serverDetails as $serviceName) {
+ $className = OS.$serviceName;
+ $service = new $className();
+ $status = $this->serviceStatus($service);
+ if($status != 'STARTED') {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* Do some basic checks to help the user overcome java problems
*
@@ -251,10 +319,36 @@ class services extends Step
$this->disableExtension = true; // Disable the use of the php bridge extension
return $this->detSettings(); // AutoDetect java settings
} else {
- return $this->useBridge(); // Use Bridge to get java settings
+ $auto = $this->useBridge(); // Use Bridge to get java settings
+ if($auto) {
+ return $auto;
+ } else {
+ $this->specifyJava(); // Ask for settings
+ }
+ return $auto;
}
}
-
+
+ private function specifyJava() {
+ $this->javaExeError = true;
+ }
+
+ private function specifyPhp() {
+ $this->phpExeError = 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
*
@@ -280,18 +374,41 @@ class services extends Step
$this->javaVersionCorrect();
$this->javaInstalled();
$this->javaCheck = 'tick';
+
return true;
}
} else {
$this->javaVersionWarning();
$this->javaCheck = 'cross_orange';
- $this->javaExeError = "Incorrect path specified";
+ $this->javaExeError = "Java : Incorrect path specified";
$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
*
@@ -320,6 +437,7 @@ class services extends Step
return true;
}
} else {
+ $this->javaCheck = 'cross_orange';
$this->javaVersionWarning();
$this->zendBridgeWarning();
$this->warnings[] = "Zend Java Bridge Not Functional";
@@ -370,27 +488,36 @@ class services extends Step
*
* @author KnowledgeTree Team
* @param none
- * @access public
+ * @access private
* @return boolean
*/
- public function installService() {
+ private function installServices() {
foreach ($this->getServices() as $serviceName) {
- $className = OS.$serviceName;
- $service = new $className();
- $status = $this->serviceHelper($service);
- if ($status) {
- $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service");
- } else {
- $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$service->getName()." Could not be added as a Service");
- $this->serviceCheck = 'cross_orange';
- }
+ $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';
+ }
+ }
+
/**
- * Executes services
+ * Installs services
*
* @author KnowledgeTree Team
* @param object
@@ -405,6 +532,20 @@ class services extends Step
}
/**
+ * Returns service status
+ *
+ * @author KnowledgeTree Team
+ * @param object
+ * @access private
+ * @return string
+ */
+ private function serviceStatus($service) {
+ $service->load(); // Load Defaults
+ $statusCheck = OS."ServiceInstalled";
+ return $this->$statusCheck($service);
+ }
+
+ /**
* Check if windows service installed
*
* @author KnowledgeTree Team
@@ -414,8 +555,7 @@ class services extends Step
*/
public function windowsServiceInstalled($service) {
$status = $service->status(); // Check if service has been installed
- if($status != 'STOPPED') { // Check service status
- $this->error[] = $service->getName()." Could not be added as a Service";
+ if($status == '') { // Check service status
return false;
}
return true;
@@ -432,7 +572,6 @@ class services extends Step
public function unixServiceInstalled($service) {
$status = $service->status(); // Check if service has been installed
if($status != 'STARTED') { // Check service status
- $this->error[] = $service->getName()." Could not be added as a Service";
return false;
}
return true;
@@ -451,9 +590,7 @@ class services extends Step
$className = OS.$serviceName;
$service = new $className();
$status = $this->serviceStart($service);
-
}
-
return true;
}
@@ -621,11 +758,29 @@ class services extends Step
* @return void
*/
private function storeSilent() {
- $this->temp_variables['javaExeError'] = $this->javaExeError;
- $this->temp_variables['javaCheck'] = $this->javaCheck;
- $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
- $this->temp_variables['serviceCheck'] = $this->serviceCheck;
- $this->temp_variables['disableExtension'] = $this->disableExtension;
+ $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled;
+ $this->temp_variables['javaExeError'] = $this->javaExeError;
+ $this->temp_variables['javaCheck'] = $this->javaCheck;
+ $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
+ $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;
+ }
+
+ 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;
+ }
}
?>
\ No newline at end of file
diff --git a/setup/wizard/templates/complete.tpl b/setup/wizard/templates/complete.tpl
index c43a51f..047728e 100644
--- a/setup/wizard/templates/complete.tpl
+++ b/setup/wizard/templates/complete.tpl
@@ -33,7 +33,6 @@ if($errors || $warnings){
-
"; ?>Database connectivity
@@ -60,7 +59,6 @@ if($errors || $warnings){
-
@@ -78,19 +77,19 @@
An administrative user is required for creating tables within the database.