diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php
index 26fb90b..e9d872b 100644
--- a/setup/migrate/steps/migrateDatabase.php
+++ b/setup/migrate/steps/migrateDatabase.php
@@ -122,16 +122,16 @@ class migrateDatabase extends Step
$manual = false; // If file was exported manually
$dbSettings = $installation['dbSettings'];
$location = $installation['location'];
- $uname = $this->temp_variables['duname'];
- $pwrd = $this->temp_variables['dpassword'];
+// $uname = $this->temp_variables['duname'];
+// $pwrd = $this->temp_variables['dpassword'];
$port = $this->util->getPort($location);
$tmpFolder = $this->resolveTempDir();
if(WINDOWS_OS) {
$termOrBash = "command prompt window";
- $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump
+ $exe = DS."$location".DS."mysql".DS."bin".DS."mysqldump.exe".DS; // Location of dump
} else {
$termOrBash = "terminal window";
- $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump
+ $exe = "'$location".DS."mysql".DS."bin".DS."mysqldump'"; // Location of dump
}
$date = date('Y-m-d-H-i-s');
if(isset($database['manual_export'])) {
@@ -147,7 +147,7 @@ class migrateDatabase extends Step
if(!$manual) { // Try to export database
$sqlFile = $tmpFolder."/kt-backup-$date.sql";
$cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
- $response = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
if(file_exists($sqlFile)) {
$fileContents = file_get_contents($sqlFile);
diff --git a/setup/migrate/steps/migrateInstallation.php b/setup/migrate/steps/migrateInstallation.php
index e935c72..cc4f25b 100644
--- a/setup/migrate/steps/migrateInstallation.php
+++ b/setup/migrate/steps/migrateInstallation.php
@@ -85,10 +85,6 @@ class migrateInstallation extends step
private $ktSettings = array();
private $urlPaths = array();
-
- private $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path");
-
- private $knownUnixLocations = array("/opt/ktdms","/var/www/ktdms");
/**
* Installation Settings
@@ -132,12 +128,14 @@ class migrateInstallation extends step
public function detectInstallation() {
if(WINDOWS_OS) {
- foreach ($this->knownWindowsLocations as $loc=>$configPath) {
+ $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path");
+ foreach ($knownWindowsLocations as $loc=>$configPath) {
if(file_exists($configPath))
$this->location = $loc;
}
} else {
- foreach ($this->knownUnixLocations as $loc=>$configPath) {
+ $knownUnixLocations = array("/opt/ktdms"=>"/opt/ktdms/knowledgeTree/config/config-path","/var/www/ktdms"=>"/var/www/ktdms/knowledgeTree/config/config-path");
+ foreach ($knownUnixLocations as $loc=>$configPath) {
if(file_exists($configPath))
$this->location = $loc;
}
@@ -162,9 +160,10 @@ class migrateInstallation extends step
if($this->foundVersion < $this->supportedVersion) {
$this->versionError = true;
$this->error[] = "KT installation needs to be 3.6.1 or higher";
- } else {
- return true;
+ return false;
}
+
+ return true;
}
public function readVersion() {
@@ -222,6 +221,8 @@ class migrateInstallation extends step
} else {
$this->error[] = "Please Enter a Location";
}
+
+ return false;
}
private function loadConfig($path) {
@@ -246,7 +247,7 @@ class migrateInstallation extends step
$this->ktSettings = array('fileSystemRoot'=> $froot,
);
// $urlPaths = $ini->getSection('urls');
- $urlPaths = $this->util->iniUtilities->getSection('urls');
+// $urlPaths = $this->util->iniUtilities->getSection('urls');
$varDir = $froot.DS.'var';
$this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir),
array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'),
diff --git a/setup/migrate/steps/migrateServices.php b/setup/migrate/steps/migrateServices.php
index 756ec5d..098a58c 100644
--- a/setup/migrate/steps/migrateServices.php
+++ b/setup/migrate/steps/migrateServices.php
@@ -201,11 +201,11 @@ class migrateServices extends Step
*/
public function unixStop() {
$cmd = $this->conf['location']."/dmsctl.sh stop lucene";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = $this->conf['location']."/dmsctl.sh stop scheduler";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = $this->conf['location']."/dmsctl.sh stop soffice";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
/**
@@ -214,11 +214,11 @@ class migrateServices extends Step
*/
public function windowsStop() {
$cmd = "sc delete KTLucene";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = "sc delete KTScheduler";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = "sc delete KTOpenoffice";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
/**
@@ -232,7 +232,7 @@ class migrateServices extends Step
$serv->load();
$sStatus = $serv->status();
if($sStatus != '') {
- $res = $serv->uninstall();
+ $serv->uninstall();
}
}
}
diff --git a/setup/wizard/dbUtilities.php b/setup/wizard/dbUtilities.php
index de7f26d..e019e60 100644
--- a/setup/wizard/dbUtilities.php
+++ b/setup/wizard/dbUtilities.php
@@ -105,15 +105,13 @@ class dbUtilities {
}
public function load($dhost = 'localhost', $duname, $dpassword, $dbname) {
- if($this->isConnected($dhost, $duname, $dpassword, $dbname)) return true;
- $this->dbhost = $dhost;
- $this->dbuname = $duname;
- $this->dbpassword = $dpassword;
- $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword);
- if(!$this->dbconnection) {
- $this->error[] = @mysql_error();
+ if(!$this->isConnected($dhost, $duname, $dpassword, $dbname)) {
+ $this->dbhost = $dhost;
+ $this->dbuname = $duname;
+ $this->dbpassword = $dpassword;
+ $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword);
+ $this->dbname = $dbname;
}
- $this->dbname = $dbname;
}
public function isConnected($dhost = 'localhost', $duname, $dpassword, $dbname) {
@@ -235,6 +233,9 @@ class dbUtilities {
* @return array.
*/
public function getErrors() {
+ if(!$this->dbconnection) {
+ $this->error[] = @mysql_error();
+ }
return $this->error;
}
diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php
index e3488ae..eae907b 100644
--- a/setup/wizard/iniUtilities.php
+++ b/setup/wizard/iniUtilities.php
@@ -67,23 +67,23 @@ class iniUtilities {
function backupIni($iniFile)
{
$content = file_get_contents($iniFile);
- if ($content === false)
+ if (!$content === false)
{
- return false;
- }
- $date = date('YmdHis');
-
- $backupFile = $iniFile . '.' .$date;
- if (is_writeable($backupFile)) {
- file_put_contents($backupFile, $content);
- }
+ $date = date('YmdHis');
+
+ $backupFile = $iniFile . '.' .$date;
+ if (is_writeable($backupFile)) {
+ file_put_contents($backupFile, $content);
+ }
+ }
+ return false;
}
function read($iniFile) {
$iniArray = file($iniFile);
$section = '';
foreach($iniArray as $iniLine) {
- $this->lineNum++;
+ ++$this->lineNum;
$iniLine = trim($iniLine);
$firstChar = substr($iniLine, 0, 1);
if($firstChar == ';') {
@@ -163,12 +163,12 @@ class iniUtilities {
}
function itemExists($checkSection, $checkItem) {
-
$this->exists = '';
foreach($this->cleanArray as $section => $items) {
if($section == $checkSection) {
$this->exists = 'section';
- foreach ($items as $key => $value) {
+ $items = array_flip($items);
+ foreach ($items as $key) {
if($key == $checkItem) {
return true;
}
diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php
index 935f5c3..35a241c 100644
--- a/setup/wizard/installUtil.php
+++ b/setup/wizard/installUtil.php
@@ -39,12 +39,11 @@
* @package Installer
* @version Version 0.1
*/
-
-require_once("../wizard/iniUtilities.php");
-require_once("../wizard/dbUtilities.php");
+require_once("path.php"); // Include if util is loaded directly
+require_once(WIZARD_DIR."iniUtilities.php");
+require_once(WIZARD_DIR."dbUtilities.php");
class InstallUtil {
-
private $salt = 'installers';
public $dbUtilities = null;
public $iniUtilities = null;
@@ -78,15 +77,17 @@ class InstallUtil {
public function error($error) {
$template_vars['error'] = $error;
$file = "templates/error.tpl";
- if (!file_exists($file)) {
- return false;
+ if (file_exists($file)) {
+ extract($template_vars); // Extract the vars to local namespace
+ ob_start();
+ include($file);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo $contents;
}
- extract($template_vars); // Extract the vars to local namespace
- ob_start();
- include($file);
- $contents = ob_get_contents();
- ob_end_clean();
- echo $contents;
+
+ return false;
+
}
/**
* Check if system needs to be installed
@@ -173,7 +174,7 @@ class InstallUtil {
return $url;
}
if (!empty($protocol)) {
- $url = $protocol .':'. end($array = explode(':', $url, 2));
+ $url = $protocol .':'. end(explode(':', $url, 2));
}
if (!empty($port)) {
$url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
@@ -333,9 +334,11 @@ class InstallUtil {
return false;
elseif(!is_dir($fullpath)) {
$perms = substr(sprintf('%o', fileperms($fullpath)), -4);
- if($perms != $filemode)
- if (!chmod($fullpath, $filemode))
+ if($perms != $filemode) {
+ if (!chmod($fullpath, $filemode)) {
return false;
+ }
+ }
} elseif(!$this->chmodRecursive($fullpath, $filemode))
return false;
}
@@ -362,7 +365,8 @@ class InstallUtil {
*/
public function canWriteFile($filename) {
$fh = fopen($filename, "w+");
- if($fr = fwrite($fh, 'test') === false) {
+ $fr = fwrite($fh, 'test');
+ if($fr === false) {
return false;
}
@@ -380,9 +384,9 @@ class InstallUtil {
*/
public function javaBridge() {
try {
- $javaSystem = new Java('java.lang.System');
+ new Java('java.lang.System');
} catch (JavaException $e) {
- return false;
+ return $e;
}
return true;
}
@@ -457,6 +461,8 @@ class InstallUtil {
return preg_replace('/java:/', '', $r);
}
}
+
+ return '';
}
/**
@@ -734,6 +740,7 @@ class InstallUtil {
* @return string
*/
public function installEnvironment() {
+ $matches = false;
preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type
if($matches) {
return 'Zend';
@@ -761,7 +768,7 @@ class InstallUtil {
array_pop($sysdir);
array_pop($sysdir);
$zendsys = '';
- foreach ($sysdir as $k=>$v) {
+ foreach ($sysdir as $v) {
$zendsys .= $v.DS;
}
$bin = $zendsys."ZendServer".DS."bin".DS;
@@ -786,15 +793,16 @@ class InstallUtil {
if(WINDOWS_OS) { // Mysql bin [Windows]
$serverPaths = explode(';',$_SERVER['PATH']);
foreach ($serverPaths as $apath) {
+ $matches = false;
preg_match('/mysql/i', $apath, $matches);
if($matches) {
return $apath.DS;
break;
}
}
- } else {
- return "mysql"; // Assume its linux and can be executed from command line
}
+
+ return "mysql"; // Assume its linux and can be executed from command line
}
public function sqlInstallDir() {
diff --git a/setup/wizard/installWizard.php b/setup/wizard/installWizard.php
index a090336..f4b2340 100644
--- a/setup/wizard/installWizard.php
+++ b/setup/wizard/installWizard.php
@@ -63,8 +63,8 @@ function __autoload($class) { // Attempt and autoload classes
if(preg_match('/Helper/', $class)) {
require_once(HELPER_DIR."$class.php");
}
- return null;
}
+ return false;
}
class InstallWizard {
@@ -263,8 +263,6 @@ class InstallWizard {
return true;
break;
}
-
- return $res;
}
/**
diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php
index e3ae105..aa4e06e 100644
--- a/setup/wizard/installer.php
+++ b/setup/wizard/installer.php
@@ -157,7 +157,7 @@ class Installer {
$this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
} catch (Exception $e) {
$util = new InstallUtil();
- $util->error("Error reading configuration file: $name");
+ $util->error("Error reading configuration file: $e");
exit();
}
}
@@ -431,8 +431,7 @@ class Installer {
if($class->runInstall()) { // Check if step needs to be installed
$class->setDataFromSession($className); // Set Session Information
$class->setPostConfig(); // Set any posted variables
- $response = $class->installStep(); // Run install step
- // TODO : Break on error response
+ $class->installStep(); // Run install step
}
} else {
$util = new InstallUtil();
diff --git a/setup/wizard/lib/helpers/htmlHelper.php b/setup/wizard/lib/helpers/htmlHelper.php
index 50150b5..2dbcb7e 100644
--- a/setup/wizard/lib/helpers/htmlHelper.php
+++ b/setup/wizard/lib/helpers/htmlHelper.php
@@ -41,7 +41,7 @@
*/
class htmlHelper {
- var $tags = array(
+ private $tags = array(
'meta' => '',
'metalink' => '',
'link' => '%s',
diff --git a/setup/wizard/lib/services/unixLucene.php b/setup/wizard/lib/services/unixLucene.php
index ff574e1..a0409da 100644
--- a/setup/wizard/lib/services/unixLucene.php
+++ b/setup/wizard/lib/services/unixLucene.php
@@ -59,7 +59,7 @@ class unixLucene extends unixService {
* @param string
* @return void
*/
- public function load($options = null) {
+ public function load() {
$this->setLuceneSource("ktlucene.jar");
$this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS);
$this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS);
@@ -148,14 +148,13 @@ class unixLucene extends unixService {
* @return array
*/
public function stop() {
- // TODO: Breaks things
$state = $this->status();
if($state != '') {
$cmd = "pkill -f ".$this->getLuceneSource();
$response = $this->util->pexec($cmd);
return $response;
}
-
+ return $state;
}
public function install() {
@@ -173,6 +172,7 @@ class unixLucene extends unixService {
if(is_array($response['out'])) {
if(count($response['out']) > 1) {
foreach ($response['out'] as $r) {
+ $matches = false;
preg_match('/grep/', $r, $matches); // Ignore grep
if(!$matches) {
return 'STARTED';
@@ -207,20 +207,14 @@ class unixLucene extends unixService {
$cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!";
if(DEBUG) {
echo "Command : $cmd
";
- return ;
+ return false;
}
$response = $this->util->pexec($cmd);
return $response;
- } elseif ($state == '') {
- // Start Service
- return true;
- } else {
- // Service Running Already
- return true;
}
- return false;
+ return true;
}
public function getName() {
diff --git a/setup/wizard/lib/services/unixOpenOffice.php b/setup/wizard/lib/services/unixOpenOffice.php
index b4b9d1d..86d1066 100644
--- a/setup/wizard/lib/services/unixOpenOffice.php
+++ b/setup/wizard/lib/services/unixOpenOffice.php
@@ -106,13 +106,14 @@ class unixOpenOffice extends unixService {
}
}
- public function status($updrade = false) {
+ public function status() {
sleep(1);
$cmd = "ps ax | grep soffice";
$response = $this->util->pexec($cmd);
if(is_array($response['out'])) {
if(count($response['out']) > 1) {
foreach ($response['out'] as $r) {
+ $matches = false;
preg_match('/grep/', $r, $matches); // Ignore grep
if(!$matches) {
return 'STARTED';
@@ -140,20 +141,13 @@ class unixOpenOffice extends unixService {
$cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -"accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." > /dev/null 2>&1 & echo $!";
if(DEBUG) {
echo "Command : $cmd
";
- return ;
+ return false;
}
- $response = $this->util->pexec($cmd);
-
- return $response;
- } elseif ($state == '') {
- // Start Service
- return true;
- } else {
- // Service Running Already
- return true;
+
+ return $this->util->pexec($cmd);
}
- return false;
+ return true;
}
/**
diff --git a/setup/wizard/lib/validation/openofficeValidation.php b/setup/wizard/lib/validation/openofficeValidation.php
index 3f69fbb..e671729 100644
--- a/setup/wizard/lib/validation/openofficeValidation.php
+++ b/setup/wizard/lib/validation/openofficeValidation.php
@@ -154,7 +154,7 @@ class openofficeValidation extends serviceValidation {
$bin = "soffice";
}
foreach ($locations as $loc) {
- $pathToBinary = $loc.$bin;
+ $pathToBinary = $loc.DS.$bin;
if(file_exists($pathToBinary)) {
return $pathToBinary;
}
diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php
index 83e47cd..75d5fc6 100644
--- a/setup/wizard/steps/configuration.php
+++ b/setup/wizard/steps/configuration.php
@@ -312,23 +312,23 @@ class configuration extends Step
$paths = $conf['paths'];
if ($this->util->isMigration()) { // Check if its an upgrade
$this->readInstallation();
- $configPath = $paths['configFile']['path'];
+ $this->confpaths['configIni'] = $paths['configFile']['path'];
} else {
$this->readConfigPath(); // initialise writing to config.ini
}
$this->getFromConfigPath(); // Sets config Paths
- if(file_exists($configPath)) {
- $this->util->iniUtilities->load($configPath);
+ if(file_exists($this->confpaths['configIni'])) {
+ $this->util->iniUtilities->load($this->confpaths['configIni']);
}
- $this->writeUrlSection();
- $this->writeDBSection($server);
- $this->writeDBPathSection($paths);
- if(!$this->util->iniUtilities === false){ // write out the config.ini file
- $this->util->iniUtilities->write();
+ if(!$this->util->iniUtilities=== false){ // write out the config.ini file
+ $this->writeUrlSection();
+ $this->writeDBSection($server);
+ $this->writeDBPathSection($paths);
+ $this->util->iniUtilities->write();
}
$this->util->dbUtilities->close(); // close the database connection
- $this->writeCachePath(); // Write cache path file
- $this->writeConfigPath($configPath); // Write config file
+ $this->writeCachePath($this->getCachePath(), $paths['cacheDirectory']['path']); // Write cache path file
+ $this->writeConfigPath($this->getContentPath(), $this->confpaths['configIni']); // Write config file
}
private function writeUrlSection() {