diff --git a/bin/system_info.php b/bin/system_info.php new file mode 100644 index 0000000..8c3ae59 --- /dev/null +++ b/bin/system_info.php @@ -0,0 +1,176 @@ +. + * + * 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): ______________________________________ + */ + +/* +* Script to collect system information as part of a call home mechanism, no identifying information is stored. +* +* The following data is collected: +* Unique installation information: installation GUID, number of users in repository, number of documents in repository, +* operating system (platform, platform version, flavor if Linux), version and edition. +*/ +chdir(realpath(dirname(__FILE__))); +require_once('../config/dmsDefaults.php'); + +global $default; +$default->log->debug('System information collection script starting...'); + +// Get installation guid +function getGuid() +{ + $guid = KTUtil::getSystemIdentifier(); + + if(PEAR::isError($guid)){ + $guid = ''; + } + return $guid; +} + +// Get the number of users in the repository +function getUserCnt() +{ + $query = 'select count(*) as cnt, disabled from users where id > 0 group by disabled;'; + $result = DBUtil::getResultArray($query); + + if(empty($result) || PEAR::isError($result)){ + return ''; + } + $users = ''; + + foreach ($result as $row){ + $str = ''; + switch($row['disabled']){ + case 0: $str = 'Enabled'; break; + case 1: $str = 'Disabled'; break; + case 2: $str = 'Deleted'; break; + } + + $str .= ': '.$row['cnt']; + + $users .= (!empty($users)) ? '; ' : ''; + $users .= $str; + } + return $users; +} + +// Get the number of documents in the repository +function getDocCnt() +{ + $query = 'select count(*) as cnt, s.name from documents d, status_lookup s WHERE s.id = d.status_id group by d.status_id;'; + $result2 = DBUtil::getResultArray($query); + + if(empty($result2) || PEAR::isError($result2)){ + return ''; + } + $docs = ''; + + foreach ($result2 as $row){ + $docs .= (!empty($docs)) ? '; ' : ''; + $docs .= $row['name'].': '.$row['cnt']; + } + return $docs; +} + +// Get the version of KT +function getKTVersion() +{ + $version = KTUtil::getSystemSetting('knowledgeTreeVersion'); + if(empty($version) || PEAR::isError($version)){ + $version = file_get_contents(KT_DIR . 'docs/VERSION.txt'); + } + // remove newline that is in the version file + $version = str_replace("\n", '', $version); + return $version; +} + +// Get the edition of KT +function getKTEdition() +{ + $edition = 'Community'; + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { + $path = KTPluginUtil::getPluginPath('ktdms.wintools'); + require_once($path . 'baobabkeyutil.inc.php'); + $edition = BaobabKeyUtil::getName(); + + // Remove the brackets around the name + $edition = substr($edition, 1); + $edition = substr($edition, 0, strlen($edition)-1); + } + return $edition; +} + + +// Get OS info - platform, version, linux flavour +function getOSInfo() +{ + $server = php_uname(); + + if(strpos($server, 'Darwin') !== false){ + $os = 'Mac OS X'; + }else if(strpos($server, 'Win') !== false){ + $os = 'Windows'; + }else { + $os = 'Linux'; + } + + return $os; +} + +function sendForm($data) +{ + $url = 'http://ktnetwork.knowledgetree.com/call_home.php'; + //$url = 'http://10.33.20.250/knowledgetree/call_home.php'; + $data = http_build_query($data); + + $ch = curl_init($url); + curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_exec($ch); + curl_close($ch); +} + +$post_str = getGuid() .'|'. getUserCnt() .'|'. getDocCnt() .'|'. getKTVersion() .'|'. getKTEdition() .'|'. getOSInfo(); +$data['system_info'] = $post_str; + +sendForm($data); + +$default->log->debug('System information collection script finishing.'); +exit(0); +?> diff --git a/setup/migrate/ini.php b/setup/migrate/ini.php deleted file mode 100644 index 9820950..0000000 --- a/setup/migrate/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; - } -} -?> diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php index 7bf3000..4c42972 100644 --- a/setup/migrate/migrateUtil.php +++ b/setup/migrate/migrateUtil.php @@ -142,6 +142,11 @@ class MigrateUtil { return new $serviceName(); } + public function loadInstallIni($path) { + require_once("../wizard/ini.php"); + return new Ini($path); + } + public function redirect($url, $exit = true, $rfc2616 = false) { return $this->bootstrap->redirect($url, $exit = true, $rfc2616 = false); diff --git a/setup/migrate/migrater.php b/setup/migrate/migrater.php index f329caf..4c8fd81 100644 --- a/setup/migrate/migrater.php +++ b/setup/migrate/migrater.php @@ -510,6 +510,9 @@ class Migrater { } elseif (isset($_POST['BInstall'])) { $this->migraterAction = 'binstall'; $this->response = 'binstall'; +// } elseif (isset($_POST['Backup'])) { +// $this->migraterAction = 'backup'; +// $this->response = 'backup'; } else { $this->response = ''; $this->migraterAction = ''; @@ -545,8 +548,8 @@ class Migrater { } break; case 'previous': - $this->_backward(); // Load previous page - break; + $this->_backward(); // Load previous page + break; case 'install': $iutil = new MigrateUtil(); $iutil->redirect('../wizard/index.php?step_name=installtype'); @@ -555,6 +558,11 @@ class Migrater { $iutil = new MigrateUtil(); $iutil->redirect('../wizard/index.php?step_name=dependencies'); break; +// case 'backup': +// $iutil = new MigrateUtil(); +// $iutil->redirect('../upgrade/index.php?step_name=backup'); +// $iutil->redirect("..".DS."upgrade".DS."index.php?step_name=backup"); +// break; default: // TODO : handle silent $this->_landing(); diff --git a/setup/migrate/path.php b/setup/migrate/path.php deleted file mode 100644 index 09d142d..0000000 --- a/setup/migrate/path.php +++ /dev/null @@ -1,135 +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 Migrater -* @version Version 0.1 -*/ - // Define installer environment - define('DEBUG', 0); - define('AJAX', 0); - // Define migrater environment - if (substr(php_uname(), 0, 7) == "Windows"){ - define('WINDOWS_OS', true); - define('UNIX_OS', false); - define('OS', 'windows'); - } else { - define('WINDOWS_OS', false); - define('UNIX_OS', true); - define('OS', 'unix'); - } - if(WINDOWS_OS) { - define('DS', '\\'); - } else { - define('DS', '/'); - } - // Define environment root - $wizard = realpath(dirname(__FILE__)); - $xdir = explode(DS, $wizard); - array_pop($xdir); - array_pop($xdir); - $sys = ''; - foreach ($xdir as $k=>$v) { - $sys .= $v.DS; - } - // Define paths to wizard - define('MIGRATE_DIR', $wizard.DS); - define('WIZARD_LIB', MIGRATE_DIR."lib".DS); - define('SERVICE_LIB', WIZARD_LIB."services".DS); - define('SQL_DIR', MIGRATE_DIR."sql".DS); - define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS); - define('CONF_DIR', MIGRATE_DIR."config".DS); - define('RES_DIR', MIGRATE_DIR."resources".DS); - define('STEP_DIR', MIGRATE_DIR."steps".DS); - define('TEMP_DIR', MIGRATE_DIR."templates".DS); - define('SHELL_DIR', MIGRATE_DIR."shells".DS); - define('OUTPUT_DIR', MIGRATE_DIR."output".DS); - // Define paths to system webroot - define('SYSTEM_DIR', $sys); - define('SYS_VAR_DIR', SYSTEM_DIR."var".DS); - define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); - define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS); - define('SYS_OUT_DIR', SYS_VAR_DIR); - define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS); - // Define paths to system - array_pop($xdir); - $asys = ''; - foreach ($xdir as $k=>$v) { - $asys .= $v.DS; - } - define('SYSTEM_ROOT', $asys); - // Migrate Type - preg_match('/Zend/', $sys, $matches); // TODO: Dirty - if($matches) { - $sysdir = explode(DS, $sys); - array_pop($sysdir); - array_pop($sysdir); - array_pop($sysdir); - array_pop($sysdir); - $zendsys = ''; - foreach ($sysdir as $k=>$v) { - $zendsys .= $v.DS; - } - define('INSTALL_TYPE', 'Zend'); - define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS); - } else { - $modules = get_loaded_extensions(); - // TODO: Dirty - if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) { - define('INSTALL_TYPE', 'Zend'); - define('PHP_DIR', ''); - } else { - define('INSTALL_TYPE', ''); - define('PHP_DIR', ''); - } - } - // Other - date_default_timezone_set('Africa/Johannesburg'); - if(WINDOWS_OS) { // Mysql bin [Windows] - $serverPaths = explode(';',$_SERVER['PATH']); - foreach ($serverPaths as $apath) { - preg_match('/mysql/i', $apath, $matches); - if($matches) { - define('MYSQL_BIN', $apath.DS); - break; - } - } - } else { - define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line - } - -?> diff --git a/setup/migrate/session.php b/setup/migrate/session.php index cea3d4b..35e7a7a 100644 --- a/setup/migrate/session.php +++ b/setup/migrate/session.php @@ -175,7 +175,7 @@ class Session * @access public * @return void */ - public function destroy() { + public function destroyMigrate() { $this->startSession(); unset($_SESSION[$this->salt]); session_destroy(); diff --git a/setup/migrate/steps/migrateComplete.php b/setup/migrate/steps/migrateComplete.php index a38a7af..b341586 100644 --- a/setup/migrate/steps/migrateComplete.php +++ b/setup/migrate/steps/migrateComplete.php @@ -82,8 +82,9 @@ class migrateComplete extends Step { } private function checkSqlDump() { - $tmpFolder = "/tmp/knowledgtree"; - $sqlFile = $tmpFolder."dms.sql"; + $database = $this->getDataFromSession("database"); // Get installation directory + // TODO + $sqlFile = $_SESSION['migrate']['database']['dumpLocation']; if(file_exists($sqlFile)) { $this->temp_variables['sql']['class'] = "tick"; $this->temp_variables['sql']['name'] = "dms.sql"; diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php index 334e014..267f363 100644 --- a/setup/migrate/steps/migrateDatabase.php +++ b/setup/migrate/steps/migrateDatabase.php @@ -52,14 +52,13 @@ class migrateDatabase extends Step public $_dbhandler = null; /** - * Reference to Database object + * Reference to Utility object * * @author KnowledgeTree Team * @access public * @var object */ - public $_util = null; - + public $util = null; /** * List of errors encountered @@ -95,7 +94,7 @@ class migrateDatabase extends Step * @access public * @var array */ - protected $silent = true; + protected $silent = false; /** * List of errors used in template @@ -105,7 +104,7 @@ class migrateDatabase extends Step * @var array */ public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword'); - + private $sqlDumpFile = ''; /** * Constructs database object * @@ -137,6 +136,7 @@ class migrateDatabase extends Step } if($this->next()) { if($this->exportDatabase()) { + $this->storeSilent(); return 'next'; } } else if($this->previous()) { @@ -147,26 +147,78 @@ class migrateDatabase extends Step } public function exportDatabase() { - if(WINDOWS_OS) { - $tmpFolder = "../"; - } else { - $tmpFolder = "/tmp/knowledgtree"; + if($this->doTest()) { + $installation = $this->getDataFromSession("installation"); // Get installation directory + $dbSettings = $installation['dbSettings']; + $location = $installation['location']; + $uname = $this->temp_variables['duname']; + $pwrd = $this->temp_variables['dpassword']; + $tmpFolder = $this->resolveTempDir(); + if(WINDOWS_OS) { +// $tmpFolder = "tmp/"; + $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump + } else { +// $tmpFolder = "/tmp/"; + $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump + } + $sqlFile = $tmpFolder."/dms_migrate.sql"; + $dbAdminUser = $dbSettings['dbAdminUser']; + $dbAdminPass = $dbSettings['dbAdminPass']; + $dbName = $dbSettings['dbName']; + $cmd = "$exe -u{$dbAdminUser} -p{$dbAdminPass} $dbName > ".$sqlFile; +// echo $cmd; +// die; + $response = $this->util->pexec($cmd); + if(file_exists($sqlFile)) { + $fileContents = file_get_contents($sqlFile); + if(!empty($fileContents)) { + $this->sqlDumpFile = realpath($sqlFile); // Store location of dump + return true; + } + } } - @mkdir($tmpFolder); + + return false; + } + + // TODO +function resolveTempDir() +{ + + if (!WINDOWS_OS) + { + $dir='/tmp/kt-db-backup'; + } + else + { + $dir='c:/kt-db-backup'; + } +// $oKTConfig =& KTConfig::getSingleton(); +// $dir = $oKTConfig->get('backup/backupDirectory',$dir); + + if (!is_dir($dir)) + { + mkdir($dir); + } + return $dir; +} + + public function doTest() { + return true; $installation = $this->getDataFromSession("installation"); // Get installation directory $dbSettings = $installation['dbSettings']; + $location = $installation['location']; $uname = $this->temp_variables['duname']; $pwrd = $this->temp_variables['dpassword']; - $sqlFile = $tmpFolder."dms.sql"; - $dbName = $dbSettings['dbName']; - $cmd = "mysqldump -u{$uname} -p{$pwrd} {$dbName} > ".$sqlFile; - echo $cmd; - $response = $this->util->pexec($cmd); - if(file_exists($sqlFile)) { - return true; - } else { - return false; - } + //dmsadmin //clean1 // 3316 // TODO + $dbhandler = $this->util->loadInstallDBUtil(); + $dbhandler->load("localhost:3316",$uname, $pwrd, "dms"); + if (!$dbhandler->getDatabaseLink()) { + $this->error['con'] = "Could not connect to the database, please check username and password"; + return false; + } + + return true; } /** @@ -180,6 +232,7 @@ class migrateDatabase extends Step private function setDetails() { $this->temp_variables['duname'] = $this->getPostSafe('duname'); $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword'); + $this->temp_variables['dumpLocation'] = $this->getPostSafe('dumpLocation'); // create lock file to indicate migration mode $this->createMigrateFile(); } @@ -245,5 +298,12 @@ class migrateDatabase extends Step $this->error[$e] = false; } } + + private function storeSilent() { + // TODO + $_SESSION['migrate']['database']['dumpLocation'] = $this->sqlDumpFile; + $this->temp_variables['dumpLocation'] = $this->sqlDumpFile; + } + } ?> \ No newline at end of file diff --git a/setup/migrate/steps/migrateInstallation.php b/setup/migrate/steps/migrateInstallation.php index be8eedf..94f0f9b 100644 --- a/setup/migrate/steps/migrateInstallation.php +++ b/setup/migrate/steps/migrateInstallation.php @@ -78,15 +78,37 @@ class migrateInstallation extends step */ protected $silent = false; + /** + * Reference to Utility object + * + * @author KnowledgeTree Team + * @access public + * @var object + */ + public $util = null; + private $location = ''; private $dbSettings = array(); 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 + * + * @author KnowledgeTree Team + * @access public + * @var object + */ + private $settings = array(); + private $supportedVersion = '3.6.1'; + private $foundVersion = 'Unknown'; + private $versionError = false; + function __construct() { $this->temp_variables = array("step_name"=>"installation", "silent"=>$this->silent); + $this->util = new MigrateUtil(); } public function doStep() { @@ -120,7 +142,7 @@ class migrateInstallation extends step $this->location = $loc; } } else { - foreach ($this->knownUnixLocations as $loc) { + foreach ($this->knownUnixLocations as $loc=>$configPath) { if(file_exists($configPath)) $this->location = $loc; } @@ -128,6 +150,44 @@ class migrateInstallation extends step } public function doRun() { + if(!$this->readConfig()) { + $this->storeSilent(); + return false; + } else { + if($this->readVersion()) { + $this->checkVersion(); + } + $this->storeSilent(); + return true; + } + + } + + + + + public function checkVersion() { + if($this->foundVersion <= $this->supportedVersion) { + $this->versionError = true; + $this->error[] = "KT installation needs to be 3.6.1 or higher"; + } else { + return true; + } + } + + public function readVersion() { + $verFile = $this->location."/knowledgeTree/docs/VERSION.txt"; + if(file_exists($verFile)) { + $this->foundVersion = file_get_contents($verFile); + return true; + } else { + $this->error[] = "KT installation version not found"; + } + + return false; + } + + public function readConfig() { $ktInstallPath = isset($_POST['location']) ? $_POST['location']: ''; if($ktInstallPath != '') { $this->location = $ktInstallPath; @@ -136,7 +196,7 @@ class migrateInstallation extends step if(file_exists($configPath)) { $configFilePath = file_get_contents($configPath); if(file_exists($configFilePath)) { // For 3.7 and after - $this->readConfig($configFilePath); + $this->loadConfig($configFilePath); $this->storeSilent(); return true; @@ -144,7 +204,7 @@ class migrateInstallation extends step $configFilePath = $ktInstallPath.DS."knowledgeTree".DS.$configFilePath; // For older than 3.6.2 $configFilePath = trim($configFilePath); if(file_exists($configFilePath)) { - $this->readConfig($configFilePath); + $this->loadConfig($configFilePath); $this->storeSilent(); return true; @@ -158,19 +218,18 @@ class migrateInstallation extends step $this->error[] = "KT installation not found"; } } - $this->storeSilent(); return false; } - private function readConfig($path) { - $ini = new Ini($path); + private function loadConfig($path) { + $ini = $this->util->loadInstallIni($path);//new Ini($path); $dbSettings = $ini->getSection('db'); $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], 'dbName'=> $dbSettings['dbName'], 'dbUser'=> $dbSettings['dbUser'], 'dbPass'=> $dbSettings['dbPass'], - 'dbPort'=> $dbSettings['dbPort'], + 'dbPort'=> $dbSettings['dbPort'] == 'default' ? "3306":"", 'dbAdminUser'=> $dbSettings['dbAdminUser'], 'dbAdminPass'=> $dbSettings['dbAdminPass'], ); @@ -197,7 +256,9 @@ class migrateInstallation extends step private function setDetails() { $inst = $this->getDataFromSession("installation"); if ($inst) { - $this->location = $inst['location']; + if(file_exists($this->location)) { + $this->location = $inst['location']; + } } } @@ -210,9 +271,11 @@ class migrateInstallation extends step } public function storeSilent() { + if($this->location==1) { $this->location = '';} $this->temp_variables['location'] = $this->location; - - } - + $this->temp_variables['foundVersion'] = $this->foundVersion; + $this->temp_variables['versionError'] = $this->versionError; + $this->temp_variables['settings'] = $this->settings; + } } ?> \ No newline at end of file diff --git a/setup/migrate/templates/database.tpl b/setup/migrate/templates/database.tpl index c5da9c0..eca620e 100644 --- a/setup/migrate/templates/database.tpl +++ b/setup/migrate/templates/database.tpl @@ -2,31 +2,40 @@

Migrate Database

- This step configures the connection to the database server and migrates the database. The details for an administrative
- user on the database server are required in order to be able to configure and migrate the database. + This step configures the connection to the database server and migrates the database. + +
+

+ !!NB!! You are advised to backup your database before proceeding. !!NB!! + - - + + - - + + -
+
--> - - + + + - -

-The database upgrade wizard completes the upgrade process on an existing installation. It applies -any upgrades to the database that may be required. -

-Only administrator users may access the upgrade wizard. -

- -

- -
Username -
Password -
-
-
-$message"; - login(); -} - -function resolveMysqlDir() -{ - // possibly detect existing installations: - - if (OS_UNIX) - { - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); - $mysqlname ='mysql'; - } - else - { - $dirs = explode(';', $_SERVER['PATH']); - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; - $dirs[] = 'c:/program files/ktdms/mysql/bin'; - $mysqlname ='mysql.exe'; - } - - $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) - { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); - } - - foreach($dirs as $dir) - { - if (is_file($dir . '/' . $mysqlname)) - { - return $dir; - } - } - - return ''; -} - - -function create_backup_stmt($targetfile=null) -{ - $oKTConfig =& KTConfig::getSingleton(); - - $adminUser = $oKTConfig->get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - - $dbPort = trim($oKTConfig->get('db/dbPort')); - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $date=date('Y-m-d-H-i-s'); - - $dir=resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else - { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir=resolveTempDir(); - - if (is_null($targetfile)) - { - $targetfile="$tmpdir/kt-backup-$date.sql"; - } - - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; - $info['display']=$stmt; - $info['target']=$targetfile; - - - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function create_restore_stmt($targetfile) -{ - $oKTConfig =& KTConfig::getSingleton(); - - $adminUser = $oKTConfig->get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - $dbPort = trim($oKTConfig->get('db/dbPort')); - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $dir=resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else - { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir=resolveTempDir(); - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; - - - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; - $info['display']=$stmt; - - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; - - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function title($title) -{ - if (!isset($_SESSION['setup_user'])) - { - print ""; - } - print "

$title

"; -} - -function resolveTempDir() -{ - - if (OS_UNIX) - { - $dir='/tmp/kt-db-backup'; - } - else - { - $dir='c:/kt-db-backup'; - } - $oKTConfig =& KTConfig::getSingleton(); - $dir = $oKTConfig->get('backup/backupDirectory',$dir); - - if (!is_dir($dir)) - { - mkdir($dir); - } - return $dir; -} - - -function upgradeConfirm() -{ - title('Confirm Upgrade'); - if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) - { -?> -
-Please ensure that you have made a backup before continuing with the upgrade process. -

-
- -

-We are about to start the upgrade process. -

- -       -       - - - -Are you sure you want to perform the backup? - -

-Your mysql installation has been resolved. Manually, you would do the following: -

- - -
-cd "" -
- -The mysql backup utility could not be found automatically. Either do a manual backup, or edit the config.ini and update the backup/mysql Directory entry. -

-You can continue to do the backup manually using the following process: -

- - -
- - -
-

- -              - - - - - - - - There don't seem to be any backups to restore from the "" directory. - -

- Select a backup to restore from the list below: -

- - - - -
Filename - File Size - Action - -
- - - -
- - -

-       - - - -

-

-Manually, you would do the following to restore the backup: -

- - -\n", htmlspecialchars($upgrade->getDescriptor()), htmlspecialchars($upgrade->getDescription()), - $upgrade->isAlreadyApplied() ? "Yes" : "No" + $upgrade->isAlreadyApplied() ? "Yes" : "No" ); } $ret .= '
-cd "" -
- -The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. -

-You can continue to do the restore manually using the following command(s): -

- - - - -
- - -
-

- -Press continue to restore to attempt the command(s) above. - -

- - -       -       - - - -       - - - - The backup file "" has been created. -

It appears as though the backup has been successful. -

- - Manually, you would do the following to restore the backup: -

- - - - - - background="../resources/graphics/ktbg.png">  - -
- cd -
- - The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. -

- If you need to restore from this backup, you should be able to use the following statements: -

- - -
- - -
- - -It appears as though the backup process has failed.

Unfortunately, it is difficult to diagnose these problems automatically -and would recommend that you try to do the backup process manually. -

-We appologise for the inconvenience. -

- - -
- -
- -
- -       - -       - - - The restore of "" has been completed. -

- It appears as though the restore has been successful. -

- - - - -It appears as though the restore process has failed.

-Unfortunately, it is difficult to diagnose these problems automatically -and would recommend that you try to do the backup process manually. -

-We appologise for the inconvenience. -

- - -
- -
- - -
- -       - - - - - The backup is now underway. Please wait till it completes. - 0) - { - $_SESSION['backupStatus'] = true; - - } - else - { - $_SESSION['backupStatus'] = false; - } -?> - - -

- The mysqldump utility was not found in the subdirectory. - -       - - The restore is now underway. Please wait till it completes. - - - -

- The mysql utility was not found in the subdirectory. - -       - -
-Welcome to the Database Upgrade Wizard.

If you have just updated -your code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version. -

-You will not be able to log into until your the database upgrade process is completed. -

-!!NB!! You are advised to backup the database before attempting the upgrade. !!NB!! -

-If you have already done this, you may skip this step can continue directly to the upgrade. -

- - -       -       -       -       - - - -

The table below describes the upgrades that need to occur to - upgrade your installation to systemVersion;?>. - Click on the button below the table to perform the upgrades.

- -
- -       -       - -

The table below describes the upgrades that have occurred to - upgrade your installation to systemVersion;?>. - - -Pre-Upgrade actions failed.
- -

-Pre-Upgrade actions succeeded.
- -

- -Upgrade failed. - -

-Upgrade succeeded. - -

- -Post-Upgrade actions failed.

- -

-Post-Upgrade actions succeeded.

- - - -       -       - -

get('ui/poweredByDisabled') == '0'){ - ?> align="right">
+header("Location: upgrade/"); +exit(); \ No newline at end of file diff --git a/setup/upgrade/index.php b/setup/upgrade/index.php index 30b902d..5048495 100644 --- a/setup/upgrade/index.php +++ b/setup/upgrade/index.php @@ -1,6 +1,6 @@ temp_variables = array("step_name"=>"backup", "silent"=>$this->silent); @@ -65,7 +62,7 @@ class upgradeBackup extends Step { $this->util = new UpgradeUtil(); } - function doStep() { + public function doStep() { parent::doStep(); if(!$this->inStep("backup")) { $this->doRun(); @@ -75,16 +72,50 @@ class upgradeBackup extends Step { if ($this->doRun()) { return 'next'; } - } else if($this->previous()) { + } + else if ($this->confirm()) { + if ($this->doRun('confirm')) { + return 'confirm'; + } + } + else if ($this->backupNow()) { + if ($this->doRun('backupNow')) { + return 'next'; + } + else { + return 'error'; + } + } + else if($this->previous()) { return 'previous'; } + else if ($this->upgrade()) { + header('Location: index.php?step_name=database'); + exit; + } $this->doRun(); return 'landing'; } - function doRun() { - $this->backupConfirm(); + private function backupNow() + { + return isset($_POST['BackupNow']); + } + + private function doRun($action = null) { + $this->temp_variables['action'] = $action; + + if (is_null($action) || ($action == 'confirm')) { + $this->temp_variables['title'] = 'Confirm Backup'; + $this->backupConfirm(); + } + else { + $this->temp_variables['title'] = 'Backup Created'; + $this->backup(); + // TODO error checking (done in backupDone at the moment) + $this->backupDone(); + } $this->storeSilent();// Set silent mode variables return true; @@ -98,273 +129,146 @@ class upgradeBackup extends Step { } private function backup() { - check_state(1); - set_state(2); - title('Backup In Progress'); - $targetfile=$_SESSION['backupFile']; - $stmt=create_backup_stmt($targetfile); - $dir=$stmt['dir']; - - - + $targetfile = $_SESSION['backupFile']; + $stmt = $this->create_backup_stmt($targetfile); + $dir = $stmt['dir']; if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe')) { - ob_flush(); - flush(); - ?> - The backup is now underway. Please wait till it completes. - resolveTempDir(); + $dir = $this->util->resolveTempDir(); $_SESSION['backupFile'] = $stmt['target']; - if (OS_UNIX) - { - chmod($stmt['target'],0600); - } + if (OS_UNIX) { + chmod($stmt['target'],0600); + } - if (is_file($stmt['target']) && filesize($stmt['target']) > 0) - { + if (is_file($stmt['target']) && filesize($stmt['target']) > 0) { $_SESSION['backupStatus'] = true; - } - else - { + else { $_SESSION['backupStatus'] = false; } - ?> - - -

- The mysqldump utility was not found in the subdirectory. - -        - temp_variables['backupStatus'] = $status; if ($status) { - $stmt=create_restore_stmt($filename); - ?> - The backup file "" has been created. + $stmt = $this->util->create_restore_stmt($filename); + $this->temp_variables['display'] = 'The backup file "' . $filename . '" has been created.

It appears as though the backup has been successful. -

- '; if ($stmt['dir'] != '') { - ?> - Manually, you would do the following to restore the backup: + $this->temp_variables['dir'] = $stmt['dir']; + $this->temp_variables['display'] .= 'Manually, you would do the following to restore the backup:

- cd -
- cd ' . $stmt['dir'] . ' +
'; } else { - ?> - The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry. + $this->temp_variables['display'] .= 'The mysql backup utility could not be found automatically. Please edit the config.ini and update the backup/mysql Directory entry.

If you need to restore from this backup, you should be able to use the following statements:

-
- '; } - ?> - -
- - temp_variables['display'] .= '' . $stmt['display'] . ' +

'; } else { - ?> - It appears as though the backup process has failed.

Unfortunately, it is difficult to diagnose these problems automatically - and would recommend that you try to do the backup process manually. -

- We appologise for the inconvenience. -

- - -
- -
- temp_variables['display'] .= 'It appears as though the backup process has failed.

Unfortunately, it is difficult to diagnose these problems automatically + and would recommend that you try to do the backup process manually. +

+ We appologise for the inconvenience. +

+ + +
' . $_SESSION['backupOutput'] . '
'; } - ?> -
+ } + + private function create_backup_stmt($targetfile=null) + { + $oKTConfig =& KTConfig::getSingleton(); -        - get('db/dbAdminUser'); + $adminPwd = $oKTConfig->get('db/dbAdminPass'); + $dbHost = $oKTConfig->get('db/dbHost'); + $dbName = $oKTConfig->get('db/dbName'); + + $dbPort = trim($oKTConfig->get('db/dbPort')); + if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); + if (empty($dbPort)) $dbPort='3306'; + $dbSocket = trim($oKTConfig->get('db/dbSocket')); + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; + + $date=date('Y-m-d-H-i-s'); + + $dir=$this->util->resolveMysqlDir(); + + $info['dir']=$dir; + + $prefix=''; + if (OS_UNIX) { - ?> -        + $prefix .= "./"; + } - get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - - $dbPort = trim($oKTConfig->get('db/dbPort')); - if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $date=date('Y-m-d-H-i-s'); - - $dir=$this->resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else - { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir=$this->resolveTempDir(); - - if (is_null($targetfile)) - { - $targetfile="$tmpdir/kt-backup-$date.sql"; - } - - $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; - $info['display']=$stmt; - $info['target']=$targetfile; - - - $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function resolveMysqlDir() -{ - // possibly detect existing installations: - - if (OS_UNIX) - { - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); - $mysqlname ='mysql'; - } - else - { - $dirs = explode(';', $_SERVER['PATH']); - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; - $dirs[] = 'c:/program files/ktdms/mysql/bin'; - $mysqlname ='mysql.exe'; - } - - $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) - { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); - } - - foreach($dirs as $dir) - { - if (is_file($dir . '/' . $mysqlname)) + else { - return $dir; + $mechanism="--port=\"$dbPort\""; } + + $tmpdir=$this->util->resolveTempDir(); + + if (is_null($targetfile)) + { + $targetfile="$tmpdir/kt-backup-$date.sql"; + } + + $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; + $info['display']=$stmt; + $info['target']=$targetfile; + + + $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; + $info['cmd']=$stmt; + return $info; } - return ''; -} - -function resolveTempDir() -{ - - if (OS_UNIX) - { - $dir='/tmp/kt-db-backup'; - } - else - { - $dir='c:/kt-db-backup'; - } - $oKTConfig =& KTConfig::getSingleton(); - $dir = $oKTConfig->get('backup/backupDirectory',$dir); - - if (!is_dir($dir)) + private function backupConfirm() { - mkdir($dir); + $stmt = $this->create_backup_stmt(); + $_SESSION['backupFile'] = $stmt['target']; + + $dir = $stmt['dir']; + $this->temp_variables['dir'] = $dir; + $this->temp_variables['display'] = $stmt['display']; } - return $dir; -} - - -function backupConfirm() -{ - $stmt = $this->create_backup_stmt(); - $_SESSION['backupFile'] = $stmt['target']; - - $dir = $stmt['dir']; - $this->temp_variables['dir'] = $dir; - $this->temp_variables['display'] = $stmt['display']; -} - - - } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeComplete.php b/setup/upgrade/steps/upgradeComplete.php index edba512..0896c1a 100644 --- a/setup/upgrade/steps/upgradeComplete.php +++ b/setup/upgrade/steps/upgradeComplete.php @@ -40,35 +40,24 @@ * @version Version 0.1 */ -class upgradeComplete extends Step { +require '../../config/dmsDefaults.php'; - /** - * Reference to Database object - * - * @author KnowledgeTree Team - * @access private - * @var object - */ - private $_dbhandler = null; +class upgradeComplete extends Step { - private $privileges_check = 'tick'; - private $database_check = 'tick'; - protected $silent = true; - protected $util = null; + protected $silent = false; + protected $temp_variables = array(); public function __construct() { $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); - $this->_dbhandler = new dbUtil(); - $this->util = new UpgradeUtil(); } - function doStep() { + public function doStep() { $this->doRun(); return 'landing'; } - function doRun() { + private function doRun() { $this->storeSilent();// Set silent mode variables } @@ -78,5 +67,6 @@ class upgradeComplete extends Step { */ private function storeSilent() { } + } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php index 2898ebb..2152471 100644 --- a/setup/upgrade/steps/upgradeDatabase.php +++ b/setup/upgrade/steps/upgradeDatabase.php @@ -1,6 +1,6 @@ initErrors(); - $this->setDetails(); // Set any posted variables if(!$this->inStep("database")) { $this->doRun(); return 'landing'; } if($this->next()) { - if ($this->doRun()) { - return 'next'; - } + $this->doRun('preview'); + return 'next'; } else if($this->previous()) { return 'previous'; } - else if ($this->backup()) { - return 'backup'; - } - else if ($this->restore()) { - return 'restore'; - } - else if ($this->upgrading()) { - $this->doRun('runUpgrade'); + else if ($this->confirmUpgrade()) { + $this->doRun('confirm'); return 'next'; } - else if ($this->confirm()) { - if ($this->doRun('confirm')) { + else if ($this->upgrading()) { + if ($this->doRun('runUpgrade')) { return 'next'; } return 'error'; @@ -304,19 +164,15 @@ class upgradeDatabase extends Step return 'landing'; } - function backup() { - return isset($_POST['Backup']); + private function confirmUpgrade() { + return isset($_POST['ConfirmUpgrade']); } - - function restore() { - return isset($_POST['Restore']); - } - - function upgrading() { + + private function upgrading() { return isset($_POST['RunUpgrade']); } - function doRun($action = null) { + private function doRun($action = null) { $this->readConfig(KTConfig::getConfigFilename()); if($this->dbSettings['dbPort'] == '') { @@ -327,21 +183,18 @@ class upgradeDatabase extends Step $this->dbSettings['dbPass'], $this->dbSettings['dbName']); } + $this->temp_variables['action'] = $action; if (is_null($action) || ($action == 'preview')) { - $this->temp_variables['action'] = 'preview'; $this->temp_variables['title'] = 'Preview Upgrade'; $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); } - else if ($action == 'runUpgrade') { - $this->temp_variables['action'] = 'runUpgrade'; + else if ($action == 'confirm') { $this->temp_variables['title'] = 'Confirm Upgrade'; $this->temp_variables['upgradeTable'] = $this->upgradeConfirm(); } - else if ($action == 'confirm') { - $this->temp_variables['action'] = 'confirm'; + else if ($action == 'runUpgrade') { $this->temp_variables['title'] = 'Upgrade In Progress'; - if (!$this->upgrade()) { - $this->temp_variables['upgradeTable'] = $this->upgradeErrors(); + if (!$this->upgradeDatabase()) { return false; } } @@ -349,7 +202,7 @@ class upgradeDatabase extends Step return true; } - public function generateUpgradeTable() { + private function generateUpgradeTable() { global $default; $this->temp_variables['systemVersion'] = $default->systemVersion; @@ -372,7 +225,7 @@ class upgradeDatabase extends Step $ret .= sprintf("

%s%s%s
'; @@ -380,42 +233,6 @@ class upgradeDatabase extends Step } /** - * Store options - * - * @author KnowledgeTree Team - * @params object SimpleXmlObject - * @access private - * @return void - */ - private function setDetails() { - // create lock file to indicate Upgrade mode - $this->createUpgradeFile(); - } - - /** - * Creates miUpgradeock file so that system knows it is supposed to run an upgrade installation - * - * @author KnowledgeTree Team - * @access private - * @return void - */ - private function createUpgradeFile() { - @touch($this->wizardLocation . DIRECTORY_SEPARATOR . "upgrade.lock"); - } - - /** - * Safer way to return post data - * - * @author KnowledgeTree Team - * @params SimpleXmlObject $simplexml - * @access public - * @return void - */ - public function getPostSafe($key) { - return isset($_POST[$key]) ? $_POST[$key] : ""; - } - - /** * Stores varibles used by template * * @author KnowledgeTree Team @@ -465,100 +282,161 @@ class upgradeDatabase extends Step 'dbAdminUser'=> $dbSettings['dbAdminUser'], 'dbAdminPass'=> $dbSettings['dbAdminPass'], ); -// $ktSettings = $ini->getSection('KnowledgeTree'); -// $froot = $ktSettings['fileSystemRoot']; -// if ($froot == 'default') { -// $froot = $this->location; -// } -// $this->ktSettings = array('fileSystemRoot'=> $froot, -// ); -// $urlPaths = $ini->getSection('urls'); -// $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $froot.DS.'var'), -// array('name'=> 'Log Directory', 'path'=> $froot.DS.'log'), -// array('name'=> 'Document Root', 'path'=> $froot.DS.'Documents'), -// array('name'=> 'UI Directory', 'path'=> $froot.DS.'presentation'.DS.'lookAndFeel'.DS.'knowledgeTree'), -// array('name'=> 'Temporary Directory', 'path'=> $froot.DS.'tmp'), -// array('name'=> 'Cache Directory', 'path'=> $froot.DS.'cache'), -// ); -// $this->temp_variables['urlPaths'] = $this->urlPaths; -// $this->temp_variables['ktSettings'] = $this->ktSettings; $this->temp_variables['dbSettings'] = $this->dbSettings; } - function upgradeConfirm() + private function upgradeConfirm() { - if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) - { + if (!isset($_SESSION['backupStatus']) || $_SESSION['backupStatus'] === false) { $this->temp_variables['backupStatus'] = false; } + else { + $this->temp_variables['backupStatus'] = true; + } } - -function upgrade() -{ - global $default; -?> -

The table below describes the upgrades that have occurred to - upgrade your installation to systemVersion;?>. - - -Pre-Upgrade actions failed.
- -

-Pre-Upgrade actions succeeded.
-temp_variables['detail'] = '

The table below describes the upgrades that have occurred to + upgrade your KnowledgeTree installation to ' . $default->systemVersion . ''; + + $pre_res = $this->performPreUpgradeActions(); + if (PEAR::isError($pre_res)) { + $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions failed.'; + } + else { + $this->temp_variables['preUpgrade'] = 'Pre-Upgrade actions succeeded.'; + + } + + $res = $this->performAllUpgrades(); + if (PEAR::isError($res) || PEAR::isError($pres)) { + // TODO instantiate error details hideable section + $this->temp_variables['upgradeStatus'] = 'Database upgrade failed +

+ Please restore from your backup and ensure that the database does not contain + any unsupported modifications and try the upgrade process again. +

+ If the problem persists, contact KnowledgeTree Support.'; + } + else { + $this->temp_variables['upgradeStatus'] = 'Upgrade succeeded.'; + } + + $post_pres = $this->performPostUpgradeActions(); + if (PEAR::isError($post_res)) { + $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.'; + } + else { + $this->temp_variables['postUpgrade'] = 'Post-Upgrade actions succeeded.'; + } } -?> -

- -Upgrade failed. -cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + touch($lockFile); + return true; + } - else - { -?> -

-Upgrade succeeded. -proxyCacheDirectory; + KTUtil::deleteDirectory($proxyDir); + + $oKTCache = new KTCache(); + $oKTCache->deleteAllCaches(); + + // Clear the configuration cache, it'll regenerate on next load + $oKTConfig = new KTConfig(); + $oKTConfig->clearCache(); + + // Unlock the scheduler + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + if(file_exists($lockFile)){ + @unlink($lockFile); + } + + return true; + } -?> -

- -Post-Upgrade actions failed.

-system_settings_table); + $lastVersion = DBUtil::getOneResultKey($query, 'value'); + $currentVersion = $default->systemVersion; + + $upgrades = describeUpgrade($lastVersion, $currentVersion); + + $this->temp_variables['upgradeTable'] = ''; + + foreach ($upgrades as $upgrade) { + if (($row % 2) == 1) { + $class = "odd"; + } else { + $class = "even"; + } + $this->temp_variables['upgradeTable'] .= sprintf('

%s
' . "\n", $class, + htmlspecialchars($upgrade->getDescription())); + ++$row; + $res = $upgrade->performUpgrade(); + $this->temp_variables['upgradeTable'] .= sprintf('
%s
', $this->showResult($res)); + $this->temp_variables['upgradeTable'] .= '
' . "\n"; + $this->temp_variables['upgradeTable'] .= "
\n"; + if (PEAR::isError($res)) { + if (!is_a($res, 'Upgrade_Already_Applied')) { + break; + } else { + $res = true; + } + } + if ($res === false) { + $res = PEAR::raiseError("Upgrade returned false"); + break; + } + } + + return $res; } - else - { -?> -

-Post-Upgrade actions succeeded.

- -Already applied'; + } + return sprintf('%s', htmlspecialchars($res->toString())); + } + if ($res === true) { + return 'Success'; + } + if ($res === false) { + return 'Failure'; + } + return $res; } -?> - -       -       - \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeInstallation.php b/setup/upgrade/steps/upgradeInstallation.php index ce09f88..2354f5a 100644 --- a/setup/upgrade/steps/upgradeInstallation.php +++ b/setup/upgrade/steps/upgradeInstallation.php @@ -1,6 +1,6 @@ temp_variables = array("step_name"=>"welcome"); + public function __construct() { + $this->temp_variables = array("step_name"=>"installation"); } - function doStep() { + public function doStep() { parent::doStep(); if($this->next()) { - return 'next'; // Just a welcome, so return "next" action + return 'next'; + } + else if ($this->restore()) { + header('Location: index.php?step_name=restore'); + exit; + } + else if ($this->upgrade()) { + header('Location: index.php?step_name=database'); + exit; } return 'landing'; diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php index 06c1f8a..5b26336 100644 --- a/setup/upgrade/steps/upgradeRestore.php +++ b/setup/upgrade/steps/upgradeRestore.php @@ -1,6 +1,6 @@ util = new UpgradeUtil(); } - function doStep() { + public function doStep() { parent::doStep(); + $this->temp_variables['restore'] = false; + if(!$this->inStep("restore")) { $this->doRun(); return 'landing'; @@ -78,22 +78,40 @@ class upgradeRestore extends Step { } else if($this->previous()) { return 'previous'; } + else if ($this->restoreNow()) { + $this->temp_variables['restoreSuccessful'] = false; + $this->doRun(true); + return 'next'; + } $this->doRun(); return 'landing'; } - function doRun() { - if ($this->select()) { - $this->restoreSelected(); + private function restoreNow() { + return isset($_POST['RunRestore']); + } + + private function doRun($restore = false) { + if (!$restore) { + $this->temp_variables['selected'] = false; + if ($this->select()) { + $this->restoreSelected(); + $this->temp_variables['selected'] = true; + $this->temp_variables['availableBackups'] = true; + } + $this->restoreConfirm(); + } // end not running a restore, just setting up + else { + $this->restoreDatabase(); } - $this->restoreConfirm(); + $this->storeSilent();// Set silent mode variables return true; } - function select() { + private function select() { return isset($_POST['RestoreSelect']); } @@ -103,332 +121,126 @@ class upgradeRestore extends Step { */ private function storeSilent() { } - - function restore() -{ - check_state(1); - set_state(5); -// title('Restore In Progress'); - $status = $_SESSION['backupStatus']; - $filename=$_SESSION['backupFile']; - $stmt=create_restore_stmt($filename); - $dir=$stmt['dir']; - - - - if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) + private function restoreDatabase() { - -?> - The restore is now underway. Please wait till it completes. -temp_variables['restore'] = true; + $status = $_SESSION['backupStatus']; + $filename = $_SESSION['backupFile']; + $stmt = $this->util->create_restore_stmt($filename); + $dir = $stmt['dir']; + + if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) { - - $handle = popen($stmt, 'r'); - if ($handle=='false') + $curdir=getcwd(); + chdir($dir); + + $ok=true; + $stmts=explode("\n",$stmt['cmd']); + foreach($stmts as $stmt) { - $ok=false; - break; + + $handle = popen($stmt, 'r'); + if ($handle=='false') + { + $ok=false; + break; + } + $read = fread($handle, 10240); + pclose($handle); + $_SESSION['restoreOutput']=$read; } - $read = fread($handle, 10240); - pclose($handle); - $_SESSION['restoreOutput']=$read; - } - - - - - + $_SESSION['restoreStatus'] = $ok; - - -?> - - -

- The mysql utility was not found in the subdirectory. - -       - - The restore of "" has been completed. -

- It appears as though the restore has been successful. -

- - - - -It appears as though the restore process has failed.

-Unfortunately, it is difficult to diagnose these problems automatically -and would recommend that you try to do the backup process manually. -

-We appologise for the inconvenience. -

- - -
- -
- - -
- -       - -get('db/dbAdminUser'); - $adminPwd = $oKTConfig->get('db/dbAdminPass'); - $dbHost = $oKTConfig->get('db/dbHost'); - $dbName = $oKTConfig->get('db/dbName'); - $dbPort = trim($oKTConfig->get('db/dbPort')); - if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); - if (empty($dbPort)) $dbPort='3306'; - $dbSocket = trim($oKTConfig->get('db/dbSocket')); - if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); - if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - - $dir = $this->resolveMysqlDir(); - - $info['dir']=$dir; - - $prefix=''; - if (OS_UNIX) - { - $prefix .= "./"; - } - - if (@stat($dbSocket) !== false) - { - $mechanism="--socket=\"$dbSocket\""; - } - else - { - $mechanism="--port=\"$dbPort\""; - } - - $tmpdir = $this->resolveTempDir(); - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; - - - $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; - $info['display']=$stmt; - - - $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; - $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; - - $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; - $info['cmd']=$stmt; - return $info; -} - -function resolveMysqlDir() -{ - // possibly detect existing installations: - - if (OS_UNIX) - { - $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); - $mysqlname ='mysql'; - } - else - { - $dirs = explode(';', $_SERVER['PATH']); - $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; - $dirs[] = 'c:/program files/ktdms/mysql/bin'; - $mysqlname ='mysql.exe'; - } - - $oKTConfig =& KTConfig::getSingleton(); - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - - if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) - { - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); + // should be some sort of error checking, really + $this->restoreDone(); + } } - foreach($dirs as $dir) + private function restoreDone() { - if (is_file($dir . '/' . $mysqlname)) + $status = $_SESSION['restoreStatus']; + $filename = $_SESSION['backupFile']; + + if ($status) { - return $dir; + $this->temp_variables['display'] = 'The restore of "' . $filename . '" has been completed. +

+ It appears as though the restore has been successful. +

'; + + $this->temp_variables['title'] = 'Restore Complete'; + $this->temp_variables['restoreSuccessful'] = true; + } + else + { + $this->temp_variables['display'] = 'It appears as though the restore process has failed.

+ Unfortunately, it is difficult to diagnose these problems automatically + and would recommend that you try to do the backup process manually. +

+ We appologise for the inconvenience. +

+ + +
' . $_SESSION['restoreOutput'] . ' +
'; + $this->temp_variables['title'] = 'Restore Failed'; + $this->temp_variables['restoreSuccessful'] = false; } } - - return ''; -} - -function resolveTempDir() -{ - - if (OS_UNIX) - { - $dir='/tmp/kt-db-backup'; - } - else - { - $dir='c:/kt-db-backup'; - } - $oKTConfig =& KTConfig::getSingleton(); - $dir = $oKTConfig->get('backup/backupDirectory',$dir); - - if (!is_dir($dir)) - { - mkdir($dir); - } - return $dir; -} - - -function restoreSelect() -{ -// title('Select Backup to Restore'); - - $dir = $this->resolveTempDir(); - - $files = array(); - if ($dh = opendir($dir)) + + private function restoreSelect() { - while (($file = readdir($dh)) !== false) + $this->temp_variables['availableBackups'] = false; + $dir = $this->util->resolveTempDir(); + + $files = array(); + if ($dh = opendir($dir)) { - if (!preg_match('/kt-backup.+\.sql/',$file)) + while (($file = readdir($dh)) !== false) { - continue; + if (!preg_match('/kt-backup.+\.sql/',$file)) { + continue; + } + $files[] = $file; } - $files[] = $file; + closedir($dh); + } + + $this->temp_variables['title'] = 'Select Backup to Restore'; + $this->temp_variables['dir'] = $dir; + if (count($files) != 0) { + $this->temp_variables['availableBackups'] = true; + $this->temp_variables['files'] = $files; } - closedir($dh); - } - - if (count($files) == 0) - { - ?> - There don't seem to be any backups to restore from the "" directory. - -

- Select a backup to restore from the list below: -

-

- - - - -
Filename - File Size - Action - -
- - - -
- -
- util->resolveTempDir(); + $_SESSION['backupFile'] = $dir . '/' . $file; } - ?> - -

-       - resolveTempDir(); - $_SESSION['backupFile'] = $dir . '/' . $file; -?> -restoreSelect(); - exit; + if (!isset($_SESSION['backupFile']) || !is_file($_SESSION['backupFile']) || filesize($_SESSION['backupFile']) == 0) + { + $this->restoreSelect(); + return; + } + + $status = $_SESSION['backupStatus']; + $filename = $_SESSION['backupFile']; + $stmt = $this->util->create_restore_stmt($filename); + + $this->temp_variables['title'] = 'Confirm Restore'; + $this->temp_variables['dir'] = $stmt['dir']; + $this->temp_variables['display'] = $stmt['display']; + $this->temp_variables['availableBackups'] = true; + $this->temp_variables['selected'] = true; } - $status = $_SESSION['backupStatus']; - $filename=$_SESSION['backupFile']; - $stmt = $this->create_restore_stmt($filename); - - $this->temp_variables['dir'] = $stmt['dir']; - $this->temp_variables['display'] = $stmt['display']; -} - - - - } ?> \ No newline at end of file diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php index b311bcd..2450584 100644 --- a/setup/upgrade/steps/upgradeWelcome.php +++ b/setup/upgrade/steps/upgradeWelcome.php @@ -40,14 +40,13 @@ * @version Version 0.1 */ -global $default; -// include defaults include '../../config/dmsDefaults.php'; require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; class upgradeWelcome extends step { - protected $silent = true; + protected $silent = false; + protected $temp_variables = array(); public function __construct() { $this->temp_variables = array("step_name"=>"welcome"); @@ -76,7 +75,6 @@ class upgradeWelcome extends step { if (!$authenticated) { session_unset(); -// loginFailed(_kt('Could not authenticate administrative user')); return false; } diff --git a/setup/upgrade/templates/backup.tpl b/setup/upgrade/templates/backup.tpl index 8ade6b5..28bc28e 100644 --- a/setup/upgrade/templates/backup.tpl +++ b/setup/upgrade/templates/backup.tpl @@ -1,5 +1,5 @@

-

Confirm Backup

+


- Are you sure you want to perform the backup? - -

-Your mysql installation has been resolved. Manually, you would do the following: -

-

- - -
-cd "" -
-

+ Are you sure you want to perform the backup? + +

+ Your mysql installation has been resolved. Manually, you would do the following: +

+

+ + +
+ cd "" +
+

- - - - + + - \ No newline at end of file diff --git a/setup/upgrade/templates/complete.tpl b/setup/upgrade/templates/complete.tpl index d7fbce6..a10016a 100644 --- a/setup/upgrade/templates/complete.tpl +++ b/setup/upgrade/templates/complete.tpl @@ -1,53 +1,13 @@ +

-

Upgrade Completed

+

Database Upgrade Completed

-

This allows you to check that your KnowledgeTree configuration is set - up correctly. You can run this at any time after configuration to check - that things are still set up correctly.

- - ' - . '' - . 'Click Here for help on overcoming post Upgrade issues
'; - } - ?>


-

     "; ?>Services

- -
Show Details
- - + Your database has been upgraded to systemVersion; ?>
- Goto Installer + Goto Login
\ No newline at end of file diff --git a/setup/upgrade/templates/database.tpl b/setup/upgrade/templates/database.tpl index 42849c0..2d708dc 100644 --- a/setup/upgrade/templates/database.tpl +++ b/setup/upgrade/templates/database.tpl @@ -6,29 +6,47 @@


- +

The table below describes the upgrades that need to occur to upgrade your KnowledgeTree installation to . Click on the button below the table to perform the upgrades.

-
- Please ensure that you have made a backup before continuing with the upgrade process. -

-
- -

- We are about to start the upgrade process. -

+ else if ($action == 'confirm') { + if (!$backupStatus) { ?> +

We are about to start the upgrade process.

+ +
+ Please ensure that you have made a backup before continuing with the upgrade process. +

+ +
'; + echo $upgradeTable; + echo '

'; + echo $postUpgrade; + echo '

'; + echo $upgradeStatus; + echo '

'; + } + ?>

- + + + + - - + + \ No newline at end of file diff --git a/setup/upgrade/templates/installation.tpl b/setup/upgrade/templates/installation.tpl index 49c7ce7..b51f7a1 100644 --- a/setup/upgrade/templates/installation.tpl +++ b/setup/upgrade/templates/installation.tpl @@ -2,7 +2,6 @@

Current Installation

-

If you have just updated your KnowledgeTree code base, you will need to complete the upgrade process in order to ensure your system is fully operational with the new version.

@@ -19,7 +18,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/setup/upgrade/templates/progress.tpl b/setup/upgrade/templates/progress.tpl new file mode 100644 index 0000000..adc2bf5 --- /dev/null +++ b/setup/upgrade/templates/progress.tpl @@ -0,0 +1,69 @@ + + + + KnowledgeTree Upgrade Wizard + + + + + + + +

+ +
+
+ +
+
+

+
+
+ ".$error.""; + ?> + + '; + foreach ($errors as $msg){ + echo $msg . "
"; + ?> + Refresh + '; + } + } + ?> +

+ +
+
+
+
+
+
 
+
+ + +
+ + + \ No newline at end of file diff --git a/setup/upgrade/templates/restore.tpl b/setup/upgrade/templates/restore.tpl index 2f3a176..e13f8e0 100644 --- a/setup/upgrade/templates/restore.tpl +++ b/setup/upgrade/templates/restore.tpl @@ -1,5 +1,5 @@
-

Confirm Restore

+


-

-

-Manually, you would do the following to restore the backup: -

- - -
-cd "" -
-There don't seem to be any backups to restore from the "" directory. +

+ Select a backup to restore from the list below: +

+ + + + +
Filename + File Size + Action + - The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. -

-You can continue to do the restore manually using the following command(s): -

- - -
"> + + + + +
+ + + +

+

+ Manually, you would do the following to restore the backup: +

+ + +
+ cd "" +
+ + The mysql backup utility could not be found automatically. Either do a manual restore, or edit the config.ini and update the backup/mysql Directory entry. +

+ You can continue to do the restore manually using the following command(s): +

+ + + @@ -46,7 +81,7 @@ You can continue to do the restore manually using the following command(s): Press Next to attempt the command(s) above. @@ -56,9 +91,12 @@ Press Next to attempt the command(s) above. } ?> - - + + + + - + \ No newline at end of file diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php index 3ae678b..5cd0634 100644 --- a/setup/upgrade/upgradeUtil.php +++ b/setup/upgrade/upgradeUtil.php @@ -39,6 +39,9 @@ * @package Upgrader * @version Version 0.1 */ + +require '../../config/dmsDefaults.php'; + class UpgradeUtil { /** * Constructs upgradeation object @@ -79,6 +82,31 @@ class UpgradeUtil { ob_end_clean(); echo $contents; } + + /** + * Function to send output to the browser prior to normal dynamic loading of a template after code execution + * + * @param string $template The name of the template to use + * @param array $output [optional] Optional array containing output text to be inserted into the template + * @return + */ + public function flushOutput($template, $output = null) { + if (is_array($output)) { + foreach ($output as $key => $value) { + $template_vars[$key] = $value; + } + } + $file = "templates/" . $template; + 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; + } /** * Check if system needs to be upgraded @@ -637,6 +665,107 @@ class UpgradeUtil { } return join(" ", $aSafeArgs); } + + public function create_restore_stmt($targetfile) + { + $oKTConfig =& KTConfig::getSingleton(); + + $adminUser = $oKTConfig->get('db/dbAdminUser'); + $adminPwd = $oKTConfig->get('db/dbAdminPass'); + $dbHost = $oKTConfig->get('db/dbHost'); + $dbName = $oKTConfig->get('db/dbName'); + $dbPort = trim($oKTConfig->get('db/dbPort')); + if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); + if (empty($dbPort)) $dbPort='3306'; + $dbSocket = trim($oKTConfig->get('db/dbSocket')); + if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); + if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; + + $dir = $this->resolveMysqlDir(); + + $info['dir']=$dir; + + $prefix=''; + if (OS_UNIX) { + $prefix .= "./"; + } + + if (@stat($dbSocket) !== false) { + $mechanism="--socket=\"$dbSocket\""; + } + else { + $mechanism="--port=\"$dbPort\""; + } + + $tmpdir = $this->resolveTempDir(); + + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; + + + $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; + $info['display']=$stmt; + + + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; + $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; + + $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; + $info['cmd']=$stmt; + return $info; + } + + public function resolveMysqlDir() + { + // possibly detect existing installations: + + if (OS_UNIX) { + $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); + $mysqlname ='mysql'; + } + else + { + $dirs = explode(';', $_SERVER['PATH']); + $dirs[] ='c:/Program Files/MySQL/MySQL Server 5.0/bin'; + $dirs[] = 'c:/program files/ktdms/mysql/bin'; + $mysqlname ='mysql.exe'; + } + + $oKTConfig =& KTConfig::getSingleton(); + $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); + $dirs[] = $mysqldir; + + if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { + $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); + } + + foreach($dirs as $dir) + { + if (is_file($dir . '/' . $mysqlname)) + { + return $dir; + } + } + + return ''; + } + + public function resolveTempDir() + { + if (OS_UNIX) { + $dir='/tmp/kt-db-backup'; + } + else { + $dir='c:/kt-db-backup'; + } + $oKTConfig =& KTConfig::getSingleton(); + $dir = $oKTConfig->get('backup/backupDirectory',$dir); + + if (!is_dir($dir)) { + mkdir($dir); + } + return $dir; + } } ?> \ No newline at end of file diff --git a/setup/upgrade/upgradeWizard.php b/setup/upgrade/upgradeWizard.php index c6afb42..6d5fa30 100644 --- a/setup/upgrade/upgradeWizard.php +++ b/setup/upgrade/upgradeWizard.php @@ -186,6 +186,9 @@ class UpgradeWizard { * @return mixed */ public function systemChecks() { + // for now we don't write to any of these locations + return true; + $res = $this->iutil->checkStructurePermissions(); if($res === true) return $res; switch ($res) { diff --git a/setup/wizard/config/config.xml b/setup/wizard/config/config.xml index dfc3e7d..8f7f9e3 100644 --- a/setup/wizard/config/config.xml +++ b/setup/wizard/config/config.xml @@ -17,7 +17,7 @@ servicesdatabaseregistration - install + installcomplete \ No newline at end of file diff --git a/setup/wizard/config/databases.xml b/setup/wizard/config/databases.xml index cd2e9a5..c218cc2 100644 --- a/setup/wizard/config/databases.xml +++ b/setup/wizard/config/databases.xml @@ -14,8 +14,8 @@ localhost3306dms - root - dmsadminuser + dms + dmsadminjs9281djwdmsuserdjw9281js diff --git a/setup/wizard/dbUtil.php b/setup/wizard/dbUtil.php index a66ab22..55c3ed7 100644 --- a/setup/wizard/dbUtil.php +++ b/setup/wizard/dbUtil.php @@ -146,8 +146,8 @@ class dbUtil { * @return object The result of the query. */ public function query($query) { - $this->useDb(); - $result = mysql_query($query, $this->dbconnection); + $this->useDb(); + $result = mysql_query($query, $this->dbconnection); if($result) { return $result; } else { @@ -165,13 +165,12 @@ class dbUtil { */ public function execute($query) { $this->useDb(); - $result = @mysql_query($query, $this->dbconnection); - if($result) { - return true; - } else { + $result = @mysql_query($query, $this->dbconnection); + if(!$result) { $this->error[] = @mysql_error($this->dbconnection); - return false; } + + return $result; } /** @@ -200,10 +199,7 @@ class dbUtil { if ($result == NULL || @mysql_num_rows($result) < 1) return NULL; else { - $row = @mysql_fetch_assoc($result); - while ($row) { - $r[] = $row; - } + while(($r[] = mysql_fetch_assoc($result)) || array_pop($r)); return $r; } } diff --git a/setup/wizard/ini.php b/setup/wizard/ini.php index ce12911..3a41f0c 100644 --- a/setup/wizard/ini.php +++ b/setup/wizard/ini.php @@ -206,9 +206,18 @@ class Ini { 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/installUtil.php b/setup/wizard/installUtil.php index 3df47c2..55e029d 100644 --- a/setup/wizard/installUtil.php +++ b/setup/wizard/installUtil.php @@ -39,8 +39,8 @@ * @package Installer * @version Version 0.1 */ -class InstallUtil { - +class InstallUtil { + private $salt = 'installers'; /** * Constructs installation object @@ -50,7 +50,7 @@ class InstallUtil { */ public function __construct() { } - + /** * Check if system needs to be installed * @@ -64,7 +64,7 @@ class InstallUtil { return true; } - + return false; } @@ -100,13 +100,13 @@ class InstallUtil { /** * Redirect - * + * * This function redirects the client. This is done by issuing * a "Location" header and exiting if wanted. If you set $rfc2616 to true * HTTP will output a hypertext note with the location of the redirect. - * - * @static - * @access public + * + * @static + * @access public * have already been sent. * @param string $url URL where the redirect should go to. * @param bool $exit Whether to exit immediately after redirection. @@ -119,10 +119,10 @@ class InstallUtil { if (headers_sent()) { return false; } - + $url = $this->absoluteURI($url); header('Location: '. $url); - + if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') { printf('Redirecting to: %s.', $url, $url); @@ -135,21 +135,21 @@ class InstallUtil { /** * Absolute URI - * + * * This function returns the absolute URI for the partial URL passed. * The current scheme (HTTP/HTTPS), host server, port, current script * location are used if necessary to resolve any relative URLs. - * + * * Offsets potentially created by PATH_INFO are taken care of to resolve * relative URLs to the current script. - * - * You can choose a new protocol while resolving the URI. This is - * particularly useful when redirecting a web browser using relative URIs + * + * You can choose a new protocol while resolving the URI. This is + * particularly useful when redirecting a web browser using relative URIs * and to switch from HTTP to HTTPS, or vice-versa, at the same time. - * - * @author Philippe Jausions - * @static - * @access public + * + * @author Philippe Jausions + * @static + * @access public * @param string $url Absolute or relative URI the redirect should go to. * @param string $protocol Protocol to use when redirecting URIs. * @param integer $port A new port number. @@ -159,7 +159,7 @@ class InstallUtil { { // filter CR/LF $url = str_replace(array("\r", "\n"), ' ', $url); - + // Mess around with already absolute URIs if (preg_match('!^([a-z0-9]+)://!i', $url)) { if (empty($protocol) && empty($port)) { @@ -169,12 +169,12 @@ class InstallUtil { $url = $protocol .':'. end($array = explode(':', $url, 2)); } if (!empty($port)) { - $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', + $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', '\1:'. $port, $url); } return $url; } - + $host = 'localhost'; if (!empty($_SERVER['HTTP_HOST'])) { list($host) = explode(':', $_SERVER['HTTP_HOST']); @@ -192,7 +192,7 @@ class InstallUtil { $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; } } - + if ($protocol == 'http' && $port == 80) { unset($port); } @@ -201,31 +201,31 @@ class InstallUtil { } $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); - + if (!strlen($url)) { - $url = isset($_SERVER['REQUEST_URI']) ? + $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']; } - + if ($url{0} == '/') { return $server . $url; } - + // Check for PATH_INFO - if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && + if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) && $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) { $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO']))); } else { $path = dirname($_SERVER['PHP_SELF']); } - + if (substr($path = strtr($path, '\\', '/'), -1) != '/') { $path .= '/'; } - + return $server . $path . $url; } - + /** * Check whether a given directory / file path exists and is writable * @@ -244,7 +244,7 @@ class InstallUtil { } } - + /** * Check whether a given directory / file path exists and is writable * @@ -258,7 +258,7 @@ class InstallUtil { { if(!$file) $exist = 'Directory doesn\'t exist'; - else + else $exist = 'File doesn\'t exist'; $write = 'Directory not writable'; $ret = array('class' => 'cross'); @@ -280,12 +280,12 @@ class InstallUtil { $ret['msg'] = $exist; return $ret; } - mkdir($dir, '0755'); + mkdir($dir, 0755); } if(is_writable($dir)){ $ret['class'] = 'tick'; - + return $ret; } @@ -293,7 +293,7 @@ class InstallUtil { $ret['msg'] = $write; return $ret; } - + /** * Change permissions on a directory helper * @@ -305,7 +305,7 @@ class InstallUtil { public function canChangePermissions($folderPath) { return $this->_chmodRecursive($folderPath, 0755); } - + /** * Change permissions on a directory (recursive) * @@ -344,7 +344,7 @@ class InstallUtil { return true; } } - + /** * Check if a file can be written to a folder * @@ -358,11 +358,11 @@ class InstallUtil { if($fr = fwrite($fh, 'test') === false) { return false; } - + fclose($fh); return true; } - + /** * Attempt using the php-java bridge * @@ -379,7 +379,7 @@ class InstallUtil { } return true; } - + /** * Check if Zend Bridge is enabled * @@ -390,12 +390,12 @@ class InstallUtil { */ public function zendBridge() { $mods = get_loaded_extensions(); - if(in_array('Zend Java Bridge', $mods)) + if(in_array('Zend Java Bridge', $mods)) return true; - else + else return false; } - + /** * Attempt java detection * @@ -412,7 +412,7 @@ class InstallUtil { return 'java'; } - + /** * Attempt java detection * @@ -429,7 +429,7 @@ class InstallUtil { return 'java'; } - + /** * Attempt java detection * @@ -451,7 +451,7 @@ class InstallUtil { } } } - + /** * Check if user entered location of JRE * @@ -471,7 +471,7 @@ class InstallUtil { return false; } } - + /** * Check if user entered location of PHP * @@ -491,7 +491,7 @@ class InstallUtil { return false; } } - + public function openOfficeSpecified() { if(isset($_POST['soffice'])) { if($_POST['soffice'] != '') { @@ -503,7 +503,7 @@ class InstallUtil { return false; } } - + /** * Get session data from post * @@ -516,10 +516,10 @@ class InstallUtil { if(empty($_SESSION[$this->salt][$class])) { return false; } - + return $_SESSION[$this->salt][$class]; } - + /** * Determine the location of JAVA_HOME * @@ -539,7 +539,7 @@ class InstallUtil { return $response; } - + /** * Determine the location of PHP * @@ -562,10 +562,10 @@ class InstallUtil { if(file_exists(PHP_DIR."php")) { return PHP_DIR."php"; } - + return 'php'; } - + function getPhpHelper($cmd) { $response = $this->pexec($cmd); if(is_array($response['out'])) { @@ -579,10 +579,10 @@ class InstallUtil { } } } - - return ''; + + return ''; } - + function getOpenOffice() { $cmd = "whereis soffice"; $res = $this->getOpenOfficeHelper($cmd); @@ -594,10 +594,10 @@ class InstallUtil { if($res != '') { return $res; } - + return 'soffice'; } - + function getOpenOfficeHelper($cmd) { $response = $this->pexec($cmd); if(is_array($response['out'])) { @@ -611,11 +611,11 @@ class InstallUtil { } } } - + return ''; } - - + + /** * Portably execute a command on any of the supported platforms. * @@ -656,9 +656,9 @@ class InstallUtil { return $aRet; } - + /** - * + * * * @author KnowledgeTree Team * @access public @@ -681,9 +681,9 @@ class InstallUtil { } return $mDefault; } - + /** - * + * * * @author KnowledgeTree Team * @access public diff --git a/setup/wizard/lib/services/unixOpenOffice.php b/setup/wizard/lib/services/unixOpenOffice.php index 5ca89cb..83004be 100644 --- a/setup/wizard/lib/services/unixOpenOffice.php +++ b/setup/wizard/lib/services/unixOpenOffice.php @@ -112,37 +112,68 @@ class unixOpenOffice extends unixService { public function status($updrade = false) { sleep(1); - if($updrade) { - $cmd = "ps ax | grep soffice"; - } else { - $cmd = "netstat -npa | grep ".$this->getPort(); - } - $response = $this->util->pexec($cmd); + $cmd = "ps ax | grep soffice"; + $response = $this->util->pexec($cmd); if(is_array($response['out'])) { - if(count($response['out']) > 0) { - preg_match('/8100/', $response['out'][0], $matches); // Ignore grep - if($matches) { - if($matches[0] == '8100') { + if(count($response['out']) > 1) { + foreach ($response['out'] as $r) { + preg_match('/grep/', $r, $matches); // Ignore grep + if(!$matches) { return 'STARTED'; } - } + } } else { return ''; } } - + /* + if($updrade) { + $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) { + preg_match('/grep/', $r, $matches); // Ignore grep + if(!$matches) { + return 'STARTED'; + } + } + } else { + return ''; + } + } + } else { + $cmd = "netstat -npa | grep ".$this->getPort(); + $response = $this->util->pexec($cmd); + if(is_array($response['out'])) { + if(count($response['out']) > 0) { + preg_match('/8100/', $response['out'][0], $matches); // Ignore grep + if($matches) { + if($matches[0] == '8100') { + return 'STARTED'; + } + } + } else { + return ''; + } + } + } + */ return ''; } public function start() { $state = $this->status(); if($state != 'STARTED') { - $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; + //$cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".$this->outputDir."openoffice.log 2>&1 & echo $!"; +// $cmd = "{$this->getBin()} ".$this->getOption(); +//"/usr/bin/java" openOffice -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" /usr/bin/soffice +//"/usr/bin/java" -cp "/var/www/installers/knowledgetree/setup/wizard/lib/system/;" openOffice /usr/bin/soffice + $cmd = "\"{$this->util->getJava()}\" -cp \"".SYS_DIR."\" openOffice ".$this->getBin(); if(DEBUG) { echo "Command : $cmd
"; return ; } - $cmd .= "\"{$this->util->getJava()}\" -cp \"".SYS_DIR.";\" openOffice \""; $response = $this->util->pexec($cmd); return $response; diff --git a/setup/wizard/lib/system/openOffice.class b/setup/wizard/lib/system/openOffice.class index 91be5be..481786f 100644 --- a/setup/wizard/lib/system/openOffice.class +++ b/setup/wizard/lib/system/openOffice.class diff --git a/setup/wizard/lib/system/openOffice.java b/setup/wizard/lib/system/openOffice.java index a909a1f..bcc3728 100644 --- a/setup/wizard/lib/system/openOffice.java +++ b/setup/wizard/lib/system/openOffice.java @@ -5,12 +5,13 @@ import java.util.Properties; public class openOffice { public static void main(String args[]) throws Exception { + String openoffice = args[0]; try { // Execute a command without arguments - String command = "nohup /usr/bin/soffice -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\" > /dev/null 2>&1 & echo $!"; + String command = "nohup "+openoffice+" -nofirststartwizard -nologo -headless -accept=\"socket,host=localhost,port=8100;urp;StarOffice.ServiceManager\""; Process child = Runtime.getRuntime().exec(command); } catch (IOException e) { System.err.println("Error: " + e.getMessage()); } } -} \ No newline at end of file +} diff --git a/setup/wizard/resources/js/wizard.js b/setup/wizard/resources/js/wizard.js index 68ed23a..bdd493d 100644 --- a/setup/wizard/resources/js/wizard.js +++ b/setup/wizard/resources/js/wizard.js @@ -219,10 +219,16 @@ wizard.prototype.sendRegistration = function () { wizard.prototype.clearSessions = function () { var address = 'session.php?action=destroyInstall'; + w.clearASession(address); + var address = 'session.php?action=destroyMigrate'; + w.clearASession(address); +} + +wizard.prototype.clearASession = function (address) { $.ajax({ url: address, dataType: "html", type: "POST", cache: false, - }); + }); } \ No newline at end of file diff --git a/setup/wizard/steps/complete.php b/setup/wizard/steps/complete.php index 2df52e4..ea996df 100644 --- a/setup/wizard/steps/complete.php +++ b/setup/wizard/steps/complete.php @@ -84,6 +84,7 @@ class complete extends Step { // check services $this->checkServices(); $this->storeSilent();// Set silent mode variables + } private function checkFileSystem() @@ -172,7 +173,8 @@ class complete extends Step { } // make db connection - user - $loaded = $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); + $this->_dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); + $loaded = $this->_dbhandler->getDatabaseLink(); // if we can log in to the database, check access // TODO check write access? if ($loaded) @@ -242,6 +244,11 @@ class complete extends Step { $this->temp_variables['paths_check'] = $this->paths_check; $this->temp_variables['privileges_check'] = $this->privileges_check; $this->temp_variables['database_check'] = $this->database_check; + if (file_exists('migrate.lock')) { + $this->temp_variables['migrate_check'] = true; + } else { + $this->temp_variables['migrate_check'] = false; + } } } ?> \ No newline at end of file diff --git a/setup/wizard/steps/configuration.php b/setup/wizard/steps/configuration.php index 176fad7..f4d1ac0 100644 --- a/setup/wizard/steps/configuration.php +++ b/setup/wizard/steps/configuration.php @@ -296,8 +296,8 @@ class configuration extends Step */ public function registerDBConfig($server, $dbconf) { // Adjust server variables $server['dbName'] = array('where'=>'file', 'name'=>ucwords($dbconf['dname']), 'section'=>'db', 'value'=>$dbconf['dname'], 'setting'=>'dbName'); - $server['dbUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['duname']), 'section'=>'db', 'value'=>$dbconf['duname'], 'setting'=>'dbUser'); - $server['dbPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dpassword']), 'section'=>'db', 'value'=>$dbconf['dpassword'], 'setting'=>'dbPass'); + $server['dbUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmsname']), 'section'=>'db', 'value'=>$dbconf['dmsname'], 'setting'=>'dbUser'); + $server['dbPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmspassword']), 'section'=>'db', 'value'=>$dbconf['dmspassword'], 'setting'=>'dbPass'); $server['dbPort'] = array('where'=>'file', 'name'=>ucwords($dbconf['dport']), 'section'=>'db', 'value'=>$dbconf['dport'], 'setting'=>'dbPort'); $server['dbAdminUser'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmsname']), 'section'=>'db', 'value'=>$dbconf['dmsname'], 'setting'=>'dbAdminUser'); $server['dbAdminPass'] = array('where'=>'file', 'name'=>ucwords($dbconf['dmspassword']), 'section'=>'db', 'value'=>$dbconf['dmspassword'], 'setting'=>'dbAdminPass'); diff --git a/setup/wizard/steps/database.php b/setup/wizard/steps/database.php index 2564802..ef5758a 100644 --- a/setup/wizard/steps/database.php +++ b/setup/wizard/steps/database.php @@ -636,6 +636,10 @@ class database extends Step } + if(!$this->importExportedDB()) { + $this->error['con'] = "Could not Import "; + } + return true; } @@ -755,7 +759,7 @@ class database extends Step } else { $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->execute($user1) && $this->_dbhandler->execute($user2)) { + if ($this->_dbhandler->query($user1) && $this->_dbhandler->query($user2)) { return true; } else { $this->error['con'] = "Could not create users for database: {$this->dname}"; @@ -784,7 +788,7 @@ class database extends Step while (!feof($handle)) { $query.= fgets($handle, 4096); if (substr(rtrim($query), -1) == ';') { - $this->_dbhandler->execute($query); + $this->_dbhandler->query($query); $query = ''; } } @@ -805,6 +809,20 @@ class database extends Step return $this->parse_mysql_dump(SQL_INSTALL_DIR."data.sql"); } + private function importExportedDB() { + if (!WINDOWS_OS) { + $dir='/tmp/kt-db-backup'; + } + else { + $dir='c:/kt-db-backup'; + } + $sqlFile = $dir."/dms_migrate.sql"; + $this->parse_mysql_dump($sqlFile); + $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); +// $this->_dbhandler->query("TRUNCATE plugins;"); + $this->_dbhandler->query("TRUNCATE plugin_helper;"); + return true; + } /** * Close connection if it exists * diff --git a/setup/wizard/steps/install.php b/setup/wizard/steps/install.php index af4f620..7313cdb 100644 --- a/setup/wizard/steps/install.php +++ b/setup/wizard/steps/install.php @@ -1,6 +1,6 @@ temp_variables = array("step_name"=>"install"); } @@ -52,12 +70,14 @@ class install extends step return 'landing'; } if($this->install()) { + $this->doRun(); return 'install'; } else if($this->previous()) { return 'previous'; } - return 'landing'; + $this->doRun(); + return 'landing'; } public function getStepVars() @@ -68,5 +88,41 @@ class install extends step public function getErrors() { return $this->error; } + + public function doRun() + { + if(isset($_POST['Install'])) { + if(isset($_POST['call_home'])){ + $value = $_POST['call_home']; + }else{ + $value = 'disable'; + } + $this->temp_variables['call_home'] = $value; + + // Force a set session + // TODO: fix this to correctly set the session + $_SESSION['installers'] ['install']['call_home'] = $value; + } + } + + public function installStep() + { + $conf = $this->getDataFromSession("install"); + // retrieve database information from session + // initialise the db connection + $this->_dbhandler = new dbUtil(); + $dbconf = $this->getDataFromSession("database"); + $this->_dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); + + $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); + + // close the database connection + $this->_dbhandler->close(); + } } ?> \ No newline at end of file diff --git a/setup/wizard/templates/complete.tpl b/setup/wizard/templates/complete.tpl index 990c351..aa63d2a 100644 --- a/setup/wizard/templates/complete.tpl +++ b/setup/wizard/templates/complete.tpl @@ -117,7 +117,12 @@ - Goto Login + + + Goto Login + + Goto Login + diff --git a/setup/wizard/templates/install.tpl b/setup/wizard/templates/install.tpl index d5d22e4..d518c4b 100644 --- a/setup/wizard/templates/install.tpl +++ b/setup/wizard/templates/install.tpl @@ -5,9 +5,14 @@

- The wizard will now complete the installation and run a final check on the system. + The wizard will now complete the installation and run a final check on the system. +

+
image('kt_browse.png'); ?>
+
+
+

+ Enable the monitoring system

-
image('dame/kt_browse.png'); ?>
diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index 8512c34..e0a111c 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -1376,7 +1376,8 @@ INSERT INTO `scheduler_tasks` VALUES (8,'Disk Usage and Folder Utilisation Statistics','plugins/housekeeper/bin/UpdateStats.php','',0,'5mins','2007-10-01 00:00:00',NULL,0,'enabled'), (9,'Refresh Index Statistics','search2/bin/cronIndexStats.php','',0,'1min','2007-10-01',NULL,0,'enabled'), (10,'Refresh Resource Dependancies','search2/bin/cronResources.php','',0,'1min','2007-10-01',NULL,0,'enabled'), -(11,'Bulk Download Queue','bin/ajaxtasks/downloadTask.php','',0,'1min','2007-10-01',NULL,0,'system'); +(11,'Bulk Download Queue','bin/ajaxtasks/downloadTask.php','',0,'1min','2007-10-01',NULL,0,'system'), +(12,'Call Home','bin/system_info.php','',0,'daily','2009-10-01',NULL,0,'system'); /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; @@ -1767,7 +1768,9 @@ INSERT INTO `upgrades` VALUES (225,'upgrade*3.6.3*99*upgrade3.6.3','Upgrade from version 3.6.2 to 3.6.3','2009-06-01 00:00:00',1,'upgrade*3.6.3*99*upgrade3.6.3'), (226,'sql*3.7.0*0*3.7.0/plugins_admin.sql','Database upgrade to version 3.7.0: Plugins admin','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), (227,'sql*3.7.0*0*3.7.0/config_settings.sql','Database upgrade to version 3.7.0: Config settings','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), -(228,'upgrade*3.7.0*99*upgrade3.7.0','Upgrade from version 3.6.3 to 3.7.0','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'); +(228,'sql*3.7.0*0*3.7.0/plugin_helper.sql','Database upgrade to version 3.7.0: Plugin helper','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), +(229,'sql*3.7.0*0*3.7.0/call_home_task.sql','Database upgrade to version 3.7.0: Call home task','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'), +(230,'upgrade*3.7.0*99*upgrade3.7.0','Upgrade from version 3.6.3 to 3.7.0','2009-09-01 00:00:00',1,'upgrade*3.7.0*99*upgrade3.7.0'); /*!40000 ALTER TABLE `upgrades` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/mysql/upgrade/3.7.0/call_home_task.sql b/sql/mysql/upgrade/3.7.0/call_home_task.sql new file mode 100644 index 0000000..0ba0234 --- /dev/null +++ b/sql/mysql/upgrade/3.7.0/call_home_task.sql @@ -0,0 +1,2 @@ +INSERT INTO `scheduler_tasks` (task, script_url, frequency, run_time, status) +VALUES ('Call Home','bin/system_info.php','daily','2009-10-01','system'); \ No newline at end of file diff --git a/templates/ktcore/ktoffice_i18n.smarty b/templates/ktcore/ktoffice_i18n.smarty index ab09275..034445e 100644 --- a/templates/ktcore/ktoffice_i18n.smarty +++ b/templates/ktcore/ktoffice_i18n.smarty @@ -22,16 +22,14 @@ i18n['Upload succeeded'] = '{i18n}Upload succeeded{/i18n}'; i18n['Document type changed'] = '{i18n}Document type changed{/i18n}'; -i18n['Upload failed'] = '{i18n}Upload failed{/i18n}'; - -i18n['Your document has not been saved.'] = '{i18n}Your document has not been saved.{/i18n}'; - -i18n['A newer version of this document is available. Would you like to open it instead?'] = '{i18n}A newer version of this document is available. Would you like to open it instead?{/i18n}'; - i18n['Upload'] = '{i18n}Upload{/i18n}'; i18n['Upload cancelled'] = '{i18n}Upload cancelled{/i18n}'; +i18n['Upload failed'] = '{i18n}Upload failed{/i18n}'; + +i18n['Your document has not been saved.'] = '{i18n}Your document has not been saved.{/i18n}'; + i18n['Your document has been saved.'] = '{i18n}Your document has been saved.{/i18n}'; i18n['Download failed'] = '{i18n}Download failed{/i18n}'; @@ -62,13 +60,13 @@ i18n['Document checked in.'] = '{i18n}Document checked in.{/i18n}'; i18n['Document checked out.'] = '{i18n}Document checked out.{/i18n}'; -i18n['Cancel edit failed'] = '{i18n}Cancel edit failed{/i18n}'; +i18n['Cancel checkout failed'] = '{i18n}Cancel checkout failed{/i18n}'; -i18n['The edit has not been cancelled.'] = '{i18n}The edit has not been cancelled.{/i18n}'; +i18n['The check-out has not been cancelled.'] = '{i18n}The check-out has not been cancelled.{/i18n}'; -i18n['Cancel edit succeeded'] = '{i18n}Cancel edit succeeded{/i18n}'; +i18n['Cancel checkout succeeded'] = '{i18n}Cancel checkout succeeded{/i18n}'; -i18n['The edit has been cancelled.'] = '{i18n}The edit has been cancelled.{/i18n}'; +i18n['The check-out has been cancelled.'] = '{i18n}The check-out has been cancelled.{/i18n}'; i18n['Properties could not be saved.'] = '{i18n}Properties could not be saved.{/i18n}'; @@ -172,16 +170,6 @@ i18n['Login'] = '{i18n}Login{/i18n}'; i18n['Document already open'] = '{i18n}Document already open{/i18n}'; -i18n['Unable to delete folder'] = '{i18n}Unable to delete folder{/i18n}'; - -i18n['Delete Folder'] = '{i18n}Delete Folder{/i18n}'; - -i18n['This will delete this folder.
Are you sure you want to continue?'] = '{i18n}This will delete this folder.
Are you sure you want to continue?{/i18n}'; - -i18n['Unable to Delete Folder'] = '{i18n}Unable to Delete Folder{/i18n}'; - -i18n['This folder contains other documents/folders
and may not be deleted.'] = '{i18n}This folder contains other documents/folders
and may not be deleted.{/i18n}'; - i18n['Introduction'] = '{i18n}Introduction{/i18n}'; i18n['The requested action has not been implemented'] = '{i18n}The requested action has not been implemented{/i18n}'; @@ -204,16 +192,6 @@ i18n['Save'] = '{i18n}Save{/i18n}'; i18n['Adds your open Office document to KnowledgeTree. You must have \'write\' permissions on the folder.'] = '{i18n}Adds your open Office document to KnowledgeTree. You must have \'write\' permissions on the folder.{/i18n}'; -i18n['Add Folder'] = '{i18n}Add Folder{/i18n}'; - -i18n['Provides an interface to create a new folder under the current folder. You must have \'add\' permissions on the folder.'] = '{i18n}Provides an interface to create a new folder under the current folder. You must have \'add\' permissions on the folder.{/i18n}'; - -i18n['Rename Folder'] = '{i18n}Rename Folder{/i18n}'; - -i18n['Provides an interface to rename the current folder. You must have \'rename\' permissions on the folder.'] = '{i18n}Provides an interface to rename the current folder. You must have \'rename\' permissions on the folder.{/i18n}'; - -i18n['Provides an interface to delete the current folder. You must have \'delete\' permissions on the folder.'] = '{i18n}Provides an interface to delete the current folder. You must have \'delete\' permissions on the folder.{/i18n}'; - i18n['New folder'] = '{i18n}New folder{/i18n}'; i18n['Saves active document to a new folder. You must have \'write\' permissions on the folder.'] = '{i18n}Saves active document to a new folder. You must have \'write\' permissions on the folder.{/i18n}'; @@ -316,8 +294,6 @@ i18n['Please complete all required fields.'] = '{i18n}Please complete all requir i18n['Editing'] = '{i18n}Editing{/i18n}'; -i18n['File Type'] = '{i18n}File Type{/i18n}'; - i18n['Type'] = '{i18n}Type{/i18n}'; i18n['Some fields are required'] = '{i18n}Some fields are required{/i18n}'; @@ -364,6 +340,6 @@ i18n['You do not have the required permissions to view the root folder. Please c i18n['Search for documents'] = '{i18n}Search for documents{/i18n}'; -// Total Language Strings: 153 +// Total Language Strings: 141 -// Unique Strings: 153 \ No newline at end of file +// Unique Strings: 141 \ No newline at end of file