Commit 7f9d4e30d9d2d6bb5678fb5ae61ac2d8a61da5ca

Authored by Jarrett Jordaan
1 parent cb720337

StoryId778896:Cleanup Installer Framework

Committed by: Jarrett Jordaan

Reviewed by: Megan Watson
setup/wizard/Ini.inc deleted
1 -<?php  
2 -/**  
3 - * $Id:$  
4 - *  
5 - * KnowledgeTree Community Edition  
6 - * Document Management Made Simple  
7 - * Copyright (C) 2008, 2009 KnowledgeTree Inc.  
8 - * Portions copyright The Jam Warehouse Software (Pty) Limited  
9 - *  
10 - * This program is free software; you can redistribute it and/or modify it under  
11 - * the terms of the GNU General Public License version 3 as published by the  
12 - * Free Software Foundation.  
13 - *  
14 - * This program is distributed in the hope that it will be useful, but WITHOUT  
15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  
16 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more  
17 - * details.  
18 - *  
19 - * You should have received a copy of the GNU General Public License  
20 - * along with this program. If not, see <http://www.gnu.org/licenses/>.  
21 - *  
22 - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,  
23 - * California 94120-7775, or email info@knowledgetree.com.  
24 - *  
25 - * The interactive user interfaces in modified source and object code versions  
26 - * of this program must display Appropriate Legal Notices, as required under  
27 - * Section 5 of the GNU General Public License version 3.  
28 - *  
29 - * In accordance with Section 7(b) of the GNU General Public License version 3,  
30 - * these Appropriate Legal Notices must retain the display of the "Powered by  
31 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the  
32 - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices  
33 - * must display the words "Powered by KnowledgeTree" and retain the original  
34 - * copyright notice.  
35 - * Contributor( s): ______________________________________  
36 - *  
37 - */  
38 -  
39 -class Ini {  
40 -  
41 - private $cleanArray = array();  
42 - private $iniFile = '';  
43 - private $lineNum = 0;  
44 - private $exists = '';  
45 -  
46 - function Ini($iniFile = '../../config.ini') {  
47 - $this->iniFile = $iniFile;  
48 - $this->backupIni($iniFile);  
49 - $this->read($iniFile);  
50 - }  
51 -  
52 - /**  
53 - * Create a backup with the date as an extension in the same location as the original config.ini  
54 - *  
55 - * @param string $iniFile  
56 - * @return boolean  
57 - */  
58 - function backupIni($iniFile)  
59 - {  
60 - $content = file_get_contents($iniFile);  
61 - if ($content === false)  
62 - {  
63 - return false;  
64 - }  
65 - $date = date('YmdHis');  
66 -  
67 - $backupFile = $iniFile . '.' .$date;  
68 - if (is_writeable($backupFile)) {  
69 - file_put_contents($backupFile, $content);  
70 - }  
71 - }  
72 -  
73 - function read($iniFile) {  
74 -  
75 - $iniArray = file($iniFile);  
76 - $section = '';  
77 - foreach($iniArray as $iniLine) {  
78 - $this->lineNum++;  
79 - $iniLine = trim($iniLine);  
80 - $firstChar = substr($iniLine, 0, 1);  
81 - if($firstChar == ';') {  
82 - if($section == ''){  
83 - $this->cleanArray['_comment_'.$this->lineNum]=$iniLine;  
84 - }else {  
85 - $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine;  
86 - }  
87 - continue;  
88 - }  
89 - if($iniLine == '') {  
90 - if($section == ''){  
91 - $this->cleanArray['_blankline_'.$this->lineNum]='';  
92 - }else {  
93 - $this->cleanArray[$section]['_blankline_'.$this->lineNum]='';  
94 - }  
95 - continue;  
96 - }  
97 -  
98 - if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') {  
99 - $section = substr($iniLine, 1, -1);  
100 - $this->sections[] = $section;  
101 - } else {  
102 - $equalsPos = strpos($iniLine, '=');  
103 - if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) {  
104 - $key = trim(substr($iniLine, 0, $equalsPos));  
105 - $value = trim(substr($iniLine, $equalsPos+1));  
106 - if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') {  
107 - $value = substr($value, 1, -1);  
108 - }  
109 - $this->cleanArray[$section][$key] = stripcslashes($value);  
110 - } else {  
111 - $this->cleanArray[$section][trim($iniLine)]='';  
112 - }  
113 - }  
114 - }  
115 - return $this->cleanArray;  
116 - }  
117 -  
118 - function write($iniFile = "") {  
119 -  
120 - if(empty($iniFile)) {  
121 - $iniFile = $this->iniFile;  
122 - }  
123 - if (!is_writeable($iniFile)) {  
124 - return;  
125 - }  
126 -  
127 - $fileHandle = fopen($iniFile, 'wb');  
128 - foreach ($this->cleanArray as $section => $items) {  
129 - if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) {  
130 - fwrite ($fileHandle, "\r\n");  
131 - continue;  
132 - }  
133 - if (substr($section, 0, strlen('_comment_')) === '_comment_' ) {  
134 - fwrite ($fileHandle, "$items\r\n");  
135 - continue;  
136 - }  
137 - fwrite ($fileHandle, "[".$section."]\r\n");  
138 - foreach ($items as $key => $value) {  
139 - if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) {  
140 - fwrite ($fileHandle, "\r\n");  
141 - continue;  
142 - }  
143 - if (substr($key, 0, strlen('_comment_')) === '_comment_' ) {  
144 - fwrite ($fileHandle, "$value\r\n");  
145 - continue;  
146 - }  
147 -  
148 - $value = addcslashes($value,'');  
149 - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n");  
150 - fwrite ($fileHandle, $key.' = '.$value."\r\n");  
151 - }  
152 - }  
153 - fclose($fileHandle);  
154 - }  
155 -  
156 - function itemExists($checkSection, $checkItem) {  
157 -  
158 - $this->exists = '';  
159 - foreach($this->cleanArray as $section => $items) {  
160 - if($section == $checkSection) {  
161 - $this->exists = 'section';  
162 - foreach ($items as $key => $value) {  
163 - if($key == $checkItem) {  
164 - return true;  
165 - }  
166 - }  
167 - }  
168 - }  
169 - return false;  
170 - }  
171 -  
172 - function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') {  
173 -  
174 - if($this->itemExists($addSection, $addItem)) {  
175 - $this->delItem($addSection, $addItem);  
176 - }  
177 -  
178 - if($this->exists != 'section') {  
179 - $this->cleanArray['_blankline_'.$this->lineNum++]='';  
180 - if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment;  
181 - }  
182 - if(!empty($itemComment)) {  
183 - $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment;  
184 - }  
185 - $this->cleanArray[$addSection][$addItem] = stripcslashes($value);  
186 - return true;  
187 - }  
188 -  
189 - function updateItem($addSection, $addItem, $value) {  
190 -  
191 - $this->cleanArray[$addSection][$addItem] = stripcslashes($value);  
192 - return true;  
193 - }  
194 -  
195 - function delItem($delSection, $delItem) {  
196 -  
197 - if(!$this->itemExists($delSection, $delItem)) return false;  
198 -  
199 - unset($this->cleanArray[$delSection][$delItem]);  
200 - return true;  
201 - }  
202 -  
203 - function delSection($delSection) {  
204 -  
205 - unset($this->cleanArray[$delSection]);  
206 - return true;  
207 - }  
208 -  
209 -}  
210 -/*  
211 -// USAGE EXAMPLE  
212 -  
213 -if(file_exists('../../config.ini')) {  
214 -  
215 - $ini = new Ini();  
216 - $ini->addItem('Section1', 'NewItem1', 'Some Text1', 'Item1 Comment', 'Section1 Comment');  
217 - $ini->addItem('Section1', 'NewItem1.2', 'Some Text1.2', 'Item1.2 Comment');  
218 - $ini->addItem('Section1', 'NewItem1.3', 'Some Text1.3', 'Item1.3 Comment');  
219 - $ini->addItem('Section1', 'NewItem1.4', 'Some Text1.4', 'Item1.4 Comment');  
220 - $ini->addItem('Section2', 'NewItem2', 'Some Text2', 'Item2 Comment');  
221 - $ini->addItem('Section2', 'NewItem2.1', 'Some Text2.1');  
222 - $ini->addItem('Section3', 'NewItem3', 'Some Text3', 'Item3 Comment', 'Section3 Comment');  
223 - $ini->addItem('Section4', 'NewItem4', 'Some Text4', 'Item4 Comment');  
224 - $ini->write();  
225 -  
226 -}  
227 -*/  
228 -?>  
setup/wizard/database.inc deleted
1 -<?php  
2 -/**  
3 -* Installer Database Control.  
4 -*  
5 -* KnowledgeTree Community Edition  
6 -* Document Management Made Simple  
7 -* Copyright (C) 2008,2009 KnowledgeTree Inc.  
8 -* Portions copyright The Jam Warehouse Software (Pty) Limited  
9 -*  
10 -* This program is free software; you can redistribute it and/or modify it under  
11 -* the terms of the GNU General Public License version 3 as published by the  
12 -* Free Software Foundation.  
13 -*  
14 -* This program is distributed in the hope that it will be useful, but WITHOUT  
15 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  
16 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more  
17 -* details.  
18 -*  
19 -* You should have received a copy of the GNU General Public License  
20 -* along with this program. If not, see <http://www.gnu.org/licenses/>.  
21 -*  
22 -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,  
23 -* California 94120-7775, or email info@knowledgetree.com.  
24 -*  
25 -* The interactive user interfaces in modified source and object code versions  
26 -* of this program must display Appropriate Legal Notices, as required under  
27 -* Section 5 of the GNU General Public License version 3.  
28 -*  
29 -* In accordance with Section 7(b) of the GNU General Public License version 3,  
30 -* these Appropriate Legal Notices must retain the display of the "Powered by  
31 -* KnowledgeTree" logo and retain the original copyright notice. If the display of the  
32 -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices  
33 -* must display the words "Powered by KnowledgeTree" and retain the original  
34 -* copyright notice.  
35 -*  
36 -* @copyright 2008-2009, KnowledgeTree Inc.  
37 -* @license GNU General Public License version 3  
38 -* @author KnowledgeTree Team  
39 -* @package Installer  
40 -* @version Version 0.1  
41 -*/  
42 -class DBUtil {  
43 - /**  
44 - * Host  
45 - *  
46 - * @author KnowledgeTree Team  
47 - * @access protected  
48 - * @var string  
49 - */  
50 - protected $dbhost = '';  
51 -  
52 - /**  
53 - * Host  
54 - *  
55 - * @author KnowledgeTree Team  
56 - * @access protected  
57 - * @var string  
58 - */  
59 - protected $dbname = '';  
60 -  
61 - /**  
62 - * Host  
63 - *  
64 - * @author KnowledgeTree Team  
65 - * @access protected  
66 - * @var string  
67 - */  
68 - protected $dbuname = '';  
69 -  
70 - /**  
71 - * Host  
72 - *  
73 - * @author KnowledgeTree Team  
74 - * @access protected  
75 - * @var string  
76 - */  
77 - protected $dbpassword = '';  
78 -  
79 - /**  
80 - * Host  
81 - *  
82 - * @author KnowledgeTree Team  
83 - * @access protected  
84 - * @var object mysql connection  
85 - */  
86 - protected $dbconnection = '';  
87 -  
88 - /**  
89 - * Any errors encountered  
90 - *  
91 - * @author KnowledgeTree Team  
92 - * @access protected  
93 - * @var string  
94 - */  
95 - protected $error = '';  
96 -  
97 - /**  
98 - * Constructs database connection object  
99 - *  
100 - * @author KnowledgeTree Team  
101 - * @access public  
102 - */  
103 - public function __construct() {  
104 - }  
105 -  
106 - /**  
107 - * Connect to a MySQL database  
108 - *  
109 - * @param string $dhost host  
110 - * @param string $duname database username  
111 - * @param string $dpassword database password  
112 - * @access public  
113 - * @return boolean  
114 - */  
115 - public function DBUtil($dhost = 'localhost', $duname, $dpassword, $dbname = '') {  
116 - $this->dbhost = $dhost;  
117 - $this->dbuname = $duname;  
118 - $this->dbpassword = $dpassword;  
119 - $this->dbconnection = mysql_connect($dhost, $duname, $dpassword);  
120 - if($dbname != '') {  
121 - $this->setDb($dbname);  
122 - $this->useBD($dbname);  
123 - }  
124 - if($this->dbconnection)  
125 - return $this->dbconnection;  
126 - else {  
127 - $this->error = mysql_error();  
128 - return false;  
129 - }  
130 - }  
131 -  
132 - /**  
133 - * Choose a database to use  
134 - *  
135 - * @param string $dbname name of the database  
136 - * @access public  
137 - * @return boolean  
138 - */  
139 - public function useBD($dbname) {  
140 - if($dbname != '') {  
141 - $this->setDb($dbname);  
142 - }  
143 -  
144 - if(mysql_select_db($this->dbname))  
145 - return true;  
146 - else {  
147 - $this->error = mysql_error();  
148 - return false;  
149 - }  
150 - }  
151 -  
152 - public function setDb($dbname) {  
153 - $this->dbname = $dbname;  
154 - }  
155 -  
156 - /**  
157 - * Query the database.  
158 - *  
159 - * @param $query the sql query.  
160 - * @access public  
161 - * @return object The result of the query.  
162 - */  
163 - public function query($query)  
164 - {  
165 - $result = mysql_query($query);  
166 - if($result) {  
167 - return $result;  
168 - } else {  
169 - $this->error = mysql_error();  
170 - return false;  
171 - }  
172 - }  
173 -  
174 - /**  
175 - * Do the same as query.  
176 - *  
177 - * @param $query the sql query.  
178 - * @access public  
179 - * @return boolean  
180 - */  
181 - public function execute($query) {  
182 - $result = mysql_query($query);  
183 - if($result) {  
184 - return true;  
185 - } else {  
186 - $this->error = mysql_error();  
187 - return false;  
188 - }  
189 - }  
190 -  
191 - /**  
192 - * Convenience method for mysql_fetch_object().  
193 - *  
194 - * @param $result The resource returned by query().  
195 - * @access public  
196 - * @return object An object representing a data row.  
197 - */  
198 - public function fetchNextObject($result = NULL) {  
199 - if ($result == NULL || mysql_num_rows($result) < 1)  
200 - return NULL;  
201 - else  
202 - return mysql_fetch_object($result);  
203 - }  
204 -  
205 - /**  
206 - * Convenience method for mysql_fetch_assoc().  
207 - *  
208 - * @param $result The resource returned by query().  
209 - * @access public  
210 - * @return array Returns an associative array of strings.  
211 - */  
212 - public function fetchAssoc($result = NULL) {  
213 - $r = array();  
214 - if ($result == NULL || mysql_num_rows($result) < 1)  
215 - return NULL;  
216 - else {  
217 - while ($row = mysql_fetch_assoc($result)) {  
218 - $r[] = $row;  
219 - }  
220 - return $r;  
221 - }  
222 - }  
223 -  
224 - /**  
225 - * Close the connection with the database server.  
226 - *  
227 - * @param none.  
228 - * @access public  
229 - * @return void.  
230 - */  
231 - public function close() {  
232 - mysql_close();  
233 - }  
234 -  
235 - /**  
236 - * Get database errors.  
237 - *  
238 - * @param none.  
239 - * @access public  
240 - * @return string.  
241 - */  
242 - public function getErrors() {  
243 - return $this->error;  
244 - }  
245 -}  
246 -?>  
247 \ No newline at end of file 0 \ No newline at end of file
setup/wizard/install_util.php deleted
1 -<?php  
2 -/**  
3 -* Configuration Step Controller.  
4 -*  
5 -* KnowledgeTree Community Edition  
6 -* Document Management Made Simple  
7 -* Copyright(C) 2008,2009 KnowledgeTree Inc.  
8 -* Portions copyright The Jam Warehouse Software(Pty) Limited  
9 -*  
10 -* This program is free software; you can redistribute it and/or modify it under  
11 -* the terms of the GNU General Public License version 3 as published by the  
12 -* Free Software Foundation.  
13 -*  
14 -* This program is distributed in the hope that it will be useful, but WITHOUT  
15 -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  
16 -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more  
17 -* details.  
18 -*  
19 -* You should have received a copy of the GNU General Public License  
20 -* along with this program. If not, see <http://www.gnu.org/licenses/>.  
21 -*  
22 -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,  
23 -* California 94120-7775, or email info@knowledgetree.com.  
24 -*  
25 -* The interactive user interfaces in modified source and object code versions  
26 -* of this program must display Appropriate Legal Notices, as required under  
27 -* Section 5 of the GNU General Public License version 3.  
28 -*  
29 -* In accordance with Section 7(b) of the GNU General Public License version 3,  
30 -* these Appropriate Legal Notices must retain the display of the "Powered by  
31 -* KnowledgeTree" logo and retain the original copyright notice. If the display of the  
32 -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices  
33 -* must display the words "Powered by KnowledgeTree" and retain the original  
34 -* copyright notice.  
35 -*  
36 -* @copyright 2008-2009, KnowledgeTree Inc.  
37 -* @license GNU General Public License version 3  
38 -* @author KnowledgeTree Team  
39 -* @package Installer  
40 -* @version Version 0.1  
41 -*/  
42 -class InstallUtil {  
43 - /**  
44 - * Constructs installation object  
45 - *  
46 - * @author KnowledgeTree Team  
47 - * @access public  
48 - */  
49 - public function __construct() {  
50 - }  
51 -  
52 - /**  
53 - * Check if system needs to be installed  
54 - *  
55 - * @author KnowledgeTree Team  
56 - * @access public  
57 - * @param none  
58 - * @return boolean  
59 - */  
60 - public function isSystemInstalled() {  
61 - if (file_exists(dirname(__FILE__)."/install")) {  
62 - return false;  
63 - }  
64 - return true;  
65 - }  
66 -  
67 - /**  
68 - * Check if system needs to be installed  
69 - *  
70 - * @author KnowledgeTree Team  
71 - * @access public  
72 - * @param none  
73 - * @return mixed  
74 - */  
75 - public function checkStructurePermissions() {  
76 - // Check if Wizard Directory is writable  
77 - if(!$this->_checkPermission(WIZARD_DIR)) {  
78 - return 'wizard';  
79 - }  
80 - if(!$this->_checkPermission(CONF_DIR)) {  
81 - return 'wizard';  
82 - }  
83 - if(!$this->_checkPermission(SQL_DIR)) {  
84 - return 'wizard';  
85 - }  
86 - if(!$this->_checkPermission(RES_DIR)) {  
87 - return 'wizard';  
88 - }  
89 - if(!$this->_checkPermission(STEP_DIR)) {  
90 - return 'wizard';  
91 - }  
92 - if(!$this->_checkPermission(TEMP_DIR)) {  
93 - return 'wizard';  
94 - }  
95 -  
96 - return true;  
97 - }  
98 -  
99 - /**  
100 - * Redirect  
101 - *  
102 - * This function redirects the client. This is done by issuing  
103 - * a "Location" header and exiting if wanted. If you set $rfc2616 to true  
104 - * HTTP will output a hypertext note with the location of the redirect.  
105 - *  
106 - * @static  
107 - * @access public  
108 - * have already been sent.  
109 - * @param string $url URL where the redirect should go to.  
110 - * @param bool $exit Whether to exit immediately after redirection.  
111 - * @param bool $rfc2616 Wheter to output a hypertext note where we're  
112 - * redirecting to (Redirecting to <a href="...">...</a>.)  
113 - * @return mixed Returns true on succes (or exits) or false if headers  
114 - */  
115 - public function redirect($url, $exit = true, $rfc2616 = false)  
116 - {  
117 - if (headers_sent()) {  
118 - return false;  
119 - }  
120 -  
121 - $url = $this->absoluteURI($url);  
122 - header('Location: '. $url);  
123 -  
124 - if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) &&  
125 - $_SERVER['REQUEST_METHOD'] != 'HEAD') {  
126 - printf('Redirecting to: <a href="%s">%s</a>.', $url, $url);  
127 - }  
128 - if ($exit) {  
129 - exit;  
130 - }  
131 - return true;  
132 - }  
133 -  
134 - /**  
135 - * Absolute URI  
136 - *  
137 - * This function returns the absolute URI for the partial URL passed.  
138 - * The current scheme (HTTP/HTTPS), host server, port, current script  
139 - * location are used if necessary to resolve any relative URLs.  
140 - *  
141 - * Offsets potentially created by PATH_INFO are taken care of to resolve  
142 - * relative URLs to the current script.  
143 - *  
144 - * You can choose a new protocol while resolving the URI. This is  
145 - * particularly useful when redirecting a web browser using relative URIs  
146 - * and to switch from HTTP to HTTPS, or vice-versa, at the same time.  
147 - *  
148 - * @author Philippe Jausions <Philippe.Jausions@11abacus.com>  
149 - * @static  
150 - * @access public  
151 - * @param string $url Absolute or relative URI the redirect should go to.  
152 - * @param string $protocol Protocol to use when redirecting URIs.  
153 - * @param integer $port A new port number.  
154 - * @return string The absolute URI.  
155 - */  
156 - public function absoluteURI($url = null, $protocol = null, $port = null)  
157 - {  
158 - // filter CR/LF  
159 - $url = str_replace(array("\r", "\n"), ' ', $url);  
160 -  
161 - // Mess around with already absolute URIs  
162 - if (preg_match('!^([a-z0-9]+)://!i', $url)) {  
163 - if (empty($protocol) && empty($port)) {  
164 - return $url;  
165 - }  
166 - if (!empty($protocol)) {  
167 - $url = $protocol .':'. end($array = explode(':', $url, 2));  
168 - }  
169 - if (!empty($port)) {  
170 - $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',  
171 - '\1:'. $port, $url);  
172 - }  
173 - return $url;  
174 - }  
175 -  
176 - $host = 'localhost';  
177 - if (!empty($_SERVER['HTTP_HOST'])) {  
178 - list($host) = explode(':', $_SERVER['HTTP_HOST']);  
179 - } elseif (!empty($_SERVER['SERVER_NAME'])) {  
180 - list($host) = explode(':', $_SERVER['SERVER_NAME']);  
181 - }  
182 -  
183 - if (empty($protocol)) {  
184 - if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) {  
185 - $protocol = 'https';  
186 - } else {  
187 - $protocol = 'http';  
188 - }  
189 - if (!isset($port) || $port != intval($port)) {  
190 - $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;  
191 - }  
192 - }  
193 -  
194 - if ($protocol == 'http' && $port == 80) {  
195 - unset($port);  
196 - }  
197 - if ($protocol == 'https' && $port == 443) {  
198 - unset($port);  
199 - }  
200 -  
201 - $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : '');  
202 -  
203 - if (!strlen($url)) {  
204 - $url = isset($_SERVER['REQUEST_URI']) ?  
205 - $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];  
206 - }  
207 -  
208 - if ($url{0} == '/') {  
209 - return $server . $url;  
210 - }  
211 -  
212 - // Check for PATH_INFO  
213 - if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) &&  
214 - $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) {  
215 - $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])));  
216 - } else {  
217 - $path = dirname($_SERVER['PHP_SELF']);  
218 - }  
219 -  
220 - if (substr($path = strtr($path, '\\', '/'), -1) != '/') {  
221 - $path .= '/';  
222 - }  
223 -  
224 - return $server . $path . $url;  
225 - }  
226 -  
227 - /**  
228 - * Check whether a given directory / file path exists and is writable  
229 - *  
230 - * @author KnowledgeTree Team  
231 - * @access private  
232 - * @param string $dir The directory / file to check  
233 - * @param boolean $create Whether to create the directory if it doesn't exist  
234 - * @return array The message and css class to use  
235 - */  
236 - private function _checkPermission($dir)  
237 - {  
238 - if(is_writable($dir)){  
239 - return true;  
240 - } else {  
241 - return false;  
242 - }  
243 -  
244 - }  
245 -  
246 - /**  
247 - * Change permissions on a directory helper  
248 - *  
249 - * @author KnowledgeTree Team  
250 - * @access public  
251 - * @param string $folderPath The directory / file to check  
252 - * @return boolean  
253 - */  
254 - public function canChangePermissions($folderPath) {  
255 - return $this->_chmodRecursive($folderPath, 0755);  
256 - }  
257 -  
258 - /**  
259 - * Change permissions on a directory (recursive)  
260 - *  
261 - * @author KnowledgeTree Team  
262 - * @access private  
263 - * @param string $folderPath The directory / file to check  
264 - * @param boolean $create Whether to create the directory if it doesn't exist  
265 - * @return boolean  
266 - */  
267 - private function _chmodRecursive($path, $filemode) {  
268 - if (!is_dir($path))  
269 - return chmod($path, $filemode);  
270 - $dh = opendir($path);  
271 - while (($file = readdir($dh)) !== false) {  
272 - if($file != '.' && $file != '..') {  
273 - $fullpath = $path.'/'.$file;  
274 - if(is_link($fullpath))  
275 - return false;  
276 - elseif(!is_dir($fullpath)) {  
277 - $perms = substr(sprintf('%o', fileperms($fullpath)), -4);  
278 - if($perms != $filemode)  
279 - if (!chmod($fullpath, $filemode))  
280 - return false;  
281 - } elseif(!$this->chmodRecursive($fullpath, $filemode))  
282 - return false;  
283 - }  
284 - }  
285 - closedir($dh);  
286 - $perms = substr(sprintf('%o', fileperms($path)), -4);  
287 - if($perms != $filemode) {  
288 - if(chmod($path, $filemode))  
289 - return true;  
290 - else  
291 - return false;  
292 - } else {  
293 - return true;  
294 - }  
295 - }  
296 -  
297 - /**  
298 - * Check if a file can be written to a folder  
299 - *  
300 - * @author KnowledgeTree Team  
301 - * @access public  
302 - * @param string $filename the path to the file to create  
303 - * @return boolean  
304 - */  
305 - public function canWriteFile($filename) {  
306 - $fh = fopen($filename, "w+");  
307 - if($fr = fwrite($fh, 'test') === false) {  
308 - return false;  
309 - }  
310 -  
311 - fclose($fh);  
312 - return true;  
313 - }  
314 -  
315 - function execInBackground($cmd) {  
316 - if (substr(php_uname(), 0, 7) == "Windows"){  
317 - pclose(popen("start /B ". $cmd, "r"));  
318 - }  
319 - else {  
320 - exec($cmd . " > /dev/null &");  
321 - }  
322 - }  
323 -}  
324 -?>  
325 \ No newline at end of file 0 \ No newline at end of file
setup/wizard/lucene.pid deleted
1 -11702  
2 -12676  
3 -12679  
setup/wizard/output deleted