diff --git a/setup/wizard/dbUtil.php b/setup/wizard/dbUtil.php
deleted file mode 100644
index 55c3ed7..0000000
--- a/setup/wizard/dbUtil.php
+++ /dev/null
@@ -1,256 +0,0 @@
-.
-*
-* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
-* California 94120-7775, or email info@knowledgetree.com.
-*
-* The interactive user interfaces in modified source and object code versions
-* of this program must display Appropriate Legal Notices, as required under
-* Section 5 of the GNU General Public License version 3.
-*
-* In accordance with Section 7(b) of the GNU General Public License version 3,
-* these Appropriate Legal Notices must retain the display of the "Powered by
-* KnowledgeTree" logo and retain the original copyright notice. If the display of the
-* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
-* must display the words "Powered by KnowledgeTree" and retain the original
-* copyright notice.
-*
-* @copyright 2008-2009, KnowledgeTree Inc.
-* @license GNU General Public License version 3
-* @author KnowledgeTree Team
-* @package Installer
-* @version Version 0.1
-*/
-class dbUtil {
- /**
- * Host
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $dbhost = '';
-
- /**
- * Host
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $dbname = '';
-
- /**
- * Host
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $dbuname = '';
-
- /**
- * Host
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var string
- */
- protected $dbpassword = '';
-
- /**
- * Host
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var object mysql connection
- */
- protected $dbconnection = '';
-
- /**
- * Any errors encountered
- *
- * @author KnowledgeTree Team
- * @access protected
- * @var array
- */
- protected $error = array();
-
- /**
- * Constructs database connection object
- *
- * @author KnowledgeTree Team
- * @access public
- */
- public function __construct() {
-
- }
-
- public function load($dhost = 'localhost', $duname, $dpassword, $dbname) {
- $this->dbhost = $dhost;
- $this->dbuname = $duname;
- $this->dbpassword = $dpassword;
- $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword);
- if(!$this->dbconnection) {
- $this->error[] = @mysql_error();
- }
- $this->dbname = $dbname;
- }
-
- public function getDatabaseLink() {
- return $this->dbconnection;
- }
- /**
- * Choose a database to use
- *
- * @param string $dbname name of the database
- * @access public
- * @return boolean
- */
- public function useDb() {
- if(@mysql_select_db($this->dbname, $this->dbconnection))
- return true;
- else {
- $this->error[] = @mysql_error($this->dbconnection);
- return false;
- }
- }
-
- public function setDb($dbname) {
- $this->dbname = $dbname;
- }
-
- /**
- * Query the database.
- *
- * @param $query the sql query.
- * @access public
- * @return object The result of the query.
- */
- public function query($query) {
- $this->useDb();
- $result = mysql_query($query, $this->dbconnection);
- if($result) {
- return $result;
- } else {
- $this->error[] = @mysql_error($this->dbconnection);
- return false;
- }
- }
-
- /**
- * Do the same as query.
- *
- * @param $query the sql query.
- * @access public
- * @return boolean
- */
- public function execute($query) {
- $this->useDb();
- $result = @mysql_query($query, $this->dbconnection);
- if(!$result) {
- $this->error[] = @mysql_error($this->dbconnection);
- }
-
- return $result;
- }
-
- /**
- * Convenience method for mysql_fetch_object().
- *
- * @param $result The resource returned by query().
- * @access public
- * @return object An object representing a data row.
- */
- public function fetchNextObject($result = NULL) {
- if ($result == NULL || @mysql_num_rows($result) < 1)
- return NULL;
- else
- return @mysql_fetch_object($result);
- }
-
- /**
- * Convenience method for mysql_fetch_assoc().
- *
- * @param $result The resource returned by query().
- * @access public
- * @return array Returns an associative array of strings.
- */
- public function fetchAssoc($result = NULL) {
- $r = array();
- if ($result == NULL || @mysql_num_rows($result) < 1)
- return NULL;
- else {
- while(($r[] = mysql_fetch_assoc($result)) || array_pop($r));
- return $r;
- }
- }
-
- /**
- * Close the connection with the database server.
- *
- * @param none.
- * @access public
- * @return void.
- */
- public function close() {
- @mysql_close($this->dbconnection);
- }
-
- /**
- * Get database errors.
- *
- * @param none.
- * @access public
- * @return array.
- */
- public function getErrors() {
- return $this->error;
- }
-
- public function clearErrors() {
- return $this->error = array();
- }
-
- /**
- * Fetches the last generated error
-
- * @return string
- */
- function getLastError() {
- return end($this->error);
- }
-
- /**
- * Start a database transaction
- */
- public function startTransaction() {
- $this->query("START TRANSACTION");
- }
-
- /**
- * Roll back a database transaction
- */
- public function rollback() {
- $this->query("ROLLBACK");
- }
-}
-?>
\ No newline at end of file
diff --git a/setup/wizard/dbUtilities.php b/setup/wizard/dbUtilities.php
index ff3af9f..de7f26d 100644
--- a/setup/wizard/dbUtilities.php
+++ b/setup/wizard/dbUtilities.php
@@ -105,6 +105,7 @@ 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;
@@ -115,6 +116,17 @@ class dbUtilities {
$this->dbname = $dbname;
}
+ public function isConnected($dhost = 'localhost', $duname, $dpassword, $dbname) {
+ $current = array($this->dbhost, $this->dbuname, $this->dbpassword, $this->dbname);
+ $new = array($dhost, $duname, $dpassword, $dbname);
+ $diff = array_diff($new, $current);
+ if(count($diff) == 0) {
+ echo 'same';
+ return true;
+ }
+ return false;
+ }
+
public function getDatabaseLink() {
return $this->dbconnection;
}
diff --git a/setup/wizard/ini.php b/setup/wizard/ini.php
deleted file mode 100644
index 3a41f0c..0000000
--- a/setup/wizard/ini.php
+++ /dev/null
@@ -1,223 +0,0 @@
-.
- *
- * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
- * California 94120-7775, or email info@knowledgetree.com.
- *
- * The interactive user interfaces in modified source and object code versions
- * of this program must display Appropriate Legal Notices, as required under
- * Section 5 of the GNU General Public License version 3.
- *
- * In accordance with Section 7(b) of the GNU General Public License version 3,
- * these Appropriate Legal Notices must retain the display of the "Powered by
- * KnowledgeTree" logo and retain the original copyright notice. If the display of the
- * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
- * must display the words "Powered by KnowledgeTree" and retain the original
- * copyright notice.
- * Contributor( s): ______________________________________
- *
- */
-
-class Ini {
-
- private $cleanArray = array();
- private $iniFile = '';
- private $lineNum = 0;
- private $exists = '';
-
- function Ini($iniFile = '../../config.ini') {
- $this->iniFile = $iniFile;
- $this->backupIni($iniFile);
- $this->read($iniFile);
- }
-
- /**
- * Create a backup with the date as an extension in the same location as the original config.ini
- *
- * @param string $iniFile
- * @return boolean
- */
- function backupIni($iniFile)
- {
- $content = file_get_contents($iniFile);
- if ($content === false)
- {
- return false;
- }
- $date = date('YmdHis');
-
- $backupFile = $iniFile . '.' .$date;
- if (is_writeable($backupFile)) {
- file_put_contents($backupFile, $content);
- }
- }
-
- function read($iniFile) {
-
- $iniArray = file($iniFile);
- $section = '';
- foreach($iniArray as $iniLine) {
- $this->lineNum++;
- $iniLine = trim($iniLine);
- $firstChar = substr($iniLine, 0, 1);
- if($firstChar == ';') {
- if($section == ''){
- $this->cleanArray['_comment_'.$this->lineNum]=$iniLine;
- }else {
- $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine;
- }
- continue;
- }
- if($iniLine == '') {
- if($section == ''){
- $this->cleanArray['_blankline_'.$this->lineNum]='';
- }else {
- $this->cleanArray[$section]['_blankline_'.$this->lineNum]='';
- }
- continue;
- }
-
- if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') {
- $section = substr($iniLine, 1, -1);
- $this->sections[] = $section;
- } else {
- $equalsPos = strpos($iniLine, '=');
- if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) {
- $key = trim(substr($iniLine, 0, $equalsPos));
- $value = trim(substr($iniLine, $equalsPos+1));
- if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') {
- $value = substr($value, 1, -1);
- }
- $this->cleanArray[$section][$key] = stripcslashes($value);
- } else {
- $this->cleanArray[$section][trim($iniLine)]='';
- }
- }
- }
- return $this->cleanArray;
- }
-
- function write($iniFile = "") {
-
- if(empty($iniFile)) {
- $iniFile = $this->iniFile;
- }
- if (!is_writeable($iniFile)) {
- return;
- }
-
- $fileHandle = fopen($iniFile, 'wb');
- foreach ($this->cleanArray as $section => $items) {
- if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) {
- fwrite ($fileHandle, "\r\n");
- continue;
- }
- if (substr($section, 0, strlen('_comment_')) === '_comment_' ) {
- fwrite ($fileHandle, "$items\r\n");
- continue;
- }
- fwrite ($fileHandle, "[".$section."]\r\n");
- foreach ($items as $key => $value) {
- if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) {
- fwrite ($fileHandle, "\r\n");
- continue;
- }
- if (substr($key, 0, strlen('_comment_')) === '_comment_' ) {
- fwrite ($fileHandle, "$value\r\n");
- continue;
- }
-
- $value = addcslashes($value,'');
- //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n");
- fwrite ($fileHandle, $key.' = '.$value."\r\n");
- }
- }
- fclose($fileHandle);
- }
-
- function itemExists($checkSection, $checkItem) {
-
- $this->exists = '';
- foreach($this->cleanArray as $section => $items) {
- if($section == $checkSection) {
- $this->exists = 'section';
- foreach ($items as $key => $value) {
- if($key == $checkItem) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') {
-
- if($this->itemExists($addSection, $addItem)) {
- $this->delItem($addSection, $addItem);
- }
-
- if($this->exists != 'section') {
- $this->cleanArray['_blankline_'.$this->lineNum++]='';
- if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment;
- }
- if(!empty($itemComment)) {
- $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment;
- }
- $this->cleanArray[$addSection][$addItem] = stripcslashes($value);
- return true;
- }
-
- function updateItem($addSection, $addItem, $value) {
-
- $this->cleanArray[$addSection][$addItem] = stripcslashes($value);
- return true;
- }
-
- function delItem($delSection, $delItem) {
-
- if(!$this->itemExists($delSection, $delItem)) return false;
-
- unset($this->cleanArray[$delSection][$delItem]);
- return true;
- }
-
- function delSection($delSection) {
-
- unset($this->cleanArray[$delSection]);
- return true;
- }
-
- // Return file line by line
- public function getFileByLine() {
- $data = $this->read($this->iniFile);
- return $data[''];
- }
-
- public function getSection($section) {
- if (isset($this->cleanArray[$section])) {
- return $this->cleanArray[$section];
- }
-
- return false;
- }
-}
-?>
\ No newline at end of file
diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php
index b036724..81c2914 100644
--- a/setup/wizard/iniUtilities.php
+++ b/setup/wizard/iniUtilities.php
@@ -43,12 +43,22 @@ class iniUtilities {
private $lineNum = 0;
private $exists = '';
- function iniUtilities($iniFile = '../../config.ini') {
+ function iniUtilities() {
+ $this->iniFile = '';
+ }
+
+ function load($iniFile) {
+ if($this->iniFile != $iniFile) {
+ $this->cleanArray = array();
+ $this->lineNum = 0;
+ $this->exists = '';
+ }
$this->iniFile = $iniFile;
$this->backupIni($iniFile);
$this->read($iniFile);
+
}
-
+
/**
* Create a backup with the date as an extension in the same location as the original config.ini
*
@@ -111,6 +121,7 @@ class iniUtilities {
}
}
}
+
return $this->cleanArray;
}
diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php
index 635817b..47bd88d 100644
--- a/setup/wizard/installUtil.php
+++ b/setup/wizard/installUtil.php
@@ -39,9 +39,13 @@
* @package Installer
* @version Version 0.1
*/
+
+
class InstallUtil {
private $salt = 'installers';
+ public $dbHandler = null;
+ public $iniHandler = null;
/**
* Constructs installation object
@@ -50,6 +54,8 @@ class InstallUtil {
* @access public
*/
public function __construct() {
+ $this->dbHandler = new dbUtilities();
+ $this->iniHandler = new iniUtilities();
}
/**
diff --git a/setup/wizard/step.php b/setup/wizard/step.php
index ff0acd0..456ac8f 100644
--- a/setup/wizard/step.php
+++ b/setup/wizard/step.php
@@ -124,10 +124,10 @@ class Step
* @access protected
* @var object
*/
- public $dbhandler;
+// public $dbhandler;
public function __construct() {
- $this->dbhandler = new dbUtilities();
+// $this->dbhandler = new dbUtilities();
$this->util = new InstallUtil();
}
/**
diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php
index ac73aee..3108468 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->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
- $loaded = $this->dbhandler->getDatabaseLink();
+ $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
+ $loaded = $this->util->dbHandler->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->dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']);
- $loaded = $this->dbhandler->getDatabaseLink();
+ $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']);
+ $loaded = $this->util->dbHandler->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->dbhandler->query('SELECT COUNT(id) FROM documents');
+ $qresult = $this->util->dbHandler->query('SELECT COUNT(id) FROM documents');
if (!$qresult)
{
$this->temp_variables['dbPrivileges'] .= ' | | '
. ''
- . 'Unable to do a basic database query. Error: ' . $this->dbhandler->getLastError()
+ . 'Unable to do a basic database query. Error: ' . $this->util->dbHandler->getLastError()
. ' | ';
$this->privileges_check = 'cross';
$this->privileges_check = 'cross';
@@ -183,17 +183,17 @@ class complete extends Step {
// check transaction support
$sTable = 'system_settings';
- $this->dbhandler->startTransaction();
- $this->dbhandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")');
- $this->dbhandler->rollback();
- $res = $this->dbhandler->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1");
+ $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");
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->dbhandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"');
+ $this->util->dbHandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"');
}
else
{
diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php
index 56abe58..da9792d 100644
--- a/setup/wizard/steps/configuration.php
+++ b/setup/wizard/steps/configuration.php
@@ -307,7 +307,7 @@ class configuration extends Step
{
$conf = $this->getDataFromSession("configuration"); // get data from the server
$dbconf = $this->getDataFromSession("database");
- $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
+ $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
$server = $conf['server'];
$paths = $conf['paths'];
if ($this->util->isMigration()) { // Check if its an upgrade
@@ -317,31 +317,28 @@ class configuration extends Step
$this->readConfigPath(); // initialise writing to config.ini
}
$this->getFromConfigPath(); // Sets config Paths
- $ini = false;
- if(file_exists($configPath)) {
- $ini = new iniUtilities($configPath);
+ if(file_exists($this->confpaths['configIni'])) {
+ $this->util->iniHandler->load($this->confpaths['configIni']);
}
- $this->writeUrlSection($ini);
- $this->writeDBSection($ini, $server);
- $this->writeDBPathSection($ini, $paths);
- if(!$ini === false){ // write out the config.ini file
- $ini->write();
+ if(!$this->util->iniHandler === false){ // write out the config.ini file
+ $this->writeUrlSection();
+ $this->writeDBSection($server);
+ $this->writeDBPathSection($paths);
+ $this->util->iniHandler->write();
}
- $this->dbhandler->close(); // close the database connection
- $this->writeCachePath(); // Write cache path file
- $this->writeConfigPath($configPath); // Write config file
+ $this->util->dbHandler->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
}
- private function writeUrlSection($ini) {
+ private function writeUrlSection() {
$directories = $this->registerDirs();
foreach($directories as $item) { // write server settings to config_settings table and config.ini
- if(!$ini === false) {
- $ini->updateItem($item['section'], $item['setting'], $item['value']);
- }
+ $this->util->iniHandler->updateItem($item['section'], $item['setting'], $item['value']);
}
}
- private function writeDBPathSection($ini, $paths) {
+ private function writeDBPathSection($paths) {
$table = 'config_settings';
if(is_array($paths)) { // write the paths to the config_settings table
foreach ($paths as $item){
@@ -351,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->dbhandler->query($sql);
+ $this->util->dbHandler->query($sql);
}
}
}
- private function writeDBSection($ini, $server) {
+ private function writeDBSection($server) {
$dbconf = $this->getDataFromSession("database"); // retrieve database information from session
- $this->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection
+ $this->util->dbHandler->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
@@ -371,16 +368,15 @@ class configuration extends Step
if($value == 'no'){
$value = 'false';
}
- if(!$ini === false){
- $ini->updateItem($item['section'], $item['setting'], $value);
- }
+ echo "{$item['section']}, {$item['setting']}, {$value}
";
+ $this->util->iniHandler->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->dbhandler->query($sql);
+ $this->util->dbHandler->query($sql);
break;
}
}
@@ -582,8 +578,8 @@ class configuration extends Step
}
$configPath = $this->getContentPath();
if(!$configPath) return false;
- $ini = new iniUtilities($configPath);
- $data = $ini->getFileByLine();
+ $this->util->iniHandler->load($configPath);
+ $data = $this->util->iniHandler->getFileByLine();
$firstline = true;
foreach ($data as $k=>$v) {
if(preg_match('/config.ini/', $k)) { // Find config.ini
@@ -605,8 +601,8 @@ class configuration extends Step
private function readConfigPath() {
$configPath = $this->getContentPath();
if(!$configPath) return false;
- $ini = new iniUtilities($configPath);
- $data = $ini->getFileByLine();
+ $this->util->iniHandler->load($configPath);
+ $data = $this->util->iniHandler->getFileByLine();
$firstline = true;
foreach ($data as $k=>$v) {
if($firstline) { // First line holds the var directory
@@ -645,46 +641,48 @@ class configuration extends Step
* @param none
* @return boolean
*/
- private function writeConfigPath($configPath = '') {
- $conf = $this->getDataFromSession("configuration"); // get data from the server
- $paths = $conf['paths'];
- if(isset($paths['configFile']['path'])) {
- $configPath = $this->getContentPath();
- $configContent = $paths['configFile']['path'];
- } else {
- $configPath = $this->getContentPath();
- if(!$configPath) return false;
- $ini = new iniUtilities($configPath);
- $data = $ini->getFileByLine();
- $configContent = '';
- foreach ($data as $k=>$v) {
- if(preg_match('/config.ini/', $k)) {
- $configContent = $k;
- break;
- }
- }
- }
- $fp = fopen($configPath, 'w');
+ private function writeConfigPath($configPath, $configContent) {
+// $conf = $this->getDataFromSession("configuration"); // get data from the server
+// $paths = $conf['paths'];
+// if(isset($paths['configFile']['path'])) {
+// $configPath = $this->getContentPath();
+// $configContent = $paths['configFile']['path'];
+// } else {
+// $configPath = $this->getContentPath();
+// if(!$configPath) return false;
+// $this->util->iniHandler->load($configPath);
+// $data = $this->util->iniHandler->getFileByLine();
+// $configContent = '';
+// foreach ($data as $k=>$v) {
+// if(preg_match('/config.ini/', $k)) {
+// $configContent = $k;
+// break;
+// }
+// }
+// }
+// print_r($configPath);
+// print_r($configContent);
+ $fp = fopen($configPath, 'w+');
if(fwrite($fp, $configContent))
return true;
return false;
}
- private function writeCachePath() {
- $cachePath = $this->getCachePath();
- if(!$cachePath) return false;
- $configPath = $this->getContentPath();
- if(!$configPath) return false;
- $ini = new iniUtilities($configPath);
- $data = $ini->getFileByLine();
- $cacheContent = '';
- foreach ($data as $k=>$v) {
- if(preg_match('/cache/', $k)) {
- $cacheContent = $k;
- break;
- }
- }
- $fp = fopen($cachePath, 'w');
+ private function writeCachePath($cachePath, $cacheContent) {
+// $cachePath = $this->getCachePath();
+// if(!$cachePath) return false;
+// $configPath = $this->getContentPath();
+// if(!$configPath) return false;
+// $this->util->iniHandler->load($configPath);
+// $data = $this->util->iniHandler->getFileByLine();
+// $cacheContent = '';
+// foreach ($data as $k=>$v) {
+// if(preg_match('/cache/', $k)) {
+// $cacheContent = $k;
+// break;
+// }
+// }
+ $fp = fopen($cachePath, 'w+');
if($cacheContent != '') {
if(fwrite($fp, $cacheContent))
return true;
diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php
index 8c3f3dc..5abb6a5 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->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
+ $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
} else {
- $this->dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
+ $this->util->dbHandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
}
- if (!$this->dbhandler->getDatabaseLink()) {
+ if (!$this->util->dbHandler->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->dbhandler->useDb();
+ return $this->util->dbHandler->useDb();
}
public function match($str1, $str2) {
@@ -583,7 +583,7 @@ class database extends Step
* @return object mysql connection
*/
private function connectMysql() {
- $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
+ $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
}
/**
@@ -642,7 +642,7 @@ class database extends Step
$this->error['con'] = "Could not create database: ";
}
}
- $this->dbhandler->clearErrors();
+ $this->util->dbHandler->clearErrors();
if(!$this->createDmsUser()) { // Create dms users
$this->error['con'] = "Could not create database users ";
}
@@ -666,7 +666,7 @@ class database extends Step
*/
private function create() {
$sql = "CREATE DATABASE {$this->dname}";
- if ($this->dbhandler->query($sql)) {
+ if ($this->util->dbHandler->query($sql)) {
return true;
}
@@ -683,7 +683,7 @@ class database extends Step
* @return boolean
*/
private function usedb() {
- if($this->dbhandler->useDb()) {
+ if($this->util->dbHandler->useDb()) {
return true;
} else {
$this->error['con'] = "Error using database: {$this->dname}";
@@ -702,7 +702,7 @@ class database extends Step
private function dropdb() {
if($this->ddrop) {
$sql = "DROP DATABASE {$this->dname};";
- if(!$this->dbhandler->query($sql)) {
+ if(!$this->util->dbHandler->query($sql)) {
$this->error['con'] = "Cannot drop database: {$this->dname}";
return false;
}
@@ -724,7 +724,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->dbhandler->query($user1) && $this->dbhandler->query($user2)) {
+ if ($this->util->dbHandler->query($user1) && $this->util->dbHandler->query($user2)) {
return true;
} else {
$this->error['con'] = "Could not create users for database: {$this->dname}";
@@ -751,7 +751,7 @@ class database extends Step
while (!feof($handle)) {
$query.= fgets($handle, 4096);
if (substr(rtrim($query), -1) == ';') {
- $this->dbhandler->query($query);
+ $this->util->dbHandler->query($query);
$query = '';
}
}
@@ -778,9 +778,9 @@ class database extends Step
$sqlFile = $dbMigrate['dumpLocation'];
$this->parse_mysql_dump($sqlFile);
$dropPluginHelper = "TRUNCATE plugin_helper;";
- $this->dbhandler->query($dropPluginHelper);
+ $this->util->dbHandler->query($dropPluginHelper);
$updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";';
- $this->dbhandler->query($updateUrls);
+ $this->util->dbHandler->query($updateUrls);
return true;
}
/**
@@ -793,7 +793,7 @@ class database extends Step
*/
private function closeMysql() {
try {
- $this->dbhandler->close();
+ $this->util->dbHandler->close();
} catch (Exeption $e) {
$this->error['con'] = "Could not close: " . $e;
}
@@ -844,7 +844,7 @@ class database extends Step
$this->dpassword = 'root';
$this->dname = 'dms_install';
$this->dbbinary = 'mysql';
- $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
+ $this->util->dbHandler->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 76c4d9c..6974716 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->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection
+ $this->util->dbHandler->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->dbhandler->query($query);
- $this->dbhandler->close(); // close the database connection
+ $this->util->dbHandler->query($query);
+ $this->util->dbHandler->close(); // close the database connection
}
}
?>
\ No newline at end of file