diff --git a/setup/migrate/batches/lucene_uninstall.bat b/setup/migrate/batches/lucene_uninstall.bat new file mode 100644 index 0000000..028e796 --- /dev/null +++ b/setup/migrate/batches/lucene_uninstall.bat @@ -0,0 +1 @@ +sc delete KTLuceneTest \ No newline at end of file diff --git a/setup/migrate/batches/scheduler_uninstall.bat b/setup/migrate/batches/scheduler_uninstall.bat new file mode 100644 index 0000000..1058327 --- /dev/null +++ b/setup/migrate/batches/scheduler_uninstall.bat @@ -0,0 +1 @@ +sc delete KTSchedulerTest \ No newline at end of file diff --git a/setup/migrate/config/config.xml b/setup/migrate/config/config.xml new file mode 100644 index 0000000..f25e7cd --- /dev/null +++ b/setup/migrate/config/config.xml @@ -0,0 +1,18 @@ + + + + + + + welcome + installation + services + database + complete + + \ No newline at end of file diff --git a/setup/migrate/config/databases.xml b/setup/migrate/config/databases.xml new file mode 100644 index 0000000..8f08518 --- /dev/null +++ b/setup/migrate/config/databases.xml @@ -0,0 +1,22 @@ + + + + + + + mysql + + localhost + 3306 + dms + root + dmsadminuser + js9281djw + dmsuser + djw9281js + diff --git a/setup/migrate/dbUtil.php b/setup/migrate/dbUtil.php new file mode 100644 index 0000000..d552918 --- /dev/null +++ b/setup/migrate/dbUtil.php @@ -0,0 +1,261 @@ +. +* +* 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 +*/ +class dbUtil { + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbhost = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbname = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbuname = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var string + */ + protected $dbpassword = ''; + + /** + * Host + * + * @author KnowledgeTree Team + * @access protected + * @var object mysql connection + */ + protected $dbconnection = ''; + + /** + * Any errors encountered + * + * @author KnowledgeTree Team + * @access protected + * @var array + */ + protected $error = array(); + + /** + * Constructs database connection object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct() { + + } + + public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { + $this->dbhost = $dhost; + $this->dbuname = $duname; + $this->dbpassword = $dpassword; + $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); + if($dbname != '') { + $this->setDb($dbname); + $this->useDb($dbname); + } + if($this->dbconnection) + return $this->dbconnection; + else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Choose a database to use + * + * @param string $dbname name of the database + * @access public + * @return boolean + */ + public function useDb($dbname = '') { + if($dbname != '') { + $this->setDb($dbname); + } + + if(@mysql_select_db($this->dbname, $this->dbconnection)) + return true; + else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + public function setDb($dbname) { + $this->dbname = $dbname; + } + + /** + * Query the database. + * + * @param $query the sql query. + * @access public + * @return object The result of the query. + */ + public function query($query) { + $result = @mysql_query($query, $this->dbconnection); + if($result) { + return $result; + } else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Do the same as query. + * + * @param $query the sql query. + * @access public + * @return boolean + */ + public function execute($query) { + $result = @mysql_query($query, $this->dbconnection); + if($result) { + return true; + } else { + $this->error[] = @mysql_error($this->dbconnection); + return false; + } + } + + /** + * Convenience method for mysql_fetch_object(). + * + * @param $result The resource returned by query(). + * @access public + * @return object An object representing a data row. + */ + public function fetchNextObject($result = NULL) { + if ($result == NULL || @mysql_num_rows($result) < 1) + return NULL; + else + return @mysql_fetch_object($result); + } + + /** + * Convenience method for mysql_fetch_assoc(). + * + * @param $result The resource returned by query(). + * @access public + * @return array Returns an associative array of strings. + */ + public function fetchAssoc($result = NULL) { + $r = array(); + if ($result == NULL || @mysql_num_rows($result) < 1) + return NULL; + else { + $row = @mysql_fetch_assoc($result); + while ($row) { + $r[] = $row; + } + return $r; + } + } + + /** + * Close the connection with the database server. + * + * @param none. + * @access public + * @return void. + */ + public function close() { + @mysql_close($this->dbconnection); + } + + /** + * Get database errors. + * + * @param none. + * @access public + * @return array. + */ + public function getErrors() { + return $this->error; + } + + /** + * Fetches the last generated error + + * @return string + */ + function getLastError() { + return end($this->error); + } + + /** + * Start a database transaction + */ + public function startTransaction() { + $this->query("START TRANSACTION"); + } + + /** + * Roll back a database transaction + */ + public function rollback() { + $this->query("ROLLBACK"); + } +} +?> \ No newline at end of file diff --git a/setup/migrate/index.php b/setup/migrate/index.php new file mode 100644 index 0000000..e95dda7 --- /dev/null +++ b/setup/migrate/index.php @@ -0,0 +1,43 @@ +. +* +* 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 +*/ +require_once("migrateWizard.php"); +?> \ No newline at end of file diff --git a/setup/migrate/ini.php b/setup/migrate/ini.php new file mode 100644 index 0000000..c5e491f --- /dev/null +++ b/setup/migrate/ini.php @@ -0,0 +1,210 @@ +. + * + * 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; + } + +} +?> diff --git a/setup/migrate/lib/helpers/phpinfo.php b/setup/migrate/lib/helpers/phpinfo.php new file mode 100644 index 0000000..ccddb96 --- /dev/null +++ b/setup/migrate/lib/helpers/phpinfo.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/setup/migrate/lib/services/service.php b/setup/migrate/lib/services/service.php new file mode 100644 index 0000000..627360d --- /dev/null +++ b/setup/migrate/lib/services/service.php @@ -0,0 +1,64 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class Service { + public function __construct() {} + + public function load() {} + + public function start() {} + + public function stop() {} + + public function migrate() {} + + public function restart() {} + + public function unmigrate() {} + + public function status() {} + + public function pause() {} + + public function cont() {} +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixAgent.php b/setup/migrate/lib/services/unixAgent.php new file mode 100644 index 0000000..0a51c5e --- /dev/null +++ b/setup/migrate/lib/services/unixAgent.php @@ -0,0 +1,51 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class unixAgent extends unixService { + + public function __construct() { + $this->name = "KTAgentTest"; + } + + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixLucene.php b/setup/migrate/lib/services/unixLucene.php new file mode 100644 index 0000000..7d7efea --- /dev/null +++ b/setup/migrate/lib/services/unixLucene.php @@ -0,0 +1,203 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class unixLucene extends unixService { + public $util; + private $shutdownScript; + private $indexerDir; + private $lucenePidFile; + private $luceneDir; + private $luceneSource; + private $luceneSourceLoc; + private $javaXms; + private $javaXmx; + + public function __construct() { + $this->name = "KTLuceneTest"; + $this->setLuceneSource("ktlucene.jar"); + $this->util = new MigrateUtil(); + } + + public function load() { + $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); + $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); + $this->setLucenePidFile("lucene_test.pid"); + $this->setJavaXms(512); + $this->setJavaXmx(512); + $this->setLuceneSourceLoc("ktlucene.jar"); + $this->setShutdownScript("shutdown.php"); + } + + public function setIndexerDir($indexerDir) { + $this->indexerDir = $indexerDir; + } + + private function getIndexerDir() { + return $this->indexerDir; + } + + private function setShutdownScript($shutdownScript) { + $this->shutdownScript = $shutdownScript; + } + + public function getShutdownScript() { + return $this->shutdownScript; + } + + private function setLucenePidFile($lucenePidFile) { + $this->lucenePidFile = $lucenePidFile; + } + + private function getLucenePidFile() { + return $this->lucenePidFile; + } + + private function setLuceneDir($luceneDir) { + $this->luceneDir = $luceneDir; + } + + public function getLuceneDir() { + return $this->luceneDir; + } + + private function setJavaXms($javaXms) { + $this->javaXms = "-Xms$javaXms"; + } + + public function getJavaXms() { + return $this->javaXms; + } + + private function setJavaXmx($javaXmx) { + $this->javaXmx = "-Xmx$javaXmx"; + } + + public function getJavaXmx() { + return $this->javaXmx; + } + + private function setLuceneSource($luceneSource) { + $this->luceneSource = $luceneSource; + } + + public function getLuceneSource() { + return $this->luceneSource; + } + + private function setLuceneSourceLoc($luceneSourceLoc) { + $this->luceneSourceLoc = $this->getLuceneDir().$luceneSourceLoc; + } + + public function getLuceneSourceLoc() { + return $this->luceneSourceLoc; + } + + public function getJavaOptions() { + return " {$this->getJavaXmx()} {$this->getJavaXmx()} -jar "; + } + + public function stop() { + // TODO: Breaks things + $state = $this->status(); + if($state != '') { + $cmd = "pkill -f ".$this->getLuceneSource(); + $response = $this->util->pexec($cmd); + return $response; + } + + } + + public function migrate() { + $status = $this->status(); + if($status == '') { + return $this->start(); + } else { + return $status; + } + } + + public function status() { + $cmd = "ps ax | grep ".$this->getLuceneSource(); + $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 ''; + } + } + + return ''; + } + + public function unmigrate() { + $this->stop(); + } + + public function start() { + $state = $this->status(); + return ; + if($state != 'STARTED') { + $cmd = "cd ".$this->getLuceneDir()."; "; + $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!"; + $response = $this->util->pexec($cmd); + + return $response; + } elseif ($state == '') { + // Start Service + return true; + } else { + // Service Running Already + return true; + } + + return false; + } + + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixOpenOffice.php b/setup/migrate/lib/services/unixOpenOffice.php new file mode 100644 index 0000000..4c2e861 --- /dev/null +++ b/setup/migrate/lib/services/unixOpenOffice.php @@ -0,0 +1,145 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class unixOpenOffice extends unixService { + + // utility + public $util; + // path to office + private $path; + // host + private $host; + // pid running + private $pidFile; + // port to bind to + private $port; + // bin folder + private $bin; + // office executable + private $soffice; + // office log file + private $log; + private $options; + + # nohup /home/jarrett/ktdms/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept=socket,host=127.0.0.1,port=8100;urp;StarOffice.ServiceManager &> /home/jarrett/ktdms/var/log/dmsctl.log & + public function __construct() { + $this->name = "openoffice"; + $this->util = new MigrateUtil(); + } + + public function load() { + $this->setPort("8100"); + $this->setHost("localhost"); + $this->setLog("openoffice.log"); + $this->setBin("soffice"); + $this->setOption(); + } + + private function setPort($port = "8100") { + $this->port = $port; + } + + public function getPort() { + return $this->port; + } + + private function setHost($host = "localhost") { + $this->host = $host; + } + + public function getHost() { + return $this->host; + } + + private function setLog($log = "openoffice.log") { + $this->log = $log; + } + + public function getLog() { + return $this->log; + } + + private function setBin($bin = "soffice") { + $this->bin = $bin; + } + + public function getBin() { + return $this->bin; + } + + private function setOption() { + $this->options = "-nofirststartwizard -nologo -headless -accept=\"socket,host={$this->getHost()},port={$this->getPort()};urp;StarOffice.ServiceManager\""; + } + + public function getOption() { + return $this->options; + } + + public function migrate() { + $status = $this->status(); + if($status == '') { + return $this->start(); + } else { + return $status; + } + } + + public function start() { + $state = $this->status(); + return ; + if($state != 'STARTED') { + $cmd = "nohup {$this->getBin()} ".$this->getOption()." > ".SYS_LOG_DIR."{$this->getLog()} 2>&1 & echo $!"; + $response = $this->util->pexec($cmd); + + return $response; + } elseif ($state == '') { + // Start Service + return true; + } else { + // Service Running Already + return true; + } + + return false; + } +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixScheduler.php b/setup/migrate/lib/services/unixScheduler.php new file mode 100644 index 0000000..d2c1ca9 --- /dev/null +++ b/setup/migrate/lib/services/unixScheduler.php @@ -0,0 +1,175 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class unixScheduler extends unixService { + private $schedulerDir; + private $schedulerSource; + private $schedulerSourceLoc; + private $systemDir; + + public function __construct() { + $this->name = "KTSchedulerTest"; + $this->util = new MigrateUtil(); + } + + public function load() { + $this->setSystemDir(SYSTEM_ROOT."bin".DS); + $this->setSchedulerDir(SYSTEM_DIR."bin".DS); + $this->setSchedulerSource('schedulerTask.sh'); + $this->setSchedulerSourceLoc('schedulerTask.sh'); + } + + function setSystemDir($systemDir) { + $this->systemDir = $systemDir; + } + + function getSystemDir() { + if(file_exists($this->systemDir)) + return $this->systemDir; + return false; + } + + function setSchedulerDir($schedulerDir) { + $this->schedulerDir = $schedulerDir; + } + + function getSchedulerDir() { + return $this->schedulerDir; + } + + function setSchedulerSource($schedulerSource) { + $this->schedulerSource = $schedulerSource; + } + + function getSchedulerSource() { + return $this->schedulerSource; + } + + function setSchedulerSourceLoc($schedulerSourceLoc) { + $this->schedulerSourceLoc = $this->getSchedulerDir().$schedulerSourceLoc; + } + + function getSchedulerSourceLoc() { + if(file_exists($this->schedulerSourceLoc)) + return $this->schedulerSourceLoc; + return false; + } + + function writeSchedulerTask() { + $fLoc = $this->getSchedulerDir().$this->getSchedulerSource(); + $fp = @fopen($fLoc, "w+"); + $content = "#!/bin/sh\n"; + $content .= "cd ".$this->getSchedulerDir()."\n"; + $content .= "while true; do\n"; + // TODO : This will not work without CLI + $content .= "php -Cq scheduler.php\n"; + $content .= "sleep 30\n"; + $content .= "done"; + @fwrite($fp, $content); + @fclose($fp); + @chmod($fLoc, '0644'); + } + + function migrate() { + $status = $this->status(); + if($status == '') { + return $this->start(); + } else { + return $status; + } + } + + function unmigrate() { + $this->stop(); + } + + function stop() { + $cmd = "pkill -f ".$this->schedulerSource; + $response = $this->util->pexec($cmd); + return $response; + } + + function status() { + $cmd = "ps ax | grep ".$this->getSchedulerSource(); + $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 ''; + } + } + + return ''; + } + + function start() { + // TODO : Write sh on the fly? Not sure the reasoning here + $source = $this->getSchedulerSourceLoc(); + return ; + if($source) { // Source + $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; + $response = $this->util->pexec($cmd); + return $response; + } else { // Could be Stack + $source = SYS_BIN_DIR.$this->schedulerSource; + if(!file_exists($source)) { + // Write it + $this->writeSchedulerTask(); + } + $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!"; + $response = $this->util->pexec($cmd); + return $response; + } + + return false; + } + + + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/unixService.php b/setup/migrate/lib/services/unixService.php new file mode 100644 index 0000000..ae4f452 --- /dev/null +++ b/setup/migrate/lib/services/unixService.php @@ -0,0 +1,146 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class unixService extends Service { + /** + * Retrieve Service name + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getName() { + return $this->name; + } + + public function load() {} + + /** + * Start Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function start() { + + } + + /** + * Stop Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function stop() { + + } + + public function migrate() {} + + /** + * Restart Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function restart() { + + } + + /** + * Unmigrate Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function unmigrate() { + + } + + /** + * Retrieve Status Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function status() { + + } + + /** + * Pause Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function pause() { + + } + + /** + * Continue Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function cont() { + + } + + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsAgent.php b/setup/migrate/lib/services/windowsAgent.php new file mode 100644 index 0000000..c0b05f5 --- /dev/null +++ b/setup/migrate/lib/services/windowsAgent.php @@ -0,0 +1,51 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class windowsAgent extends windowsService { + + + public function __construct() { + $this->name = "KTAgentTest"; + } + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsLucene.php b/setup/migrate/lib/services/windowsLucene.php new file mode 100644 index 0000000..2db2a14 --- /dev/null +++ b/setup/migrate/lib/services/windowsLucene.php @@ -0,0 +1,375 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ +class windowsLucene extends windowsService { + /** + * Java Directory path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $javaBin; + + /** + * Java JVM path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $javaJVM; + + /** + * Java System object + * + * @author KnowledgeTree Team + * @access private + * @var object + */ + private $javaSystem; + + /** + * Lucene executable path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneExe; + + /** + * Lucene jar path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneSource; + + /** + * Lucene package name + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneServer; + + /** + * Lucene output log path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneOut; + + /** + * Lucene error log path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneError; + + /** + * Lucene directory path + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $luceneDir; + + /** + * Load defaults needed by service + * + * @author KnowledgeTree Team + * @access public + * @param string + * @return void + */ + public function load() { + $this->name = "KTLuceneTest"; + $this->javaSystem = new Java('java.lang.System'); + $this->setJavaBin($this->javaSystem->getProperty('java.home').DS."bin"); + $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver"); + $this->setLuceneExe("KTLuceneService.exe"); + $this->setJavaJVM(); + $this->setLuceneSource("ktlucene.jar"); + $this->setLuceneServer("com.knowledgetree.lucene.KTLuceneServer"); + $this->setLuceneOut("lucene-out.txt"); + $this->setLuceneError("lucene-err.txt"); + } + + /** + * Set Java Directory path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setJavaBin($javaBin) { + $this->javaBin = $javaBin; + } + + /** + * Get Java Directory path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getJavaBin() { + return $this->javaBin; + } + + /** + * Set Lucene directory path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneDIR($luceneDir) { + $this->luceneDir = $luceneDir; + } + + /** + * Get Lucene directory path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getluceneDir() { + if(file_exists($this->luceneDir)) + return $this->luceneDir; + return false; + } + + /** + * Set Lucene executable path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneExe($luceneExe) { + $this->luceneExe = $this->getluceneDir().DS.$luceneExe; + } + + /** + * Get Lucene executable path + * + * @author KnowledgeTree Team + * @access public + * @param string + * @return void + */ + public function getLuceneExe() { + if(file_exists($this->luceneExe)) + return $this->luceneExe; + return false; + } + + /** + * Set Lucene source path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneSource($luceneSource) { + $this->luceneSource = $this->getluceneDir().DS.$luceneSource; + } + + /** + * Get Lucene source path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getLuceneSource() { + if(file_exists($this->luceneSource)) + return $this->luceneSource; + return false; + } + + /** + * Set Lucene package name + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneServer($luceneServer) { + $this->luceneServer = $luceneServer; + } + + /** + * Get Lucene package name + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getLuceneServer() { + return $this->luceneServer; + } + + /** + * Set Lucene output file path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneOut($luceneOut) { + $this->luceneOut = SYS_LOG_DIR.$luceneOut; + } + + /** + * Get Lucene output file path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getLuceneOut() { + return $this->luceneOut; + } + + /** + * Set Lucene error file path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setLuceneError($luceneError) { + $this->luceneError = SYS_LOG_DIR.$luceneError; + } + + /** + * Get Lucene error file path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getLuceneError() { + return $this->luceneError; + } + + /** + * Set Java JVM path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setJavaJVM() { + if(file_exists($this->getJavaBin().DS."client".DS."jvm.dll")) { + $this->javaJVM = $this->getJavaBin().DS."client".DS."jvm.dll"; + } elseif (file_exists($this->getJavaBin().DS."server".DS."jvm.dll")) { + $this->javaJVM = $this->getJavaBin().DS."server".DS."jvm.dll"; + } else { + return false; + } + } + + /** + * Get Java JVM path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getJavaJVM() { + return $this->javaJVM; + } + + /** + * Migrate Lucene Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + function migrate() { + $state = $this->status(); + if($state == '') { + $luceneExe = $this->getLuceneExe(); + $luceneSource = $this->getLuceneSource(); + $luceneDir = $this->getluceneDir(); + if($luceneExe && $luceneSource && $luceneDir) { + $cmd = "\"{$luceneExe}\""." -migrate \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto"; + $response = $this->util->pexec($cmd); + return $response; + } + return $state; + } + + return $state; + } + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsOpenOffice.php b/setup/migrate/lib/services/windowsOpenOffice.php new file mode 100644 index 0000000..c3894a1 --- /dev/null +++ b/setup/migrate/lib/services/windowsOpenOffice.php @@ -0,0 +1,162 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class windowsOpenOffice extends windowsService { + + // utility + public $util; + // path to office + private $path; + // host + private $host; + // pid running + private $pidFile; + // port to bind to + private $port; + // bin folder + private $bin; + // office executable + private $soffice; + // office log file + private $log; + private $options; + private $winservice; + + public function __construct() { + $this->name = "openoffice"; + $this->util = new MigrateUtil(); + } + + public function load() { + // hack for testing + $this->setPort("8100"); + $this->setHost("127.0.0.1"); + $this->setLog("openoffice.log"); + $this->setBin("C:\Program Files (x86)\OpenOffice.org 3\program\soffice.bin"); + $this->setBin("C:\Program Files (x86)\ktdms\openoffice\program\soffice.bin"); + $this->setBin("C:\Program Files (x86)\ktdms\openoffice.2.4\program\soffice.bin"); + $this->setWinservice("winserv.exe"); + $this->setOption(); + } + + private function setPort($port = "8100") { + $this->port = $port; + } + + public function getPort() { + return $this->port; + } + + private function setHost($host = "127.0.0.1") { + $this->host = $host; + } + + public function getHost() { + return $this->host; + } + + private function setLog($log = "openoffice.log") { + $this->log = $log; + } + + public function getLog() { + return $this->log; + } + + private function setBin($bin = "soffice") { + $this->bin = $bin; + } + + public function getBin() { + return $this->bin; + } + + private function setWinservice($winservice = "winserv.exe") { + $this->winservice = SYS_BIN_DIR . $winservice; + } + + public function getWinservice() { + return $this->winservice; + } + + private function setOption() { + $this->options = "-displayname {$this->name} -start auto \"{$this->bin}\" -headless -invisible " + . "-accept=socket,host={$this->host},port={$this->port};urp;"; + } + + public function getOption() { + return $this->options; + } + + public function migrate() { + $status = $this->status(); + + if($status == '') { + $cmd = "\"{$this->winservice}\" migrate $this->name $this->options"; + $response = $this->util->pexec($cmd); + return $response; + } + else { + return $status; + } + } + +// public function start() { +// $state = $this->status(); +// if($state != 'STARTED') { +// $cmd = 'sc start ' . $this->name; +// $response = $this->util->pexec($cmd); +// +// return $response; +// } elseif ($state == '') { +// // Start Service +// return true; +// } else { +// // Service Running Already +// return true; +// } +// +// return false; +// } + +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsScheduler.php b/setup/migrate/lib/services/windowsScheduler.php new file mode 100644 index 0000000..19f0a93 --- /dev/null +++ b/setup/migrate/lib/services/windowsScheduler.php @@ -0,0 +1,199 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ +class windowsScheduler extends windowsService { + /** + * Batch Script to execute + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $schedulerScriptPath; + + /** + * Php Script to execute + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $schedulerSource; + + /** + * Scheduler Directory + * + * @author KnowledgeTree Team + * @access private + * @var string + */ + private $schedulerDir; + + /** + * Load defaults needed by service + * + * @author KnowledgeTree Team + * @access public + * @param string + * @return void + */ + function load() { + $this->name = "KTSchedulerTest"; + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32"); +// $this->setSchedulerScriptPath("taskrunner_test.bat"); + $this->setSchedulerScriptPath("taskrunner.bat"); + $this->setSchedulerSource("schedulerService.php"); + } + + /** + * Set Batch Script path + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + private function setSchedulerScriptPath($schedulerScriptPath) { + $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath"; + } + + /** + * Retrieve Batch Script path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getSchedulerScriptPath() { + if(file_exists($this->schedulerScriptPath)) + return $this->schedulerScriptPath; + return false; + } + + /** + * Set Scheduler Directory path + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return string + */ + private function setSchedulerDIR($schedulerDIR) { + $this->schedulerDir = $schedulerDIR; + } + + /** + * Retrieve Scheduler Directory path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getSchedulerDir() { + if(file_exists($this->schedulerDir)) + return $this->schedulerDir; + return false; + } + + /** + * Set Php Script path + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return string + */ + private function setSchedulerSource($schedulerSource) { + $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource; + } + + /** + * Retrieve Php Script path + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getSchedulerSource() { + if(file_exists($this->schedulerSource)) + return $this->schedulerSource; + return false; + } + + /** + * Migrate Scheduler Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function migrate() { + $state = $this->status(); + if($state == '') { + if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) { + if(!file_exists($this->getSchedulerScriptPath())) { + $fp = fopen($this->getSchedulerScriptPath(), "w+"); + $content = "@echo off\n"; + $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\""; + fwrite($fp, $content); + fclose($fp); + } + } + + // TODO what if it does not exist? check how the dmsctl.bat does this + if (function_exists('win32_create_service')) + { + $response = win32_create_service(array( + 'service' => $this->name, + 'display' => $this->name, + 'path' => $this->getSchedulerScriptPath() + )); + return $response; + } + } + return $state; + } +} +?> \ No newline at end of file diff --git a/setup/migrate/lib/services/windowsService.php b/setup/migrate/lib/services/windowsService.php new file mode 100644 index 0000000..214a8a3 --- /dev/null +++ b/setup/migrate/lib/services/windowsService.php @@ -0,0 +1,181 @@ +. +* +* 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 Migrateer +* @version Version 0.1 +*/ + +class windowsService extends Service { + public $name; + public $util; + + public function __construct() { + $this->util = new MigrateUtil(); + } + + /** + * Retrieve Service name + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function getName() { + return $this->name; + } + + /** + * Start Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function start() { + $status = $this->status(); + if ($status != 'RUNNING') { + $cmd = "sc start {$this->name}"; + $response = $this->util->pexec($cmd); + return $response; + } + return $status; + } + + /** + * Stop Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function stop() { + $status = $this->status(); + if ($status != 'STOPPED') { + $cmd = "sc stop {$this->name}"; + $response = $this->util->pexec($cmd); + return $response; + } + return $status; + } + + public function migrate() {} + + /** + * Restart Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function restart() { + $response = $this->stop(); + sleep(10); + $this->start(); + } + + /** + * Unmigrate Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function unmigrate() { + $status = $this->status(); + if ($status != '') { + $cmd = "sc delete {$this->name}"; + $response = $this->util->pexec($cmd); + sleep(10); + return $response; + } + return $status; + } + + /** + * Retrieve Status Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return string + */ + public function status() { + $cmd = "sc query {$this->name}"; + $response = $this->util->pexec($cmd); + if($response['out']) { + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key + return $state; + } + + return ''; + } + + /** + * Pause Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function pause() { + $cmd = "sc pause {$this->name}"; + $response = $this->util->pexec($cmd); + return $response; + } + + /** + * Continue Service + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return array + */ + public function cont() { + $cmd = "sc continue {$this->name}"; + $response = $this->util->pexec($cmd); + return $response; + } +} +?> \ No newline at end of file diff --git a/setup/migrate/migrate.php b/setup/migrate/migrate.php new file mode 100644 index 0000000..a7969fa --- /dev/null +++ b/setup/migrate/migrate.php @@ -0,0 +1,673 @@ +. +* +* 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 +*/ + +class Migrater { + /** + * Reference to simple xml object + * + * @author KnowledgeTree Team + * @access protected + * @var object SimpleXMLElement + */ + protected $simpleXmlObj = null; + + /** + * Reference to step action object + * + * @author KnowledgeTree Team + * @access protected + * @var object StepAction + */ + protected $stepAction = null; + + /** + * Reference to session object + * + * @author KnowledgeTree Team + * @access protected + * @var object Session + */ + protected $session = null; + + /** + * List of migrateation steps as strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepClassNames = array(); + + /** + * List of migrateation steps as human readable strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepNames = array(); + + /** + * List of migrateation steps as human readable strings + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $stepObjects = array(); + + /** + * Order in which steps have to be migrateed + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $migrateOrders = array(); + + /** + * List of migrateation properties + * + * @author KnowledgeTree Team + * @access protected + * @var array string + */ + protected $migrateProperties = array(); + + /** + * Flag if a step object needs confirmation + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $stepConfirmation = false; + + /** + * Flag if a step object needs confirmation + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $stepDisplayFirst = false; + + private $migrateerAction = ''; + + /** + * Constructs migrateation object + * + * @author KnowledgeTree Team + * @access public + * @param object Session $session Instance of the Session object + */ + public function __construct($session = null) { + $this->session = $session; + } + + /** + * Read xml configuration file + * + * @author KnowledgeTree Team + * @param string $name of config file + * @access private + * @return object + */ + private function _readXml($name = "config.xml") { + try { + $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); + } catch (Exception $e) { + $iutil = new MigrateUtil(); + $iutil->error("Error reading configuration file: $name"); + exit(); + } + } + + /** + * Checks if first step of migrateer + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function _firstStep() { + if(isset($_GET['step_name'])) { + return false; + } + + return true; + } + + /** + * Checks if first step of migrateer + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return boolean + */ + private function _firstStepPeriod() { + if(isset($_GET['step_name'])) { + if($_GET['step_name'] != 'welcome') + return false; + } + + return true; + } + + /** + * Returns next step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _getNextStep() { + return $this->_getStepName(1); + } + + /** + * Returns previous step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _getPreviousStep() { + return $this->_getStepName(-1); + } + + /** + * Returns the step name, given a position + * + * @author KnowledgeTree Team + * @param integer $pos current position + * @access private + * @return string $name + */ + private function _getStepName($pos = 0) { + if($this->_firstStep()) { + $step = (string) $this->simpleXmlObj->steps->step[0]; + } else { + $pos += $this->getStepPosition(); + $step = (string) $this->simpleXmlObj->steps->step[$pos]; + } + + return $step; + } + + /** + * Executes next step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _proceed() { + $step_name = $this->_getNextStep(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes previous step + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _backward() { + $step_name = $this->_getPreviousStep(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes step landing + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return string + */ + private function _landing() { + $step_name = $this->_getStepName(); + + return $this->_runStepAction($step_name); + } + + /** + * Executes step based on step class name + * + * @author KnowledgeTree Team + * @param string $step_name + * @access private + * @return string + */ + private function _runStepAction($stepName) { + $this->stepAction = new stepAction($stepName); + $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getMigrateProperties()); + + return $this->stepAction->doAction(); + } + + private function stepDisplayFirst() { + if($this->migrateerAction == 'edit') + return false; // + $class = $this->stepAction->createStep(); // Get step class + return $class->displayFirst(); // Check if class needs to display first + } + + /** + * Set steps class names in string format + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return array + */ + private function _getMigrateOrders() { + return $this->migrateOrders; + } + + /** + * Set steps as names + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsToArray() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step_name = (string) $d_step[0]; + $this->stepClassNames[] = $step_name; + } + $this->_loadToSession('stepClassNames', $this->stepClassNames); + } + } + + /** + * Set steps as human readable strings + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsNames() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step_name = (string) $d_step[0]; + $this->stepNames[$step_name] = (string) $d_step['name']; + } + $this->_loadToSession('stepNames', $this->stepNames); + } + } + + /** + * Set steps migrate order + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlStepsOrders() { + if(isset($this->simpleXmlObj)) { + foreach($this->simpleXmlObj->steps->step as $d_step) { + if(isset($d_step['order'])) { + $step_name = (string) $d_step[0]; + $order = (string) $d_step['order']; + $this->migrateOrders[$order] = $step_name; // Store step migrate order + } + } + $this->_loadToSession('migrateOrders', $this->migrateOrders); + } + } + + /** + * Set migrate properties + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _xmlMigrateProperties() { + if(isset($this->simpleXmlObj)) { + $this->migrateProperties['migrate_version'] = (string) $this->simpleXmlObj['version']; + $this->migrateProperties['migrate_type'] = (string) $this->simpleXmlObj['type']; + $this->_loadToSession('migrateProperties', $this->migrateProperties); + } + } + + /** + * Migrate steps + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _runStepsMigraters() { + $steps = $this->_getMigrateOrders(); + for ($i=1; $i< count($steps)+1; $i++) { + $this->_migrateHelper($steps[$i]); + } + + $this->_completeMigrate(); + } + + /** + * Complete migrate cleanup process + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _completeMigrate() { + @touch("migrate"); + } + + /** + * Migrate steps helper + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _migrateHelper($className) { + $stepAction = new stepAction($className); // Instantiate a step action + $class = $stepAction->createStep(); // Get step class + if($class) { // Check if class Exists + if($class->runMigrate()) { // Check if step needs to be migrateed + $class->setDataFromSession($className); // Set Session Information + $class->setPostConfig(); // Set any posted variables + $response = $class->migrateStep(); // Run migrate step + // TODO : Break on error response + } + } else { + $iutil = new MigrateUtil(); + $iutil->error("Class File Missing in Step Directory: $className"); + exit(); + } + } + + /** + * Reset all session information on welcome landing + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return void + */ + private function _resetSessions() { + if($this->session) { + if($this->_firstStepPeriod()) { + foreach ($this->getSteps() as $class) { + $this->session->un_setClass($class); + } + foreach ($this->getStepNames() as $class) { + $this->session->un_setClass($class); + } + foreach ($this->_getMigrateOrders() as $class) { + $this->session->un_setClass($class); + } + } + } + } + + function _loadFromSessions() { + $this->stepClassNames = $this->session->get('stepClassNames'); + if(!$this->stepClassNames) { + $this->_xmlStepsToArray(); // String steps + } + $this->stepNames = $this->session->get('stepNames'); + if(!$this->stepNames) { + $this->_xmlStepsNames(); + } + $this->migrateOrders = $this->session->get('migrateOrders'); + if(!$this->migrateOrders) { + $this->_xmlStepsOrders(); + } + $this->migrateProperties = $this->session->get('migrateProperties'); + if(!$this->migrateProperties) { + $this->_xmlMigrateProperties(); + } + } + + private function loadNeeded() { + $this->_readXml(); // Xml steps + // Make sure session is cleared + $this->_resetSessions(); + $this->_loadFromSessions(); + if(isset($_POST['Next'])) { + $this->migrateerAction = 'next'; + $this->response = 'next'; + } elseif (isset($_POST['Previous'])) { + $this->migrateerAction = 'previous'; + $this->response = 'previous'; + } elseif (isset($_POST['Confirm'])) { + $this->migrateerAction = 'confirm'; + $this->response = 'next'; + } elseif (isset($_POST['Migrate'])) { + $this->migrateerAction = 'migrate'; + $this->response = 'next'; + } elseif (isset($_POST['Edit'])) { + $this->migrateerAction = 'edit'; + $this->response = 'next'; + } else { + $this->response = ''; + $this->migrateerAction = ''; + } + } + + /** + * Main control to handle the flow of migrate + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function step() { + $this->loadNeeded(); + switch($this->response) { + case 'next': + $step_name = $this->_getStepName(); + $res = $this->_runStepAction($step_name); + if($res == 'next') + $this->_proceed(); // Load next window + elseif ($res == 'migrate') { + $this->_runStepsMigraters(); // Load landing + $this->_proceed(); // Load next window + } elseif ($res == 'confirm') { + if(!$this->stepDisplayFirst()) + $this->stepConfirmation = true; + $this->_landing(); + } elseif ($res == 'landing') { + $this->_landing(); + } else { + } + break; + case 'previous': + $this->_backward(); // Load previous page + break; + default: + // TODO : handle silent + $this->_landing(); + break; + } + $this->stepAction->paintAction(); // Display step + } + + /** + * Returns the step number + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return integer $pos + */ + public function getStepPosition() { + $pos = 0; + foreach($this->simpleXmlObj->steps->step as $d_step) { + $step = (string) $d_step; + if ($step == $_GET['step_name']) { + break; + } + $pos++; + } + if(isset($_GET['step'])) { + if($_GET['step'] == "next") + $pos = $pos+1; + else + $pos = $pos-1; + } + + return $pos; + } + + /** + * Returns the step names for classes + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function getSteps() { + return $this->stepClassNames; + } + + /** + * Returns the steps as human readable string + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function getStepNames() { + return $this->stepNames; + } + + /** + * Returns whether or not a confirmation step is needed + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function getStepConfirmation() { + return $this->stepConfirmation; + } + + /** + * Return migrate properties + * + * @author KnowledgeTree Team + * @param string + * @access public + * @return string + */ + public function getMigrateProperties() { + return $this->migrateProperties; + } + + /** + * Returns session + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return boolean + */ + public function getSession() { + return $this->session; + } + + /** + * Dump of SESSION + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return array + */ + public function showSession() { + echo '
';
+        print_r($_SESSION);
+        echo '
'; + } + + /** + * Display errors that are not allowing the migrateer to operate + * + * @author KnowledgeTree Team + * @param none + * @access public + * @return void + */ + public function resolveErrors($errors) { + echo $errors; + exit(); + } + + private function _loadToSession($type, $values) { + if($values) { + $this->session->set($type , $values); + } + } +} + +?> diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php new file mode 100644 index 0000000..6b77b07 --- /dev/null +++ b/setup/migrate/migrateUtil.php @@ -0,0 +1,640 @@ +. +* +* 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 +*/ +class MigrateUtil { + /** + * Constructs migrateation object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct() { + } + + /** + * Check if system needs to be migrateed + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function isSystemMigrateed() { + if (file_exists(dirname(__FILE__)."/migrate")) { + + return true; + } + + return false; + } + + public function error($error) { + $template_vars['error'] = $error; + $file = "templates/error.tpl"; + if (!file_exists($file)) { + return false; + } + extract($template_vars); // Extract the vars to local namespace + ob_start(); + include($file); + $contents = ob_get_contents(); + ob_end_clean(); + echo $contents; + } + /** + * Check if system needs to be migrateed + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function checkStructurePermissions() { + // Check if Wizard Directory is writable + if(!$this->_checkPermission(WIZARD_DIR)) { + return 'wizard'; + } + + return true; + } + + /** + * 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 + * have already been sent. + * @param string $url URL where the redirect should go to. + * @param bool $exit Whether to exit immediately after redirection. + * @param bool $rfc2616 Wheter to output a hypertext note where we're + * redirecting to (Redirecting to ....) + * @return mixed Returns true on succes (or exits) or false if headers + */ + public function redirect($url, $exit = true, $rfc2616 = false) + { + 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); + } + if ($exit) { + exit; + } + return true; + } + + /** + * 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 + * and to switch from HTTP to HTTPS, or vice-versa, at the same time. + * + * @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. + * @return string The absolute URI. + */ + public function absoluteURI($url = null, $protocol = null, $port = null) + { + // 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)) { + return $url; + } + if (!empty($protocol)) { + $url = $protocol .':'. end($array = explode(':', $url, 2)); + } + if (!empty($port)) { + $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']); + } elseif (!empty($_SERVER['SERVER_NAME'])) { + list($host) = explode(':', $_SERVER['SERVER_NAME']); + } + + if (empty($protocol)) { + if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) { + $protocol = 'https'; + } else { + $protocol = 'http'; + } + if (!isset($port) || $port != intval($port)) { + $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80; + } + } + + if ($protocol == 'http' && $port == 80) { + unset($port); + } + if ($protocol == 'https' && $port == 443) { + unset($port); + } + + $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : ''); + + if (!strlen($url)) { + $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']) && + $_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 + * + * @author KnowledgeTree Team + * @access private + * @param string $dir The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return array The message and css class to use + */ + private function _checkPermission($dir) + { + if(is_readable($dir) && is_writable($dir)) { + return true; + } else { + return false; + } + + } + + /** + * Check whether a given directory / file path exists and is writable + * + * @author KnowledgeTree Team + * @access private + * @param string $dir The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return array The message and css class to use + */ + public function checkPermission($dir, $create=false) + { + $exist = 'Directory doesn\'t exist'; + $write = 'Directory not writable'; + $ret = array('class' => 'cross'); + + if(!file_exists($dir)){ + if($create === false){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + $par_dir = dirname($dir); + if(!file_exists($par_dir)){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + if(!is_writable($par_dir)){ + $this->done = false; + $ret['msg'] = $exist; + return $ret; + } + mkdir($dir, '0755'); + } + + if(is_writable($dir)){ + $ret['class'] = 'tick'; + + return $ret; + } + + $this->done = false; + $ret['msg'] = $write; + return $ret; + } + + /** + * Change permissions on a directory helper + * + * @author KnowledgeTree Team + * @access public + * @param string $folderPath The directory / file to check + * @return boolean + */ + public function canChangePermissions($folderPath) { + return $this->_chmodRecursive($folderPath, 0755); + } + + /** + * Change permissions on a directory (recursive) + * + * @author KnowledgeTree Team + * @access private + * @param string $folderPath The directory / file to check + * @param boolean $create Whether to create the directory if it doesn't exist + * @return boolean + */ + private function _chmodRecursive($path, $filemode) { + if (!is_dir($path)) + return chmod($path, $filemode); + $dh = opendir($path); + while (($file = readdir($dh)) !== false) { + if($file != '.' && $file != '..') { + $fullpath = $path.'/'.$file; + if(is_link($fullpath)) + return false; + elseif(!is_dir($fullpath)) { + $perms = substr(sprintf('%o', fileperms($fullpath)), -4); + if($perms != $filemode) + if (!chmod($fullpath, $filemode)) + return false; + } elseif(!$this->chmodRecursive($fullpath, $filemode)) + return false; + } + } + closedir($dh); + $perms = substr(sprintf('%o', fileperms($path)), -4); + if($perms != $filemode) { + if(chmod($path, $filemode)) + return true; + else + return false; + } else { + return true; + } + } + + /** + * Check if a file can be written to a folder + * + * @author KnowledgeTree Team + * @access public + * @param string $filename the path to the file to create + * @return boolean + */ + public function canWriteFile($filename) { + $fh = fopen($filename, "w+"); + if($fr = fwrite($fh, 'test') === false) { + return false; + } + + fclose($fh); + return true; + } + + /** + * Attempt using the php-java bridge + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function javaBridge() { + try { + $javaSystem = new Java('java.lang.System'); + } catch (JavaException $e) { + return false; + } + return true; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava1() { + $response = $this->pexec("java -version"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + + return 'java'; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava2() { + $response = $this->pexec("java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + + return 'java'; + } + + /** + * Attempt java detection + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function tryJava3() { + $response = $this->pexec("whereis java"); // Java Runtime Check + if(empty($response['out'])) { + return false; + } + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/java:/', '', $r); + } + } + } + + /** + * Check if user entered location of JRE + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + public function javaSpecified() { + if(isset($_POST['java'])) { + if($_POST['java'] != '') { + return $_POST['java']; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Check if user entered location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + public function phpSpecified() { + if(isset($_POST['php'])) { + if($_POST['php'] != '') { + return $_POST['php']; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Determine the location of JAVA_HOME + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + function getJava() { + $response = $this->tryJava1(); + if(!is_array($response)) { + $response = $this->tryJava2(); + if(!is_array($response)) { + $response = $this->tryJava3(); + } + } +// return false; + return $response; + } + + /** + * Determine the location of PHP + * + * @author KnowledgeTree Team + * @param none + * @access private + * @return mixed + */ + function getPhp() { + $cmd = "whereis php"; + $res = $this->getPhpHelper($cmd); + if($res != '') { + return $res; + } + $cmd = "which php"; + return $this->getPhpHelper($cmd); + } + + function getPhpHelper($cmd) { + $response = $this->pexec($cmd); + if(is_array($response['out'])) { + if (isset($response['out'][0])) { + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/php:/', '', $r); + } + } + } + } + + return ''; + } + + function getOpenOffice() { + $cmd = "whereis soffice"; + $response = $this->pexec($cmd); + if(is_array($response['out'])) { + if (isset($response['out'][0])) { + $broke = explode(' ', $response['out'][0]); + foreach ($broke as $r) { + $match = preg_match('/bin/', $r); + if($match) { + return preg_replace('/soffice:/', '', $r); + } + } + } + } + + return ''; + } + /** + * Portably execute a command on any of the supported platforms. + * + * @author KnowledgeTree Team + * @access public + * @param string $aCmd + * @param array $aOptions + * @return array + */ + public function pexec($aCmd, $aOptions = null) { + if (is_array($aCmd)) { + $sCmd = $this->safeShellString($aCmd); + } else { + $sCmd = $aCmd; + } + $sAppend = $this->arrayGet($aOptions, 'append'); + if ($sAppend) { + $sCmd .= " >> " . escapeshellarg($sAppend); + } + $sPopen = $this->arrayGet($aOptions, 'popen'); + if ($sPopen) { + if (WINDOWS_OS) { + $sCmd = "start /b \"kt\" " . $sCmd; + } + return popen($sCmd, $sPopen); + } + // for exec, check return code and output... + $aRet = array(); + $aOutput = array(); + $iRet = ''; + if(WINDOWS_OS) { + $sCmd = 'call '.$sCmd; + } + + exec($sCmd, $aOutput, $iRet); + $aRet['ret'] = $iRet; + $aRet['out'] = $aOutput; + + return $aRet; + } + + /** + * + * + * @author KnowledgeTree Team + * @access public + * @return string + */ + public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) { + if (!is_array($aArray)) { + $aArray = (array) $aArray; + } + + if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) { + return $mDefault; + } + if (array_key_exists($sKey, $aArray)) { + $mVal =& $aArray[$sKey]; + if (empty($mVal) && $bDefaultIfEmpty) { + return $mDefault; + } + return $mVal; + } + return $mDefault; + } + + /** + * + * + * @author KnowledgeTree Team + * @access public + * @return string + */ + public function safeShellString () { + $aArgs = func_get_args(); + $aSafeArgs = array(); + if (is_array($aArgs[0])) { + $aArgs = $aArgs[0]; + } + $aSafeArgs[] = escapeshellarg(array_shift($aArgs)); + if (is_array($aArgs[0])) { + $aArgs = $aArgs; + } + foreach ($aArgs as $sArg) { + if (empty($sArg)) { + $aSafeArgs[] = "''"; + } else { + $aSafeArgs[] = escapeshellarg($sArg); + } + } + return join(" ", $aSafeArgs); + } + +} +?> \ No newline at end of file diff --git a/setup/migrate/migrateWizard.php b/setup/migrate/migrateWizard.php new file mode 100644 index 0000000..fbfcffc --- /dev/null +++ b/setup/migrate/migrateWizard.php @@ -0,0 +1,268 @@ +. +* +* 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 +*/ +include("path.php"); // Paths + +/** + * Auto loader to bind migrateer package + * + * @param string $class + * @return void + */ +function __autoload($class) { // Attempt and autoload classes + $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. + if(file_exists(WIZARD_DIR."$class.php")) { + require_once(WIZARD_DIR."$class.php"); + } elseif (file_exists(STEP_DIR."$class.php")) { + require_once(STEP_DIR."$class.php"); + } elseif (file_exists(WIZARD_LIB."$class.php")) { + require_once(WIZARD_LIB."$class.php"); + } elseif (file_exists(SERVICE_LIB."$class.php")) { + require_once(SERVICE_LIB."$class.php"); + } else { + return null; + } +} + +class MigrateWizard { + /** + * Migrate bypass flag + * + * @author KnowledgeTree Team + * @access protected + * @var mixed + */ + protected $bypass = null; + + /** + * Reference to migrateer utility object + * + * @author KnowledgeTree Team + * @access protected + * @var boolean + */ + protected $iutil = null; + + /** + * Constructs migrateation wizard object + * + * @author KnowledgeTree Team + * @access public + */ + public function __construct(){} + + /** + * Check if system has been migrate + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return boolean + */ + private function isSystemMigrateed() { + return $this->iutil->isSystemMigrateed(); + } + + /** + * Display the wizard + * + * @author KnowledgeTree Team + * @access private + * @param string + * @return void + */ + public function displayMigrater($response = null) { + if($response) { + $ins = new Migrater(); // Instantiate the migrateer + $ins->resolveErrors($response); // Run step + } else { + $ins = new Migrater(new Session()); // Instantiate the migrateer and pass the session class + $ins->step(); // Run step + } + } + + /** + * Set bypass flag + * + * @author KnowledgeTree Team + * @access private + * @param boolean + * @return void + */ + private function setBypass($bypass) { + $this->bypass = $bypass; + } + + /** + * Set util reference + * + * @author KnowledgeTree Team + * @access private + * @param object migrateer utility + * @return void + */ + private function setIUtil($iutil) { + $this->iutil = $iutil; + } + + /** + * Get bypass flag + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return boolean + */ + public function getBypass() { + return $this->bypass; + } + + /** + * Bypass and force an migrate + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return boolean + */ + private function bypass() { + + } + + /** + * Create migrate file + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + private function createMigrateFile() { + @touch("migrate"); + } + + /** + * Remove migrate file + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + private function removeMigrateFile() { + @unlink("migrate"); + } + + /** + * Load default values + * + * @author KnowledgeTree Team + * @access private + * @param none + * @return void + */ + function load() { + if(isset($_GET['bypass'])) { + $this->setBypass($_GET['bypass']); + } + $this->setIUtil(new MigrateUtil()); + } + + /** + * Run pre-migrateation system checks + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return mixed + */ + public function systemChecks() { + $res = $this->iutil->checkStructurePermissions(); + if($res === true) return $res; + switch ($res) { + case "wizard": + $this->iutil->error("Migrater directory is not writable (KT_Migrateation_Directory/setup/wizard/)"); + return 'Migrater directory is not writable (KT_Migrateation_Directory/setup/wizard/)'; + break; + case "/": + $this->iutil->error("System root is not writable (KT_Migrateation_Directory/)"); + return "System root is not writable (KT_Migrateation_Directory/)"; + break; + default: + return true; + break; + } + + return $res; + } + + /** + * Control all requests to wizard + * + * @author KnowledgeTree Team + * @access public + * @param none + * @return void + */ + public function dispatch() { + $this->load(); + if($this->getBypass() === "1") { + $this->removeMigrateFile(); + } elseif ($this->getBypass() === "0") { + $this->createMigrateFile(); + } + if(!$this->isSystemMigrateed()) { // Check if the systems not migrateed + $response = $this->systemChecks(); + if($response === true) { + $this->displayMigrater(); + } else { + exit(); + } + } else { + // TODO: Die gracefully + $this->iutil->error("System has been migrateed
Goto Login
"); + } + } +} + +$ic = new MigrateWizard(); +$ic->dispatch(); +?> \ No newline at end of file diff --git a/setup/migrate/path.php b/setup/migrate/path.php new file mode 100644 index 0000000..58d0574 --- /dev/null +++ b/setup/migrate/path.php @@ -0,0 +1,129 @@ +. +* +* 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 migrateer 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('WIZARD_DIR', $wizard.DS); + define('WIZARD_LIB', WIZARD_DIR."lib".DS); + define('SERVICE_LIB', WIZARD_LIB."services".DS); + define('SQL_DIR', WIZARD_DIR."sql".DS); + define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS); + define('CONF_DIR', WIZARD_DIR."config".DS); + define('RES_DIR', WIZARD_DIR."resources".DS); + define('STEP_DIR', WIZARD_DIR."steps".DS); + define('TEMP_DIR', WIZARD_DIR."templates".DS); + define('SHELL_DIR', WIZARD_DIR."shells".DS); + define('OUTPUT_DIR', WIZARD_DIR."output".DS); + // Define paths to system webroot + define('SYSTEM_DIR', $sys); + define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS); + define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".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/resources/graphics/active.png b/setup/migrate/resources/graphics/active.png new file mode 100644 index 0000000..62b232c --- /dev/null +++ b/setup/migrate/resources/graphics/active.png diff --git a/setup/migrate/resources/graphics/background.gif b/setup/migrate/resources/graphics/background.gif new file mode 100644 index 0000000..d8039fb --- /dev/null +++ b/setup/migrate/resources/graphics/background.gif diff --git a/setup/migrate/resources/graphics/big-ok.png b/setup/migrate/resources/graphics/big-ok.png new file mode 100644 index 0000000..62c9046 --- /dev/null +++ b/setup/migrate/resources/graphics/big-ok.png diff --git a/setup/migrate/resources/graphics/cross.png b/setup/migrate/resources/graphics/cross.png new file mode 100644 index 0000000..3ba9615 --- /dev/null +++ b/setup/migrate/resources/graphics/cross.png diff --git a/setup/migrate/resources/graphics/cross_orange.png b/setup/migrate/resources/graphics/cross_orange.png new file mode 100644 index 0000000..cb02cd5 --- /dev/null +++ b/setup/migrate/resources/graphics/cross_orange.png diff --git a/setup/migrate/resources/graphics/dame/dot.png b/setup/migrate/resources/graphics/dame/dot.png new file mode 100644 index 0000000..0365307 --- /dev/null +++ b/setup/migrate/resources/graphics/dame/dot.png diff --git a/setup/migrate/resources/graphics/dame/finish.png b/setup/migrate/resources/graphics/dame/finish.png new file mode 100644 index 0000000..6176f6e --- /dev/null +++ b/setup/migrate/resources/graphics/dame/finish.png diff --git a/setup/migrate/resources/graphics/dame/gradiant.gif b/setup/migrate/resources/graphics/dame/gradiant.gif new file mode 100644 index 0000000..019998d --- /dev/null +++ b/setup/migrate/resources/graphics/dame/gradiant.gif diff --git a/setup/migrate/resources/graphics/dame/kt_gradient.jpg b/setup/migrate/resources/graphics/dame/kt_gradient.jpg new file mode 100644 index 0000000..e5c3b5b --- /dev/null +++ b/setup/migrate/resources/graphics/dame/kt_gradient.jpg diff --git a/setup/migrate/resources/graphics/dame/loginbg.png b/setup/migrate/resources/graphics/dame/loginbg.png new file mode 100644 index 0000000..02c3ad7 --- /dev/null +++ b/setup/migrate/resources/graphics/dame/loginbg.png diff --git a/setup/migrate/resources/graphics/dame/migrater-header_logo.png b/setup/migrate/resources/graphics/dame/migrater-header_logo.png new file mode 100644 index 0000000..c5d8e7d --- /dev/null +++ b/setup/migrate/resources/graphics/dame/migrater-header_logo.png diff --git a/setup/migrate/resources/graphics/dame/migrater_head.png b/setup/migrate/resources/graphics/dame/migrater_head.png new file mode 100644 index 0000000..dcd92ac --- /dev/null +++ b/setup/migrate/resources/graphics/dame/migrater_head.png diff --git a/setup/migrate/resources/graphics/dame/navbar.png b/setup/migrate/resources/graphics/dame/navbar.png new file mode 100644 index 0000000..c29b192 --- /dev/null +++ b/setup/migrate/resources/graphics/dame/navbar.png diff --git a/setup/migrate/resources/graphics/dame/powered-by-kt.png b/setup/migrate/resources/graphics/dame/powered-by-kt.png new file mode 100644 index 0000000..0526fd8 --- /dev/null +++ b/setup/migrate/resources/graphics/dame/powered-by-kt.png diff --git a/setup/migrate/resources/graphics/dame/tick1.png b/setup/migrate/resources/graphics/dame/tick1.png new file mode 100644 index 0000000..2df208f --- /dev/null +++ b/setup/migrate/resources/graphics/dame/tick1.png diff --git a/setup/migrate/resources/graphics/dame/tick2.png b/setup/migrate/resources/graphics/dame/tick2.png new file mode 100644 index 0000000..979f834 --- /dev/null +++ b/setup/migrate/resources/graphics/dame/tick2.png diff --git a/setup/migrate/resources/graphics/dropbox.png b/setup/migrate/resources/graphics/dropbox.png new file mode 100644 index 0000000..af538e5 --- /dev/null +++ b/setup/migrate/resources/graphics/dropbox.png diff --git a/setup/migrate/resources/graphics/dropbox_old.png b/setup/migrate/resources/graphics/dropbox_old.png new file mode 100644 index 0000000..6958c3c --- /dev/null +++ b/setup/migrate/resources/graphics/dropbox_old.png diff --git a/setup/migrate/resources/graphics/footer.png b/setup/migrate/resources/graphics/footer.png new file mode 100644 index 0000000..6486da9 --- /dev/null +++ b/setup/migrate/resources/graphics/footer.png diff --git a/setup/migrate/resources/graphics/gradient.png b/setup/migrate/resources/graphics/gradient.png new file mode 100644 index 0000000..6074bca --- /dev/null +++ b/setup/migrate/resources/graphics/gradient.png diff --git a/setup/migrate/resources/graphics/inactive.png b/setup/migrate/resources/graphics/inactive.png new file mode 100644 index 0000000..dfe29a2 --- /dev/null +++ b/setup/migrate/resources/graphics/inactive.png diff --git a/setup/migrate/resources/graphics/indicator.png b/setup/migrate/resources/graphics/indicator.png new file mode 100644 index 0000000..89dbff0 --- /dev/null +++ b/setup/migrate/resources/graphics/indicator.png diff --git a/setup/migrate/resources/graphics/kt_browse.png b/setup/migrate/resources/graphics/kt_browse.png new file mode 100644 index 0000000..048cd6c --- /dev/null +++ b/setup/migrate/resources/graphics/kt_browse.png diff --git a/setup/migrate/resources/graphics/left.png b/setup/migrate/resources/graphics/left.png new file mode 100644 index 0000000..b74fcf7 --- /dev/null +++ b/setup/migrate/resources/graphics/left.png diff --git a/setup/migrate/resources/graphics/logo.png b/setup/migrate/resources/graphics/logo.png new file mode 100644 index 0000000..bfeefd8 --- /dev/null +++ b/setup/migrate/resources/graphics/logo.png diff --git a/setup/migrate/resources/graphics/powered-by-kt.png b/setup/migrate/resources/graphics/powered-by-kt.png new file mode 100644 index 0000000..2bc078b --- /dev/null +++ b/setup/migrate/resources/graphics/powered-by-kt.png diff --git a/setup/migrate/resources/graphics/question.gif b/setup/migrate/resources/graphics/question.gif new file mode 100644 index 0000000..390a7fc --- /dev/null +++ b/setup/migrate/resources/graphics/question.gif diff --git a/setup/migrate/resources/graphics/tick.png b/setup/migrate/resources/graphics/tick.png new file mode 100644 index 0000000..a24d605 --- /dev/null +++ b/setup/migrate/resources/graphics/tick.png diff --git a/setup/migrate/resources/graphics/tree.jpg b/setup/migrate/resources/graphics/tree.jpg new file mode 100644 index 0000000..d9e11f6 --- /dev/null +++ b/setup/migrate/resources/graphics/tree.jpg diff --git a/setup/migrate/resources/jquery-tooltip/changelog.txt b/setup/migrate/resources/jquery-tooltip/changelog.txt new file mode 100644 index 0000000..510a791 --- /dev/null +++ b/setup/migrate/resources/jquery-tooltip/changelog.txt @@ -0,0 +1,38 @@ +1.3 +--- + +* Added fade option (duration in ms) for fading in/out tooltips; IE <= 6 is excluded when bgiframe plugin is included +* Fixed imagemaps in IE, added back example +* Added positionLeft-option - positions the tooltip to the left of the cursor +* Remove deprecated $.fn.Tooltip in favor of $.fn.tooltip + +1.2 +--- + +* Improved bodyHandler option to accept HTML strings, DOM elements and jQuery objects as the return value +* Fixed bug in Safari 3 where to tooltip is initially visible, by first appending to DOM then hiding it +* Improvement for viewport-border-positioning: Add the classes "viewport-right" and "viewport-bottom" when the element is moved at the viewport border. +* Moved and enhanced documentation to docs.jquery.com +* Added examples for bodyHandler: footnote-tooltip and thumbnail +* Added id option, defaults to "tooltip", override to use a different id in your stylesheet +* Moved demo tooltip style to screen.css +* Moved demo files to demo folder and dependencies to lib folder +* Dropped image map example - completely incompatible with IE; image maps aren't supported anymore + +1.1 +--- + +* Use bgiframe-plugin if available +* Use dimensions-plugin to calculate viewport +* Expose global blocked-property via $.Tooltip.blocked to programmatically disable all tooltips +* Fixed image maps in IE by setting the alt-attribute to an empty string +* Removed event-option (only hover-tooltips now) +* Simplified event-handling (using hover instead of mouseover und mouseout) +* Added another "pretty" example +* Added top and left options to specify tooltip offset +* Reworked example page: New layout, code examples + +1.0 +--- + +* first release considered stable \ No newline at end of file diff --git a/setup/migrate/resources/jquery-tooltip/demo/bg.gif b/setup/migrate/resources/jquery-tooltip/demo/bg.gif new file mode 100644 index 0000000..846add0 --- /dev/null +++ b/setup/migrate/resources/jquery-tooltip/demo/bg.gif diff --git a/setup/migrate/resources/jquery-tooltip/demo/chili-1.7.pack.js b/setup/migrate/resources/jquery-tooltip/demo/chili-1.7.pack.js new file mode 100644 index 0000000..90e7735 --- /dev/null +++ b/setup/migrate/resources/jquery-tooltip/demo/chili-1.7.pack.js @@ -0,0 +1 @@ +eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('8={3b:"1.6",2o:"1B.1Y,1B.23,1B.2e",2i:"",2H:1a,12:"",2C:1a,Z:"",2a:\'$$\',R:"&#F;",1j:"&#F;&#F;&#F;&#F;",1f:"&#F;<1W/>",3c:5(){9 $(y).39("1k")[0]},I:{},N:{}};(5($){$(5(){5 1J(l,a){5 2I(A,h){4 3=(1v h.3=="1h")?h.3:h.3.1w;k.1m({A:A,3:"("+3+")",u:1+(3.c(/\\\\./g,"%").c(/\\[.*?\\]/g,"%").3a(/\\((?!\\?)/g)||[]).u,z:(h.z)?h.z:8.2a})}5 2z(){4 1E=0;4 1x=x 2A;Q(4 i=0;i\';8.N[X]=1H;7($.31.34){4 W=J.1L(Y);4 $W=$(W);$("2d").1O($W)}v{$("2d").1O(Y)}}}5 1q(e,a){4 l=e&&e.1g&&e.1g[0]&&e.1g[0].37;7(!l)l="";l=l.c(/\\r\\n?/g,"\\n");4 C=1J(l,a);7(8.1j){C=C.c(/\\t/g,8.1j)}7(8.1f){C=C.c(/\\n/g,8.1f)}$(e).38(C)}5 1o(q,13){4 1l={12:8.12,2x:q+".1d",Z:8.Z,2w:q+".2u"};4 B;7(13&&1v 13=="2l")B=$.35(1l,13);v B=1l;9{a:B.12+B.2x,1p:B.Z+B.2w}}7($.2q)$.2q({36:"2l.15"});4 2n=x 1u("\\\\b"+8.2i+"\\\\b","2j");4 1e=[];$(8.2o).2D(5(){4 e=y;4 1n=$(e).3i("V");7(!1n){9}4 q=$.3u(1n.c(2n,""));7(\'\'!=q){1e.1m(e);4 f=1o(q,e.15);7(8.2H||e.15){7(!8.N[f.a]){1D{8.N[f.a]=1H;$.3v(f.a,5(M){M.f=f.a;8.I[f.a]=M;7(8.2C){2B(f.1p)}$("."+q).2D(5(){4 f=1o(q,y.15);7(M.f==f.a){1q(y,M)}})})}1I(3s){3t("a 3w Q: "+q+\'@\'+3z)}}}v{4 a=8.I[f.a];7(a){1q(e,a)}}}});7(J.1i&&J.1i.29){5 22(p){7(\'\'==p){9""}1z{4 16=(x 3A()).2k()}19(p.3x(16)>-1);p=p.c(/\\<1W[^>]*?\\>/3y,16);4 e=J.1L(\'<1k>\');e.3l=p;p=e.3m.c(x 1u(16,"g"),\'\\r\\n\');9 p}4 T="";4 18=1G;$(1e).3j().G("1k").U("2c",5(){18=y}).U("1M",5(){7(18==y)T=J.1i.29().3k});$("3n").U("3q",5(){7(\'\'!=T){2p.3r.3o(\'3p\',22(T));2V.2R=1a}}).U("2c",5(){T=""}).U("1M",5(){18=1G})}})})(1Z);8.I["1Y.1d"]={k:{2M:{3:/\\/\\*[^*]*\\*+(?:[^\\/][^*]*\\*+)*\\//},25:{3:/\\ +
+

     "; ?>Paths and Permissions

+ +
Show Details
+ + +
+

+
+ +

     "; ?>Database connectivity

+ +
Show Details
+ + +

+ + +

     "; ?>Privileges

+ +
Show Details
+ + +
+ +

+
+

     "; ?>Services

+ +
Show Details
+ + +
+ + Goto Login + + " class="back" target="_blank">Zend Server Configuration + + \ No newline at end of file diff --git a/setup/migrate/templates/database.tpl b/setup/migrate/templates/database.tpl new file mode 100644 index 0000000..f96c8cb --- /dev/null +++ b/setup/migrate/templates/database.tpl @@ -0,0 +1,140 @@ +
+

Confirming Database Configurations

+ + + +/> + + +
+
+ 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 migrateation database. +
+
+ + + + + + + $v) { + ?> + + + + + + + + + + + + + + + + + + +
Your current database type is: +   + + /> +
+

+
  Advanced Options
+ +
+ + + + + + +
+ + + + + + +
\ No newline at end of file diff --git a/setup/migrate/templates/errors.tpl b/setup/migrate/templates/errors.tpl new file mode 100644 index 0000000..f105fa7 --- /dev/null +++ b/setup/migrate/templates/errors.tpl @@ -0,0 +1,14 @@ +

Welcome to the KnowledgeTree Setup Wizard

+ +
+ +'; + foreach ($errors as $msg){ + echo $msg . "
\n"; + } + echo '
'; +} +?> + \ No newline at end of file diff --git a/setup/migrate/templates/installation.tpl b/setup/migrate/templates/installation.tpl new file mode 100644 index 0000000..8de6b75 --- /dev/null +++ b/setup/migrate/templates/installation.tpl @@ -0,0 +1,14 @@ +
+

Finalizing System Migrateation

+ +
+
+
+

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

+
+
+ + +
\ No newline at end of file diff --git a/setup/migrate/templates/services.tpl b/setup/migrate/templates/services.tpl new file mode 100644 index 0000000..043419f --- /dev/null +++ b/setup/migrate/templates/services.tpl @@ -0,0 +1,166 @@ +
+ + + +

Checking Service Dependencies

+ +

+ The wizard will review your system to determine whether you can run KnowledgeTree background services.
Once the scan is completed, you’ll see whether your system has met the requirements or whether there are areas you need to address. +

+ + +       + All service dependencies are met. Please click next to continue. +

+ + + +       + Your system is not quite ready to run KnowledgeTree. See the list below to determine which areas you need to address. +
+ +       + Not all optional dependencies required by KnowledgeTree have been met but you will be able to continue. +
+ + +      Click here for help on overcoming service issues + + +
+ + + + Specify the location of your Java executable +     + ' style="float:none;"/> +     + Submit +
+ + + +
+ Specify the location of your PHP executable +
+ + '/> + + '/> + +     + + +

     "; ?>Java Check

+ +
Show Details
+ + + +

     "; ?>Java Extensions

+ +
Show Details
+ + + + + + All services are already migrateed. + + +

     "; ?>Services Check

+ +
Show Details
+ + +
+ + +
\ No newline at end of file diff --git a/setup/migrate/templates/welcome.tpl b/setup/migrate/templates/welcome.tpl new file mode 100644 index 0000000..eeba243 --- /dev/null +++ b/setup/migrate/templates/welcome.tpl @@ -0,0 +1,10 @@ +
+

Welcome to KnowledgeTree

+
+
+
+

This wizard will lead you through the steps needed to migrate and configure KnowledgeTree on your server.

+
+
+ +
\ No newline at end of file diff --git a/setup/migrate/templates/wizard.tpl b/setup/migrate/templates/wizard.tpl new file mode 100644 index 0000000..fc59a20 --- /dev/null +++ b/setup/migrate/templates/wizard.tpl @@ -0,0 +1,41 @@ + + + + KnowledgeTree Migrateer + + + + + + +
+ +
+
+ +
+
+ +
+
+
+
 
+
+ + +
+ + + \ No newline at end of file