diff --git a/config/cache-path b/config/cache-path index 80a084a..e69de29 100644 --- a/config/cache-path +++ b/config/cache-path @@ -1 +0,0 @@ -var/cache diff --git a/config/config-path b/config/config-path index 4bfe59e..2be1a8b 100644 --- a/config/config-path +++ b/config/config-path @@ -1 +1 @@ -config/config.ini +C:\ktdms\config\config.ini \ No newline at end of file diff --git a/config/config.ini b/config/config.ini index 3168122..e97498f 100644 --- a/config/config.ini +++ b/config/config.ini @@ -9,14 +9,14 @@ dbType = mysql ; Database login details -dbHost = localhost -dbName = dms -dbUser = dms -dbPass = djw9281js -dbPort = default +dbHost = localhost +dbName = dms_migrate +dbUser = dmsadmin +dbPass = js9281djw +dbPort = 3306 -dbAdminUser = dmsadmin -dbAdminPass = js9281djw +dbAdminUser = dmsadmin +dbAdminPass = js9281djw [KnowledgeTree] @@ -31,7 +31,7 @@ dbAdminPass = js9281djw ; ; Leave as default to have it automatically detected. ; -fileSystemRoot = default +fileSystemRoot = D:/Program Files/Zend/Apache2/htdocs/knowledgetree ; Webserver name (host name) ; @@ -43,7 +43,7 @@ serverName = default ; ; Leave as default to have it automatically detected. ; -sslEnabled = default +sslEnabled = false ; Path to the web application from the root of the web site. ; If KT is at http://example.org/foo/, then rootUrl should be '/foo' @@ -115,11 +115,11 @@ phpErrorLogFile = false [urls] ; directories -varDirectory = ${fileSystemRoot}/var -logDirectory = ${varDirectory}/log -documentRoot = ${varDirectory}/Documents +varDirectory = C:\Program Files\ktdms\var +logDirectory = C:\Program Files\ktdms\var\log +documentRoot = C:\Program Files\ktdms\var\Documents uiDirectory = ${fileSystemRoot}/presentation/lookAndFeel/knowledgeTree -tmpDirectory = ${varDirectory}/tmp +tmpDirectory = C:\Program Files\ktdms\var\tmp ;dedicated feed url ;dedicatedrsstitle = RSS Feed Title @@ -146,4 +146,4 @@ encoding = default ; cacheEnabled = true cacheDirectory = ${varDirectory}/cache -cachePlugins = true \ No newline at end of file +cachePlugins = true diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php index 28fd474..ac07f0f 100644 --- a/setup/migrate/migrateUtil.php +++ b/setup/migrate/migrateUtil.php @@ -63,14 +63,14 @@ class MigrateUtil extends InstallUtil { $template_vars['error'] = $error; $file = "templates/error.tpl"; if (!file_exists($file)) { - return false; + 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; } /** @@ -89,19 +89,10 @@ class MigrateUtil extends InstallUtil { return true; } - - public function loadInstallDBUtil() { - require_once("../wizard/dbUtilities.php"); - return new dbUtilities(); - } - - public function loadInstallUtil() { - require_once("../wizard/steps/services.php"); - return new services(); - } public function loadInstallServices() { - $s = $this->loadInstallUtil(); + require_once("../wizard/steps/services.php"); + $s = new services(); return $s->getServices(); } @@ -112,11 +103,6 @@ class MigrateUtil extends InstallUtil { return new $serviceName(); } - public function loadInstallIni($path) { - require_once("../wizard/iniUtilities.php"); - return new iniUtilities($path); - } - public function getPort($location) { if(WINDOWS_OS) { $myIni = "my.ini"; @@ -125,8 +111,8 @@ class MigrateUtil extends InstallUtil { } $dbConfigPath = $location.DS."mysql".DS."$myIni"; if(file_exists($dbConfigPath)) { - $ini = $this->loadInstallIni($dbConfigPath); - $dbSettings = $ini->getSection('mysqladmin'); + $this->iniUtilities->load($dbConfigPath); + $dbSettings = $this->iniUtilities->getSection('mysqladmin'); return $dbSettings['port']; } diff --git a/setup/migrate/migrateWizard.php b/setup/migrate/migrateWizard.php index 0bb58d0..03c93fe 100644 --- a/setup/migrate/migrateWizard.php +++ b/setup/migrate/migrateWizard.php @@ -52,16 +52,14 @@ function __autoload($class) { // Attempt and autoload classes if ($class == "template") { // Load existing templating classes require_once("../wizard/template.php"); require_once("../wizard/lib/helpers/htmlHelper.php"); - return ; - } - if(file_exists(WIZARD_DIR."$class.php")) { - require_once(WIZARD_DIR."$class.php"); - } elseif (file_exists(STEP_DIR."$class.php")) { - require_once(STEP_DIR."$class.php"); - } elseif (file_exists(WIZARD_LIB."$class.php")) { - require_once(WIZARD_LIB."$class.php"); } else { - return null; + if(file_exists(WIZARD_DIR."$class.php")) { + require_once(WIZARD_DIR."$class.php"); + } elseif (file_exists(STEP_DIR."$class.php")) { + require_once(STEP_DIR."$class.php"); + } elseif (file_exists(WIZARD_LIB."$class.php")) { + require_once(WIZARD_LIB."$class.php"); + } } } @@ -233,8 +231,6 @@ class MigrateWizard { return true; break; } - - return $res; } /** diff --git a/setup/migrate/migrater.php b/setup/migrate/migrater.php index 249fa36..86f78f5 100644 --- a/setup/migrate/migrater.php +++ b/setup/migrate/migrater.php @@ -157,7 +157,7 @@ class Migrater { $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); } catch (Exception $e) { $util = new MigrateUtil(); - $util->error("Error reading configuration file: $name"); + $util->error("Error reading configuration file: $e"); exit(); } } @@ -431,8 +431,7 @@ class Migrater { if($class->runMigrate()) { // Check if step needs to be migrated $class->setDataFromSession($className); // Set Session Information $class->setPostConfig(); // Set any posted variables - $response = $class->migrateStep(); // Run migrate step - // TODO : Break on error response + $class->migrateStep(); // Run migrate step } } else { $util = new MigrateUtil(); diff --git a/setup/migrate/step.php b/setup/migrate/step.php index 897b710..315fd53 100644 --- a/setup/migrate/step.php +++ b/setup/migrate/step.php @@ -128,7 +128,6 @@ class Step public function __construct() { $this->util = new MigrateUtil(); - $this->dbhandler = $this->util->loadInstallDBUtil(); } /** diff --git a/setup/migrate/stepAction.php b/setup/migrate/stepAction.php index 30724ed..e804976 100644 --- a/setup/migrate/stepAction.php +++ b/setup/migrate/stepAction.php @@ -224,17 +224,18 @@ class stepAction { if($this->action->storeInSession()) { // Check if class values need to be stored in session $this->_loadStepToSession($this->stepName); // Send class to session } - if ($response == 'error') { - $this->_handleErrors(); // Send Errors to session - } else { - $this->_clearErrors($this->stepName); // Send Errors to session - } - return $response; } else { $this->stepName = 'errors'; $this->action = $this->createStep(); $this->action->error = array('Class File Missing in Step Directory'); + + } + if ($response == 'error') { + $this->_handleErrors(); // Send Errors to session + } else { + $this->_clearErrors($this->stepName); // Send Errors to session } + return $response; } /** @@ -308,7 +309,7 @@ class stepAction { $menu = ''; $active = false; if($this->stepClassNames) { - foreach ($this->stepClassNames as $k=>$step) { + foreach ($this->stepClassNames as $step) { if($this->step_names[$step] != '') { $item = $this->step_names[$step]; } else { @@ -452,7 +453,7 @@ class stepAction { * @access private * @return void */ - private function _loadValueToSession($class, $k, $v, $overwrite = false) { + private function _loadValueToSession($class, $k, $v) { if($this->session != null) { $this->session->setClass($class, $k, $v); } else { @@ -502,8 +503,7 @@ class stepAction { * @access private * @return void */ - private function _loadErrorToSession($class, $k, $v, $overwrite = false) { - $k = "errors"; + private function _loadErrorToSession($class, $k = "errors", $v) { if($this->session != null) { $this->session->setClassError($class, $k, $v); } else { diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php index 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 07230bb..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,11 +221,15 @@ class migrateInstallation extends step } else { $this->error[] = "Please Enter a Location"; } + + return false; } private function loadConfig($path) { - $ini = $this->util->loadInstallIni($path); - $dbSettings = $ini->getSection('db'); +// $ini = $this->util->loadInstallIni($path); + $this->util->iniUtilities->load($path); +// $dbSettings = $ini->getSection('db'); + $dbSettings = $this->util->iniUtilities->getSection('db'); $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], 'dbName'=> $dbSettings['dbName'], 'dbUser'=> $dbSettings['dbUser'], @@ -235,14 +238,16 @@ class migrateInstallation extends step 'dbAdminUser'=> $dbSettings['dbAdminUser'], 'dbAdminPass'=> $dbSettings['dbAdminPass'], ); - $ktSettings = $ini->getSection('KnowledgeTree'); + $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree'); +// $ktSettings = $ini->getSection('KnowledgeTree'); $froot = $ktSettings['fileSystemRoot']; if ($froot == 'default') { $froot = $this->location; } $this->ktSettings = array('fileSystemRoot'=> $froot, ); - $urlPaths = $ini->getSection('urls'); +// $urlPaths = $ini->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 b0bc18e..098a58c 100644 --- a/setup/migrate/steps/migrateServices.php +++ b/setup/migrate/steps/migrateServices.php @@ -127,7 +127,6 @@ class migrateServices extends Step public function doStep() { $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent); - $this->installServices = $this->util->loadInstallUtil(); // Use installer utility class $this->services = $this->util->loadInstallServices(); // Use installer services class $this->storeSilent(); if(!$this->inStep("services")) { @@ -202,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); } /** @@ -215,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); } /** @@ -233,7 +232,7 @@ class migrateServices extends Step $serv->load(); $sStatus = $serv->status(); if($sStatus != '') { - $res = $serv->uninstall(); + $serv->uninstall(); } } } diff --git a/setup/upgrade/step.php b/setup/upgrade/step.php index e762275..6a66986 100644 --- a/setup/upgrade/step.php +++ b/setup/upgrade/step.php @@ -110,7 +110,7 @@ class Step public function __construct() { $this->util = new UpgradeUtil(); - $this->dbhandler = $this->util->loadInstallDBUtil(); + //$this->dbhandler = $this->util->dbUtilities; } /** diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index 8987695..88e8cda 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -242,7 +242,9 @@ class upgradeDatabase extends Step } private function readConfig($path) { - $ini = $this->util->loadInstallIni($path); + //$ini = $this->util->loadInstallIni($path); + $ini = $this->util->iniUtilities; + $ini->load($path); $dbSettings = $ini->getSection('db'); $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], 'dbName'=> $dbSettings['dbName'], diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php index c3df258..ae86767 100644 --- a/setup/upgrade/steps/upgradeWelcome.php +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -40,6 +40,9 @@ * @version Version 0.1 */ +//require_once('../../config/dmsDefaults.php'); +//require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; + class upgradeWelcome extends step { protected $silent = false; @@ -91,15 +94,9 @@ class upgradeWelcome extends step { $dconf = $ini->getSection('db'); $this->dbhandler->load($dconf['dbHost'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); } - $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; - $res = $this->dbhandler->query($sQuery); - $ass = $this->dbhandler->fetchAssoc($res); - if(isset($ass[0]['match_count'])) { - if($ass[0]['match_count']) - return true; - } $this->error[] = 'Could Not Authenticate User'; return false; + } public function getErrors() { diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php index 1816df1..ad78277 100644 --- a/setup/upgrade/upgradeUtil.php +++ b/setup/upgrade/upgradeUtil.php @@ -40,10 +40,9 @@ * @version Version 0.1 */ -//require_once('../../config/dmsDefaults.php'); require_once("../wizard/installUtil.php"); -class UpgradeUtil extends InstallUtil { +class UpgradeUtil extends InstallUtil { /** * Check if system needs to be upgraded * @@ -75,16 +74,6 @@ class UpgradeUtil extends InstallUtil { echo $contents; } - public function loadInstallIni($path) { - require_once("../wizard/iniUtilities.php"); - return new iniUtilities($path); - } - - public function loadInstallDBUtil() { - require_once("../wizard/dbUtilities.php"); - return new dbUtilities(); - } - /** * Function to send output to the browser prior to normal dynamic loading of a template after code execution * 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 81c2914..eae907b 100644 --- a/setup/wizard/iniUtilities.php +++ b/setup/wizard/iniUtilities.php @@ -43,11 +43,8 @@ class iniUtilities { private $lineNum = 0; private $exists = ''; - function iniUtilities() { - $this->iniFile = ''; - } - - function load($iniFile) { + + function load($iniFile) { if($this->iniFile != $iniFile) { $this->cleanArray = array(); $this->lineNum = 0; @@ -56,9 +53,11 @@ class iniUtilities { $this->iniFile = $iniFile; $this->backupIni($iniFile); $this->read($iniFile); - } + function __construct() { + } + /** * Create a backup with the date as an extension in the same location as the original config.ini * @@ -68,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 == ';') { @@ -164,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 47bd88d..35a241c 100644 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -39,13 +39,14 @@ * @package Installer * @version Version 0.1 */ - +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 $dbHandler = null; - public $iniHandler = null; + public $dbUtilities = null; + public $iniUtilities = null; /** * Constructs installation object @@ -54,8 +55,8 @@ class InstallUtil { * @access public */ public function __construct() { - $this->dbHandler = new dbUtilities(); - $this->iniHandler = new iniUtilities(); + $this->dbUtilities = new dbUtilities(); + $this->iniUtilities = new iniUtilities(); } /** @@ -76,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 @@ -171,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', @@ -331,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; } @@ -360,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; } @@ -378,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; } @@ -455,6 +461,8 @@ class InstallUtil { return preg_replace('/java:/', '', $r); } } + + return ''; } /** @@ -732,6 +740,7 @@ class InstallUtil { * @return string */ public function installEnvironment() { + $matches = false; preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type if($matches) { return 'Zend'; @@ -759,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; @@ -784,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/step.php b/setup/wizard/step.php index 456ac8f..35edf1a 100644 --- a/setup/wizard/step.php +++ b/setup/wizard/step.php @@ -127,7 +127,6 @@ class Step // public $dbhandler; public function __construct() { -// $this->dbhandler = new dbUtilities(); $this->util = new InstallUtil(); } /** diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php index 3108468..e3b66cf 100644 --- a/setup/wizard/steps/complete.php +++ b/setup/wizard/steps/complete.php @@ -142,8 +142,8 @@ class complete extends Step { // retrieve database information from session $dbconf = $this->getDataFromSession("database"); // make db connection - admin - $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); - $loaded = $this->util->dbHandler->getDatabaseLink(); + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); + $loaded = $this->util->dbUtilities->getDatabaseLink(); if (!$loaded) { $this->temp_variables['dbConnectAdmin'] .= '
' . 'Unable to connect to database (user: ' @@ -157,20 +157,20 @@ class complete extends Step { } // make db connection - user - $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); - $loaded = $this->util->dbHandler->getDatabaseLink(); + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); + $loaded = $this->util->dbUtilities->getDatabaseLink(); // if we can log in to the database, check access // TODO check write access? if ($loaded) { $this->temp_variables['dbConnectUser'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: ' . $dbconf['dmsusername'] . ')'); - $qresult = $this->util->dbHandler->query('SELECT COUNT(id) FROM documents'); + $qresult = $this->util->dbUtilities->query('SELECT COUNT(id) FROM documents'); if (!$qresult) { $this->temp_variables['dbPrivileges'] .= '
' . '' - . 'Unable to do a basic database query. Error: ' . $this->util->dbHandler->getLastError() + . 'Unable to do a basic database query. Error: ' . $this->util->dbUtilities->getLastError() . ''; $this->privileges_check = 'cross'; $this->privileges_check = 'cross'; @@ -183,17 +183,17 @@ class complete extends Step { // check transaction support $sTable = 'system_settings'; - $this->util->dbHandler->startTransaction(); - $this->util->dbHandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); - $this->util->dbHandler->rollback(); - $res = $this->util->dbHandler->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); + $this->util->dbUtilities->startTransaction(); + $this->util->dbUtilities->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); + $this->util->dbUtilities->rollback(); + $res = $this->util->dbUtilities->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); if (!$res) { $this->temp_variables['dbTransaction'] .= sprintf($html, 'cross', 'class="error"', 'Transaction support not available in database'); $this->privileges_check = 'cross'; } else { $this->temp_variables['dbTransaction'] .= sprintf($html, 'tick', '', 'Database has transaction support'); } - $this->util->dbHandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); + $this->util->dbUtilities->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); } else { diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index 197dfa1..75d5fc6 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -307,26 +307,26 @@ class configuration extends Step { $conf = $this->getDataFromSession("configuration"); // get data from the server $dbconf = $this->getDataFromSession("database"); - $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); $server = $conf['server']; $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($this->confpaths['configIni'])) { - $this->util->iniHandler->load($this->confpaths['configIni']); + $this->util->iniUtilities->load($this->confpaths['configIni']); } - if(!$this->util->iniHandler === false){ // write out the config.ini file + if(!$this->util->iniUtilities=== false){ // write out the config.ini file $this->writeUrlSection(); $this->writeDBSection($server); $this->writeDBPathSection($paths); - $this->util->iniHandler->write(); + $this->util->iniUtilities->write(); } - $this->util->dbHandler->close(); // close the database connection + $this->util->dbUtilities->close(); // close the database connection $this->writeCachePath($this->getCachePath(), $paths['cacheDirectory']['path']); // Write cache path file $this->writeConfigPath($this->getContentPath(), $this->confpaths['configIni']); // Write config file } @@ -334,7 +334,7 @@ class configuration extends Step private function writeUrlSection() { $directories = $this->registerDirs(); foreach($directories as $item) { // write server settings to config_settings table and config.ini - $this->util->iniHandler->updateItem($item['section'], $item['setting'], $item['value']); + $this->util->iniUtilities->updateItem($item['section'], $item['setting'], $item['value']); } } @@ -348,14 +348,14 @@ class configuration extends Step $value = mysql_real_escape_string($item['path']); $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; - $this->util->dbHandler->query($sql); + $this->util->dbUtilities->query($sql); } } } private function writeDBSection($server) { $dbconf = $this->getDataFromSession("database"); // retrieve database information from session - $this->util->dbHandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables $table = 'config_settings'; foreach($server as $item) { // write server settings to config_settings table and config.ini @@ -368,14 +368,14 @@ class configuration extends Step if($value == 'no'){ $value = 'false'; } - $this->util->iniHandler->updateItem($item['section'], $item['setting'], $value); + $this->util->iniUtilities->updateItem($item['section'], $item['setting'], $value); break; case 'db': $value = mysql_real_escape_string($item['value']); $setting = mysql_real_escape_string($item['setting']); $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; - $this->util->dbHandler->query($sql); + $this->util->dbUtilities->query($sql); break; } } @@ -573,12 +573,13 @@ class configuration extends Step public function readConfigPathIni() { if(isset($this->temp_variables['paths']['configFile']['path'])) { - return $this->temp_variables['paths']['configFile']['path']; + if($this->temp_variables['paths']['configFile']['path'] != '') + return $this->temp_variables['paths']['configFile']['path']; } $configPath = $this->getContentPath(); if(!$configPath) return false; - $this->util->iniHandler->load($configPath); - $data = $this->util->iniHandler->getFileByLine(); + $this->util->iniUtilities->load($configPath); + $data = $this->util->iniUtilities->getFileByLine(); $firstline = true; foreach ($data as $k=>$v) { if(preg_match('/config.ini/', $k)) { // Find config.ini @@ -600,8 +601,8 @@ class configuration extends Step private function readConfigPath() { $configPath = $this->getContentPath(); if(!$configPath) return false; - $this->util->iniHandler->load($configPath); - $data = $this->util->iniHandler->getFileByLine(); + $this->util->iniUtilities->load($configPath); + $data = $this->util->iniUtilities->getFileByLine(); $firstline = true; foreach ($data as $k=>$v) { if($firstline) { // First line holds the var directory diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 5abb6a5..922d5d0 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -320,11 +320,11 @@ class database extends Step return false; } if($this->dport == '') { - $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); + $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); } else { - $this->util->dbHandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname); + $this->util->dbUtilities->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname); } - if (!$this->util->dbHandler->getDatabaseLink()) { + if (!$this->util->dbUtilities->getDatabaseLink()) { $this->error['con'] = "Could not connect to the database, please check username and password"; return false; } else { @@ -339,7 +339,7 @@ class database extends Step } public function dbExists() { - return $this->util->dbHandler->useDb(); + return $this->util->dbUtilities->useDb(); } public function match($str1, $str2) { @@ -500,7 +500,6 @@ class database extends Step * @return object SimpleXmlObject */ public function readXml() { -// echo CONF_DIR."databases.xml"; $simplexml = simplexml_load_file(CONF_DIR."databases.xml"); return $simplexml; @@ -583,7 +582,7 @@ class database extends Step * @return object mysql connection */ private function connectMysql() { - $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); + $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); } /** @@ -642,7 +641,7 @@ class database extends Step $this->error['con'] = "Could not create database: "; } } - $this->util->dbHandler->clearErrors(); + $this->util->dbUtilities->clearErrors(); if(!$this->createDmsUser()) { // Create dms users $this->error['con'] = "Could not create database users "; } @@ -666,8 +665,7 @@ class database extends Step */ private function create() { $sql = "CREATE DATABASE {$this->dname}"; - if ($this->util->dbHandler->query($sql)) { - + if ($this->util->dbUtilities->query($sql)) { return true; } @@ -683,7 +681,7 @@ class database extends Step * @return boolean */ private function usedb() { - if($this->util->dbHandler->useDb()) { + if($this->util->dbUtilities->useDb()) { return true; } else { $this->error['con'] = "Error using database: {$this->dname}"; @@ -702,7 +700,7 @@ class database extends Step private function dropdb() { if($this->ddrop) { $sql = "DROP DATABASE {$this->dname};"; - if(!$this->util->dbHandler->query($sql)) { + if(!$this->util->dbUtilities->query($sql)) { $this->error['con'] = "Cannot drop database: {$this->dname}"; return false; } @@ -724,7 +722,7 @@ class database extends Step private function createDmsUser() { $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->util->dbHandler->query($user1) && $this->util->dbHandler->query($user2)) { + if ($this->util->dbUtilities->query($user1) && $this->util->dbUtilities->query($user2)) { return true; } else { $this->error['con'] = "Could not create users for database: {$this->dname}"; @@ -751,7 +749,7 @@ class database extends Step while (!feof($handle)) { $query.= fgets($handle, 4096); if (substr(rtrim($query), -1) == ';') { - $this->util->dbHandler->query($query); + $this->util->dbUtilities->query($query); $query = ''; } } @@ -778,9 +776,9 @@ class database extends Step $sqlFile = $dbMigrate['dumpLocation']; $this->parse_mysql_dump($sqlFile); $dropPluginHelper = "TRUNCATE plugin_helper;"; - $this->util->dbHandler->query($dropPluginHelper); + $this->util->dbUtilities->query($dropPluginHelper); $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; - $this->util->dbHandler->query($updateUrls); + $this->util->dbUtilities->query($updateUrls); return true; } /** @@ -793,7 +791,7 @@ class database extends Step */ private function closeMysql() { try { - $this->util->dbHandler->close(); + $this->util->dbUtilities->close(); } catch (Exeption $e) { $this->error['con'] = "Could not close: " . $e; } @@ -844,7 +842,7 @@ class database extends Step $this->dpassword = 'root'; $this->dname = 'dms_install'; $this->dbbinary = 'mysql'; - $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); + $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); $this->createSchema(); echo 'Schema loaded
'; } diff --git a/setup/wizard/steps/install.php b/setup/wizard/steps/install.php index 6974716..48ba644 100644 --- a/setup/wizard/steps/install.php +++ b/setup/wizard/steps/install.php @@ -107,14 +107,14 @@ class install extends step public function callHome() { $conf = $this->getDataFromSession("install"); // retrieve database information from session $dbconf = $this->getDataFromSession("database"); - $this->util->dbHandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection $complete = 1; if($conf['call_home'] == 'enable'){ $complete = 0; } $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'"; - $this->util->dbHandler->query($query); - $this->util->dbHandler->close(); // close the database connection + $this->util->dbUtilities->query($query); + $this->util->dbUtilities->close(); // close the database connection } } ?> \ No newline at end of file diff --git a/thirdparty/Smarty/internals/core.write_compiled_resource.php b/thirdparty/Smarty/internals/core.write_compiled_resource.php index b902eff..c3c6a3f 100644 --- a/thirdparty/Smarty/internals/core.write_compiled_resource.php +++ b/thirdparty/Smarty/internals/core.write_compiled_resource.php @@ -17,7 +17,7 @@ function smarty_core_write_compiled_resource($params, &$smarty) if(!@is_writable($smarty->compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($smarty->compile_dir)) { - $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); + $smarty->trigger_error('the '.$compile_dir.' \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); diff --git a/var/bin/taskrunner.bat b/var/bin/taskrunner.bat index 7002021..d25defc 100644 --- a/var/bin/taskrunner.bat +++ b/var/bin/taskrunner.bat @@ -1 +1,2 @@ -// DO NOT DELETE \ No newline at end of file +@echo off +"D:\Program Files\Zend\ZendServer\bin\php.exe" "D:\Program Files\Zend\Apache2\htdocs\knowledgetree\bin\win32\schedulerService.php" \ No newline at end of file