Commit d1b581849e4e6c877c52f930320a9d3357646567
1 parent
3f4d9610
KTS-4438: Updated Services
Committed by: Jarrett Jordaan Reviewed by: Megan Watson
Showing
10 changed files
with
123 additions
and
575 deletions
setup/wizard/dbUtil.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | -* Installer Database Control. | ||
| 4 | -* | ||
| 5 | -* KnowledgeTree Community Edition | ||
| 6 | -* Document Management Made Simple | ||
| 7 | -* Copyright (C) 2008,2009 KnowledgeTree Inc. | ||
| 8 | -* Portions copyright The Jam Warehouse Software (Pty) Limited | ||
| 9 | -* | ||
| 10 | -* This program is free software; you can redistribute it and/or modify it under | ||
| 11 | -* the terms of the GNU General Public License version 3 as published by the | ||
| 12 | -* Free Software Foundation. | ||
| 13 | -* | ||
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | -* details. | ||
| 18 | -* | ||
| 19 | -* You should have received a copy of the GNU General Public License | ||
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | -* | ||
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | ||
| 24 | -* | ||
| 25 | -* The interactive user interfaces in modified source and object code versions | ||
| 26 | -* of this program must display Appropriate Legal Notices, as required under | ||
| 27 | -* Section 5 of the GNU General Public License version 3. | ||
| 28 | -* | ||
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | -* copyright notice. | ||
| 35 | -* | ||
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | ||
| 37 | -* @license GNU General Public License version 3 | ||
| 38 | -* @author KnowledgeTree Team | ||
| 39 | -* @package Installer | ||
| 40 | -* @version Version 0.1 | ||
| 41 | -*/ | ||
| 42 | -class dbUtil { | ||
| 43 | - /** | ||
| 44 | - * Host | ||
| 45 | - * | ||
| 46 | - * @author KnowledgeTree Team | ||
| 47 | - * @access protected | ||
| 48 | - * @var string | ||
| 49 | - */ | ||
| 50 | - protected $dbhost = ''; | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | - * Host | ||
| 54 | - * | ||
| 55 | - * @author KnowledgeTree Team | ||
| 56 | - * @access protected | ||
| 57 | - * @var string | ||
| 58 | - */ | ||
| 59 | - protected $dbname = ''; | ||
| 60 | - | ||
| 61 | - /** | ||
| 62 | - * Host | ||
| 63 | - * | ||
| 64 | - * @author KnowledgeTree Team | ||
| 65 | - * @access protected | ||
| 66 | - * @var string | ||
| 67 | - */ | ||
| 68 | - protected $dbuname = ''; | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * Host | ||
| 72 | - * | ||
| 73 | - * @author KnowledgeTree Team | ||
| 74 | - * @access protected | ||
| 75 | - * @var string | ||
| 76 | - */ | ||
| 77 | - protected $dbpassword = ''; | ||
| 78 | - | ||
| 79 | - /** | ||
| 80 | - * Host | ||
| 81 | - * | ||
| 82 | - * @author KnowledgeTree Team | ||
| 83 | - * @access protected | ||
| 84 | - * @var object mysql connection | ||
| 85 | - */ | ||
| 86 | - protected $dbconnection = ''; | ||
| 87 | - | ||
| 88 | - /** | ||
| 89 | - * Any errors encountered | ||
| 90 | - * | ||
| 91 | - * @author KnowledgeTree Team | ||
| 92 | - * @access protected | ||
| 93 | - * @var array | ||
| 94 | - */ | ||
| 95 | - protected $error = array(); | ||
| 96 | - | ||
| 97 | - /** | ||
| 98 | - * Constructs database connection object | ||
| 99 | - * | ||
| 100 | - * @author KnowledgeTree Team | ||
| 101 | - * @access public | ||
| 102 | - */ | ||
| 103 | - public function __construct() { | ||
| 104 | - | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | ||
| 108 | - $this->dbhost = $dhost; | ||
| 109 | - $this->dbuname = $duname; | ||
| 110 | - $this->dbpassword = $dpassword; | ||
| 111 | - $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | ||
| 112 | - if(!$this->dbconnection) { | ||
| 113 | - $this->error[] = @mysql_error(); | ||
| 114 | - } | ||
| 115 | - $this->dbname = $dbname; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - public function getDatabaseLink() { | ||
| 119 | - return $this->dbconnection; | ||
| 120 | - } | ||
| 121 | - /** | ||
| 122 | - * Choose a database to use | ||
| 123 | - * | ||
| 124 | - * @param string $dbname name of the database | ||
| 125 | - * @access public | ||
| 126 | - * @return boolean | ||
| 127 | - */ | ||
| 128 | - public function useDb() { | ||
| 129 | - if(@mysql_select_db($this->dbname, $this->dbconnection)) | ||
| 130 | - return true; | ||
| 131 | - else { | ||
| 132 | - $this->error[] = @mysql_error($this->dbconnection); | ||
| 133 | - return false; | ||
| 134 | - } | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - public function setDb($dbname) { | ||
| 138 | - $this->dbname = $dbname; | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - /** | ||
| 142 | - * Query the database. | ||
| 143 | - * | ||
| 144 | - * @param $query the sql query. | ||
| 145 | - * @access public | ||
| 146 | - * @return object The result of the query. | ||
| 147 | - */ | ||
| 148 | - public function query($query) { | ||
| 149 | - $this->useDb(); | ||
| 150 | - $result = mysql_query($query, $this->dbconnection); | ||
| 151 | - if($result) { | ||
| 152 | - return $result; | ||
| 153 | - } else { | ||
| 154 | - $this->error[] = @mysql_error($this->dbconnection); | ||
| 155 | - return false; | ||
| 156 | - } | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - /** | ||
| 160 | - * Do the same as query. | ||
| 161 | - * | ||
| 162 | - * @param $query the sql query. | ||
| 163 | - * @access public | ||
| 164 | - * @return boolean | ||
| 165 | - */ | ||
| 166 | - public function execute($query) { | ||
| 167 | - $this->useDb(); | ||
| 168 | - $result = @mysql_query($query, $this->dbconnection); | ||
| 169 | - if(!$result) { | ||
| 170 | - $this->error[] = @mysql_error($this->dbconnection); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - return $result; | ||
| 174 | - } | ||
| 175 | - | ||
| 176 | - /** | ||
| 177 | - * Convenience method for mysql_fetch_object(). | ||
| 178 | - * | ||
| 179 | - * @param $result The resource returned by query(). | ||
| 180 | - * @access public | ||
| 181 | - * @return object An object representing a data row. | ||
| 182 | - */ | ||
| 183 | - public function fetchNextObject($result = NULL) { | ||
| 184 | - if ($result == NULL || @mysql_num_rows($result) < 1) | ||
| 185 | - return NULL; | ||
| 186 | - else | ||
| 187 | - return @mysql_fetch_object($result); | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - /** | ||
| 191 | - * Convenience method for mysql_fetch_assoc(). | ||
| 192 | - * | ||
| 193 | - * @param $result The resource returned by query(). | ||
| 194 | - * @access public | ||
| 195 | - * @return array Returns an associative array of strings. | ||
| 196 | - */ | ||
| 197 | - public function fetchAssoc($result = NULL) { | ||
| 198 | - $r = array(); | ||
| 199 | - if ($result == NULL || @mysql_num_rows($result) < 1) | ||
| 200 | - return NULL; | ||
| 201 | - else { | ||
| 202 | - while(($r[] = mysql_fetch_assoc($result)) || array_pop($r)); | ||
| 203 | - return $r; | ||
| 204 | - } | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - /** | ||
| 208 | - * Close the connection with the database server. | ||
| 209 | - * | ||
| 210 | - * @param none. | ||
| 211 | - * @access public | ||
| 212 | - * @return void. | ||
| 213 | - */ | ||
| 214 | - public function close() { | ||
| 215 | - @mysql_close($this->dbconnection); | ||
| 216 | - } | ||
| 217 | - | ||
| 218 | - /** | ||
| 219 | - * Get database errors. | ||
| 220 | - * | ||
| 221 | - * @param none. | ||
| 222 | - * @access public | ||
| 223 | - * @return array. | ||
| 224 | - */ | ||
| 225 | - public function getErrors() { | ||
| 226 | - return $this->error; | ||
| 227 | - } | ||
| 228 | - | ||
| 229 | - public function clearErrors() { | ||
| 230 | - return $this->error = array(); | ||
| 231 | - } | ||
| 232 | - | ||
| 233 | - /** | ||
| 234 | - * Fetches the last generated error | ||
| 235 | - | ||
| 236 | - * @return string | ||
| 237 | - */ | ||
| 238 | - function getLastError() { | ||
| 239 | - return end($this->error); | ||
| 240 | - } | ||
| 241 | - | ||
| 242 | - /** | ||
| 243 | - * Start a database transaction | ||
| 244 | - */ | ||
| 245 | - public function startTransaction() { | ||
| 246 | - $this->query("START TRANSACTION"); | ||
| 247 | - } | ||
| 248 | - | ||
| 249 | - /** | ||
| 250 | - * Roll back a database transaction | ||
| 251 | - */ | ||
| 252 | - public function rollback() { | ||
| 253 | - $this->query("ROLLBACK"); | ||
| 254 | - } | ||
| 255 | -} | ||
| 256 | -?> | ||
| 257 | \ No newline at end of file | 0 | \ No newline at end of file |
setup/wizard/dbUtilities.php
| @@ -105,6 +105,7 @@ class dbUtilities { | @@ -105,6 +105,7 @@ class dbUtilities { | ||
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | 107 | public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { |
| 108 | + if($this->isConnected($dhost, $duname, $dpassword, $dbname)) return true; | ||
| 108 | $this->dbhost = $dhost; | 109 | $this->dbhost = $dhost; |
| 109 | $this->dbuname = $duname; | 110 | $this->dbuname = $duname; |
| 110 | $this->dbpassword = $dpassword; | 111 | $this->dbpassword = $dpassword; |
| @@ -115,6 +116,17 @@ class dbUtilities { | @@ -115,6 +116,17 @@ class dbUtilities { | ||
| 115 | $this->dbname = $dbname; | 116 | $this->dbname = $dbname; |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 119 | + public function isConnected($dhost = 'localhost', $duname, $dpassword, $dbname) { | ||
| 120 | + $current = array($this->dbhost, $this->dbuname, $this->dbpassword, $this->dbname); | ||
| 121 | + $new = array($dhost, $duname, $dpassword, $dbname); | ||
| 122 | + $diff = array_diff($new, $current); | ||
| 123 | + if(count($diff) == 0) { | ||
| 124 | + echo 'same'; | ||
| 125 | + return true; | ||
| 126 | + } | ||
| 127 | + return false; | ||
| 128 | + } | ||
| 129 | + | ||
| 118 | public function getDatabaseLink() { | 130 | public function getDatabaseLink() { |
| 119 | return $this->dbconnection; | 131 | return $this->dbconnection; |
| 120 | } | 132 | } |
setup/wizard/ini.php deleted
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * $Id:$ | ||
| 4 | - * | ||
| 5 | - * KnowledgeTree Community Edition | ||
| 6 | - * Document Management Made Simple | ||
| 7 | - * Copyright (C) 2008, 2009 KnowledgeTree Inc. | ||
| 8 | - * Portions copyright The Jam Warehouse Software (Pty) Limited | ||
| 9 | - * | ||
| 10 | - * This program is free software; you can redistribute it and/or modify it under | ||
| 11 | - * the terms of the GNU General Public License version 3 as published by the | ||
| 12 | - * Free Software Foundation. | ||
| 13 | - * | ||
| 14 | - * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | - * details. | ||
| 18 | - * | ||
| 19 | - * You should have received a copy of the GNU General Public License | ||
| 20 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | - * | ||
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | - * California 94120-7775, or email info@knowledgetree.com. | ||
| 24 | - * | ||
| 25 | - * The interactive user interfaces in modified source and object code versions | ||
| 26 | - * of this program must display Appropriate Legal Notices, as required under | ||
| 27 | - * Section 5 of the GNU General Public License version 3. | ||
| 28 | - * | ||
| 29 | - * In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | - * these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | - * copyright notice. | ||
| 35 | - * Contributor( s): ______________________________________ | ||
| 36 | - * | ||
| 37 | - */ | ||
| 38 | - | ||
| 39 | -class Ini { | ||
| 40 | - | ||
| 41 | - private $cleanArray = array(); | ||
| 42 | - private $iniFile = ''; | ||
| 43 | - private $lineNum = 0; | ||
| 44 | - private $exists = ''; | ||
| 45 | - | ||
| 46 | - function Ini($iniFile = '../../config.ini') { | ||
| 47 | - $this->iniFile = $iniFile; | ||
| 48 | - $this->backupIni($iniFile); | ||
| 49 | - $this->read($iniFile); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - /** | ||
| 53 | - * Create a backup with the date as an extension in the same location as the original config.ini | ||
| 54 | - * | ||
| 55 | - * @param string $iniFile | ||
| 56 | - * @return boolean | ||
| 57 | - */ | ||
| 58 | - function backupIni($iniFile) | ||
| 59 | - { | ||
| 60 | - $content = file_get_contents($iniFile); | ||
| 61 | - if ($content === false) | ||
| 62 | - { | ||
| 63 | - return false; | ||
| 64 | - } | ||
| 65 | - $date = date('YmdHis'); | ||
| 66 | - | ||
| 67 | - $backupFile = $iniFile . '.' .$date; | ||
| 68 | - if (is_writeable($backupFile)) { | ||
| 69 | - file_put_contents($backupFile, $content); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - function read($iniFile) { | ||
| 74 | - | ||
| 75 | - $iniArray = file($iniFile); | ||
| 76 | - $section = ''; | ||
| 77 | - foreach($iniArray as $iniLine) { | ||
| 78 | - $this->lineNum++; | ||
| 79 | - $iniLine = trim($iniLine); | ||
| 80 | - $firstChar = substr($iniLine, 0, 1); | ||
| 81 | - if($firstChar == ';') { | ||
| 82 | - if($section == ''){ | ||
| 83 | - $this->cleanArray['_comment_'.$this->lineNum]=$iniLine; | ||
| 84 | - }else { | ||
| 85 | - $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine; | ||
| 86 | - } | ||
| 87 | - continue; | ||
| 88 | - } | ||
| 89 | - if($iniLine == '') { | ||
| 90 | - if($section == ''){ | ||
| 91 | - $this->cleanArray['_blankline_'.$this->lineNum]=''; | ||
| 92 | - }else { | ||
| 93 | - $this->cleanArray[$section]['_blankline_'.$this->lineNum]=''; | ||
| 94 | - } | ||
| 95 | - continue; | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') { | ||
| 99 | - $section = substr($iniLine, 1, -1); | ||
| 100 | - $this->sections[] = $section; | ||
| 101 | - } else { | ||
| 102 | - $equalsPos = strpos($iniLine, '='); | ||
| 103 | - if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) { | ||
| 104 | - $key = trim(substr($iniLine, 0, $equalsPos)); | ||
| 105 | - $value = trim(substr($iniLine, $equalsPos+1)); | ||
| 106 | - if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { | ||
| 107 | - $value = substr($value, 1, -1); | ||
| 108 | - } | ||
| 109 | - $this->cleanArray[$section][$key] = stripcslashes($value); | ||
| 110 | - } else { | ||
| 111 | - $this->cleanArray[$section][trim($iniLine)]=''; | ||
| 112 | - } | ||
| 113 | - } | ||
| 114 | - } | ||
| 115 | - return $this->cleanArray; | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - function write($iniFile = "") { | ||
| 119 | - | ||
| 120 | - if(empty($iniFile)) { | ||
| 121 | - $iniFile = $this->iniFile; | ||
| 122 | - } | ||
| 123 | - if (!is_writeable($iniFile)) { | ||
| 124 | - return; | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - $fileHandle = fopen($iniFile, 'wb'); | ||
| 128 | - foreach ($this->cleanArray as $section => $items) { | ||
| 129 | - if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { | ||
| 130 | - fwrite ($fileHandle, "\r\n"); | ||
| 131 | - continue; | ||
| 132 | - } | ||
| 133 | - if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { | ||
| 134 | - fwrite ($fileHandle, "$items\r\n"); | ||
| 135 | - continue; | ||
| 136 | - } | ||
| 137 | - fwrite ($fileHandle, "[".$section."]\r\n"); | ||
| 138 | - foreach ($items as $key => $value) { | ||
| 139 | - if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { | ||
| 140 | - fwrite ($fileHandle, "\r\n"); | ||
| 141 | - continue; | ||
| 142 | - } | ||
| 143 | - if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { | ||
| 144 | - fwrite ($fileHandle, "$value\r\n"); | ||
| 145 | - continue; | ||
| 146 | - } | ||
| 147 | - | ||
| 148 | - $value = addcslashes($value,''); | ||
| 149 | - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); | ||
| 150 | - fwrite ($fileHandle, $key.' = '.$value."\r\n"); | ||
| 151 | - } | ||
| 152 | - } | ||
| 153 | - fclose($fileHandle); | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - function itemExists($checkSection, $checkItem) { | ||
| 157 | - | ||
| 158 | - $this->exists = ''; | ||
| 159 | - foreach($this->cleanArray as $section => $items) { | ||
| 160 | - if($section == $checkSection) { | ||
| 161 | - $this->exists = 'section'; | ||
| 162 | - foreach ($items as $key => $value) { | ||
| 163 | - if($key == $checkItem) { | ||
| 164 | - return true; | ||
| 165 | - } | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - return false; | ||
| 170 | - } | ||
| 171 | - | ||
| 172 | - function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { | ||
| 173 | - | ||
| 174 | - if($this->itemExists($addSection, $addItem)) { | ||
| 175 | - $this->delItem($addSection, $addItem); | ||
| 176 | - } | ||
| 177 | - | ||
| 178 | - if($this->exists != 'section') { | ||
| 179 | - $this->cleanArray['_blankline_'.$this->lineNum++]=''; | ||
| 180 | - if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment; | ||
| 181 | - } | ||
| 182 | - if(!empty($itemComment)) { | ||
| 183 | - $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment; | ||
| 184 | - } | ||
| 185 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | ||
| 186 | - return true; | ||
| 187 | - } | ||
| 188 | - | ||
| 189 | - function updateItem($addSection, $addItem, $value) { | ||
| 190 | - | ||
| 191 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | ||
| 192 | - return true; | ||
| 193 | - } | ||
| 194 | - | ||
| 195 | - function delItem($delSection, $delItem) { | ||
| 196 | - | ||
| 197 | - if(!$this->itemExists($delSection, $delItem)) return false; | ||
| 198 | - | ||
| 199 | - unset($this->cleanArray[$delSection][$delItem]); | ||
| 200 | - return true; | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - function delSection($delSection) { | ||
| 204 | - | ||
| 205 | - unset($this->cleanArray[$delSection]); | ||
| 206 | - return true; | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - // Return file line by line | ||
| 210 | - public function getFileByLine() { | ||
| 211 | - $data = $this->read($this->iniFile); | ||
| 212 | - return $data['']; | ||
| 213 | - } | ||
| 214 | - | ||
| 215 | - public function getSection($section) { | ||
| 216 | - if (isset($this->cleanArray[$section])) { | ||
| 217 | - return $this->cleanArray[$section]; | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - return false; | ||
| 221 | - } | ||
| 222 | -} | ||
| 223 | -?> | ||
| 224 | \ No newline at end of file | 0 | \ No newline at end of file |
setup/wizard/iniUtilities.php
| @@ -43,12 +43,22 @@ class iniUtilities { | @@ -43,12 +43,22 @@ class iniUtilities { | ||
| 43 | private $lineNum = 0; | 43 | private $lineNum = 0; |
| 44 | private $exists = ''; | 44 | private $exists = ''; |
| 45 | 45 | ||
| 46 | - function iniUtilities($iniFile = '../../config.ini') { | 46 | + function iniUtilities() { |
| 47 | + $this->iniFile = ''; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + function load($iniFile) { | ||
| 51 | + if($this->iniFile != $iniFile) { | ||
| 52 | + $this->cleanArray = array(); | ||
| 53 | + $this->lineNum = 0; | ||
| 54 | + $this->exists = ''; | ||
| 55 | + } | ||
| 47 | $this->iniFile = $iniFile; | 56 | $this->iniFile = $iniFile; |
| 48 | $this->backupIni($iniFile); | 57 | $this->backupIni($iniFile); |
| 49 | $this->read($iniFile); | 58 | $this->read($iniFile); |
| 59 | + | ||
| 50 | } | 60 | } |
| 51 | - | 61 | + |
| 52 | /** | 62 | /** |
| 53 | * Create a backup with the date as an extension in the same location as the original config.ini | 63 | * Create a backup with the date as an extension in the same location as the original config.ini |
| 54 | * | 64 | * |
| @@ -111,6 +121,7 @@ class iniUtilities { | @@ -111,6 +121,7 @@ class iniUtilities { | ||
| 111 | } | 121 | } |
| 112 | } | 122 | } |
| 113 | } | 123 | } |
| 124 | + | ||
| 114 | return $this->cleanArray; | 125 | return $this->cleanArray; |
| 115 | } | 126 | } |
| 116 | 127 |
setup/wizard/installUtil.php
| @@ -39,9 +39,13 @@ | @@ -39,9 +39,13 @@ | ||
| 39 | * @package Installer | 39 | * @package Installer |
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | + | ||
| 43 | + | ||
| 42 | class InstallUtil { | 44 | class InstallUtil { |
| 43 | 45 | ||
| 44 | private $salt = 'installers'; | 46 | private $salt = 'installers'; |
| 47 | + public $dbHandler = null; | ||
| 48 | + public $iniHandler = null; | ||
| 45 | 49 | ||
| 46 | /** | 50 | /** |
| 47 | * Constructs installation object | 51 | * Constructs installation object |
| @@ -50,6 +54,8 @@ class InstallUtil { | @@ -50,6 +54,8 @@ class InstallUtil { | ||
| 50 | * @access public | 54 | * @access public |
| 51 | */ | 55 | */ |
| 52 | public function __construct() { | 56 | public function __construct() { |
| 57 | + $this->dbHandler = new dbUtilities(); | ||
| 58 | + $this->iniHandler = new iniUtilities(); | ||
| 53 | } | 59 | } |
| 54 | 60 | ||
| 55 | /** | 61 | /** |
setup/wizard/step.php
| @@ -124,10 +124,10 @@ class Step | @@ -124,10 +124,10 @@ class Step | ||
| 124 | * @access protected | 124 | * @access protected |
| 125 | * @var object | 125 | * @var object |
| 126 | */ | 126 | */ |
| 127 | - public $dbhandler; | 127 | +// public $dbhandler; |
| 128 | 128 | ||
| 129 | public function __construct() { | 129 | public function __construct() { |
| 130 | - $this->dbhandler = new dbUtilities(); | 130 | +// $this->dbhandler = new dbUtilities(); |
| 131 | $this->util = new InstallUtil(); | 131 | $this->util = new InstallUtil(); |
| 132 | } | 132 | } |
| 133 | /** | 133 | /** |
setup/wizard/steps/complete.php
| @@ -142,8 +142,8 @@ class complete extends Step { | @@ -142,8 +142,8 @@ class complete extends Step { | ||
| 142 | // retrieve database information from session | 142 | // retrieve database information from session |
| 143 | $dbconf = $this->getDataFromSession("database"); | 143 | $dbconf = $this->getDataFromSession("database"); |
| 144 | // make db connection - admin | 144 | // make db connection - admin |
| 145 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | ||
| 146 | - $loaded = $this->dbhandler->getDatabaseLink(); | 145 | + $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); |
| 146 | + $loaded = $this->util->dbHandler->getDatabaseLink(); | ||
| 147 | if (!$loaded) { | 147 | if (!$loaded) { |
| 148 | $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' | 148 | $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' |
| 149 | . '<td class="error">Unable to connect to database (user: ' | 149 | . '<td class="error">Unable to connect to database (user: ' |
| @@ -157,20 +157,20 @@ class complete extends Step { | @@ -157,20 +157,20 @@ class complete extends Step { | ||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | // make db connection - user | 159 | // make db connection - user |
| 160 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | ||
| 161 | - $loaded = $this->dbhandler->getDatabaseLink(); | 160 | + $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); |
| 161 | + $loaded = $this->util->dbHandler->getDatabaseLink(); | ||
| 162 | // if we can log in to the database, check access | 162 | // if we can log in to the database, check access |
| 163 | // TODO check write access? | 163 | // TODO check write access? |
| 164 | if ($loaded) | 164 | if ($loaded) |
| 165 | { | 165 | { |
| 166 | $this->temp_variables['dbConnectUser'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: ' . $dbconf['dmsusername'] . ')'); | 166 | $this->temp_variables['dbConnectUser'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: ' . $dbconf['dmsusername'] . ')'); |
| 167 | 167 | ||
| 168 | - $qresult = $this->dbhandler->query('SELECT COUNT(id) FROM documents'); | 168 | + $qresult = $this->util->dbHandler->query('SELECT COUNT(id) FROM documents'); |
| 169 | if (!$qresult) | 169 | if (!$qresult) |
| 170 | { | 170 | { |
| 171 | $this->temp_variables['dbPrivileges'] .= '<td style="width:15px;"><div class="cross" style="float:left;"></div></td>' | 171 | $this->temp_variables['dbPrivileges'] .= '<td style="width:15px;"><div class="cross" style="float:left;"></div></td>' |
| 172 | . '<td class="error" style="width:500px;">' | 172 | . '<td class="error" style="width:500px;">' |
| 173 | - . 'Unable to do a basic database query. Error: ' . $this->dbhandler->getLastError() | 173 | + . 'Unable to do a basic database query. Error: ' . $this->util->dbHandler->getLastError() |
| 174 | . '</td>'; | 174 | . '</td>'; |
| 175 | $this->privileges_check = 'cross'; | 175 | $this->privileges_check = 'cross'; |
| 176 | $this->privileges_check = 'cross'; | 176 | $this->privileges_check = 'cross'; |
| @@ -183,17 +183,17 @@ class complete extends Step { | @@ -183,17 +183,17 @@ class complete extends Step { | ||
| 183 | 183 | ||
| 184 | // check transaction support | 184 | // check transaction support |
| 185 | $sTable = 'system_settings'; | 185 | $sTable = 'system_settings'; |
| 186 | - $this->dbhandler->startTransaction(); | ||
| 187 | - $this->dbhandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); | ||
| 188 | - $this->dbhandler->rollback(); | ||
| 189 | - $res = $this->dbhandler->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); | 186 | + $this->util->dbHandler->startTransaction(); |
| 187 | + $this->util->dbHandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); | ||
| 188 | + $this->util->dbHandler->rollback(); | ||
| 189 | + $res = $this->util->dbHandler->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); | ||
| 190 | if (!$res) { | 190 | if (!$res) { |
| 191 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'cross', 'class="error"', 'Transaction support not available in database'); | 191 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'cross', 'class="error"', 'Transaction support not available in database'); |
| 192 | $this->privileges_check = 'cross'; | 192 | $this->privileges_check = 'cross'; |
| 193 | } else { | 193 | } else { |
| 194 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'tick', '', 'Database has transaction support'); | 194 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'tick', '', 'Database has transaction support'); |
| 195 | } | 195 | } |
| 196 | - $this->dbhandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); | 196 | + $this->util->dbHandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); |
| 197 | } | 197 | } |
| 198 | else | 198 | else |
| 199 | { | 199 | { |
setup/wizard/steps/configuration.php
| @@ -307,7 +307,7 @@ class configuration extends Step | @@ -307,7 +307,7 @@ class configuration extends Step | ||
| 307 | { | 307 | { |
| 308 | $conf = $this->getDataFromSession("configuration"); // get data from the server | 308 | $conf = $this->getDataFromSession("configuration"); // get data from the server |
| 309 | $dbconf = $this->getDataFromSession("database"); | 309 | $dbconf = $this->getDataFromSession("database"); |
| 310 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | 310 | + $this->util->dbHandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); |
| 311 | $server = $conf['server']; | 311 | $server = $conf['server']; |
| 312 | $paths = $conf['paths']; | 312 | $paths = $conf['paths']; |
| 313 | if ($this->util->isMigration()) { // Check if its an upgrade | 313 | if ($this->util->isMigration()) { // Check if its an upgrade |
| @@ -317,31 +317,28 @@ class configuration extends Step | @@ -317,31 +317,28 @@ class configuration extends Step | ||
| 317 | $this->readConfigPath(); // initialise writing to config.ini | 317 | $this->readConfigPath(); // initialise writing to config.ini |
| 318 | } | 318 | } |
| 319 | $this->getFromConfigPath(); // Sets config Paths | 319 | $this->getFromConfigPath(); // Sets config Paths |
| 320 | - $ini = false; | ||
| 321 | - if(file_exists($configPath)) { | ||
| 322 | - $ini = new iniUtilities($configPath); | 320 | + if(file_exists($this->confpaths['configIni'])) { |
| 321 | + $this->util->iniHandler->load($this->confpaths['configIni']); | ||
| 323 | } | 322 | } |
| 324 | - $this->writeUrlSection($ini); | ||
| 325 | - $this->writeDBSection($ini, $server); | ||
| 326 | - $this->writeDBPathSection($ini, $paths); | ||
| 327 | - if(!$ini === false){ // write out the config.ini file | ||
| 328 | - $ini->write(); | 323 | + if(!$this->util->iniHandler === false){ // write out the config.ini file |
| 324 | + $this->writeUrlSection(); | ||
| 325 | + $this->writeDBSection($server); | ||
| 326 | + $this->writeDBPathSection($paths); | ||
| 327 | + $this->util->iniHandler->write(); | ||
| 329 | } | 328 | } |
| 330 | - $this->dbhandler->close(); // close the database connection | ||
| 331 | - $this->writeCachePath(); // Write cache path file | ||
| 332 | - $this->writeConfigPath($configPath); // Write config file | 329 | + $this->util->dbHandler->close(); // close the database connection |
| 330 | + $this->writeCachePath($this->getCachePath(), $paths['cacheDirectory']['path']); // Write cache path file | ||
| 331 | + $this->writeConfigPath($this->getContentPath(), $this->confpaths['configIni']); // Write config file | ||
| 333 | } | 332 | } |
| 334 | 333 | ||
| 335 | - private function writeUrlSection($ini) { | 334 | + private function writeUrlSection() { |
| 336 | $directories = $this->registerDirs(); | 335 | $directories = $this->registerDirs(); |
| 337 | foreach($directories as $item) { // write server settings to config_settings table and config.ini | 336 | foreach($directories as $item) { // write server settings to config_settings table and config.ini |
| 338 | - if(!$ini === false) { | ||
| 339 | - $ini->updateItem($item['section'], $item['setting'], $item['value']); | ||
| 340 | - } | 337 | + $this->util->iniHandler->updateItem($item['section'], $item['setting'], $item['value']); |
| 341 | } | 338 | } |
| 342 | } | 339 | } |
| 343 | 340 | ||
| 344 | - private function writeDBPathSection($ini, $paths) { | 341 | + private function writeDBPathSection($paths) { |
| 345 | $table = 'config_settings'; | 342 | $table = 'config_settings'; |
| 346 | if(is_array($paths)) { // write the paths to the config_settings table | 343 | if(is_array($paths)) { // write the paths to the config_settings table |
| 347 | foreach ($paths as $item){ | 344 | foreach ($paths as $item){ |
| @@ -351,14 +348,14 @@ class configuration extends Step | @@ -351,14 +348,14 @@ class configuration extends Step | ||
| 351 | $value = mysql_real_escape_string($item['path']); | 348 | $value = mysql_real_escape_string($item['path']); |
| 352 | $setting = mysql_real_escape_string($item['setting']); | 349 | $setting = mysql_real_escape_string($item['setting']); |
| 353 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; | 350 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; |
| 354 | - $this->dbhandler->query($sql); | 351 | + $this->util->dbHandler->query($sql); |
| 355 | } | 352 | } |
| 356 | } | 353 | } |
| 357 | } | 354 | } |
| 358 | 355 | ||
| 359 | - private function writeDBSection($ini, $server) { | 356 | + private function writeDBSection($server) { |
| 360 | $dbconf = $this->getDataFromSession("database"); // retrieve database information from session | 357 | $dbconf = $this->getDataFromSession("database"); // retrieve database information from session |
| 361 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | 358 | + $this->util->dbHandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection |
| 362 | $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables | 359 | $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables |
| 363 | $table = 'config_settings'; | 360 | $table = 'config_settings'; |
| 364 | foreach($server as $item) { // write server settings to config_settings table and config.ini | 361 | foreach($server as $item) { // write server settings to config_settings table and config.ini |
| @@ -371,16 +368,15 @@ class configuration extends Step | @@ -371,16 +368,15 @@ class configuration extends Step | ||
| 371 | if($value == 'no'){ | 368 | if($value == 'no'){ |
| 372 | $value = 'false'; | 369 | $value = 'false'; |
| 373 | } | 370 | } |
| 374 | - if(!$ini === false){ | ||
| 375 | - $ini->updateItem($item['section'], $item['setting'], $value); | ||
| 376 | - } | 371 | + echo "{$item['section']}, {$item['setting']}, {$value}<br/>"; |
| 372 | + $this->util->iniHandler->updateItem($item['section'], $item['setting'], $value); | ||
| 377 | break; | 373 | break; |
| 378 | case 'db': | 374 | case 'db': |
| 379 | $value = mysql_real_escape_string($item['value']); | 375 | $value = mysql_real_escape_string($item['value']); |
| 380 | $setting = mysql_real_escape_string($item['setting']); | 376 | $setting = mysql_real_escape_string($item['setting']); |
| 381 | 377 | ||
| 382 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; | 378 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; |
| 383 | - $this->dbhandler->query($sql); | 379 | + $this->util->dbHandler->query($sql); |
| 384 | break; | 380 | break; |
| 385 | } | 381 | } |
| 386 | } | 382 | } |
| @@ -582,8 +578,8 @@ class configuration extends Step | @@ -582,8 +578,8 @@ class configuration extends Step | ||
| 582 | } | 578 | } |
| 583 | $configPath = $this->getContentPath(); | 579 | $configPath = $this->getContentPath(); |
| 584 | if(!$configPath) return false; | 580 | if(!$configPath) return false; |
| 585 | - $ini = new iniUtilities($configPath); | ||
| 586 | - $data = $ini->getFileByLine(); | 581 | + $this->util->iniHandler->load($configPath); |
| 582 | + $data = $this->util->iniHandler->getFileByLine(); | ||
| 587 | $firstline = true; | 583 | $firstline = true; |
| 588 | foreach ($data as $k=>$v) { | 584 | foreach ($data as $k=>$v) { |
| 589 | if(preg_match('/config.ini/', $k)) { // Find config.ini | 585 | if(preg_match('/config.ini/', $k)) { // Find config.ini |
| @@ -605,8 +601,8 @@ class configuration extends Step | @@ -605,8 +601,8 @@ class configuration extends Step | ||
| 605 | private function readConfigPath() { | 601 | private function readConfigPath() { |
| 606 | $configPath = $this->getContentPath(); | 602 | $configPath = $this->getContentPath(); |
| 607 | if(!$configPath) return false; | 603 | if(!$configPath) return false; |
| 608 | - $ini = new iniUtilities($configPath); | ||
| 609 | - $data = $ini->getFileByLine(); | 604 | + $this->util->iniHandler->load($configPath); |
| 605 | + $data = $this->util->iniHandler->getFileByLine(); | ||
| 610 | $firstline = true; | 606 | $firstline = true; |
| 611 | foreach ($data as $k=>$v) { | 607 | foreach ($data as $k=>$v) { |
| 612 | if($firstline) { // First line holds the var directory | 608 | if($firstline) { // First line holds the var directory |
| @@ -645,46 +641,48 @@ class configuration extends Step | @@ -645,46 +641,48 @@ class configuration extends Step | ||
| 645 | * @param none | 641 | * @param none |
| 646 | * @return boolean | 642 | * @return boolean |
| 647 | */ | 643 | */ |
| 648 | - private function writeConfigPath($configPath = '') { | ||
| 649 | - $conf = $this->getDataFromSession("configuration"); // get data from the server | ||
| 650 | - $paths = $conf['paths']; | ||
| 651 | - if(isset($paths['configFile']['path'])) { | ||
| 652 | - $configPath = $this->getContentPath(); | ||
| 653 | - $configContent = $paths['configFile']['path']; | ||
| 654 | - } else { | ||
| 655 | - $configPath = $this->getContentPath(); | ||
| 656 | - if(!$configPath) return false; | ||
| 657 | - $ini = new iniUtilities($configPath); | ||
| 658 | - $data = $ini->getFileByLine(); | ||
| 659 | - $configContent = ''; | ||
| 660 | - foreach ($data as $k=>$v) { | ||
| 661 | - if(preg_match('/config.ini/', $k)) { | ||
| 662 | - $configContent = $k; | ||
| 663 | - break; | ||
| 664 | - } | ||
| 665 | - } | ||
| 666 | - } | ||
| 667 | - $fp = fopen($configPath, 'w'); | 644 | + private function writeConfigPath($configPath, $configContent) { |
| 645 | +// $conf = $this->getDataFromSession("configuration"); // get data from the server | ||
| 646 | +// $paths = $conf['paths']; | ||
| 647 | +// if(isset($paths['configFile']['path'])) { | ||
| 648 | +// $configPath = $this->getContentPath(); | ||
| 649 | +// $configContent = $paths['configFile']['path']; | ||
| 650 | +// } else { | ||
| 651 | +// $configPath = $this->getContentPath(); | ||
| 652 | +// if(!$configPath) return false; | ||
| 653 | +// $this->util->iniHandler->load($configPath); | ||
| 654 | +// $data = $this->util->iniHandler->getFileByLine(); | ||
| 655 | +// $configContent = ''; | ||
| 656 | +// foreach ($data as $k=>$v) { | ||
| 657 | +// if(preg_match('/config.ini/', $k)) { | ||
| 658 | +// $configContent = $k; | ||
| 659 | +// break; | ||
| 660 | +// } | ||
| 661 | +// } | ||
| 662 | +// } | ||
| 663 | +// print_r($configPath); | ||
| 664 | +// print_r($configContent); | ||
| 665 | + $fp = fopen($configPath, 'w+'); | ||
| 668 | if(fwrite($fp, $configContent)) | 666 | if(fwrite($fp, $configContent)) |
| 669 | return true; | 667 | return true; |
| 670 | return false; | 668 | return false; |
| 671 | } | 669 | } |
| 672 | 670 | ||
| 673 | - private function writeCachePath() { | ||
| 674 | - $cachePath = $this->getCachePath(); | ||
| 675 | - if(!$cachePath) return false; | ||
| 676 | - $configPath = $this->getContentPath(); | ||
| 677 | - if(!$configPath) return false; | ||
| 678 | - $ini = new iniUtilities($configPath); | ||
| 679 | - $data = $ini->getFileByLine(); | ||
| 680 | - $cacheContent = ''; | ||
| 681 | - foreach ($data as $k=>$v) { | ||
| 682 | - if(preg_match('/cache/', $k)) { | ||
| 683 | - $cacheContent = $k; | ||
| 684 | - break; | ||
| 685 | - } | ||
| 686 | - } | ||
| 687 | - $fp = fopen($cachePath, 'w'); | 671 | + private function writeCachePath($cachePath, $cacheContent) { |
| 672 | +// $cachePath = $this->getCachePath(); | ||
| 673 | +// if(!$cachePath) return false; | ||
| 674 | +// $configPath = $this->getContentPath(); | ||
| 675 | +// if(!$configPath) return false; | ||
| 676 | +// $this->util->iniHandler->load($configPath); | ||
| 677 | +// $data = $this->util->iniHandler->getFileByLine(); | ||
| 678 | +// $cacheContent = ''; | ||
| 679 | +// foreach ($data as $k=>$v) { | ||
| 680 | +// if(preg_match('/cache/', $k)) { | ||
| 681 | +// $cacheContent = $k; | ||
| 682 | +// break; | ||
| 683 | +// } | ||
| 684 | +// } | ||
| 685 | + $fp = fopen($cachePath, 'w+'); | ||
| 688 | if($cacheContent != '') { | 686 | if($cacheContent != '') { |
| 689 | if(fwrite($fp, $cacheContent)) | 687 | if(fwrite($fp, $cacheContent)) |
| 690 | return true; | 688 | return true; |
setup/wizard/steps/database.php
| @@ -320,11 +320,11 @@ class database extends Step | @@ -320,11 +320,11 @@ class database extends Step | ||
| 320 | return false; | 320 | return false; |
| 321 | } | 321 | } |
| 322 | if($this->dport == '') { | 322 | if($this->dport == '') { |
| 323 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | 323 | + $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); |
| 324 | } else { | 324 | } else { |
| 325 | - $this->dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname); | 325 | + $this->util->dbHandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname); |
| 326 | } | 326 | } |
| 327 | - if (!$this->dbhandler->getDatabaseLink()) { | 327 | + if (!$this->util->dbHandler->getDatabaseLink()) { |
| 328 | $this->error['con'] = "Could not connect to the database, please check username and password"; | 328 | $this->error['con'] = "Could not connect to the database, please check username and password"; |
| 329 | return false; | 329 | return false; |
| 330 | } else { | 330 | } else { |
| @@ -339,7 +339,7 @@ class database extends Step | @@ -339,7 +339,7 @@ class database extends Step | ||
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | public function dbExists() { | 341 | public function dbExists() { |
| 342 | - return $this->dbhandler->useDb(); | 342 | + return $this->util->dbHandler->useDb(); |
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | public function match($str1, $str2) { | 345 | public function match($str1, $str2) { |
| @@ -583,7 +583,7 @@ class database extends Step | @@ -583,7 +583,7 @@ class database extends Step | ||
| 583 | * @return object mysql connection | 583 | * @return object mysql connection |
| 584 | */ | 584 | */ |
| 585 | private function connectMysql() { | 585 | private function connectMysql() { |
| 586 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | 586 | + $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); |
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | /** | 589 | /** |
| @@ -642,7 +642,7 @@ class database extends Step | @@ -642,7 +642,7 @@ class database extends Step | ||
| 642 | $this->error['con'] = "Could not create database: "; | 642 | $this->error['con'] = "Could not create database: "; |
| 643 | } | 643 | } |
| 644 | } | 644 | } |
| 645 | - $this->dbhandler->clearErrors(); | 645 | + $this->util->dbHandler->clearErrors(); |
| 646 | if(!$this->createDmsUser()) { // Create dms users | 646 | if(!$this->createDmsUser()) { // Create dms users |
| 647 | $this->error['con'] = "Could not create database users "; | 647 | $this->error['con'] = "Could not create database users "; |
| 648 | } | 648 | } |
| @@ -666,7 +666,7 @@ class database extends Step | @@ -666,7 +666,7 @@ class database extends Step | ||
| 666 | */ | 666 | */ |
| 667 | private function create() { | 667 | private function create() { |
| 668 | $sql = "CREATE DATABASE {$this->dname}"; | 668 | $sql = "CREATE DATABASE {$this->dname}"; |
| 669 | - if ($this->dbhandler->query($sql)) { | 669 | + if ($this->util->dbHandler->query($sql)) { |
| 670 | 670 | ||
| 671 | return true; | 671 | return true; |
| 672 | } | 672 | } |
| @@ -683,7 +683,7 @@ class database extends Step | @@ -683,7 +683,7 @@ class database extends Step | ||
| 683 | * @return boolean | 683 | * @return boolean |
| 684 | */ | 684 | */ |
| 685 | private function usedb() { | 685 | private function usedb() { |
| 686 | - if($this->dbhandler->useDb()) { | 686 | + if($this->util->dbHandler->useDb()) { |
| 687 | return true; | 687 | return true; |
| 688 | } else { | 688 | } else { |
| 689 | $this->error['con'] = "Error using database: {$this->dname}"; | 689 | $this->error['con'] = "Error using database: {$this->dname}"; |
| @@ -702,7 +702,7 @@ class database extends Step | @@ -702,7 +702,7 @@ class database extends Step | ||
| 702 | private function dropdb() { | 702 | private function dropdb() { |
| 703 | if($this->ddrop) { | 703 | if($this->ddrop) { |
| 704 | $sql = "DROP DATABASE {$this->dname};"; | 704 | $sql = "DROP DATABASE {$this->dname};"; |
| 705 | - if(!$this->dbhandler->query($sql)) { | 705 | + if(!$this->util->dbHandler->query($sql)) { |
| 706 | $this->error['con'] = "Cannot drop database: {$this->dname}"; | 706 | $this->error['con'] = "Cannot drop database: {$this->dname}"; |
| 707 | return false; | 707 | return false; |
| 708 | } | 708 | } |
| @@ -724,7 +724,7 @@ class database extends Step | @@ -724,7 +724,7 @@ class database extends Step | ||
| 724 | private function createDmsUser() { | 724 | private function createDmsUser() { |
| 725 | $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";"; | 725 | $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";"; |
| 726 | $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";"; | 726 | $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";"; |
| 727 | - if ($this->dbhandler->query($user1) && $this->dbhandler->query($user2)) { | 727 | + if ($this->util->dbHandler->query($user1) && $this->util->dbHandler->query($user2)) { |
| 728 | return true; | 728 | return true; |
| 729 | } else { | 729 | } else { |
| 730 | $this->error['con'] = "Could not create users for database: {$this->dname}"; | 730 | $this->error['con'] = "Could not create users for database: {$this->dname}"; |
| @@ -751,7 +751,7 @@ class database extends Step | @@ -751,7 +751,7 @@ class database extends Step | ||
| 751 | while (!feof($handle)) { | 751 | while (!feof($handle)) { |
| 752 | $query.= fgets($handle, 4096); | 752 | $query.= fgets($handle, 4096); |
| 753 | if (substr(rtrim($query), -1) == ';') { | 753 | if (substr(rtrim($query), -1) == ';') { |
| 754 | - $this->dbhandler->query($query); | 754 | + $this->util->dbHandler->query($query); |
| 755 | $query = ''; | 755 | $query = ''; |
| 756 | } | 756 | } |
| 757 | } | 757 | } |
| @@ -778,9 +778,9 @@ class database extends Step | @@ -778,9 +778,9 @@ class database extends Step | ||
| 778 | $sqlFile = $dbMigrate['dumpLocation']; | 778 | $sqlFile = $dbMigrate['dumpLocation']; |
| 779 | $this->parse_mysql_dump($sqlFile); | 779 | $this->parse_mysql_dump($sqlFile); |
| 780 | $dropPluginHelper = "TRUNCATE plugin_helper;"; | 780 | $dropPluginHelper = "TRUNCATE plugin_helper;"; |
| 781 | - $this->dbhandler->query($dropPluginHelper); | 781 | + $this->util->dbHandler->query($dropPluginHelper); |
| 782 | $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; | 782 | $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; |
| 783 | - $this->dbhandler->query($updateUrls); | 783 | + $this->util->dbHandler->query($updateUrls); |
| 784 | return true; | 784 | return true; |
| 785 | } | 785 | } |
| 786 | /** | 786 | /** |
| @@ -793,7 +793,7 @@ class database extends Step | @@ -793,7 +793,7 @@ class database extends Step | ||
| 793 | */ | 793 | */ |
| 794 | private function closeMysql() { | 794 | private function closeMysql() { |
| 795 | try { | 795 | try { |
| 796 | - $this->dbhandler->close(); | 796 | + $this->util->dbHandler->close(); |
| 797 | } catch (Exeption $e) { | 797 | } catch (Exeption $e) { |
| 798 | $this->error['con'] = "Could not close: " . $e; | 798 | $this->error['con'] = "Could not close: " . $e; |
| 799 | } | 799 | } |
| @@ -844,7 +844,7 @@ class database extends Step | @@ -844,7 +844,7 @@ class database extends Step | ||
| 844 | $this->dpassword = 'root'; | 844 | $this->dpassword = 'root'; |
| 845 | $this->dname = 'dms_install'; | 845 | $this->dname = 'dms_install'; |
| 846 | $this->dbbinary = 'mysql'; | 846 | $this->dbbinary = 'mysql'; |
| 847 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | 847 | + $this->util->dbHandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); |
| 848 | $this->createSchema(); | 848 | $this->createSchema(); |
| 849 | echo 'Schema loaded<br>'; | 849 | echo 'Schema loaded<br>'; |
| 850 | } | 850 | } |
setup/wizard/steps/install.php
| @@ -107,14 +107,14 @@ class install extends step | @@ -107,14 +107,14 @@ class install extends step | ||
| 107 | public function callHome() { | 107 | public function callHome() { |
| 108 | $conf = $this->getDataFromSession("install"); // retrieve database information from session | 108 | $conf = $this->getDataFromSession("install"); // retrieve database information from session |
| 109 | $dbconf = $this->getDataFromSession("database"); | 109 | $dbconf = $this->getDataFromSession("database"); |
| 110 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | 110 | + $this->util->dbHandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection |
| 111 | $complete = 1; | 111 | $complete = 1; |
| 112 | if($conf['call_home'] == 'enable'){ | 112 | if($conf['call_home'] == 'enable'){ |
| 113 | $complete = 0; | 113 | $complete = 0; |
| 114 | } | 114 | } |
| 115 | $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'"; | 115 | $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'"; |
| 116 | - $this->dbhandler->query($query); | ||
| 117 | - $this->dbhandler->close(); // close the database connection | 116 | + $this->util->dbHandler->query($query); |
| 117 | + $this->util->dbHandler->close(); // close the database connection | ||
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | ?> | 120 | ?> |
| 121 | \ No newline at end of file | 121 | \ No newline at end of file |