From 7f9d4e30d9d2d6bb5678fb5ae61ac2d8a61da5ca Mon Sep 17 00:00:00 2001 From: Jarrett Jordaan Date: Mon, 27 Jul 2009 14:18:40 +0200 Subject: [PATCH] StoryId778896:Cleanup Installer Framework --- setup/wizard/Ini.inc | 228 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ setup/wizard/database.inc | 246 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ setup/wizard/install_util.php | 324 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ setup/wizard/lucene.pid | 3 --- setup/wizard/output | 0 5 files changed, 0 insertions(+), 801 deletions(-) delete mode 100644 setup/wizard/Ini.inc delete mode 100644 setup/wizard/database.inc delete mode 100644 setup/wizard/install_util.php delete mode 100644 setup/wizard/lucene.pid delete mode 100644 setup/wizard/output diff --git a/setup/wizard/Ini.inc b/setup/wizard/Ini.inc deleted file mode 100644 index 745602d..0000000 --- a/setup/wizard/Ini.inc +++ /dev/null @@ -1,228 +0,0 @@ -. - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, - * California 94120-7775, or email info@knowledgetree.com. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU General Public License version 3. - * - * In accordance with Section 7(b) of the GNU General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. - * Contributor( s): ______________________________________ - * - */ - -class Ini { - - private $cleanArray = array(); - private $iniFile = ''; - private $lineNum = 0; - private $exists = ''; - - function Ini($iniFile = '../../config.ini') { - $this->iniFile = $iniFile; - $this->backupIni($iniFile); - $this->read($iniFile); - } - - /** - * Create a backup with the date as an extension in the same location as the original config.ini - * - * @param string $iniFile - * @return boolean - */ - function backupIni($iniFile) - { - $content = file_get_contents($iniFile); - if ($content === false) - { - return false; - } - $date = date('YmdHis'); - - $backupFile = $iniFile . '.' .$date; - if (is_writeable($backupFile)) { - file_put_contents($backupFile, $content); - } - } - - function read($iniFile) { - - $iniArray = file($iniFile); - $section = ''; - foreach($iniArray as $iniLine) { - $this->lineNum++; - $iniLine = trim($iniLine); - $firstChar = substr($iniLine, 0, 1); - if($firstChar == ';') { - if($section == ''){ - $this->cleanArray['_comment_'.$this->lineNum]=$iniLine; - }else { - $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine; - } - continue; - } - if($iniLine == '') { - if($section == ''){ - $this->cleanArray['_blankline_'.$this->lineNum]=''; - }else { - $this->cleanArray[$section]['_blankline_'.$this->lineNum]=''; - } - continue; - } - - if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') { - $section = substr($iniLine, 1, -1); - $this->sections[] = $section; - } else { - $equalsPos = strpos($iniLine, '='); - if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) { - $key = trim(substr($iniLine, 0, $equalsPos)); - $value = trim(substr($iniLine, $equalsPos+1)); - if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { - $value = substr($value, 1, -1); - } - $this->cleanArray[$section][$key] = stripcslashes($value); - } else { - $this->cleanArray[$section][trim($iniLine)]=''; - } - } - } - return $this->cleanArray; - } - - function write($iniFile = "") { - - if(empty($iniFile)) { - $iniFile = $this->iniFile; - } - if (!is_writeable($iniFile)) { - return; - } - - $fileHandle = fopen($iniFile, 'wb'); - foreach ($this->cleanArray as $section => $items) { - if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { - fwrite ($fileHandle, "\r\n"); - continue; - } - if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { - fwrite ($fileHandle, "$items\r\n"); - continue; - } - fwrite ($fileHandle, "[".$section."]\r\n"); - foreach ($items as $key => $value) { - if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { - fwrite ($fileHandle, "\r\n"); - continue; - } - if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { - fwrite ($fileHandle, "$value\r\n"); - continue; - } - - $value = addcslashes($value,''); - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); - fwrite ($fileHandle, $key.' = '.$value."\r\n"); - } - } - fclose($fileHandle); - } - - function itemExists($checkSection, $checkItem) { - - $this->exists = ''; - foreach($this->cleanArray as $section => $items) { - if($section == $checkSection) { - $this->exists = 'section'; - foreach ($items as $key => $value) { - if($key == $checkItem) { - return true; - } - } - } - } - return false; - } - - function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { - - if($this->itemExists($addSection, $addItem)) { - $this->delItem($addSection, $addItem); - } - - if($this->exists != 'section') { - $this->cleanArray['_blankline_'.$this->lineNum++]=''; - if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment; - } - if(!empty($itemComment)) { - $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment; - } - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); - return true; - } - - function updateItem($addSection, $addItem, $value) { - - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); - return true; - } - - function delItem($delSection, $delItem) { - - if(!$this->itemExists($delSection, $delItem)) return false; - - unset($this->cleanArray[$delSection][$delItem]); - return true; - } - - function delSection($delSection) { - - unset($this->cleanArray[$delSection]); - return true; - } - -} -/* -// USAGE EXAMPLE - -if(file_exists('../../config.ini')) { - - $ini = new Ini(); - $ini->addItem('Section1', 'NewItem1', 'Some Text1', 'Item1 Comment', 'Section1 Comment'); - $ini->addItem('Section1', 'NewItem1.2', 'Some Text1.2', 'Item1.2 Comment'); - $ini->addItem('Section1', 'NewItem1.3', 'Some Text1.3', 'Item1.3 Comment'); - $ini->addItem('Section1', 'NewItem1.4', 'Some Text1.4', 'Item1.4 Comment'); - $ini->addItem('Section2', 'NewItem2', 'Some Text2', 'Item2 Comment'); - $ini->addItem('Section2', 'NewItem2.1', 'Some Text2.1'); - $ini->addItem('Section3', 'NewItem3', 'Some Text3', 'Item3 Comment', 'Section3 Comment'); - $ini->addItem('Section4', 'NewItem4', 'Some Text4', 'Item4 Comment'); - $ini->write(); - -} -*/ -?> diff --git a/setup/wizard/database.inc b/setup/wizard/database.inc deleted file mode 100644 index 7cad7d2..0000000 --- a/setup/wizard/database.inc +++ /dev/null @@ -1,246 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Installer -* @version Version 0.1 -*/ -class DBUtil { - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbhost = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbname = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbuname = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $dbpassword = ''; - - /** - * Host - * - * @author KnowledgeTree Team - * @access protected - * @var object mysql connection - */ - protected $dbconnection = ''; - - /** - * Any errors encountered - * - * @author KnowledgeTree Team - * @access protected - * @var string - */ - protected $error = ''; - - /** - * Constructs database connection object - * - * @author KnowledgeTree Team - * @access public - */ - public function __construct() { - } - - /** - * Connect to a MySQL database - * - * @param string $dhost host - * @param string $duname database username - * @param string $dpassword database password - * @access public - * @return boolean - */ - public function DBUtil($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->useBD($dbname); - } - if($this->dbconnection) - return $this->dbconnection; - else { - $this->error = mysql_error(); - return false; - } - } - - /** - * Choose a database to use - * - * @param string $dbname name of the database - * @access public - * @return boolean - */ - public function useBD($dbname) { - if($dbname != '') { - $this->setDb($dbname); - } - - if(mysql_select_db($this->dbname)) - return true; - else { - $this->error = mysql_error(); - 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); - if($result) { - return $result; - } else { - $this->error = mysql_error(); - return false; - } - } - - /** - * Do the same as query. - * - * @param $query the sql query. - * @access public - * @return boolean - */ - public function execute($query) { - $result = mysql_query($query); - if($result) { - return true; - } else { - $this->error = mysql_error(); - 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 { - while ($row = mysql_fetch_assoc($result)) { - $r[] = $row; - } - return $r; - } - } - - /** - * Close the connection with the database server. - * - * @param none. - * @access public - * @return void. - */ - public function close() { - mysql_close(); - } - - /** - * Get database errors. - * - * @param none. - * @access public - * @return string. - */ - public function getErrors() { - return $this->error; - } -} -?> \ No newline at end of file diff --git a/setup/wizard/install_util.php b/setup/wizard/install_util.php deleted file mode 100644 index b87274c..0000000 --- a/setup/wizard/install_util.php +++ /dev/null @@ -1,324 +0,0 @@ -. -* -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, -* California 94120-7775, or email info@knowledgetree.com. -* -* The interactive user interfaces in modified source and object code versions -* of this program must display Appropriate Legal Notices, as required under -* Section 5 of the GNU General Public License version 3. -* -* In accordance with Section 7(b) of the GNU General Public License version 3, -* these Appropriate Legal Notices must retain the display of the "Powered by -* KnowledgeTree" logo and retain the original copyright notice. If the display of the -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices -* must display the words "Powered by KnowledgeTree" and retain the original -* copyright notice. -* -* @copyright 2008-2009, KnowledgeTree Inc. -* @license GNU General Public License version 3 -* @author KnowledgeTree Team -* @package Installer -* @version Version 0.1 -*/ -class InstallUtil { - /** - * Constructs installation object - * - * @author KnowledgeTree Team - * @access public - */ - public function __construct() { - } - - /** - * Check if system needs to be installed - * - * @author KnowledgeTree Team - * @access public - * @param none - * @return boolean - */ - public function isSystemInstalled() { - if (file_exists(dirname(__FILE__)."/install")) { - return false; - } - return true; - } - - /** - * Check if system needs to be installed - * - * @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'; - } - if(!$this->_checkPermission(CONF_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(SQL_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(RES_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(STEP_DIR)) { - return 'wizard'; - } - if(!$this->_checkPermission(TEMP_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_writable($dir)){ - return true; - } else { - return false; - } - - } - - /** - * 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; - } - - function execInBackground($cmd) { - if (substr(php_uname(), 0, 7) == "Windows"){ - pclose(popen("start /B ". $cmd, "r")); - } - else { - exec($cmd . " > /dev/null &"); - } - } -} -?> \ No newline at end of file diff --git a/setup/wizard/lucene.pid b/setup/wizard/lucene.pid deleted file mode 100644 index 6f02528..0000000 --- a/setup/wizard/lucene.pid +++ /dev/null @@ -1,3 +0,0 @@ -11702 -12676 -12679 diff --git a/setup/wizard/output b/setup/wizard/output deleted file mode 100644 index e69de29..0000000 --- a/setup/wizard/output +++ /dev/null -- libgit2 0.21.4