Commit d03540dfb5449cc2fca768f536d4ed521cde4eca

Authored by Kevin G Fourie
2 parents a6849828 f456030a

Merge branch 'edge' of github.com:ktgit/knowledgetree into edge

setup/wizard/installUtil.php
1 -<?php  
2 -/**  
3 -* Installer Utilities Library  
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 -  
63 - return true;  
64 - }  
65 -  
66 - return false;  
67 - }  
68 -  
69 - public function error($error) {  
70 - $template_vars['error'] = $error;  
71 - $file = "templates/error.tpl";  
72 - if (!file_exists($file)) {  
73 - return false;  
74 - }  
75 - extract($template_vars); // Extract the vars to local namespace  
76 - ob_start();  
77 - include($file);  
78 - $contents = ob_get_contents();  
79 - ob_end_clean();  
80 - echo $contents;  
81 - }  
82 - /**  
83 - * Check if system needs to be installed  
84 - *  
85 - * @author KnowledgeTree Team  
86 - * @access public  
87 - * @param none  
88 - * @return mixed  
89 - */  
90 - public function checkStructurePermissions() {  
91 - // Check if Wizard Directory is writable  
92 - if(!$this->_checkPermission(WIZARD_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_readable($dir) && is_writable($dir)) {  
239 - return true;  
240 - } else {  
241 - return false;  
242 - }  
243 -  
244 - }  
245 -  
246 - /**  
247 - * Check whether a given directory / file path exists and is writable  
248 - *  
249 - * @author KnowledgeTree Team  
250 - * @access private  
251 - * @param string $dir The directory / file to check  
252 - * @param boolean $create Whether to create the directory if it doesn't exist  
253 - * @return array The message and css class to use  
254 - */  
255 - public function checkPermission($dir, $create=false)  
256 - {  
257 - $exist = 'Directory doesn\'t exist';  
258 - $write = 'Directory not writable';  
259 - $ret = array('class' => 'cross');  
260 -  
261 - if(!file_exists($dir)){  
262 - if($create === false){  
263 - $this->done = false;  
264 - $ret['msg'] = $exist;  
265 - return $ret;  
266 - }  
267 - $par_dir = dirname($dir);  
268 - if(!file_exists($par_dir)){  
269 - $this->done = false;  
270 - $ret['msg'] = $exist;  
271 - return $ret;  
272 - }  
273 - if(!is_writable($par_dir)){  
274 - $this->done = false;  
275 - $ret['msg'] = $exist;  
276 - return $ret;  
277 - }  
278 - mkdir($dir, '0755');  
279 - }  
280 -  
281 - if(is_writable($dir)){  
282 - $ret['class'] = 'tick';  
283 -  
284 - return $ret;  
285 - }  
286 -  
287 - $this->done = false;  
288 - $ret['msg'] = $write;  
289 - return $ret;  
290 - }  
291 -  
292 - /**  
293 - * Change permissions on a directory helper  
294 - *  
295 - * @author KnowledgeTree Team  
296 - * @access public  
297 - * @param string $folderPath The directory / file to check  
298 - * @return boolean  
299 - */  
300 - public function canChangePermissions($folderPath) {  
301 - return $this->_chmodRecursive($folderPath, 0755);  
302 - }  
303 -  
304 - /**  
305 - * Change permissions on a directory (recursive)  
306 - *  
307 - * @author KnowledgeTree Team  
308 - * @access private  
309 - * @param string $folderPath The directory / file to check  
310 - * @param boolean $create Whether to create the directory if it doesn't exist  
311 - * @return boolean  
312 - */  
313 - private function _chmodRecursive($path, $filemode) {  
314 - if (!is_dir($path))  
315 - return chmod($path, $filemode);  
316 - $dh = opendir($path);  
317 - while (($file = readdir($dh)) !== false) {  
318 - if($file != '.' && $file != '..') {  
319 - $fullpath = $path.'/'.$file;  
320 - if(is_link($fullpath))  
321 - return false;  
322 - elseif(!is_dir($fullpath)) {  
323 - $perms = substr(sprintf('%o', fileperms($fullpath)), -4);  
324 - if($perms != $filemode)  
325 - if (!chmod($fullpath, $filemode))  
326 - return false;  
327 - } elseif(!$this->chmodRecursive($fullpath, $filemode))  
328 - return false;  
329 - }  
330 - }  
331 - closedir($dh);  
332 - $perms = substr(sprintf('%o', fileperms($path)), -4);  
333 - if($perms != $filemode) {  
334 - if(chmod($path, $filemode))  
335 - return true;  
336 - else  
337 - return false;  
338 - } else {  
339 - return true;  
340 - }  
341 - }  
342 -  
343 - /**  
344 - * Check if a file can be written to a folder  
345 - *  
346 - * @author KnowledgeTree Team  
347 - * @access public  
348 - * @param string $filename the path to the file to create  
349 - * @return boolean  
350 - */  
351 - public function canWriteFile($filename) {  
352 - $fh = fopen($filename, "w+");  
353 - if($fr = fwrite($fh, 'test') === false) {  
354 - return false;  
355 - }  
356 -  
357 - fclose($fh);  
358 - return true;  
359 - }  
360 -  
361 - /**  
362 - * Attempt using the php-java bridge  
363 - *  
364 - * @author KnowledgeTree Team  
365 - * @access public  
366 - * @param none  
367 - * @return boolean  
368 - */  
369 - public function javaBridge() {  
370 - try {  
371 - $javaSystem = new Java('java.lang.System');  
372 - } catch (JavaException $e) {  
373 - return false;  
374 - }  
375 - return true;  
376 - }  
377 -  
378 - /**  
379 - * Check if Zend Bridge is enabled  
380 - *  
381 - * @author KnowledgeTree Team  
382 - * @param none  
383 - * @access public  
384 - * @return boolean  
385 - */  
386 - public function zendBridge() {  
387 - $mods = get_loaded_extensions();  
388 - if(in_array('Zend Java Bridge', $mods))  
389 - return true;  
390 - else  
391 - return false;  
392 - }  
393 -  
394 - /**  
395 - * Attempt java detection  
396 - *  
397 - * @author KnowledgeTree Team  
398 - * @access public  
399 - * @param none  
400 - * @return boolean  
401 - */  
402 - public function tryJava1() {  
403 - $response = $this->pexec("java -version"); // Java Runtime Check  
404 - if(empty($response['out'])) {  
405 - return '';  
406 - }  
407 -  
408 - return 'java';  
409 - }  
410 -  
411 - /**  
412 - * Attempt java detection  
413 - *  
414 - * @author KnowledgeTree Team  
415 - * @access public  
416 - * @param none  
417 - * @return boolean  
418 - */  
419 - public function tryJava2() {  
420 - $response = $this->pexec("java"); // Java Runtime Check  
421 - if(empty($response['out'])) {  
422 - return '';  
423 - }  
424 -  
425 - return 'java';  
426 - }  
427 -  
428 - /**  
429 - * Attempt java detection  
430 - *  
431 - * @author KnowledgeTree Team  
432 - * @access public  
433 - * @param none  
434 - * @return boolean  
435 - */  
436 - public function tryJava3() {  
437 - $response = $this->pexec("whereis java"); // Java Runtime Check  
438 - if(empty($response['out'])) {  
439 - return '';  
440 - }  
441 - $broke = explode(' ', $response['out'][0]);  
442 - foreach ($broke as $r) {  
443 - $match = preg_match('/bin/', $r);  
444 - if($match) {  
445 - return preg_replace('/java:/', '', $r);  
446 - }  
447 - }  
448 - }  
449 -  
450 - /**  
451 - * Check if user entered location of JRE  
452 - *  
453 - * @author KnowledgeTree Team  
454 - * @param none  
455 - * @access private  
456 - * @return mixed  
457 - */  
458 - public function javaSpecified() {  
459 - if(isset($_POST['java'])) {  
460 - if($_POST['java'] != '') {  
461 - return $_POST['java'];  
462 - } else {  
463 - return false;  
464 - }  
465 - } else {  
466 - return false;  
467 - }  
468 - }  
469 -  
470 - /**  
471 - * Check if user entered location of PHP  
472 - *  
473 - * @author KnowledgeTree Team  
474 - * @param none  
475 - * @access private  
476 - * @return mixed  
477 - */  
478 - public function phpSpecified() {  
479 - if(isset($_POST['php'])) {  
480 - if($_POST['php'] != '') {  
481 - return $_POST['php'];  
482 - } else {  
483 - return false;  
484 - }  
485 - } else {  
486 - return false;  
487 - }  
488 - }  
489 -  
490 - public function openOfficeSpecified() {  
491 - if(isset($_POST['soffice'])) {  
492 - if($_POST['soffice'] != '') {  
493 - return $_POST['soffice'];  
494 - } else {  
495 - return false;  
496 - }  
497 - } else {  
498 - return false;  
499 - }  
500 - }  
501 -  
502 - /**  
503 - * Get session data from post  
504 - *  
505 - * @author KnowledgeTree Team  
506 - * @params none  
507 - * @access private  
508 - * @return boolean  
509 - */  
510 - public function getDataFromSession($class) {  
511 - if(empty($_SESSION[$class])) {  
512 - return false;  
513 - }  
514 -  
515 - return $_SESSION[$class];  
516 - }  
517 -  
518 - /**  
519 - * Determine the location of JAVA_HOME  
520 - *  
521 - * @author KnowledgeTree Team  
522 - * @param none  
523 - * @access private  
524 - * @return mixed  
525 - */  
526 - function getJava() {  
527 - $response = $this->tryJava1();  
528 - if(!is_array($response)) {  
529 - $response = $this->tryJava2();  
530 - if(!is_array($response)) {  
531 - $response = $this->tryJava3();  
532 - }  
533 - }  
534 -  
535 - return $response;  
536 - }  
537 -  
538 - /**  
539 - * Determine the location of PHP  
540 - *  
541 - * @author KnowledgeTree Team  
542 - * @param none  
543 - * @access private  
544 - * @return mixed  
545 - */  
546 - function getPhp() {  
547 - $cmd = "whereis php";  
548 - $res = $this->getPhpHelper($cmd);  
549 - if($res != '') {  
550 - return $res;  
551 - }  
552 - $cmd = "which php";  
553 - return $this->getPhpHelper($cmd);  
554 - }  
555 -  
556 - function getPhpHelper($cmd) {  
557 - $response = $this->pexec($cmd);  
558 - if(is_array($response['out'])) {  
559 - if (isset($response['out'][0])) {  
560 - $broke = explode(' ', $response['out'][0]);  
561 - foreach ($broke as $r) {  
562 - $match = preg_match('/bin/', $r);  
563 - if($match) {  
564 - return preg_replace('/php:/', '', $r);  
565 - }  
566 - }  
567 - }  
568 - }  
569 -  
570 - return '';  
571 - }  
572 -  
573 - function getOpenOffice() {  
574 - $cmd = "whereis soffice";  
575 - $res = $this->getOpenOfficeHelper($cmd);  
576 - if($res != '') {  
577 - return $res;  
578 - }  
579 - $cmd = "which soffice";  
580 - return $this->getOpenOfficeHelper($cmd);  
581 - }  
582 -  
583 - function getOpenOfficeHelper($cmd) {  
584 - $response = $this->pexec($cmd);  
585 - if(is_array($response['out'])) {  
586 - if (isset($response['out'][0])) {  
587 - $broke = explode(' ', $response['out'][0]);  
588 - foreach ($broke as $r) {  
589 - $match = preg_match('/bin/', $r);  
590 - if($match) {  
591 - return preg_replace('/soffice:/', '', $r);  
592 - }  
593 - }  
594 - }  
595 - }  
596 -  
597 - return '';  
598 - }  
599 -  
600 -  
601 - /**  
602 - * Portably execute a command on any of the supported platforms.  
603 - *  
604 - * @author KnowledgeTree Team  
605 - * @access public  
606 - * @param string $aCmd  
607 - * @param array $aOptions  
608 - * @return array  
609 - */  
610 - public function pexec($aCmd, $aOptions = null) {  
611 - if (is_array($aCmd)) {  
612 - $sCmd = $this->safeShellString($aCmd);  
613 - } else {  
614 - $sCmd = $aCmd;  
615 - }  
616 - $sAppend = $this->arrayGet($aOptions, 'append');  
617 - if ($sAppend) {  
618 - $sCmd .= " >> " . escapeshellarg($sAppend);  
619 - }  
620 - $sPopen = $this->arrayGet($aOptions, 'popen');  
621 - if ($sPopen) {  
622 - if (WINDOWS_OS) {  
623 - $sCmd = "start /b \"kt\" " . $sCmd;  
624 - }  
625 - return popen($sCmd, $sPopen);  
626 - }  
627 - // for exec, check return code and output...  
628 - $aRet = array();  
629 - $aOutput = array();  
630 - $iRet = '';  
631 - if(WINDOWS_OS) {  
632 - $sCmd = 'call '.$sCmd;  
633 - }  
634 -  
635 - exec($sCmd, $aOutput, $iRet);  
636 - $aRet['ret'] = $iRet;  
637 - $aRet['out'] = $aOutput;  
638 -  
639 - return $aRet;  
640 - }  
641 -  
642 - /**  
643 - *  
644 - *  
645 - * @author KnowledgeTree Team  
646 - * @access public  
647 - * @return string  
648 - */  
649 - public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {  
650 - if (!is_array($aArray)) {  
651 - $aArray = (array) $aArray;  
652 - }  
653 -  
654 - if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) {  
655 - return $mDefault;  
656 - }  
657 - if (array_key_exists($sKey, $aArray)) {  
658 - $mVal =& $aArray[$sKey];  
659 - if (empty($mVal) && $bDefaultIfEmpty) {  
660 - return $mDefault;  
661 - }  
662 - return $mVal;  
663 - }  
664 - return $mDefault;  
665 - }  
666 -  
667 - /**  
668 - *  
669 - *  
670 - * @author KnowledgeTree Team  
671 - * @access public  
672 - * @return string  
673 - */  
674 - public function safeShellString () {  
675 - $aArgs = func_get_args();  
676 - $aSafeArgs = array();  
677 - if (is_array($aArgs[0])) {  
678 - $aArgs = $aArgs[0];  
679 - }  
680 - $aSafeArgs[] = escapeshellarg(array_shift($aArgs));  
681 - if (is_array($aArgs[0])) {  
682 - $aArgs = $aArgs;  
683 - }  
684 - foreach ($aArgs as $sArg) {  
685 - if (empty($sArg)) {  
686 - $aSafeArgs[] = "''";  
687 - } else {  
688 - $aSafeArgs[] = escapeshellarg($sArg);  
689 - }  
690 - }  
691 - return join(" ", $aSafeArgs);  
692 - }  
693 -  
694 -} 1 +<?php
  2 +/**
  3 +* Installer Utilities Library
  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 + private $salt = 'install';
  45 + /**
  46 + * Constructs installation object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + */
  51 + public function __construct() {
  52 + }
  53 +
  54 + /**
  55 + * Check if system needs to be installed
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access public
  59 + * @param none
  60 + * @return boolean
  61 + */
  62 + public function isSystemInstalled() {
  63 + if (file_exists(dirname(__FILE__)."/install")) {
  64 +
  65 + return true;
  66 + }
  67 +
  68 + return false;
  69 + }
  70 +
  71 + public function error($error) {
  72 + $template_vars['error'] = $error;
  73 + $file = "templates/error.tpl";
  74 + if (!file_exists($file)) {
  75 + return false;
  76 + }
  77 + extract($template_vars); // Extract the vars to local namespace
  78 + ob_start();
  79 + include($file);
  80 + $contents = ob_get_contents();
  81 + ob_end_clean();
  82 + echo $contents;
  83 + }
  84 + /**
  85 + * Check if system needs to be installed
  86 + *
  87 + * @author KnowledgeTree Team
  88 + * @access public
  89 + * @param none
  90 + * @return mixed
  91 + */
  92 + public function checkStructurePermissions() {
  93 + // Check if Wizard Directory is writable
  94 + if(!$this->_checkPermission(WIZARD_DIR)) {
  95 + return 'wizard';
  96 + }
  97 +
  98 + return true;
  99 + }
  100 +
  101 + /**
  102 + * Redirect
  103 + *
  104 + * This function redirects the client. This is done by issuing
  105 + * a "Location" header and exiting if wanted. If you set $rfc2616 to true
  106 + * HTTP will output a hypertext note with the location of the redirect.
  107 + *
  108 + * @static
  109 + * @access public
  110 + * have already been sent.
  111 + * @param string $url URL where the redirect should go to.
  112 + * @param bool $exit Whether to exit immediately after redirection.
  113 + * @param bool $rfc2616 Wheter to output a hypertext note where we're
  114 + * redirecting to (Redirecting to <a href="...">...</a>.)
  115 + * @return mixed Returns true on succes (or exits) or false if headers
  116 + */
  117 + public function redirect($url, $exit = true, $rfc2616 = false)
  118 + {
  119 + if (headers_sent()) {
  120 + return false;
  121 + }
  122 +
  123 + $url = $this->absoluteURI($url);
  124 + header('Location: '. $url);
  125 +
  126 + if ( $rfc2616 && isset($_SERVER['REQUEST_METHOD']) &&
  127 + $_SERVER['REQUEST_METHOD'] != 'HEAD') {
  128 + printf('Redirecting to: <a href="%s">%s</a>.', $url, $url);
  129 + }
  130 + if ($exit) {
  131 + exit;
  132 + }
  133 + return true;
  134 + }
  135 +
  136 + /**
  137 + * Absolute URI
  138 + *
  139 + * This function returns the absolute URI for the partial URL passed.
  140 + * The current scheme (HTTP/HTTPS), host server, port, current script
  141 + * location are used if necessary to resolve any relative URLs.
  142 + *
  143 + * Offsets potentially created by PATH_INFO are taken care of to resolve
  144 + * relative URLs to the current script.
  145 + *
  146 + * You can choose a new protocol while resolving the URI. This is
  147 + * particularly useful when redirecting a web browser using relative URIs
  148 + * and to switch from HTTP to HTTPS, or vice-versa, at the same time.
  149 + *
  150 + * @author Philippe Jausions <Philippe.Jausions@11abacus.com>
  151 + * @static
  152 + * @access public
  153 + * @param string $url Absolute or relative URI the redirect should go to.
  154 + * @param string $protocol Protocol to use when redirecting URIs.
  155 + * @param integer $port A new port number.
  156 + * @return string The absolute URI.
  157 + */
  158 + public function absoluteURI($url = null, $protocol = null, $port = null)
  159 + {
  160 + // filter CR/LF
  161 + $url = str_replace(array("\r", "\n"), ' ', $url);
  162 +
  163 + // Mess around with already absolute URIs
  164 + if (preg_match('!^([a-z0-9]+)://!i', $url)) {
  165 + if (empty($protocol) && empty($port)) {
  166 + return $url;
  167 + }
  168 + if (!empty($protocol)) {
  169 + $url = $protocol .':'. end($array = explode(':', $url, 2));
  170 + }
  171 + if (!empty($port)) {
  172 + $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
  173 + '\1:'. $port, $url);
  174 + }
  175 + return $url;
  176 + }
  177 +
  178 + $host = 'localhost';
  179 + if (!empty($_SERVER['HTTP_HOST'])) {
  180 + list($host) = explode(':', $_SERVER['HTTP_HOST']);
  181 + } elseif (!empty($_SERVER['SERVER_NAME'])) {
  182 + list($host) = explode(':', $_SERVER['SERVER_NAME']);
  183 + }
  184 +
  185 + if (empty($protocol)) {
  186 + if (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on')) {
  187 + $protocol = 'https';
  188 + } else {
  189 + $protocol = 'http';
  190 + }
  191 + if (!isset($port) || $port != intval($port)) {
  192 + $port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
  193 + }
  194 + }
  195 +
  196 + if ($protocol == 'http' && $port == 80) {
  197 + unset($port);
  198 + }
  199 + if ($protocol == 'https' && $port == 443) {
  200 + unset($port);
  201 + }
  202 +
  203 + $server = $protocol .'://'. $host . (isset($port) ? ':'. $port : '');
  204 +
  205 + if (!strlen($url)) {
  206 + $url = isset($_SERVER['REQUEST_URI']) ?
  207 + $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
  208 + }
  209 +
  210 + if ($url{0} == '/') {
  211 + return $server . $url;
  212 + }
  213 +
  214 + // Check for PATH_INFO
  215 + if (isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO']) &&
  216 + $_SERVER['PHP_SELF'] != $_SERVER['PATH_INFO']) {
  217 + $path = dirname(substr($_SERVER['PHP_SELF'], 0, -strlen($_SERVER['PATH_INFO'])));
  218 + } else {
  219 + $path = dirname($_SERVER['PHP_SELF']);
  220 + }
  221 +
  222 + if (substr($path = strtr($path, '\\', '/'), -1) != '/') {
  223 + $path .= '/';
  224 + }
  225 +
  226 + return $server . $path . $url;
  227 + }
  228 +
  229 + /**
  230 + * Check whether a given directory / file path exists and is writable
  231 + *
  232 + * @author KnowledgeTree Team
  233 + * @access private
  234 + * @param string $dir The directory / file to check
  235 + * @param boolean $create Whether to create the directory if it doesn't exist
  236 + * @return array The message and css class to use
  237 + */
  238 + private function _checkPermission($dir)
  239 + {
  240 + if(is_readable($dir) && is_writable($dir)) {
  241 + return true;
  242 + } else {
  243 + return false;
  244 + }
  245 +
  246 + }
  247 +
  248 + /**
  249 + * Check whether a given directory / file path exists and is writable
  250 + *
  251 + * @author KnowledgeTree Team
  252 + * @access private
  253 + * @param string $dir The directory / file to check
  254 + * @param boolean $create Whether to create the directory if it doesn't exist
  255 + * @return array The message and css class to use
  256 + */
  257 + public function checkPermission($dir, $create=false)
  258 + {
  259 + $exist = 'Directory doesn\'t exist';
  260 + $write = 'Directory not writable';
  261 + $ret = array('class' => 'cross');
  262 +
  263 + if(!file_exists($dir)){
  264 + if($create === false){
  265 + $this->done = false;
  266 + $ret['msg'] = $exist;
  267 + return $ret;
  268 + }
  269 + $par_dir = dirname($dir);
  270 + if(!file_exists($par_dir)){
  271 + $this->done = false;
  272 + $ret['msg'] = $exist;
  273 + return $ret;
  274 + }
  275 + if(!is_writable($par_dir)){
  276 + $this->done = false;
  277 + $ret['msg'] = $exist;
  278 + return $ret;
  279 + }
  280 + mkdir($dir, '0755');
  281 + }
  282 +
  283 + if(is_writable($dir)){
  284 + $ret['class'] = 'tick';
  285 +
  286 + return $ret;
  287 + }
  288 +
  289 + $this->done = false;
  290 + $ret['msg'] = $write;
  291 + return $ret;
  292 + }
  293 +
  294 + /**
  295 + * Change permissions on a directory helper
  296 + *
  297 + * @author KnowledgeTree Team
  298 + * @access public
  299 + * @param string $folderPath The directory / file to check
  300 + * @return boolean
  301 + */
  302 + public function canChangePermissions($folderPath) {
  303 + return $this->_chmodRecursive($folderPath, 0755);
  304 + }
  305 +
  306 + /**
  307 + * Change permissions on a directory (recursive)
  308 + *
  309 + * @author KnowledgeTree Team
  310 + * @access private
  311 + * @param string $folderPath The directory / file to check
  312 + * @param boolean $create Whether to create the directory if it doesn't exist
  313 + * @return boolean
  314 + */
  315 + private function _chmodRecursive($path, $filemode) {
  316 + if (!is_dir($path))
  317 + return chmod($path, $filemode);
  318 + $dh = opendir($path);
  319 + while (($file = readdir($dh)) !== false) {
  320 + if($file != '.' && $file != '..') {
  321 + $fullpath = $path.'/'.$file;
  322 + if(is_link($fullpath))
  323 + return false;
  324 + elseif(!is_dir($fullpath)) {
  325 + $perms = substr(sprintf('%o', fileperms($fullpath)), -4);
  326 + if($perms != $filemode)
  327 + if (!chmod($fullpath, $filemode))
  328 + return false;
  329 + } elseif(!$this->chmodRecursive($fullpath, $filemode))
  330 + return false;
  331 + }
  332 + }
  333 + closedir($dh);
  334 + $perms = substr(sprintf('%o', fileperms($path)), -4);
  335 + if($perms != $filemode) {
  336 + if(chmod($path, $filemode))
  337 + return true;
  338 + else
  339 + return false;
  340 + } else {
  341 + return true;
  342 + }
  343 + }
  344 +
  345 + /**
  346 + * Check if a file can be written to a folder
  347 + *
  348 + * @author KnowledgeTree Team
  349 + * @access public
  350 + * @param string $filename the path to the file to create
  351 + * @return boolean
  352 + */
  353 + public function canWriteFile($filename) {
  354 + $fh = fopen($filename, "w+");
  355 + if($fr = fwrite($fh, 'test') === false) {
  356 + return false;
  357 + }
  358 +
  359 + fclose($fh);
  360 + return true;
  361 + }
  362 +
  363 + /**
  364 + * Attempt using the php-java bridge
  365 + *
  366 + * @author KnowledgeTree Team
  367 + * @access public
  368 + * @param none
  369 + * @return boolean
  370 + */
  371 + public function javaBridge() {
  372 + try {
  373 + $javaSystem = new Java('java.lang.System');
  374 + } catch (JavaException $e) {
  375 + return false;
  376 + }
  377 + return true;
  378 + }
  379 +
  380 + /**
  381 + * Check if Zend Bridge is enabled
  382 + *
  383 + * @author KnowledgeTree Team
  384 + * @param none
  385 + * @access public
  386 + * @return boolean
  387 + */
  388 + public function zendBridge() {
  389 + $mods = get_loaded_extensions();
  390 + if(in_array('Zend Java Bridge', $mods))
  391 + return true;
  392 + else
  393 + return false;
  394 + }
  395 +
  396 + /**
  397 + * Attempt java detection
  398 + *
  399 + * @author KnowledgeTree Team
  400 + * @access public
  401 + * @param none
  402 + * @return boolean
  403 + */
  404 + public function tryJava1() {
  405 + $response = $this->pexec("java -version"); // Java Runtime Check
  406 + if(empty($response['out'])) {
  407 + return '';
  408 + }
  409 +
  410 + return 'java';
  411 + }
  412 +
  413 + /**
  414 + * Attempt java detection
  415 + *
  416 + * @author KnowledgeTree Team
  417 + * @access public
  418 + * @param none
  419 + * @return boolean
  420 + */
  421 + public function tryJava2() {
  422 + $response = $this->pexec("java"); // Java Runtime Check
  423 + if(empty($response['out'])) {
  424 + return '';
  425 + }
  426 +
  427 + return 'java';
  428 + }
  429 +
  430 + /**
  431 + * Attempt java detection
  432 + *
  433 + * @author KnowledgeTree Team
  434 + * @access public
  435 + * @param none
  436 + * @return boolean
  437 + */
  438 + public function tryJava3() {
  439 + $response = $this->pexec("whereis java"); // Java Runtime Check
  440 + if(empty($response['out'])) {
  441 + return '';
  442 + }
  443 + $broke = explode(' ', $response['out'][0]);
  444 + foreach ($broke as $r) {
  445 + $match = preg_match('/bin/', $r);
  446 + if($match) {
  447 + return preg_replace('/java:/', '', $r);
  448 + }
  449 + }
  450 + }
  451 +
  452 + /**
  453 + * Check if user entered location of JRE
  454 + *
  455 + * @author KnowledgeTree Team
  456 + * @param none
  457 + * @access private
  458 + * @return mixed
  459 + */
  460 + public function javaSpecified() {
  461 + if(isset($_POST['java'])) {
  462 + if($_POST['java'] != '') {
  463 + return $_POST['java'];
  464 + } else {
  465 + return false;
  466 + }
  467 + } else {
  468 + return false;
  469 + }
  470 + }
  471 +
  472 + /**
  473 + * Check if user entered location of PHP
  474 + *
  475 + * @author KnowledgeTree Team
  476 + * @param none
  477 + * @access private
  478 + * @return mixed
  479 + */
  480 + public function phpSpecified() {
  481 + if(isset($_POST['php'])) {
  482 + if($_POST['php'] != '') {
  483 + return $_POST['php'];
  484 + } else {
  485 + return false;
  486 + }
  487 + } else {
  488 + return false;
  489 + }
  490 + }
  491 +
  492 + public function openOfficeSpecified() {
  493 + if(isset($_POST['soffice'])) {
  494 + if($_POST['soffice'] != '') {
  495 + return $_POST['soffice'];
  496 + } else {
  497 + return false;
  498 + }
  499 + } else {
  500 + return false;
  501 + }
  502 + }
  503 +
  504 + /**
  505 + * Get session data from post
  506 + *
  507 + * @author KnowledgeTree Team
  508 + * @params none
  509 + * @access private
  510 + * @return boolean
  511 + */
  512 + public function getDataFromSession($class) {
  513 + if(empty($_SESSION[$this->salt][$class])) {
  514 + return false;
  515 + }
  516 +
  517 + return $_SESSION[$this->salt][$class];
  518 + }
  519 +
  520 + /**
  521 + * Determine the location of JAVA_HOME
  522 + *
  523 + * @author KnowledgeTree Team
  524 + * @param none
  525 + * @access private
  526 + * @return mixed
  527 + */
  528 + function getJava() {
  529 + $response = $this->tryJava1();
  530 + if(!is_array($response)) {
  531 + $response = $this->tryJava2();
  532 + if(!is_array($response)) {
  533 + $response = $this->tryJava3();
  534 + }
  535 + }
  536 +
  537 + return $response;
  538 + }
  539 +
  540 + /**
  541 + * Determine the location of PHP
  542 + *
  543 + * @author KnowledgeTree Team
  544 + * @param none
  545 + * @access private
  546 + * @return mixed
  547 + */
  548 + function getPhp() {
  549 + $cmd = "whereis php";
  550 + $res = $this->getPhpHelper($cmd);
  551 + if($res != '') {
  552 + return $res;
  553 + }
  554 + $cmd = "which php";
  555 + return $this->getPhpHelper($cmd);
  556 + }
  557 +
  558 + function getPhpHelper($cmd) {
  559 + $response = $this->pexec($cmd);
  560 + if(is_array($response['out'])) {
  561 + if (isset($response['out'][0])) {
  562 + $broke = explode(' ', $response['out'][0]);
  563 + foreach ($broke as $r) {
  564 + $match = preg_match('/bin/', $r);
  565 + if($match) {
  566 + return preg_replace('/php:/', '', $r);
  567 + }
  568 + }
  569 + }
  570 + }
  571 +
  572 + return '';
  573 + }
  574 +
  575 + function getOpenOffice() {
  576 + $cmd = "whereis soffice";
  577 + $res = $this->getOpenOfficeHelper($cmd);
  578 + if($res != '') {
  579 + return $res;
  580 + }
  581 + $cmd = "which soffice";
  582 + return $this->getOpenOfficeHelper($cmd);
  583 + }
  584 +
  585 + function getOpenOfficeHelper($cmd) {
  586 + $response = $this->pexec($cmd);
  587 + if(is_array($response['out'])) {
  588 + if (isset($response['out'][0])) {
  589 + $broke = explode(' ', $response['out'][0]);
  590 + foreach ($broke as $r) {
  591 + $match = preg_match('/bin/', $r);
  592 + if($match) {
  593 + return preg_replace('/soffice:/', '', $r);
  594 + }
  595 + }
  596 + }
  597 + }
  598 +
  599 + return '';
  600 + }
  601 +
  602 +
  603 + /**
  604 + * Portably execute a command on any of the supported platforms.
  605 + *
  606 + * @author KnowledgeTree Team
  607 + * @access public
  608 + * @param string $aCmd
  609 + * @param array $aOptions
  610 + * @return array
  611 + */
  612 + public function pexec($aCmd, $aOptions = null) {
  613 + if (is_array($aCmd)) {
  614 + $sCmd = $this->safeShellString($aCmd);
  615 + } else {
  616 + $sCmd = $aCmd;
  617 + }
  618 + $sAppend = $this->arrayGet($aOptions, 'append');
  619 + if ($sAppend) {
  620 + $sCmd .= " >> " . escapeshellarg($sAppend);
  621 + }
  622 + $sPopen = $this->arrayGet($aOptions, 'popen');
  623 + if ($sPopen) {
  624 + if (WINDOWS_OS) {
  625 + $sCmd = "start /b \"kt\" " . $sCmd;
  626 + }
  627 + return popen($sCmd, $sPopen);
  628 + }
  629 + // for exec, check return code and output...
  630 + $aRet = array();
  631 + $aOutput = array();
  632 + $iRet = '';
  633 + if(WINDOWS_OS) {
  634 + $sCmd = 'call '.$sCmd;
  635 + }
  636 +
  637 + exec($sCmd, $aOutput, $iRet);
  638 + $aRet['ret'] = $iRet;
  639 + $aRet['out'] = $aOutput;
  640 +
  641 + return $aRet;
  642 + }
  643 +
  644 + /**
  645 + *
  646 + *
  647 + * @author KnowledgeTree Team
  648 + * @access public
  649 + * @return string
  650 + */
  651 + public function arrayGet($aArray, $sKey, $mDefault = null, $bDefaultIfEmpty = true) {
  652 + if (!is_array($aArray)) {
  653 + $aArray = (array) $aArray;
  654 + }
  655 +
  656 + if ($aArray !== 0 && $aArray !== '0' && empty($aArray)) {
  657 + return $mDefault;
  658 + }
  659 + if (array_key_exists($sKey, $aArray)) {
  660 + $mVal =& $aArray[$sKey];
  661 + if (empty($mVal) && $bDefaultIfEmpty) {
  662 + return $mDefault;
  663 + }
  664 + return $mVal;
  665 + }
  666 + return $mDefault;
  667 + }
  668 +
  669 + /**
  670 + *
  671 + *
  672 + * @author KnowledgeTree Team
  673 + * @access public
  674 + * @return string
  675 + */
  676 + public function safeShellString () {
  677 + $aArgs = func_get_args();
  678 + $aSafeArgs = array();
  679 + if (is_array($aArgs[0])) {
  680 + $aArgs = $aArgs[0];
  681 + }
  682 + $aSafeArgs[] = escapeshellarg(array_shift($aArgs));
  683 + if (is_array($aArgs[0])) {
  684 + $aArgs = $aArgs;
  685 + }
  686 + foreach ($aArgs as $sArg) {
  687 + if (empty($sArg)) {
  688 + $aSafeArgs[] = "''";
  689 + } else {
  690 + $aSafeArgs[] = escapeshellarg($sArg);
  691 + }
  692 + }
  693 + return join(" ", $aSafeArgs);
  694 + }
  695 +
  696 +}
695 ?> 697 ?>
696 \ No newline at end of file 698 \ No newline at end of file
setup/wizard/installer.php
1 -<?php  
2 -/**  
3 -* Installer 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 -  
43 -class Installer {  
44 - /**  
45 - * Reference to simple xml object  
46 - *  
47 - * @author KnowledgeTree Team  
48 - * @access protected  
49 - * @var object SimpleXMLElement  
50 - */  
51 - protected $simpleXmlObj = null;  
52 -  
53 - /**  
54 - * Reference to step action object  
55 - *  
56 - * @author KnowledgeTree Team  
57 - * @access protected  
58 - * @var object StepAction  
59 - */  
60 - protected $stepAction = null;  
61 -  
62 - /**  
63 - * Reference to session object  
64 - *  
65 - * @author KnowledgeTree Team  
66 - * @access protected  
67 - * @var object Session  
68 - */  
69 - protected $session = null;  
70 -  
71 - /**  
72 - * List of installation steps as strings  
73 - *  
74 - * @author KnowledgeTree Team  
75 - * @access protected  
76 - * @var array string  
77 - */  
78 - protected $stepClassNames = array();  
79 -  
80 - /**  
81 - * List of installation steps as human readable strings  
82 - *  
83 - * @author KnowledgeTree Team  
84 - * @access protected  
85 - * @var array string  
86 - */  
87 - protected $stepNames = array();  
88 -  
89 - /**  
90 - * List of installation steps as human readable strings  
91 - *  
92 - * @author KnowledgeTree Team  
93 - * @access protected  
94 - * @var array string  
95 - */  
96 - protected $stepObjects = array();  
97 -  
98 - /**  
99 - * Order in which steps have to be installed  
100 - *  
101 - * @author KnowledgeTree Team  
102 - * @access protected  
103 - * @var array string  
104 - */  
105 - protected $installOrders = array();  
106 -  
107 - /**  
108 - * List of installation properties  
109 - *  
110 - * @author KnowledgeTree Team  
111 - * @access protected  
112 - * @var array string  
113 - */  
114 - protected $installProperties = array();  
115 -  
116 - /**  
117 - * Flag if a step object needs confirmation  
118 - *  
119 - * @author KnowledgeTree Team  
120 - * @access protected  
121 - * @var boolean  
122 - */  
123 - protected $stepConfirmation = false;  
124 -  
125 - /**  
126 - * Flag if a step object needs confirmation  
127 - *  
128 - * @author KnowledgeTree Team  
129 - * @access protected  
130 - * @var boolean  
131 - */  
132 - protected $stepDisplayFirst = false;  
133 -  
134 - private $installerAction = '';  
135 -  
136 - /**  
137 - * Constructs installation object  
138 - *  
139 - * @author KnowledgeTree Team  
140 - * @access public  
141 - * @param object Session $session Instance of the Session object  
142 - */  
143 - public function __construct($session = null) {  
144 - $this->session = $session;  
145 - }  
146 -  
147 - /**  
148 - * Read xml configuration file  
149 - *  
150 - * @author KnowledgeTree Team  
151 - * @param string $name of config file  
152 - * @access private  
153 - * @return object  
154 - */  
155 - private function _readXml($name = "config.xml") {  
156 - try {  
157 - $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);  
158 - } catch (Exception $e) {  
159 - $iutil = new InstallUtil();  
160 - $iutil->error("Error reading configuration file: $name");  
161 - exit();  
162 - }  
163 - }  
164 -  
165 - /**  
166 - * Checks if first step of installer  
167 - *  
168 - * @author KnowledgeTree Team  
169 - * @param none  
170 - * @access private  
171 - * @return boolean  
172 - */  
173 - private function _firstStep() {  
174 - if(isset($_GET['step_name'])) {  
175 - return false;  
176 - }  
177 -  
178 - return true;  
179 - }  
180 -  
181 - /**  
182 - * Checks if first step of installer  
183 - *  
184 - * @author KnowledgeTree Team  
185 - * @param none  
186 - * @access private  
187 - * @return boolean  
188 - */  
189 - private function _firstStepPeriod() {  
190 - if(isset($_GET['step_name'])) {  
191 - if($_GET['step_name'] != 'welcome')  
192 - return false;  
193 - }  
194 -  
195 - return true;  
196 - }  
197 -  
198 - /**  
199 - * Returns next step  
200 - *  
201 - * @author KnowledgeTree Team  
202 - * @param none  
203 - * @access private  
204 - * @return string  
205 - */  
206 - private function _getNextStep() {  
207 - return $this->_getStepName(1);  
208 - }  
209 -  
210 - /**  
211 - * Returns previous step  
212 - *  
213 - * @author KnowledgeTree Team  
214 - * @param none  
215 - * @access private  
216 - * @return string  
217 - */  
218 - private function _getPreviousStep() {  
219 - return $this->_getStepName(-1);  
220 - }  
221 -  
222 - /**  
223 - * Returns the step name, given a position  
224 - *  
225 - * @author KnowledgeTree Team  
226 - * @param integer $pos current position  
227 - * @access private  
228 - * @return string $name  
229 - */  
230 - private function _getStepName($pos = 0) {  
231 - if($this->_firstStep()) {  
232 - $step = (string) $this->simpleXmlObj->steps->step[0];  
233 - } else {  
234 - $pos += $this->getStepPosition();  
235 - $step = (string) $this->simpleXmlObj->steps->step[$pos];  
236 - }  
237 -  
238 - return $step;  
239 - }  
240 -  
241 - /**  
242 - * Executes next step  
243 - *  
244 - * @author KnowledgeTree Team  
245 - * @param none  
246 - * @access private  
247 - * @return string  
248 - */  
249 - private function _proceed() {  
250 - $step_name = $this->_getNextStep();  
251 -  
252 - return $this->_runStepAction($step_name);  
253 - }  
254 -  
255 - /**  
256 - * Executes previous step  
257 - *  
258 - * @author KnowledgeTree Team  
259 - * @param none  
260 - * @access private  
261 - * @return string  
262 - */  
263 - private function _backward() {  
264 - $step_name = $this->_getPreviousStep();  
265 -  
266 - return $this->_runStepAction($step_name);  
267 - }  
268 -  
269 - /**  
270 - * Executes step landing  
271 - *  
272 - * @author KnowledgeTree Team  
273 - * @param none  
274 - * @access private  
275 - * @return string  
276 - */  
277 - private function _landing() {  
278 - $step_name = $this->_getStepName();  
279 -  
280 - return $this->_runStepAction($step_name);  
281 - }  
282 -  
283 - /**  
284 - * Executes step based on step class name  
285 - *  
286 - * @author KnowledgeTree Team  
287 - * @param string $step_name  
288 - * @access private  
289 - * @return string  
290 - */  
291 - private function _runStepAction($stepName) {  
292 - $this->stepAction = new stepAction($stepName);  
293 - $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getInstallProperties());  
294 -  
295 - return $this->stepAction->doAction();  
296 - }  
297 -  
298 - private function stepDisplayFirst() {  
299 - if($this->installerAction == 'edit')  
300 - return false; //  
301 - $class = $this->stepAction->createStep(); // Get step class  
302 - return $class->displayFirst(); // Check if class needs to display first  
303 - }  
304 -  
305 - /**  
306 - * Set steps class names in string format  
307 - *  
308 - * @author KnowledgeTree Team  
309 - * @param none  
310 - * @access private  
311 - * @return array  
312 - */  
313 - private function _getInstallOrders() {  
314 - return $this->installOrders;  
315 - }  
316 -  
317 - /**  
318 - * Set steps as names  
319 - *  
320 - * @author KnowledgeTree Team  
321 - * @param none  
322 - * @access private  
323 - * @return void  
324 - */  
325 - private function _xmlStepsToArray() {  
326 - if(isset($this->simpleXmlObj)) {  
327 - foreach($this->simpleXmlObj->steps->step as $d_step) {  
328 - $step_name = (string) $d_step[0];  
329 - $this->stepClassNames[] = $step_name;  
330 - }  
331 - $this->_loadToSession('stepClassNames', $this->stepClassNames);  
332 - }  
333 - }  
334 -  
335 - /**  
336 - * Set steps as human readable strings  
337 - *  
338 - * @author KnowledgeTree Team  
339 - * @param none  
340 - * @access private  
341 - * @return void  
342 - */  
343 - private function _xmlStepsNames() {  
344 - if(isset($this->simpleXmlObj)) {  
345 - foreach($this->simpleXmlObj->steps->step as $d_step) {  
346 - $step_name = (string) $d_step[0];  
347 - $this->stepNames[$step_name] = (string) $d_step['name'];  
348 - }  
349 - $this->_loadToSession('stepNames', $this->stepNames);  
350 - }  
351 - }  
352 -  
353 - /**  
354 - * Set steps install order  
355 - *  
356 - * @author KnowledgeTree Team  
357 - * @param none  
358 - * @access private  
359 - * @return void  
360 - */  
361 - private function _xmlStepsOrders() {  
362 - if(isset($this->simpleXmlObj)) {  
363 - foreach($this->simpleXmlObj->steps->step as $d_step) {  
364 - if(isset($d_step['order'])) {  
365 - $step_name = (string) $d_step[0];  
366 - $order = (string) $d_step['order'];  
367 - $this->installOrders[$order] = $step_name; // Store step install order  
368 - }  
369 - }  
370 - $this->_loadToSession('installOrders', $this->installOrders);  
371 - }  
372 - }  
373 -  
374 - /**  
375 - * Set install properties  
376 - *  
377 - * @author KnowledgeTree Team  
378 - * @param none  
379 - * @access private  
380 - * @return void  
381 - */  
382 - private function _xmlInstallProperties() {  
383 - if(isset($this->simpleXmlObj)) {  
384 - $this->installProperties['install_version'] = (string) $this->simpleXmlObj['version'];  
385 - $this->installProperties['install_type'] = (string) $this->simpleXmlObj['type'];  
386 - $this->_loadToSession('installProperties', $this->installProperties);  
387 - }  
388 - }  
389 -  
390 - /**  
391 - * Install steps  
392 - *  
393 - * @author KnowledgeTree Team  
394 - * @param none  
395 - * @access private  
396 - * @return void  
397 - */  
398 - private function _runStepsInstallers() {  
399 - $steps = $this->_getInstallOrders();  
400 - for ($i=1; $i< count($steps)+1; $i++) {  
401 - $this->_installHelper($steps[$i]);  
402 - }  
403 -  
404 - $this->_completeInstall();  
405 - }  
406 -  
407 - /**  
408 - * Complete install cleanup process  
409 - *  
410 - * @author KnowledgeTree Team  
411 - * @param none  
412 - * @access private  
413 - * @return void  
414 - */  
415 - private function _completeInstall() {  
416 - @touch("install");  
417 - }  
418 -  
419 - /**  
420 - * Install steps helper  
421 - *  
422 - * @author KnowledgeTree Team  
423 - * @param none  
424 - * @access private  
425 - * @return void  
426 - */  
427 - private function _installHelper($className) {  
428 - $stepAction = new stepAction($className); // Instantiate a step action  
429 - $class = $stepAction->createStep(); // Get step class  
430 - if($class) { // Check if class Exists  
431 - if($class->runInstall()) { // Check if step needs to be installed  
432 - $class->setDataFromSession($className); // Set Session Information  
433 - $class->setPostConfig(); // Set any posted variables  
434 - $response = $class->installStep(); // Run install step  
435 - // TODO : Break on error response  
436 - }  
437 - } else {  
438 - $iutil = new InstallUtil();  
439 - $iutil->error("Class File Missing in Step Directory: $className");  
440 - exit();  
441 - }  
442 - }  
443 -  
444 - /**  
445 - * Reset all session information on welcome landing  
446 - *  
447 - * @author KnowledgeTree Team  
448 - * @param none  
449 - * @access private  
450 - * @return void  
451 - */  
452 - private function _resetSessions() {  
453 - if($this->session) {  
454 - if($this->_firstStepPeriod()) {  
455 - foreach ($this->getSteps() as $class) {  
456 - $this->session->un_setClass($class);  
457 - }  
458 - foreach ($this->getStepNames() as $class) {  
459 - $this->session->un_setClass($class);  
460 - }  
461 - foreach ($this->_getInstallOrders() as $class) {  
462 - $this->session->un_setClass($class);  
463 - }  
464 - }  
465 - }  
466 - }  
467 -  
468 - function _loadFromSessions() {  
469 - $this->stepClassNames = $this->session->get('stepClassNames');  
470 - if(!$this->stepClassNames) {  
471 - $this->_xmlStepsToArray(); // String steps  
472 - }  
473 - $this->stepNames = $this->session->get('stepNames');  
474 - if(!$this->stepNames) {  
475 - $this->_xmlStepsNames();  
476 - }  
477 - $this->installOrders = $this->session->get('installOrders');  
478 - if(!$this->installOrders) {  
479 - $this->_xmlStepsOrders();  
480 - }  
481 - $this->installProperties = $this->session->get('installProperties');  
482 - if(!$this->installProperties) {  
483 - $this->_xmlInstallProperties();  
484 - }  
485 - }  
486 -  
487 - private function loadNeeded() {  
488 - $this->_readXml(); // Xml steps  
489 - // Make sure session is cleared  
490 - $this->_resetSessions();  
491 - $this->_loadFromSessions();  
492 - if(isset($_POST['Next'])) {  
493 - $this->installerAction = 'next';  
494 - $this->response = 'next';  
495 - } elseif (isset($_POST['Previous'])) {  
496 - $this->installerAction = 'previous';  
497 - $this->response = 'previous';  
498 - } elseif (isset($_POST['Confirm'])) {  
499 - $this->installerAction = 'confirm';  
500 - $this->response = 'next';  
501 - } elseif (isset($_POST['Install'])) {  
502 - $this->installerAction = 'install';  
503 - $this->response = 'next';  
504 - } elseif (isset($_POST['Edit'])) {  
505 - $this->installerAction = 'edit';  
506 - $this->response = 'next';  
507 - } else {  
508 - $this->response = '';  
509 - $this->installerAction = '';  
510 - }  
511 - }  
512 -  
513 - /**  
514 - * Main control to handle the flow of install  
515 - *  
516 - * @author KnowledgeTree Team  
517 - * @param none  
518 - * @access public  
519 - * @return void  
520 - */  
521 - public function step() {  
522 - $this->loadNeeded();  
523 - switch($this->response) {  
524 - case 'next':  
525 - $step_name = $this->_getStepName();  
526 - $res = $this->_runStepAction($step_name);  
527 - if($res == 'next')  
528 - $this->_proceed(); // Load next window  
529 - elseif ($res == 'install') {  
530 - $this->_runStepsInstallers(); // Load landing  
531 - $this->_proceed(); // Load next window  
532 - } elseif ($res == 'confirm') {  
533 - if(!$this->stepDisplayFirst())  
534 - $this->stepConfirmation = true;  
535 - $this->_landing();  
536 - } elseif ($res == 'landing') {  
537 - $this->_landing();  
538 - } else {  
539 - }  
540 - break;  
541 - case 'previous':  
542 - $this->_backward(); // Load previous page  
543 - break;  
544 - default:  
545 - // TODO : handle silent  
546 - $this->_landing();  
547 - break;  
548 - }  
549 - $this->stepAction->paintAction(); // Display step  
550 - }  
551 -  
552 - /**  
553 - * Returns the step number  
554 - *  
555 - * @author KnowledgeTree Team  
556 - * @param none  
557 - * @access public  
558 - * @return integer $pos  
559 - */  
560 - public function getStepPosition() {  
561 - $pos = 0;  
562 - foreach($this->simpleXmlObj->steps->step as $d_step) {  
563 - $step = (string) $d_step;  
564 - if ($step == $_GET['step_name']) {  
565 - break;  
566 - }  
567 - $pos++;  
568 - }  
569 - if(isset($_GET['step'])) {  
570 - if($_GET['step'] == "next")  
571 - $pos = $pos+1;  
572 - else  
573 - $pos = $pos-1;  
574 - }  
575 -  
576 - return $pos;  
577 - }  
578 -  
579 - /**  
580 - * Returns the step names for classes  
581 - *  
582 - * @author KnowledgeTree Team  
583 - * @param none  
584 - * @access public  
585 - * @return array  
586 - */  
587 - public function getSteps() {  
588 - return $this->stepClassNames;  
589 - }  
590 -  
591 - /**  
592 - * Returns the steps as human readable string  
593 - *  
594 - * @author KnowledgeTree Team  
595 - * @param none  
596 - * @access public  
597 - * @return array  
598 - */  
599 - public function getStepNames() {  
600 - return $this->stepNames;  
601 - }  
602 -  
603 - /**  
604 - * Returns whether or not a confirmation step is needed  
605 - *  
606 - * @author KnowledgeTree Team  
607 - * @param none  
608 - * @access public  
609 - * @return boolean  
610 - */  
611 - public function getStepConfirmation() {  
612 - return $this->stepConfirmation;  
613 - }  
614 -  
615 - /**  
616 - * Return install properties  
617 - *  
618 - * @author KnowledgeTree Team  
619 - * @param string  
620 - * @access public  
621 - * @return string  
622 - */  
623 - public function getInstallProperties() {  
624 - return $this->installProperties;  
625 - }  
626 -  
627 - /**  
628 - * Returns session  
629 - *  
630 - * @author KnowledgeTree Team  
631 - * @param none  
632 - * @access public  
633 - * @return boolean  
634 - */  
635 - public function getSession() {  
636 - return $this->session;  
637 - }  
638 -  
639 - /**  
640 - * Dump of SESSION  
641 - *  
642 - * @author KnowledgeTree Team  
643 - * @param none  
644 - * @access public  
645 - * @return array  
646 - */  
647 - public function showSession() {  
648 - echo '<pre>';  
649 - print_r($_SESSION);  
650 - echo '</pre>';  
651 - }  
652 -  
653 - /**  
654 - * Display errors that are not allowing the installer to operate  
655 - *  
656 - * @author KnowledgeTree Team  
657 - * @param none  
658 - * @access public  
659 - * @return void  
660 - */  
661 - public function resolveErrors($errors) {  
662 - echo $errors;  
663 - exit();  
664 - }  
665 -  
666 - private function _loadToSession($type, $values) {  
667 - if($values) {  
668 - $this->session->set($type , $values);  
669 - }  
670 - }  
671 -}  
672 -  
673 -?> 1 +<?php
  2 +/**
  3 +* Installer 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 +
  43 +class Installer {
  44 + /**
  45 + * Reference to simple xml object
  46 + *
  47 + * @author KnowledgeTree Team
  48 + * @access protected
  49 + * @var object SimpleXMLElement
  50 + */
  51 + protected $simpleXmlObj = null;
  52 +
  53 + /**
  54 + * Reference to step action object
  55 + *
  56 + * @author KnowledgeTree Team
  57 + * @access protected
  58 + * @var object StepAction
  59 + */
  60 + protected $stepAction = null;
  61 +
  62 + /**
  63 + * Reference to session object
  64 + *
  65 + * @author KnowledgeTree Team
  66 + * @access protected
  67 + * @var object Session
  68 + */
  69 + protected $session = null;
  70 +
  71 + /**
  72 + * List of installation steps as strings
  73 + *
  74 + * @author KnowledgeTree Team
  75 + * @access protected
  76 + * @var array string
  77 + */
  78 + protected $stepClassNames = array();
  79 +
  80 + /**
  81 + * List of installation steps as human readable strings
  82 + *
  83 + * @author KnowledgeTree Team
  84 + * @access protected
  85 + * @var array string
  86 + */
  87 + protected $stepNames = array();
  88 +
  89 + /**
  90 + * List of installation steps as human readable strings
  91 + *
  92 + * @author KnowledgeTree Team
  93 + * @access protected
  94 + * @var array string
  95 + */
  96 + protected $stepObjects = array();
  97 +
  98 + /**
  99 + * Order in which steps have to be installed
  100 + *
  101 + * @author KnowledgeTree Team
  102 + * @access protected
  103 + * @var array string
  104 + */
  105 + protected $installOrders = array();
  106 +
  107 + /**
  108 + * List of installation properties
  109 + *
  110 + * @author KnowledgeTree Team
  111 + * @access protected
  112 + * @var array string
  113 + */
  114 + protected $installProperties = array();
  115 +
  116 + /**
  117 + * Flag if a step object needs confirmation
  118 + *
  119 + * @author KnowledgeTree Team
  120 + * @access protected
  121 + * @var boolean
  122 + */
  123 + protected $stepConfirmation = false;
  124 +
  125 + /**
  126 + * Flag if a step object needs confirmation
  127 + *
  128 + * @author KnowledgeTree Team
  129 + * @access protected
  130 + * @var boolean
  131 + */
  132 + protected $stepDisplayFirst = false;
  133 +
  134 + private $installerAction = '';
  135 +
  136 + /**
  137 + * Constructs installation object
  138 + *
  139 + * @author KnowledgeTree Team
  140 + * @access public
  141 + * @param object Session $session Instance of the Session object
  142 + */
  143 + public function __construct($session = null) {
  144 + $this->session = $session;
  145 + }
  146 +
  147 + /**
  148 + * Read xml configuration file
  149 + *
  150 + * @author KnowledgeTree Team
  151 + * @param string $name of config file
  152 + * @access private
  153 + * @return object
  154 + */
  155 + private function _readXml($name = "config.xml") {
  156 + try {
  157 + $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
  158 + } catch (Exception $e) {
  159 + $iutil = new InstallUtil();
  160 + $iutil->error("Error reading configuration file: $name");
  161 + exit();
  162 + }
  163 + }
  164 +
  165 + /**
  166 + * Checks if first step of installer
  167 + *
  168 + * @author KnowledgeTree Team
  169 + * @param none
  170 + * @access private
  171 + * @return boolean
  172 + */
  173 + private function _firstStep() {
  174 + if(isset($_GET['step_name'])) {
  175 + return false;
  176 + }
  177 +
  178 + return true;
  179 + }
  180 +
  181 + /**
  182 + * Checks if first step of installer
  183 + *
  184 + * @author KnowledgeTree Team
  185 + * @param none
  186 + * @access private
  187 + * @return boolean
  188 + */
  189 + private function _firstStepPeriod() {
  190 + if(isset($_GET['step_name'])) {
  191 + if($_GET['step_name'] != 'welcome')
  192 + return false;
  193 + }
  194 +
  195 + return true;
  196 + }
  197 +
  198 + /**
  199 + * Returns next step
  200 + *
  201 + * @author KnowledgeTree Team
  202 + * @param none
  203 + * @access private
  204 + * @return string
  205 + */
  206 + private function _getNextStep() {
  207 + return $this->_getStepName(1);
  208 + }
  209 +
  210 + /**
  211 + * Returns previous step
  212 + *
  213 + * @author KnowledgeTree Team
  214 + * @param none
  215 + * @access private
  216 + * @return string
  217 + */
  218 + private function _getPreviousStep() {
  219 + return $this->_getStepName(-1);
  220 + }
  221 +
  222 + /**
  223 + * Returns the step name, given a position
  224 + *
  225 + * @author KnowledgeTree Team
  226 + * @param integer $pos current position
  227 + * @access private
  228 + * @return string $name
  229 + */
  230 + private function _getStepName($pos = 0) {
  231 + if($this->_firstStep()) {
  232 + $step = (string) $this->simpleXmlObj->steps->step[0];
  233 + } else {
  234 + $pos += $this->getStepPosition();
  235 + $step = (string) $this->simpleXmlObj->steps->step[$pos];
  236 + }
  237 +
  238 + return $step;
  239 + }
  240 +
  241 + /**
  242 + * Executes next step
  243 + *
  244 + * @author KnowledgeTree Team
  245 + * @param none
  246 + * @access private
  247 + * @return string
  248 + */
  249 + private function _proceed() {
  250 + $step_name = $this->_getNextStep();
  251 +
  252 + return $this->_runStepAction($step_name);
  253 + }
  254 +
  255 + /**
  256 + * Executes previous step
  257 + *
  258 + * @author KnowledgeTree Team
  259 + * @param none
  260 + * @access private
  261 + * @return string
  262 + */
  263 + private function _backward() {
  264 + $step_name = $this->_getPreviousStep();
  265 +
  266 + return $this->_runStepAction($step_name);
  267 + }
  268 +
  269 + /**
  270 + * Executes step landing
  271 + *
  272 + * @author KnowledgeTree Team
  273 + * @param none
  274 + * @access private
  275 + * @return string
  276 + */
  277 + private function _landing() {
  278 + $step_name = $this->_getStepName();
  279 +
  280 + return $this->_runStepAction($step_name);
  281 + }
  282 +
  283 + /**
  284 + * Executes step based on step class name
  285 + *
  286 + * @author KnowledgeTree Team
  287 + * @param string $step_name
  288 + * @access private
  289 + * @return string
  290 + */
  291 + private function _runStepAction($stepName) {
  292 + $this->stepAction = new stepAction($stepName);
  293 + $this->stepAction->setUpStepAction($this->getSteps(), $this->getStepNames(), $this->getStepConfirmation(), $this->stepDisplayFirst(), $this->getSession(), $this->getInstallProperties());
  294 +
  295 + return $this->stepAction->doAction();
  296 + }
  297 +
  298 + private function stepDisplayFirst() {
  299 + if($this->installerAction == 'edit')
  300 + return false; //
  301 + $class = $this->stepAction->createStep(); // Get step class
  302 + return $class->displayFirst(); // Check if class needs to display first
  303 + }
  304 +
  305 + /**
  306 + * Set steps class names in string format
  307 + *
  308 + * @author KnowledgeTree Team
  309 + * @param none
  310 + * @access private
  311 + * @return array
  312 + */
  313 + private function _getInstallOrders() {
  314 + return $this->installOrders;
  315 + }
  316 +
  317 + /**
  318 + * Set steps as names
  319 + *
  320 + * @author KnowledgeTree Team
  321 + * @param none
  322 + * @access private
  323 + * @return void
  324 + */
  325 + private function _xmlStepsToArray() {
  326 + if(isset($this->simpleXmlObj)) {
  327 + foreach($this->simpleXmlObj->steps->step as $d_step) {
  328 + $step_name = (string) $d_step[0];
  329 + $this->stepClassNames[] = $step_name;
  330 + }
  331 + $this->_loadToSession('stepClassNames', $this->stepClassNames);
  332 + }
  333 + }
  334 +
  335 + /**
  336 + * Set steps as human readable strings
  337 + *
  338 + * @author KnowledgeTree Team
  339 + * @param none
  340 + * @access private
  341 + * @return void
  342 + */
  343 + private function _xmlStepsNames() {
  344 + if(isset($this->simpleXmlObj)) {
  345 + foreach($this->simpleXmlObj->steps->step as $d_step) {
  346 + $step_name = (string) $d_step[0];
  347 + $this->stepNames[$step_name] = (string) $d_step['name'];
  348 + }
  349 + $this->_loadToSession('stepNames', $this->stepNames);
  350 + }
  351 + }
  352 +
  353 + /**
  354 + * Set steps install order
  355 + *
  356 + * @author KnowledgeTree Team
  357 + * @param none
  358 + * @access private
  359 + * @return void
  360 + */
  361 + private function _xmlStepsOrders() {
  362 + if(isset($this->simpleXmlObj)) {
  363 + foreach($this->simpleXmlObj->steps->step as $d_step) {
  364 + if(isset($d_step['order'])) {
  365 + $step_name = (string) $d_step[0];
  366 + $order = (string) $d_step['order'];
  367 + $this->installOrders[$order] = $step_name; // Store step install order
  368 + }
  369 + }
  370 + $this->_loadToSession('installOrders', $this->installOrders);
  371 + }
  372 + }
  373 +
  374 + /**
  375 + * Set install properties
  376 + *
  377 + * @author KnowledgeTree Team
  378 + * @param none
  379 + * @access private
  380 + * @return void
  381 + */
  382 + private function _xmlInstallProperties() {
  383 + if(isset($this->simpleXmlObj)) {
  384 + $this->installProperties['install_version'] = (string) $this->simpleXmlObj['version'];
  385 + $this->installProperties['install_type'] = (string) $this->simpleXmlObj['type'];
  386 + $this->_loadToSession('installProperties', $this->installProperties);
  387 + }
  388 + }
  389 +
  390 + /**
  391 + * Install steps
  392 + *
  393 + * @author KnowledgeTree Team
  394 + * @param none
  395 + * @access private
  396 + * @return void
  397 + */
  398 + private function _runStepsInstallers() {
  399 + $steps = $this->_getInstallOrders();
  400 + for ($i=1; $i< count($steps)+1; $i++) {
  401 + $this->_installHelper($steps[$i]);
  402 + }
  403 +
  404 + $this->_completeInstall();
  405 + }
  406 +
  407 + /**
  408 + * Complete install cleanup process
  409 + *
  410 + * @author KnowledgeTree Team
  411 + * @param none
  412 + * @access private
  413 + * @return void
  414 + */
  415 + private function _completeInstall() {
  416 + @touch("install");
  417 + }
  418 +
  419 + /**
  420 + * Install steps helper
  421 + *
  422 + * @author KnowledgeTree Team
  423 + * @param none
  424 + * @access private
  425 + * @return void
  426 + */
  427 + private function _installHelper($className) {
  428 + $stepAction = new stepAction($className); // Instantiate a step action
  429 + $class = $stepAction->createStep(); // Get step class
  430 + if($class) { // Check if class Exists
  431 + if($class->runInstall()) { // Check if step needs to be installed
  432 + $class->setDataFromSession($className); // Set Session Information
  433 + $class->setPostConfig(); // Set any posted variables
  434 + $response = $class->installStep(); // Run install step
  435 + // TODO : Break on error response
  436 + }
  437 + } else {
  438 + $iutil = new InstallUtil();
  439 + $iutil->error("Class File Missing in Step Directory: $className");
  440 + exit();
  441 + }
  442 + }
  443 +
  444 + /**
  445 + * Reset all session information on welcome landing
  446 + *
  447 + * @author KnowledgeTree Team
  448 + * @param none
  449 + * @access private
  450 + * @return void
  451 + */
  452 + private function _resetSessions() {
  453 + if($this->session) {
  454 + if($this->_firstStepPeriod()) {
  455 + foreach ($this->getSteps() as $class) {
  456 + $this->session->un_setClass($class);
  457 + }
  458 + foreach ($this->getStepNames() as $class) {
  459 + $this->session->un_setClass($class);
  460 + }
  461 + foreach ($this->_getInstallOrders() as $class) {
  462 + $this->session->un_setClass($class);
  463 + }
  464 + }
  465 + }
  466 + }
  467 +
  468 + function _loadFromSessions() {
  469 + $this->stepClassNames = $this->session->get('stepClassNames');
  470 + if(!$this->stepClassNames) {
  471 + $this->_xmlStepsToArray(); // String steps
  472 + }
  473 + $this->stepNames = $this->session->get('stepNames');
  474 + if(!$this->stepNames) {
  475 + $this->_xmlStepsNames();
  476 + }
  477 + $this->installOrders = $this->session->get('installOrders');
  478 + if(!$this->installOrders) {
  479 + $this->_xmlStepsOrders();
  480 + }
  481 + $this->installProperties = $this->session->get('installProperties');
  482 + if(!$this->installProperties) {
  483 + $this->_xmlInstallProperties();
  484 + }
  485 + }
  486 +
  487 + private function loadNeeded() {
  488 + $this->_readXml(); // Xml steps
  489 + // Make sure session is cleared
  490 + $this->_resetSessions();
  491 + $this->_loadFromSessions();
  492 + if(isset($_POST['Next'])) {
  493 + $this->installerAction = 'next';
  494 + $this->response = 'next';
  495 + } elseif (isset($_POST['Previous'])) {
  496 + $this->installerAction = 'previous';
  497 + $this->response = 'previous';
  498 + } elseif (isset($_POST['Confirm'])) {
  499 + $this->installerAction = 'confirm';
  500 + $this->response = 'next';
  501 + } elseif (isset($_POST['Install'])) {
  502 + $this->installerAction = 'install';
  503 + $this->response = 'next';
  504 + } elseif (isset($_POST['Edit'])) {
  505 + $this->installerAction = 'edit';
  506 + $this->response = 'next';
  507 + } else {
  508 + $this->response = '';
  509 + $this->installerAction = '';
  510 + }
  511 + }
  512 +
  513 + /**
  514 + * Main control to handle the flow of install
  515 + *
  516 + * @author KnowledgeTree Team
  517 + * @param none
  518 + * @access public
  519 + * @return void
  520 + */
  521 + public function step() {
  522 + $this->loadNeeded();
  523 + switch($this->response) {
  524 + case 'next':
  525 + $step_name = $this->_getStepName();
  526 + $res = $this->_runStepAction($step_name);
  527 + if($res == 'next')
  528 + $this->_proceed(); // Load next window
  529 + elseif ($res == 'install') {
  530 + $this->_runStepsInstallers(); // Load landing
  531 + $this->_proceed(); // Load next window
  532 + } elseif ($res == 'confirm') {
  533 + if(!$this->stepDisplayFirst())
  534 + $this->stepConfirmation = true;
  535 + $this->_landing();
  536 + } elseif ($res == 'landing') {
  537 + $this->_landing();
  538 + } else {
  539 + }
  540 + break;
  541 + case 'previous':
  542 + $this->_backward(); // Load previous page
  543 + break;
  544 + default:
  545 + // TODO : handle silent
  546 + $this->_landing();
  547 + break;
  548 + }
  549 + $this->stepAction->paintAction(); // Display step
  550 + }
  551 +
  552 + /**
  553 + * Returns the step number
  554 + *
  555 + * @author KnowledgeTree Team
  556 + * @param none
  557 + * @access public
  558 + * @return integer $pos
  559 + */
  560 + public function getStepPosition() {
  561 + $pos = 0;
  562 + foreach($this->simpleXmlObj->steps->step as $d_step) {
  563 + $step = (string) $d_step;
  564 + if ($step == $_GET['step_name']) {
  565 + break;
  566 + }
  567 + $pos++;
  568 + }
  569 + if(isset($_GET['step'])) {
  570 + if($_GET['step'] == "next")
  571 + $pos = $pos+1;
  572 + else
  573 + $pos = $pos-1;
  574 + }
  575 +
  576 + return $pos;
  577 + }
  578 +
  579 + /**
  580 + * Returns the step names for classes
  581 + *
  582 + * @author KnowledgeTree Team
  583 + * @param none
  584 + * @access public
  585 + * @return array
  586 + */
  587 + public function getSteps() {
  588 + return $this->stepClassNames;
  589 + }
  590 +
  591 + /**
  592 + * Returns the steps as human readable string
  593 + *
  594 + * @author KnowledgeTree Team
  595 + * @param none
  596 + * @access public
  597 + * @return array
  598 + */
  599 + public function getStepNames() {
  600 + return $this->stepNames;
  601 + }
  602 +
  603 + /**
  604 + * Returns whether or not a confirmation step is needed
  605 + *
  606 + * @author KnowledgeTree Team
  607 + * @param none
  608 + * @access public
  609 + * @return boolean
  610 + */
  611 + public function getStepConfirmation() {
  612 + return $this->stepConfirmation;
  613 + }
  614 +
  615 + /**
  616 + * Return install properties
  617 + *
  618 + * @author KnowledgeTree Team
  619 + * @param string
  620 + * @access public
  621 + * @return string
  622 + */
  623 + public function getInstallProperties() {
  624 + return $this->installProperties;
  625 + }
  626 +
  627 + /**
  628 + * Returns session
  629 + *
  630 + * @author KnowledgeTree Team
  631 + * @param none
  632 + * @access public
  633 + * @return boolean
  634 + */
  635 + public function getSession() {
  636 + return $this->session;
  637 + }
  638 +
  639 + /**
  640 + * Dump of SESSION
  641 + *
  642 + * @author KnowledgeTree Team
  643 + * @param none
  644 + * @access public
  645 + * @return array
  646 + */
  647 + public function showSession() {
  648 + echo '<pre>';
  649 + print_r($_SESSION['install']);
  650 + echo '</pre>';
  651 + }
  652 +
  653 + /**
  654 + * Display errors that are not allowing the installer to operate
  655 + *
  656 + * @author KnowledgeTree Team
  657 + * @param none
  658 + * @access public
  659 + * @return void
  660 + */
  661 + public function resolveErrors($errors) {
  662 + echo $errors;
  663 + exit();
  664 + }
  665 +
  666 + private function _loadToSession($type, $values) {
  667 + if($values) {
  668 + $this->session->set($type , $values);
  669 + }
  670 + }
  671 +}
  672 +
  673 +?>
setup/wizard/lib/services/windowsOpenOffice.php
1 -<?php  
2 -/**  
3 -* Windows Agent Service 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 -  
43 -class windowsOpenOffice extends windowsService {  
44 -  
45 - /**  
46 - * Reference to utility object  
47 - *  
48 - * @author KnowledgeTree Team  
49 - * @access protected  
50 - * @var string  
51 - */  
52 - public $util;  
53 -  
54 - /**  
55 - * Path to office executable  
56 - *  
57 - * @author KnowledgeTree Team  
58 - * @access protected  
59 - * @var string  
60 - */  
61 - private $path;  
62 -  
63 - /**  
64 - * Web server  
65 - *  
66 - * @author KnowledgeTree Team  
67 - * @access protected  
68 - * @var string  
69 - */  
70 - private $host;  
71 -  
72 - /**  
73 - * Path to temp pid file  
74 - *  
75 - * @author KnowledgeTree Team  
76 - * @access protected  
77 - * @var string  
78 - */  
79 - private $pidFile;  
80 -  
81 - /**  
82 - * Web server Port  
83 - *  
84 - * @author KnowledgeTree Team  
85 - * @access protected  
86 - * @var string  
87 - */  
88 - private $port;  
89 -  
90 - /**  
91 - * Web server  
92 - *  
93 - * @author KnowledgeTree Team  
94 - * @access protected  
95 - * @var string  
96 - */  
97 - private $bin;  
98 -  
99 - /**  
100 - * Office executable name  
101 - *  
102 - * @author KnowledgeTree Team  
103 - * @access protected  
104 - * @var string  
105 - */  
106 - private $soffice;  
107 -  
108 - /**  
109 - * Log file  
110 - *  
111 - * @author KnowledgeTree Team  
112 - * @access protected  
113 - * @var string  
114 - */  
115 - private $log;  
116 -  
117 - /**  
118 - * Open office options  
119 - *  
120 - * @author KnowledgeTree Team  
121 - * @access protected  
122 - * @var string  
123 - */  
124 - private $options;  
125 -  
126 - /**  
127 - * Path to win service  
128 - *  
129 - * @author KnowledgeTree Team  
130 - * @access protected  
131 - * @var string  
132 - */  
133 - private $winservice;  
134 -  
135 - /**  
136 - * Service name  
137 - *  
138 - * @author KnowledgeTree Team  
139 - * @access public  
140 - * @param none  
141 - * @return string  
142 - */  
143 - public $name = "KTOpenOfficeTest";  
144 -  
145 - public function load() {  
146 - // hack for testing  
147 - $this->setPort("8100");  
148 - $this->setHost("127.0.0.1");  
149 - $this->setLog("openoffice.log");  
150 - $this->setWinservice("winserv.exe");  
151 - $this->setOption();  
152 - }  
153 -  
154 - private function setPort($port = "8100") {  
155 - $this->port = $port;  
156 - }  
157 -  
158 - public function getPort() {  
159 - return $this->port;  
160 - }  
161 -  
162 - private function setHost($host = "127.0.0.1") {  
163 - $this->host = $host;  
164 - }  
165 -  
166 - public function getHost() {  
167 - return $this->host;  
168 - }  
169 -  
170 - private function setLog($log = "openoffice.log") {  
171 - $this->log = $log;  
172 - }  
173 -  
174 - public function getLog() {  
175 - return $this->log;  
176 - }  
177 -  
178 - private function setBin($bin) {  
179 - $this->bin = "\"".$bin."\"";  
180 - }  
181 -  
182 - public function getBin() {  
183 - return $this->bin;  
184 - }  
185 -  
186 - private function setWinservice($winservice = "winserv.exe") {  
187 - $this->winservice = SYS_BIN_DIR . $winservice;  
188 - }  
189 -  
190 - public function getWinservice() {  
191 - return $this->winservice;  
192 - }  
193 -  
194 - private function setOption() {  
195 - $this->options = "-displayname {$this->name} -start auto {$this->getBin()} -headless -invisible -nofirststartwizard"  
196 - . "-accept=\"socket,host={$this->host},port={$this->port};urp;StarOffice.ServiceManager\"";  
197 - }  
198 -  
199 - public function getOption() {  
200 - return $this->options;  
201 - }  
202 -  
203 - public function install() {  
204 - $status = $this->status();  
205 - if($status == '') {  
206 - $services = $this->util->getDataFromSession('services');  
207 - $this->setBin("{$services['openOfficeExe']}");  
208 - $this->setOption();  
209 - $cmd = "\"{$this->winservice}\" install $this->name {$this->getOption()}";  
210 - if(DEBUG) {  
211 - echo "$cmd<br/>";  
212 - return ;  
213 - }  
214 - $response = $this->util->pexec($cmd);  
215 - return $response;  
216 - }  
217 - else {  
218 - return $status;  
219 - }  
220 - }  
221 -  
222 - /**  
223 - * Retrieve Status Service  
224 - *  
225 - * @author KnowledgeTree Team  
226 - * @access public  
227 - * @param none  
228 - * @return string  
229 - */  
230 - public function status() {  
231 - $cmd = "sc query {$this->name}";  
232 - $response = $this->util->pexec($cmd);  
233 - if($response['out']) {  
234 - $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key  
235 - return $state;  
236 - }  
237 -  
238 - return '';  
239 - }  
240 -} 1 +<?php
  2 +/**
  3 +* Windows Agent Service 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 +
  43 +class windowsOpenOffice extends windowsService {
  44 +
  45 + /**
  46 + * Reference to utility object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access protected
  50 + * @var string
  51 + */
  52 + public $util;
  53 +
  54 + /**
  55 + * Path to office executable
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access protected
  59 + * @var string
  60 + */
  61 + private $path;
  62 +
  63 + /**
  64 + * Web server
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access protected
  68 + * @var string
  69 + */
  70 + private $host;
  71 +
  72 + /**
  73 + * Path to temp pid file
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access protected
  77 + * @var string
  78 + */
  79 + private $pidFile;
  80 +
  81 + /**
  82 + * Web server Port
  83 + *
  84 + * @author KnowledgeTree Team
  85 + * @access protected
  86 + * @var string
  87 + */
  88 + private $port;
  89 +
  90 + /**
  91 + * Web server
  92 + *
  93 + * @author KnowledgeTree Team
  94 + * @access protected
  95 + * @var string
  96 + */
  97 + private $bin;
  98 +
  99 + /**
  100 + * Office executable name
  101 + *
  102 + * @author KnowledgeTree Team
  103 + * @access protected
  104 + * @var string
  105 + */
  106 + private $soffice;
  107 +
  108 + /**
  109 + * Log file
  110 + *
  111 + * @author KnowledgeTree Team
  112 + * @access protected
  113 + * @var string
  114 + */
  115 + private $log;
  116 +
  117 + /**
  118 + * Open office options
  119 + *
  120 + * @author KnowledgeTree Team
  121 + * @access protected
  122 + * @var string
  123 + */
  124 + private $options;
  125 +
  126 + /**
  127 + * Path to win service
  128 + *
  129 + * @author KnowledgeTree Team
  130 + * @access protected
  131 + * @var string
  132 + */
  133 + private $winservice;
  134 +
  135 + /**
  136 + * Service name
  137 + *
  138 + * @author KnowledgeTree Team
  139 + * @access public
  140 + * @param none
  141 + * @return string
  142 + */
  143 + public $name = "KTOpenOfficeTest";
  144 +
  145 + public function load() {
  146 + // hack for testing
  147 + $this->setPort("8100");
  148 + $this->setHost("127.0.0.1");
  149 + $this->setLog("openoffice.log");
  150 + $this->setWinservice("winserv.exe");
  151 + $this->setOption();
  152 + }
  153 +
  154 + private function setPort($port = "8100") {
  155 + $this->port = $port;
  156 + }
  157 +
  158 + public function getPort() {
  159 + return $this->port;
  160 + }
  161 +
  162 + private function setHost($host = "127.0.0.1") {
  163 + $this->host = $host;
  164 + }
  165 +
  166 + public function getHost() {
  167 + return $this->host;
  168 + }
  169 +
  170 + private function setLog($log = "openoffice.log") {
  171 + $this->log = $log;
  172 + }
  173 +
  174 + public function getLog() {
  175 + return $this->log;
  176 + }
  177 +
  178 + private function setBin($bin) {
  179 + $this->bin = "\"".$bin."\"";
  180 + }
  181 +
  182 + public function getBin() {
  183 + return $this->bin;
  184 + }
  185 +
  186 + private function setWinservice($winservice = "winserv.exe") {
  187 + if(file_exists(SYS_BIN_DIR . $winservice))
  188 + $this->winservice = SYS_BIN_DIR . $winservice;
  189 + else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice))
  190 + $this->winservice = SYS_BIN_DIR . "win32" . DS. $winservice;
  191 + }
  192 +
  193 + public function getWinservice() {
  194 + return $this->winservice;
  195 + }
  196 +
  197 + private function setOption() {
  198 + $this->options = "-displayname {$this->name} -start auto {$this->getBin()} -headless -invisible -nofirststartwizard"
  199 + . "-accept=\"socket,host={$this->host},port={$this->port};urp;StarOffice.ServiceManager\"";
  200 + }
  201 +
  202 + public function getOption() {
  203 + return $this->options;
  204 + }
  205 +
  206 + public function install() {
  207 + $status = $this->status();
  208 + if($status == '') {
  209 + $services = $this->util->getDataFromSession('services');
  210 + $this->setBin("{$services['openOfficeExe']}");
  211 + $this->setOption();
  212 + $cmd = "\"{$this->winservice}\" install $this->name {$this->getOption()}";
  213 + if(DEBUG) {
  214 + echo "$cmd<br/>";
  215 + return ;
  216 + }
  217 + $response = $this->util->pexec($cmd);
  218 + return $response;
  219 + }
  220 + else {
  221 + return $status;
  222 + }
  223 + }
  224 +
  225 + /**
  226 + * Retrieve Status Service
  227 + *
  228 + * @author KnowledgeTree Team
  229 + * @access public
  230 + * @param none
  231 + * @return string
  232 + */
  233 + public function status() {
  234 + $cmd = "sc query {$this->name}";
  235 + $response = $this->util->pexec($cmd);
  236 + if($response['out']) {
  237 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  238 + return $state;
  239 + }
  240 +
  241 + return '';
  242 + }
  243 +}
241 ?> 244 ?>
242 \ No newline at end of file 245 \ No newline at end of file
setup/wizard/lib/services/windowsScheduler.php
1 -<?php  
2 -/**  
3 -* Windows Scheduler Service 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 windowsScheduler extends windowsService {  
43 - /**  
44 - * Batch Script to execute  
45 - *  
46 - * @author KnowledgeTree Team  
47 - * @access private  
48 - * @var string  
49 - */  
50 - private $schedulerScriptPath;  
51 -  
52 - /**  
53 - * Php Script to execute  
54 - *  
55 - * @author KnowledgeTree Team  
56 - * @access private  
57 - * @var string  
58 - */  
59 - private $schedulerSource;  
60 -  
61 - /**  
62 - * Scheduler Directory  
63 - *  
64 - * @author KnowledgeTree Team  
65 - * @access private  
66 - * @var string  
67 - */  
68 - private $schedulerDir;  
69 -  
70 - /**  
71 - * Service name  
72 - *  
73 - * @author KnowledgeTree Team  
74 - * @access public  
75 - * @param none  
76 - * @return string  
77 - */  
78 - public $name = "KTSchedulerTest";  
79 -  
80 - /**  
81 - * Load defaults needed by service  
82 - *  
83 - * @author KnowledgeTree Team  
84 - * @access public  
85 - * @param string  
86 - * @return void  
87 - */  
88 - function load() {  
89 - $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");  
90 - $this->setSchedulerScriptPath("taskrunner.bat");  
91 - $this->setSchedulerSource("schedulerService.php");  
92 -  
93 - }  
94 -  
95 - /**  
96 - * Set Scheduler Directory path  
97 - *  
98 - * @author KnowledgeTree Team  
99 - * @access private  
100 - * @param none  
101 - * @return string  
102 - */  
103 - private function setSchedulerDIR($schedulerDIR) {  
104 - $this->schedulerDir = $schedulerDIR;  
105 - }  
106 -  
107 - /**  
108 - * Retrieve Scheduler Directory path  
109 - *  
110 - * @author KnowledgeTree Team  
111 - * @access public  
112 - * @param none  
113 - * @return string  
114 - */  
115 - public function getSchedulerDir() {  
116 - if(file_exists($this->schedulerDir))  
117 - return $this->schedulerDir;  
118 - return false;  
119 - }  
120 -  
121 - /**  
122 - * Set Batch Script path  
123 - *  
124 - * @author KnowledgeTree Team  
125 - * @access private  
126 - * @param string  
127 - * @return void  
128 - */  
129 - private function setSchedulerScriptPath($schedulerScriptPath) {  
130 - $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath";  
131 - }  
132 -  
133 - /**  
134 - * Retrieve Batch Script path  
135 - *  
136 - * @author KnowledgeTree Team  
137 - * @access public  
138 - * @param none  
139 - * @return string  
140 - */  
141 - public function getSchedulerScriptPath() {  
142 - if(file_exists($this->schedulerScriptPath))  
143 - return $this->schedulerScriptPath;  
144 - return false;  
145 - }  
146 -  
147 - /**  
148 - * Set Php Script path  
149 - *  
150 - * @author KnowledgeTree Team  
151 - * @access private  
152 - * @param none  
153 - * @return string  
154 - */  
155 - private function setSchedulerSource($schedulerSource) {  
156 - $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource;  
157 - }  
158 -  
159 - /**  
160 - * Retrieve Php Script path  
161 - *  
162 - * @author KnowledgeTree Team  
163 - * @access public  
164 - * @param none  
165 - * @return string  
166 - */  
167 - public function getSchedulerSource() {  
168 - if(file_exists($this->schedulerSource))  
169 - return $this->schedulerSource;  
170 - return false;  
171 - }  
172 -  
173 - /**  
174 - * Retrieve Status Service  
175 - *  
176 - * @author KnowledgeTree Team  
177 - * @access public  
178 - * @param none  
179 - * @return string  
180 - */  
181 - public function status() {  
182 - $cmd = "sc query {$this->name}";  
183 - $response = $this->util->pexec($cmd);  
184 - if($response['out']) {  
185 - $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key  
186 - return $state;  
187 - }  
188 -  
189 - return '';  
190 - }  
191 -  
192 - /**  
193 - * Install Scheduler Service  
194 - *  
195 - * @author KnowledgeTree Team  
196 - * @access public  
197 - * @param none  
198 - * @return array  
199 - */  
200 - public function install() {  
201 - $state = $this->status();  
202 - if($state == '') {  
203 - $this->writeSchedulerTask();  
204 - $this->writeTaskRunner();  
205 - // TODO what if it does not exist? check how the dmsctl.bat does this  
206 - if (function_exists('win32_create_service')) {  
207 - $response = win32_create_service(array(  
208 - 'service' => $this->name,  
209 - 'display' => $this->name,  
210 - 'path' => $this->getSchedulerScriptPath()  
211 - ));  
212 - return $response;  
213 - } else { // Attempt to use the winserv  
214 - // TODO: Add service using winserv  
215 - $this->setWinservice();  
216 - $this->setOptions();  
217 - $cmd = "\"{$this->winservice}\" install $this->name $this->options";  
218 - if(DEBUG) {  
219 - echo "$cmd<br/>";  
220 - return ;  
221 - }  
222 - $response = $this->util->pexec($cmd);  
223 - return $response;  
224 - }  
225 - }  
226 - return $state;  
227 - }  
228 -  
229 - private function setWinservice($winservice = "winserv.exe") {  
230 - $this->winservice = SYS_BIN_DIR . $winservice;  
231 - }  
232 -  
233 - private function setOptions() {  
234 - $this->options = "-displayname {$this->name} -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible "  
235 - . "";  
236 - }  
237 -  
238 - private function writeTaskRunner() {  
239 - // Check if bin is readable and writable  
240 - if(is_readable(SYS_BIN_DIR."win32") && is_writable(SYS_BIN_DIR."win32")) {  
241 - $fp = fopen($this->getSchedulerDir().""."\\taskrunner.bat", "w+");  
242 - $content = "@echo off \n";  
243 - $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";  
244 - fwrite($fp, $content);  
245 - fclose($fp);  
246 - } else {  
247 - // TODO: Should not reach this point  
248 - }  
249 - }  
250 -  
251 - private function writeSchedulerTask() {  
252 - // Check if bin is readable and writable  
253 - if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) {  
254 - if(!$this->getSchedulerScriptPath()) {  
255 - $fp = fopen($this->getSchedulerScriptPath(), "w+");  
256 - $content = "@echo off\n";  
257 - $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";  
258 - fwrite($fp, $content);  
259 - fclose($fp);  
260 - }  
261 - } else {  
262 - // TODO: Should not reach this point  
263 - }  
264 - }  
265 -} 1 +<?php
  2 +/**
  3 +* Windows Scheduler Service 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 windowsScheduler extends windowsService {
  43 + /**
  44 + * Batch Script to execute
  45 + *
  46 + * @author KnowledgeTree Team
  47 + * @access private
  48 + * @var string
  49 + */
  50 + private $schedulerScriptPath;
  51 +
  52 + /**
  53 + * Php Script to execute
  54 + *
  55 + * @author KnowledgeTree Team
  56 + * @access private
  57 + * @var string
  58 + */
  59 + private $schedulerSource;
  60 +
  61 + /**
  62 + * Scheduler Directory
  63 + *
  64 + * @author KnowledgeTree Team
  65 + * @access private
  66 + * @var string
  67 + */
  68 + private $schedulerDir;
  69 +
  70 + /**
  71 + * Service name
  72 + *
  73 + * @author KnowledgeTree Team
  74 + * @access public
  75 + * @param none
  76 + * @return string
  77 + */
  78 + public $name = "KTSchedulerTest";
  79 +
  80 + /**
  81 + * Load defaults needed by service
  82 + *
  83 + * @author KnowledgeTree Team
  84 + * @access public
  85 + * @param string
  86 + * @return void
  87 + */
  88 + function load() {
  89 + $this->setSchedulerDIR(SYSTEM_DIR."bin".DS."win32");
  90 + $this->setSchedulerScriptPath("taskrunner.bat");
  91 + $this->setSchedulerSource("schedulerService.php");
  92 +
  93 + }
  94 +
  95 + /**
  96 + * Set Scheduler Directory path
  97 + *
  98 + * @author KnowledgeTree Team
  99 + * @access private
  100 + * @param none
  101 + * @return string
  102 + */
  103 + private function setSchedulerDIR($schedulerDIR) {
  104 + $this->schedulerDir = $schedulerDIR;
  105 + }
  106 +
  107 + /**
  108 + * Retrieve Scheduler Directory path
  109 + *
  110 + * @author KnowledgeTree Team
  111 + * @access public
  112 + * @param none
  113 + * @return string
  114 + */
  115 + public function getSchedulerDir() {
  116 + if(file_exists($this->schedulerDir))
  117 + return $this->schedulerDir;
  118 + return false;
  119 + }
  120 +
  121 + /**
  122 + * Set Batch Script path
  123 + *
  124 + * @author KnowledgeTree Team
  125 + * @access private
  126 + * @param string
  127 + * @return void
  128 + */
  129 + private function setSchedulerScriptPath($schedulerScriptPath) {
  130 + $this->schedulerScriptPath = "{$this->getSchedulerDir()}".DS."$schedulerScriptPath";
  131 + }
  132 +
  133 + /**
  134 + * Retrieve Batch Script path
  135 + *
  136 + * @author KnowledgeTree Team
  137 + * @access public
  138 + * @param none
  139 + * @return string
  140 + */
  141 + public function getSchedulerScriptPath() {
  142 + if(file_exists($this->schedulerScriptPath))
  143 + return $this->schedulerScriptPath;
  144 + return false;
  145 + }
  146 +
  147 + /**
  148 + * Set Php Script path
  149 + *
  150 + * @author KnowledgeTree Team
  151 + * @access private
  152 + * @param none
  153 + * @return string
  154 + */
  155 + private function setSchedulerSource($schedulerSource) {
  156 + $this->schedulerSource = $this->getSchedulerDir().DS.$schedulerSource;
  157 + }
  158 +
  159 + /**
  160 + * Retrieve Php Script path
  161 + *
  162 + * @author KnowledgeTree Team
  163 + * @access public
  164 + * @param none
  165 + * @return string
  166 + */
  167 + public function getSchedulerSource() {
  168 + if(file_exists($this->schedulerSource))
  169 + return $this->schedulerSource;
  170 + return false;
  171 + }
  172 +
  173 + /**
  174 + * Retrieve Status Service
  175 + *
  176 + * @author KnowledgeTree Team
  177 + * @access public
  178 + * @param none
  179 + * @return string
  180 + */
  181 + public function status() {
  182 + $cmd = "sc query {$this->name}";
  183 + $response = $this->util->pexec($cmd);
  184 + if($response['out']) {
  185 + $state = preg_replace('/^STATE *\: *\d */', '', trim($response['out'][3])); // Status store in third key
  186 + return $state;
  187 + }
  188 +
  189 + return '';
  190 + }
  191 +
  192 + /**
  193 + * Install Scheduler Service
  194 + *
  195 + * @author KnowledgeTree Team
  196 + * @access public
  197 + * @param none
  198 + * @return array
  199 + */
  200 + public function install() {
  201 + $state = $this->status();
  202 + if($state == '') {
  203 + $this->writeSchedulerTask();
  204 + $this->writeTaskRunner();
  205 + // TODO what if it does not exist? check how the dmsctl.bat does this
  206 + if (function_exists('win32_create_service')) {
  207 + $response = win32_create_service(array(
  208 + 'service' => $this->name,
  209 + 'display' => $this->name,
  210 + 'path' => $this->getSchedulerScriptPath()
  211 + ));
  212 + return $response;
  213 + } else { // Attempt to use the winserv
  214 + // TODO: Add service using winserv
  215 + $this->setWinservice();
  216 + $this->setOptions();
  217 + $cmd = "\"{$this->winservice}\" install $this->name $this->options";
  218 + if(DEBUG) {
  219 + echo "$cmd<br/>";
  220 + return ;
  221 + }
  222 + $response = $this->util->pexec($cmd);
  223 + return $response;
  224 + }
  225 + }
  226 + return $state;
  227 + }
  228 +
  229 + private function setWinservice($winservice = "winserv.exe") {
  230 + $this->winservice = SYS_BIN_DIR . $winservice;
  231 + }
  232 +
  233 + private function setOptions() {
  234 + $this->options = "-displayname {$this->name} -start auto -binary \"{$this->getSchedulerScriptPath()}\" -headless -invisible "
  235 + . "";
  236 + }
  237 +
  238 + private function writeTaskRunner() {
  239 + // Check if bin is readable and writable
  240 + if(is_readable(SYS_BIN_DIR."win32") && is_writable(SYS_BIN_DIR."win32")) {
  241 + $fp = fopen($this->getSchedulerDir().""."\\taskrunner.bat", "w+");
  242 + $content = "@echo off \n";
  243 + $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
  244 + fwrite($fp, $content);
  245 + fclose($fp);
  246 + } else {
  247 + // TODO: Should not reach this point
  248 + }
  249 + }
  250 +
  251 + private function writeSchedulerTask() {
  252 + // Check if bin is readable and writable
  253 + if(is_readable(SYS_BIN_DIR) && is_writable(SYS_BIN_DIR)) {
  254 + if(!$this->getSchedulerScriptPath()) {
  255 + $fp = fopen($this->getSchedulerScriptPath(), "w+");
  256 + $content = "@echo off\n";
  257 + $content .= "\"".PHP_DIR."php.exe\" "."\"{$this->getSchedulerSource()}\"";
  258 + fwrite($fp, $content);
  259 + fclose($fp);
  260 + }
  261 + } else {
  262 + // TODO: Should not reach this point
  263 + }
  264 + }
  265 +}
266 ?> 266 ?>
267 \ No newline at end of file 267 \ No newline at end of file
setup/wizard/path.php
1 -<?php  
2 -/**  
3 -* Installer Paths.  
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 - // Define installer environment  
43 - define('DEBUG', 1);  
44 - define('AJAX', 0);  
45 - if (substr(php_uname(), 0, 7) == "Windows"){  
46 - define('WINDOWS_OS', true);  
47 - define('UNIX_OS', false);  
48 - define('OS', 'windows');  
49 - } else {  
50 - define('WINDOWS_OS', false);  
51 - define('UNIX_OS', true);  
52 - define('OS', 'unix');  
53 - }  
54 - if(WINDOWS_OS) {  
55 - define('DS', '\\');  
56 - } else {  
57 - define('DS', '/');  
58 - }  
59 - // Define environment root  
60 - $wizard = realpath(dirname(__FILE__));  
61 - $xdir = explode(DS, $wizard);  
62 - array_pop($xdir);  
63 - array_pop($xdir);  
64 - $sys = '';  
65 - foreach ($xdir as $k=>$v) {  
66 - $sys .= $v.DS;  
67 - }  
68 - // Define paths to wizard  
69 - define('WIZARD_DIR', $wizard.DS);  
70 - define('WIZARD_LIB', WIZARD_DIR."lib".DS);  
71 - define('SERVICE_LIB', WIZARD_LIB."services".DS);  
72 - define('SQL_DIR', WIZARD_DIR."sql".DS);  
73 - define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS);  
74 - define('CONF_DIR', WIZARD_DIR."config".DS);  
75 - define('RES_DIR', WIZARD_DIR."resources".DS);  
76 - define('STEP_DIR', WIZARD_DIR."steps".DS);  
77 - define('TEMP_DIR', WIZARD_DIR."templates".DS);  
78 - define('SHELL_DIR', WIZARD_DIR."shells".DS);  
79 - define('OUTPUT_DIR', WIZARD_DIR."output".DS);  
80 - // Define paths to system webroot  
81 - define('SYSTEM_DIR', $sys);  
82 - define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);  
83 - define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS);  
84 - // Define paths to system  
85 - array_pop($xdir);  
86 - $asys = '';  
87 - foreach ($xdir as $k=>$v) {  
88 - $asys .= $v.DS;  
89 - }  
90 - define('SYSTEM_ROOT', $asys);  
91 - // Install Type  
92 - preg_match('/Zend/', $sys, $matches); // TODO: Dirty  
93 - if($matches) {  
94 - $sysdir = explode(DS, $sys);  
95 - array_pop($sysdir);  
96 - array_pop($sysdir);  
97 - array_pop($sysdir);  
98 - array_pop($sysdir);  
99 - $zendsys = '';  
100 - foreach ($sysdir as $k=>$v) {  
101 - $zendsys .= $v.DS;  
102 - }  
103 - define('INSTALL_TYPE', 'Zend');  
104 - define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);  
105 - } else {  
106 - $modules = get_loaded_extensions();  
107 - // TODO: Dirty  
108 - if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) {  
109 - define('INSTALL_TYPE', 'Zend');  
110 - define('PHP_DIR', '');  
111 - } else {  
112 - define('INSTALL_TYPE', '');  
113 - define('PHP_DIR', '');  
114 - }  
115 - }  
116 - // Other  
117 - date_default_timezone_set('Africa/Johannesburg');  
118 - if(WINDOWS_OS) { // Mysql bin [Windows]  
119 - $serverPaths = explode(';',$_SERVER['PATH']);  
120 - foreach ($serverPaths as $apath) {  
121 - preg_match('/mysql/i', $apath, $matches);  
122 - if($matches) {  
123 - define('MYSQL_BIN', $apath.DS);  
124 - break;  
125 - }  
126 - }  
127 - } else {  
128 - define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line  
129 - }  
130 -  
131 -?> 1 +<?php
  2 +/**
  3 +* Installer Paths.
  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 + // Define installer environment
  43 + define('DEBUG', 0);
  44 + define('AJAX', 0);
  45 + if (substr(php_uname(), 0, 7) == "Windows"){
  46 + define('WINDOWS_OS', true);
  47 + define('UNIX_OS', false);
  48 + define('OS', 'windows');
  49 + } else {
  50 + define('WINDOWS_OS', false);
  51 + define('UNIX_OS', true);
  52 + define('OS', 'unix');
  53 + }
  54 + if(WINDOWS_OS) {
  55 + define('DS', '\\');
  56 + } else {
  57 + define('DS', '/');
  58 + }
  59 + // Define environment root
  60 + $wizard = realpath(dirname(__FILE__));
  61 + $xdir = explode(DS, $wizard);
  62 + array_pop($xdir);
  63 + array_pop($xdir);
  64 + $sys = '';
  65 + foreach ($xdir as $k=>$v) {
  66 + $sys .= $v.DS;
  67 + }
  68 + // Define paths to wizard
  69 + define('WIZARD_DIR', $wizard.DS);
  70 + define('WIZARD_LIB', WIZARD_DIR."lib".DS);
  71 + define('SERVICE_LIB', WIZARD_LIB."services".DS);
  72 + define('SQL_DIR', WIZARD_DIR."sql".DS);
  73 + define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS);
  74 + define('CONF_DIR', WIZARD_DIR."config".DS);
  75 + define('RES_DIR', WIZARD_DIR."resources".DS);
  76 + define('STEP_DIR', WIZARD_DIR."steps".DS);
  77 + define('TEMP_DIR', WIZARD_DIR."templates".DS);
  78 + define('SHELL_DIR', WIZARD_DIR."shells".DS);
  79 + define('OUTPUT_DIR', WIZARD_DIR."output".DS);
  80 + // Define paths to system webroot
  81 + define('SYSTEM_DIR', $sys);
  82 + define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
  83 + define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS);
  84 + // Define paths to system
  85 + array_pop($xdir);
  86 + $asys = '';
  87 + foreach ($xdir as $k=>$v) {
  88 + $asys .= $v.DS;
  89 + }
  90 + define('SYSTEM_ROOT', $asys);
  91 + // Install Type
  92 + preg_match('/Zend/', $sys, $matches); // TODO: Dirty
  93 + if($matches) {
  94 + $sysdir = explode(DS, $sys);
  95 + array_pop($sysdir);
  96 + array_pop($sysdir);
  97 + array_pop($sysdir);
  98 + array_pop($sysdir);
  99 + $zendsys = '';
  100 + foreach ($sysdir as $k=>$v) {
  101 + $zendsys .= $v.DS;
  102 + }
  103 + define('INSTALL_TYPE', 'Zend');
  104 + define('PHP_DIR', $zendsys."ZendServer".DS."bin".DS);
  105 + } else {
  106 + $modules = get_loaded_extensions();
  107 + // TODO: Dirty
  108 + if(in_array('Zend Download Server', $modules) || in_array('Zend Monitor', $modules) || in_array('Zend Utils', $modules) || in_array('Zend Page Cache', $modules)) {
  109 + define('INSTALL_TYPE', 'Zend');
  110 + define('PHP_DIR', '');
  111 + } else {
  112 + define('INSTALL_TYPE', '');
  113 + define('PHP_DIR', '');
  114 + }
  115 + }
  116 + // Other
  117 + date_default_timezone_set('Africa/Johannesburg');
  118 + if(WINDOWS_OS) { // Mysql bin [Windows]
  119 + $serverPaths = explode(';',$_SERVER['PATH']);
  120 + foreach ($serverPaths as $apath) {
  121 + preg_match('/mysql/i', $apath, $matches);
  122 + if($matches) {
  123 + define('MYSQL_BIN', $apath.DS);
  124 + break;
  125 + }
  126 + }
  127 + } else {
  128 + define('MYSQL_BIN', ''); // Assume its linux and can be executed from command line
  129 + }
  130 +
  131 +?>
setup/wizard/resources/form.js
@@ -9,5 +9,4 @@ $(document).ready(function() { @@ -9,5 +9,4 @@ $(document).ready(function() {
9 var options = {target: '#content_container', beforeSubmit: w.validateRegistration, success: w.adjustMenu($('form').attr('id'))}; 9 var options = {target: '#content_container', beforeSubmit: w.validateRegistration, success: w.adjustMenu($('form').attr('id'))};
10 $('form').ajaxForm(options); 10 $('form').ajaxForm(options);
11 } 11 }
12 -});  
13 - 12 +});
14 \ No newline at end of file 13 \ No newline at end of file
setup/wizard/resources/wizard.js
1 -// Class Wizard  
2 -function wizard() {  
3 -}  
4 -  
5 -// Toggle Advance Database options  
6 -wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details  
7 - if($('.'+ele).attr('style') == 'display: none;') {  
8 - $('.'+ele).attr('style', 'display: block;');  
9 - if($('#'+option).attr('innerHTML') != '&nbsp;&nbsp;Advanced Options')  
10 - $('#'+option).attr('innerHTML', 'Hide Details');  
11 - } else {  
12 - $('.'+ele).attr('style', 'display: none;');  
13 - if($('#'+option).attr('innerHTML') != '&nbsp;&nbsp;Advanced Options')  
14 - $('#'+option).attr('innerHTML', 'Show Details');  
15 - }  
16 -}  
17 -  
18 -// Focus on element  
19 -wizard.prototype.focusElement = function(el) {  
20 - el.focus();  
21 -}  
22 -  
23 -// Force previous click  
24 -wizard.prototype.pClick = function() {  
25 - var state = $('#state');  
26 - if(state != undefined) {  
27 - state.attr('name', 'previous');  
28 - }  
29 -}  
30 -  
31 -// Force next click  
32 -wizard.prototype.nClick = function() {  
33 - var state = $('#state');;  
34 - if(state != undefined) {  
35 - state.attr('name', 'next');  
36 - }  
37 -}  
38 -  
39 -// Validate Registration Page  
40 -wizard.prototype.validateRegistration = function() {  
41 - // See if next or previous is clicked.  
42 - var state = $('#state').attr('name');  
43 - if(state == 'next') {  
44 - if(w.valRegHelper()) {  
45 - $('#sendAll').attr('name', 'Next'); // Force the next step  
46 - $('#sendAll').attr('value', 'next');  
47 - return true;  
48 - }  
49 - } else if(state == 'previous') {  
50 - $('#sendAll').attr('name', 'Previous'); // Force the previous step  
51 - $('#sendAll').attr('value', 'previous');  
52 - return true;  
53 - }  
54 -  
55 - return false;  
56 -}  
57 -  
58 -wizard.prototype.valRegHelper = function() {  
59 - var first = document.getElementById('first');  
60 - var last = document.getElementById('last');  
61 - var email = document.getElementById('email');  
62 - if(first.value.length < 1) {  
63 - document.getElementById("reg_error").innerHTML = "Please enter a First Name";  
64 - w.focusElement(first);  
65 - return false;  
66 - }  
67 - if(!w.nameCheck(first.value)) {  
68 - document.getElementById("reg_error").innerHTML = "Please enter a valid First Name";  
69 - w.focusElement(first);  
70 - return false;  
71 - }  
72 - if(last.value.length < 1) {  
73 - document.getElementById("reg_error").innerHTML = "Please enter a Last Name";  
74 - w.focusElement(last);  
75 - return false;  
76 - }  
77 - if(!w.nameCheck(last.value)) {  
78 - document.getElementById("reg_error").innerHTML = "Please enter a valid Last Name";  
79 - w.focusElement(last);  
80 - return false;  
81 - }  
82 - if(!w.emailCheck(email.value)) {  
83 - document.getElementById("reg_error").innerHTML = "Please enter a valid email address";  
84 - w.focusElement(email);  
85 - return false;  
86 - }  
87 -  
88 - return true;  
89 -}  
90 -  
91 -wizard.prototype.nameCheck = function(str) {  
92 - var nameRegxp = /^([a-zA-Z]+)$/;  
93 - if(str.match(nameRegxp)) {  
94 - return true;  
95 - } else {  
96 - return false;  
97 - }  
98 -}  
99 -  
100 -// Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)  
101 -wizard.prototype.emailCheck = function(str) {  
102 - str = w.trim(str);  
103 - var at="@";  
104 - var dot=".";  
105 - var lat=str.indexOf(at);  
106 - var lstr=str.length;  
107 - var ldot=str.indexOf(dot);  
108 - if (str.indexOf(at)==-1) {  
109 - return false;  
110 - }  
111 - if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {  
112 - return false;  
113 - }  
114 - if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {  
115 - return false;  
116 - }  
117 - if (str.indexOf(at,(lat+1))!=-1) {  
118 - return false;  
119 - }  
120 - if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){  
121 - return false;  
122 - }  
123 - if (str.indexOf(dot,(lat+2))==-1){  
124 - return false;  
125 - }  
126 - if (str.indexOf(" ")!=-1){  
127 - return false;  
128 - }  
129 - return true;  
130 -}  
131 -  
132 -wizard.prototype.trim = function (str, chars) {  
133 - return w.ltrim(w.rtrim(str, chars), chars);  
134 -}  
135 -  
136 -wizard.prototype.ltrim = function (str, chars) {  
137 - chars = chars || "\\s";  
138 - return str.replace(new RegExp("^[" + chars + "]+", "g"), "");  
139 -}  
140 -  
141 -wizard.prototype.rtrim = function (str, chars) {  
142 - chars = chars || "\\s";  
143 - return str.replace(new RegExp("[" + chars + "]+$", "g"), "");  
144 -}  
145 -  
146 -wizard.prototype.adjustMenu = function (form_id, previous) {  
147 - form_name = form_id.split('_');  
148 - if(form_name.length == 2) {  
149 - current_step = form_name[0];  
150 - next_step = form_name[1];  
151 - $('#'+current_step).attr('class', 'current');  
152 - $('#'+next_step).attr('class', 'inactive');  
153 - } else if(form_name.length == 3) {  
154 - previous_step = form_name[0];  
155 - current_step = form_name[1];  
156 - next_step = form_name[2];  
157 - $('#'+previous_step).attr('class', 'active');  
158 - $('#'+current_step).attr('class', 'current');  
159 - $('#'+next_step).attr('class', 'inactive');  
160 - }  
161 -}  
162 -  
163 -wizard.prototype.dummy = function () {  
164 -  
165 -}  
166 -  
167 -// pre-submit callback  
168 -wizard.prototype.showRequest = function (formData, jqForm, options) {  
169 - $.blockUI({message:''});  
170 - $('#loading').attr('style', 'display:block;');  
171 -}  
172 -  
173 -// post-submit callback  
174 -wizard.prototype.showResponse = function (responseText, statusText) {  
175 - $.unblockUI();  
176 - $('#loading').attr('style', 'display:none;');  
177 -}  
178 -  
179 -wizard.prototype.refresh = function (page) {  
180 - var address = "index.php?step_name="+page;  
181 - var div = 'content_container';  
182 - $.ajax({  
183 - url: address,  
184 - dataType: "html",  
185 - type: "GET",  
186 - cache: false,  
187 - beforeSubmit: w.showRequest,  
188 - success: function(data){  
189 - $("#"+div).empty();  
190 - $("#"+div).append(data);  
191 - w.showResponse;  
192 - return;  
193 - }  
194 - });  
195 -}  
196 -  
197 -wizard.prototype.getUrl = function (address, div) {  
198 - $("#"+div).empty();  
199 - $.ajax({  
200 - url: address,  
201 - dataType: "html",  
202 - type: "GET",  
203 - cache: false,  
204 - success: function(data){  
205 - $("#"+div).empty();  
206 - $("#"+div).append(data);  
207 - return;  
208 - }  
209 - });  
210 -}  
211 -  
212 -wizard.prototype.sendJavaLocation = function () {  
213 - $('form').submit();  
214 -}  
215 -  
216 -wizard.prototype.sendRegistration = function () {  
217 - $('form').submit(); 1 +// Class Wizard
  2 +function wizard() {
  3 +}
  4 +
  5 +// Toggle Advance Database options
  6 +wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details
  7 + if($('.'+ele).attr('style') == 'display: none;') {
  8 + $('.'+ele).attr('style', 'display: block;');
  9 + if($('#'+option).attr('innerHTML') != '&nbsp;&nbsp;Advanced Options')
  10 + $('#'+option).attr('innerHTML', 'Hide Details');
  11 + } else {
  12 + $('.'+ele).attr('style', 'display: none;');
  13 + if($('#'+option).attr('innerHTML') != '&nbsp;&nbsp;Advanced Options')
  14 + $('#'+option).attr('innerHTML', 'Show Details');
  15 + }
  16 +}
  17 +
  18 +// Focus on element
  19 +wizard.prototype.focusElement = function(el) {
  20 + el.focus();
  21 +}
  22 +
  23 +// Force previous click
  24 +wizard.prototype.pClick = function() {
  25 + var state = $('#state');
  26 + if(state != undefined) {
  27 + state.attr('name', 'previous');
  28 + }
  29 +}
  30 +
  31 +// Force next click
  32 +wizard.prototype.nClick = function() {
  33 + var state = $('#state');;
  34 + if(state != undefined) {
  35 + state.attr('name', 'next');
  36 + }
  37 +}
  38 +
  39 +// Validate Registration Page
  40 +wizard.prototype.validateRegistration = function() {
  41 + // See if next or previous is clicked.
  42 + var state = $('#state').attr('name');
  43 + if(state == 'next') {
  44 + if(w.valRegHelper()) {
  45 + $('#sendAll').attr('name', 'Next'); // Force the next step
  46 + $('#sendAll').attr('value', 'next');
  47 + return true;
  48 + }
  49 + } else if(state == 'previous') {
  50 + $('#sendAll').attr('name', 'Previous'); // Force the previous step
  51 + $('#sendAll').attr('value', 'previous');
  52 + return true;
  53 + }
  54 +
  55 + return false;
  56 +}
  57 +
  58 +wizard.prototype.valRegHelper = function() {
  59 + var first = document.getElementById('first');
  60 + var last = document.getElementById('last');
  61 + var email = document.getElementById('email');
  62 + if(first.value.length < 1) {
  63 + document.getElementById("reg_error").innerHTML = "Please enter a First Name";
  64 + w.focusElement(first);
  65 + return false;
  66 + }
  67 + if(!w.nameCheck(first.value)) {
  68 + document.getElementById("reg_error").innerHTML = "Please enter a valid First Name";
  69 + w.focusElement(first);
  70 + return false;
  71 + }
  72 + if(last.value.length < 1) {
  73 + document.getElementById("reg_error").innerHTML = "Please enter a Last Name";
  74 + w.focusElement(last);
  75 + return false;
  76 + }
  77 + if(!w.nameCheck(last.value)) {
  78 + document.getElementById("reg_error").innerHTML = "Please enter a valid Last Name";
  79 + w.focusElement(last);
  80 + return false;
  81 + }
  82 + if(!w.emailCheck(email.value)) {
  83 + document.getElementById("reg_error").innerHTML = "Please enter a valid email address";
  84 + w.focusElement(email);
  85 + return false;
  86 + }
  87 +
  88 + return true;
  89 +}
  90 +
  91 +wizard.prototype.nameCheck = function(str) {
  92 + var nameRegxp = /^([a-zA-Z]+)$/;
  93 + if(str.match(nameRegxp)) {
  94 + return true;
  95 + } else {
  96 + return false;
  97 + }
  98 +}
  99 +
  100 +// Validate Registration Page Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
  101 +wizard.prototype.emailCheck = function(str) {
  102 + str = w.trim(str);
  103 + var at="@";
  104 + var dot=".";
  105 + var lat=str.indexOf(at);
  106 + var lstr=str.length;
  107 + var ldot=str.indexOf(dot);
  108 + if (str.indexOf(at)==-1) {
  109 + return false;
  110 + }
  111 + if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
  112 + return false;
  113 + }
  114 + if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
  115 + return false;
  116 + }
  117 + if (str.indexOf(at,(lat+1))!=-1) {
  118 + return false;
  119 + }
  120 + if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
  121 + return false;
  122 + }
  123 + if (str.indexOf(dot,(lat+2))==-1){
  124 + return false;
  125 + }
  126 + if (str.indexOf(" ")!=-1){
  127 + return false;
  128 + }
  129 + return true;
  130 +}
  131 +
  132 +wizard.prototype.trim = function (str, chars) {
  133 + return w.ltrim(w.rtrim(str, chars), chars);
  134 +}
  135 +
  136 +wizard.prototype.ltrim = function (str, chars) {
  137 + chars = chars || "\\s";
  138 + return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
  139 +}
  140 +
  141 +wizard.prototype.rtrim = function (str, chars) {
  142 + chars = chars || "\\s";
  143 + return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
  144 +}
  145 +
  146 +wizard.prototype.adjustMenu = function (form_id, previous) {
  147 + form_name = form_id.split('_');
  148 + if(form_name.length == 2) {
  149 + current_step = form_name[0];
  150 + next_step = form_name[1];
  151 + $('#'+current_step).attr('class', 'current');
  152 + $('#'+next_step).attr('class', 'inactive');
  153 + } else if(form_name.length == 3) {
  154 + previous_step = form_name[0];
  155 + current_step = form_name[1];
  156 + next_step = form_name[2];
  157 + $('#'+previous_step).attr('class', 'active');
  158 + $('#'+current_step).attr('class', 'current');
  159 + $('#'+next_step).attr('class', 'inactive');
  160 + }
  161 +}
  162 +
  163 +wizard.prototype.dummy = function () {
  164 +
  165 +}
  166 +
  167 +// pre-submit callback
  168 +wizard.prototype.showRequest = function (formData, jqForm, options) {
  169 + $.blockUI({message:''});
  170 + $('#loading').attr('style', 'display:block;');
  171 +}
  172 +
  173 +// post-submit callback
  174 +wizard.prototype.showResponse = function (responseText, statusText) {
  175 + $.unblockUI();
  176 + $('#loading').attr('style', 'display:none;');
  177 +}
  178 +
  179 +wizard.prototype.refresh = function (page) {
  180 + var address = "index.php?step_name="+page;
  181 + var div = 'content_container';
  182 + $.ajax({
  183 + url: address,
  184 + dataType: "html",
  185 + type: "GET",
  186 + cache: false,
  187 + beforeSubmit: w.showRequest,
  188 + success: function(data){
  189 + $("#"+div).empty();
  190 + $("#"+div).append(data);
  191 + w.showResponse;
  192 + return;
  193 + }
  194 + });
  195 +}
  196 +
  197 +wizard.prototype.getUrl = function (address, div) {
  198 + $("#"+div).empty();
  199 + $.ajax({
  200 + url: address,
  201 + dataType: "html",
  202 + type: "GET",
  203 + cache: false,
  204 + success: function(data){
  205 + $("#"+div).empty();
  206 + $("#"+div).append(data);
  207 + return;
  208 + }
  209 + });
  210 +}
  211 +
  212 +wizard.prototype.sendJavaLocation = function () {
  213 + $('form').submit();
  214 +}
  215 +
  216 +wizard.prototype.sendRegistration = function () {
  217 + $('form').submit();
  218 +}
  219 +
  220 +wizard.prototype.clearSessions = function () {
  221 + var address = 'session.php?action=destroyInstall';
  222 + $.ajax({
  223 + url: address,
  224 + dataType: "html",
  225 + type: "POST",
  226 + cache: false,
  227 + });
218 } 228 }
219 \ No newline at end of file 229 \ No newline at end of file
setup/wizard/session.php
1 -<?php  
2 -/**  
3 -* Session 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 Session  
43 -{  
44 - /**  
45 - * Constructs session object  
46 - *  
47 - * @author KnowledgeTree Team  
48 - * @access public  
49 - * @param none  
50 - */  
51 - public function __construct() {  
52 - $this->startSession();  
53 - }  
54 -  
55 - /**  
56 - * Starts a session if one does not exist  
57 - *  
58 - * @author KnowledgeTree Team  
59 - * @param none  
60 - * @access public  
61 - * @return void  
62 - */  
63 - public function startSession() {  
64 - if(!isset($_SESSION['ready'])) {  
65 - session_start();  
66 - $_SESSION ['ready'] = TRUE;  
67 - }  
68 - }  
69 -  
70 - /**  
71 - * Sets a value key pair in session  
72 - *  
73 - * @author KnowledgeTree Team  
74 - * @param string $fld  
75 - * @param string $val  
76 - * @access public  
77 - * @return void  
78 - */  
79 - public function set($fld, $val) {  
80 - $this->startSession();  
81 - $_SESSION [$fld] = $val;  
82 - }  
83 -  
84 - /**  
85 - * Sets a value key pair in a class in session  
86 - *  
87 - * @author KnowledgeTree Team  
88 - * @param string $class  
89 - * @param string $fld  
90 - * @param string $val  
91 - * @access public  
92 - * @return void  
93 - */  
94 - public function setClass($class , $k, $v) {  
95 - $this->startSession();  
96 - $classArray = $this->get($class);  
97 - if(isset($classArray[$k])) {  
98 - $classArray[$k] = $v;  
99 - } else {  
100 - $classArray[$k] = $v;  
101 - }  
102 - $_SESSION [ $class] = $classArray;  
103 - }  
104 -  
105 - /**  
106 - * Sets a error value key pair in a class in session  
107 - *  
108 - * @author KnowledgeTree Team  
109 - * @param string $class  
110 - * @param string $fld  
111 - * @param string $val  
112 - * @access public  
113 - * @return void  
114 - */  
115 - public function setClassError($class, $k, $v) {  
116 - $this->startSession();  
117 - $classArray = $this->get($class);  
118 - if(isset($classArray[$k])) {  
119 - $classArray[$k] = $v;  
120 - } else {  
121 - $classArray[$k] = $v;  
122 - }  
123 - $_SESSION [ $class] = $classArray;  
124 - }  
125 -  
126 - /**  
127 - * Clear error values in a class session  
128 - *  
129 - * @author KnowledgeTree Team  
130 - * @param string $class  
131 - * @param string $fld  
132 - * @param string $val  
133 - * @access public  
134 - * @return void  
135 - */  
136 - public function clearErrors($class) {  
137 - $classArray = $this->get($class);  
138 - unset($classArray['errors']);  
139 - $_SESSION [ $class] = $classArray;  
140 - }  
141 -  
142 - /**  
143 - * Unset a value in session  
144 - *  
145 - * @author KnowledgeTree Team  
146 - * @param string $fld  
147 - * @access public  
148 - * @return void  
149 - */  
150 - public function un_set($fld) {  
151 - $this->startSession();  
152 - unset($_SESSION [$fld]);  
153 - }  
154 -  
155 - /**  
156 - * Unset a class value in session  
157 - *  
158 - * @author KnowledgeTree Team  
159 - * @param string $class  
160 - * @access public  
161 - * @return void  
162 - */  
163 - public function un_setClass($class) {  
164 - $this->startSession();  
165 - if(isset($_SESSION [$class]))  
166 - unset($_SESSION [$class]);  
167 - }  
168 -  
169 - /**  
170 - * Destroy the session  
171 - *  
172 - * @author KnowledgeTree Team  
173 - * @param none  
174 - * @access public  
175 - * @return void  
176 - */  
177 - public function destroy() {  
178 - $this->startSession();  
179 - unset($_SESSION);  
180 - session_destroy();  
181 - }  
182 -  
183 - /**  
184 - * Get a session value  
185 - *  
186 - * @author KnowledgeTree Team  
187 - * @param string $fld  
188 - * @access public  
189 - * @return string  
190 - */  
191 - public function get($fld) {  
192 - $this->startSession();  
193 - if(isset($_SESSION [$fld]))  
194 - return $_SESSION [$fld];  
195 - return false;  
196 - }  
197 -  
198 - /**  
199 - * Check if a field exists in session  
200 - *  
201 - * @author KnowledgeTree Team  
202 - * @param string $fld  
203 - * @access public  
204 - * @return string  
205 - */  
206 - public function is_set($fld) {  
207 - $this->startSession();  
208 - return isset($_SESSION [$fld]);  
209 - }  
210 -  
211 - /**  
212 - * Return a class from session  
213 - *  
214 - * @author KnowledgeTree Team  
215 - * @param string $fld  
216 - * @access public  
217 - * @return string  
218 - */  
219 - public function getClass($class) {  
220 - return $_SESSION[$class];  
221 - }  
222 -} 1 +<?php
  2 +/**
  3 +* Session 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +class Session
  43 +{
  44 + private $salt = 'install';
  45 + /**
  46 + * Constructs session object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + * @param none
  51 + */
  52 + public function __construct() {
  53 + $this->startSession();
  54 + }
  55 +
  56 + /**
  57 + * Starts a session if one does not exist
  58 + *
  59 + * @author KnowledgeTree Team
  60 + * @param none
  61 + * @access public
  62 + * @return void
  63 + */
  64 + public function startSession() {
  65 + if(!isset($_SESSION[$this->salt]['ready'])) {
  66 + session_start();
  67 + $_SESSION[$this->salt] ['ready'] = TRUE;
  68 + }
  69 + }
  70 +
  71 + /**
  72 + * Sets a value key pair in session
  73 + *
  74 + * @author KnowledgeTree Team
  75 + * @param string $fld
  76 + * @param string $val
  77 + * @access public
  78 + * @return void
  79 + */
  80 + public function set($fld, $val) {
  81 + $this->startSession();
  82 + $_SESSION[$this->salt] [$fld] = $val;
  83 + }
  84 +
  85 + /**
  86 + * Sets a value key pair in a class in session
  87 + *
  88 + * @author KnowledgeTree Team
  89 + * @param string $class
  90 + * @param string $fld
  91 + * @param string $val
  92 + * @access public
  93 + * @return void
  94 + */
  95 + public function setClass($class , $k, $v) {
  96 + $this->startSession();
  97 + $classArray = $this->get($class);
  98 + if(isset($classArray[$k])) {
  99 + $classArray[$k] = $v;
  100 + } else {
  101 + $classArray[$k] = $v;
  102 + }
  103 + $_SESSION[$this->salt] [ $class] = $classArray;
  104 + }
  105 +
  106 + /**
  107 + * Sets a error value key pair in a class in session
  108 + *
  109 + * @author KnowledgeTree Team
  110 + * @param string $class
  111 + * @param string $fld
  112 + * @param string $val
  113 + * @access public
  114 + * @return void
  115 + */
  116 + public function setClassError($class, $k, $v) {
  117 + $this->startSession();
  118 + $classArray = $this->get($class);
  119 + if(isset($classArray[$k])) {
  120 + $classArray[$k] = $v;
  121 + } else {
  122 + $classArray[$k] = $v;
  123 + }
  124 + $_SESSION[$this->salt] [ $class] = $classArray;
  125 + }
  126 +
  127 + /**
  128 + * Clear error values in a class session
  129 + *
  130 + * @author KnowledgeTree Team
  131 + * @param string $class
  132 + * @param string $fld
  133 + * @param string $val
  134 + * @access public
  135 + * @return void
  136 + */
  137 + public function clearErrors($class) {
  138 + $classArray = $this->get($class);
  139 + unset($classArray['errors']);
  140 + $_SESSION[$this->salt] [ $class] = $classArray;
  141 + }
  142 +
  143 + /**
  144 + * Unset a value in session
  145 + *
  146 + * @author KnowledgeTree Team
  147 + * @param string $fld
  148 + * @access public
  149 + * @return void
  150 + */
  151 + public function un_set($fld) {
  152 + $this->startSession();
  153 + unset($_SESSION[$this->salt] [$fld]);
  154 + }
  155 +
  156 + /**
  157 + * Unset a class value in session
  158 + *
  159 + * @author KnowledgeTree Team
  160 + * @param string $class
  161 + * @access public
  162 + * @return void
  163 + */
  164 + public function un_setClass($class) {
  165 + $this->startSession();
  166 + if(isset($_SESSION[$this->salt] [$class]))
  167 + unset($_SESSION[$this->salt] [$class]);
  168 + }
  169 +
  170 + /**
  171 + * Destroy the session
  172 + *
  173 + * @author KnowledgeTree Team
  174 + * @param none
  175 + * @access public
  176 + * @return void
  177 + */
  178 + public function destroy() {
  179 + $this->startSession();
  180 + unset($_SESSION[$this->salt]);
  181 + session_destroy();
  182 + }
  183 +
  184 + /**
  185 + * Get a session value
  186 + *
  187 + * @author KnowledgeTree Team
  188 + * @param string $fld
  189 + * @access public
  190 + * @return string
  191 + */
  192 + public function get($fld) {
  193 + $this->startSession();
  194 + if(isset($_SESSION[$this->salt] [$fld]))
  195 + return $_SESSION[$this->salt] [$fld];
  196 + return false;
  197 + }
  198 +
  199 + /**
  200 + * Check if a field exists in session
  201 + *
  202 + * @author KnowledgeTree Team
  203 + * @param string $fld
  204 + * @access public
  205 + * @return string
  206 + */
  207 + public function is_set($fld) {
  208 + $this->startSession();
  209 + return isset($_SESSION[$this->salt] [$fld]);
  210 + }
  211 +
  212 + /**
  213 + * Return a class from session
  214 + *
  215 + * @author KnowledgeTree Team
  216 + * @param string $fld
  217 + * @access public
  218 + * @return string
  219 + */
  220 + public function getClass($class) {
  221 + return $_SESSION[$this->salt][$class];
  222 + }
  223 +
  224 + public function destroyInstall() {
  225 + $_SESSION[$this->salt] = '';
  226 + $this->destroy();
  227 + }
  228 +}
  229 +
  230 +if(isset($_GET['action'])) {
  231 + $func = $_GET['action'];
  232 + if($func != '') {
  233 + $ses = new Session();
  234 + $method = "$func";
  235 + $ses->$method();
  236 + }
  237 +}
223 ?> 238 ?>
224 \ No newline at end of file 239 \ No newline at end of file
setup/wizard/step.php
1 -<?php  
2 -/**  
3 -* Step .  
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 Step  
43 -{  
44 - /**  
45 - * List of variables to be loaded to template  
46 - *  
47 - * @author KnowledgeTree Team  
48 - * @access protected  
49 - * @var array  
50 - */  
51 - protected $temp_variables = array();  
52 -  
53 - /**  
54 - * List of errors encountered by step  
55 - *  
56 - * @author KnowledgeTree Team  
57 - * @access protected  
58 - * @var array  
59 - */  
60 - protected $error = array();  
61 -  
62 - /**  
63 - * List of warnings encountered by step  
64 - *  
65 - * @author KnowledgeTree Team  
66 - * @access protected  
67 - * @var array  
68 - */  
69 - protected $warnings = array();  
70 -  
71 - /**  
72 - * Flag to store class information in session  
73 - *  
74 - * @author KnowledgeTree Team  
75 - * @access public  
76 - * @var array  
77 - */  
78 - protected $storeInSession = false;  
79 -  
80 - /**  
81 - * Flag if step needs to be installed  
82 - *  
83 - * @author KnowledgeTree Team  
84 - * @access public  
85 - * @var array  
86 - */  
87 - protected $runInstall = false;  
88 -  
89 - /**  
90 - * Step order  
91 - *  
92 - * @author KnowledgeTree Team  
93 - * @access public  
94 - * @var string  
95 - */  
96 - protected $order = false;  
97 -  
98 - /**  
99 - * Flag if step needs to run silently  
100 - *  
101 - * @author KnowledgeTree Team  
102 - * @access public  
103 - * @var boolean  
104 - */  
105 - protected $silent = false;  
106 -  
107 - public $displayFirst = false;  
108 - /**  
109 - * Returns step state  
110 - *  
111 - * @author KnowledgeTree Team  
112 - * @param none  
113 - * @access public  
114 - * @return string  
115 - */  
116 - public function doStep()  
117 - {  
118 - return '';  
119 - }  
120 -  
121 - public function displayFirst() {  
122 - return $this->displayFirst;  
123 - }  
124 -  
125 - /**  
126 - * Returns step variables  
127 - *  
128 - * @author KnowledgeTree Team  
129 - * @param none  
130 - * @access public  
131 - * @return array  
132 - */  
133 - public function getStepVars()  
134 - {  
135 - return $this->temp_variables;  
136 - }  
137 -  
138 - /**  
139 - * Returns step errors  
140 - *  
141 - * @author KnowledgeTree Team  
142 - * @param none  
143 - * @access public  
144 - * @return array  
145 - */  
146 - public function getErrors() {  
147 - return $this->error;  
148 - }  
149 -  
150 - /**  
151 - * Returns step errors  
152 - *  
153 - * @author KnowledgeTree Team  
154 - * @param none  
155 - * @access public  
156 - * @return array  
157 - */  
158 - public function getWarnings() {  
159 - return $this->warnings;  
160 - }  
161 -  
162 - /**  
163 - * Load default step values  
164 - *  
165 - * @author KnowledgeTree Team  
166 - * @param none  
167 - * @access public  
168 - * @return void  
169 - */  
170 - public function loadDefaults() {  
171 -  
172 - }  
173 -  
174 - /**  
175 - * Return default step values  
176 - *  
177 - * @author KnowledgeTree Team  
178 - * @param none  
179 - * @access public  
180 - * @return array  
181 - */  
182 - public function getDefaults() {  
183 - return array();  
184 - }  
185 -  
186 - /**  
187 - * Checks if edit button has been clicked  
188 - *  
189 - * @author KnowledgeTree Team  
190 - * @param none  
191 - * @access public  
192 - * @return boolean  
193 - */  
194 - public function edit() {  
195 - if(isset($_POST['Edit'])) {  
196 - return true;  
197 - }  
198 -  
199 - return false;  
200 - }  
201 -  
202 - /**  
203 - * Checks if next button has been clicked  
204 - *  
205 - * @author KnowledgeTree Team  
206 - * @param none  
207 - * @access public  
208 - * @return boolean  
209 - */  
210 - public function next() {  
211 - if(isset($_POST['Next'])) {  
212 - return true;  
213 - }  
214 -  
215 - return false;  
216 - }  
217 -  
218 - /**  
219 - * Checks if previous button has been clicked  
220 - *  
221 - * @author KnowledgeTree Team  
222 - * @param none  
223 - * @access public  
224 - * @return boolean  
225 - */  
226 - public function previous() {  
227 - if(isset($_POST['Previous'])) {  
228 - return true;  
229 - }  
230 -  
231 - return false;  
232 - }  
233 -  
234 - /**  
235 - * Checks if Confirm button has been clicked  
236 - *  
237 - * @author KnowledgeTree Team  
238 - * @param none  
239 - * @access public  
240 - * @return boolean  
241 - */  
242 - function confirm() {  
243 - if(isset($_POST['Confirm'])) {  
244 - return true;  
245 - }  
246 -  
247 - return false;  
248 - }  
249 -  
250 - /**  
251 - * Checks if Confirm button has been clicked  
252 - *  
253 - * @author KnowledgeTree Team  
254 - * @param none  
255 - * @access public  
256 - * @return boolean  
257 - */  
258 - function install() {  
259 - if(isset($_POST['Install'])) {  
260 - return true;  
261 - }  
262 -  
263 - return false;  
264 - }  
265 -  
266 - /**  
267 - * Checks if we are currently in this class step  
268 - *  
269 - * @author KnowledgeTree Team  
270 - * @param string  
271 - * @access public  
272 - * @return boolean  
273 - */  
274 - public function inStep($name) {  
275 - if($_GET['step_name'] == $name)  
276 - return true;  
277 - return false;  
278 - }  
279 -  
280 - /**  
281 - * Load session data to post  
282 - *  
283 - * @author KnowledgeTree Team  
284 - * @params none  
285 - * @access private  
286 - * @return boolean  
287 - */  
288 - public function setDataFromSession($class) {  
289 - if(empty($_SESSION[$class])) {  
290 - return false;  
291 - }  
292 - $_POST = $_SESSION[$class];  
293 -  
294 - return true;  
295 - }  
296 -  
297 - /**  
298 - * Get session data from post  
299 - *  
300 - * @author KnowledgeTree Team  
301 - * @params none  
302 - * @access private  
303 - * @return boolean  
304 - */  
305 - public function getDataFromSession($class) {  
306 - if(empty($_SESSION[$class])) {  
307 - return false;  
308 - }  
309 -  
310 - return $_SESSION[$class];  
311 - }  
312 -  
313 - /**  
314 - * Safer way to return post data  
315 - *  
316 - * @author KnowledgeTree Team  
317 - * @params SimpleXmlObject $simplexml  
318 - * @access public  
319 - * @return void  
320 - */  
321 - public function getPostSafe($key) {  
322 - return isset($_POST[$key]) ? $_POST[$key] : "";  
323 - }  
324 -  
325 - /**  
326 - * Safer way to return post data  
327 - *  
328 - * @author KnowledgeTree Team  
329 - * @params SimpleXmlObject $simplexml  
330 - * @access public  
331 - * @return void  
332 - */  
333 - public function getPostBoolean($key) {  
334 - return isset($_POST[$key]) ? $_POST[$key] : false;  
335 - }  
336 -  
337 - /**  
338 - * Runs step install if required  
339 - *  
340 - * @author KnowledgeTree Team  
341 - * @param none  
342 - * @access public  
343 - * @return void  
344 - */  
345 - public function installStep() {  
346 - return '';  
347 - }  
348 -  
349 - /**  
350 - * Return whether or not to store a step information in session  
351 - *  
352 - * @author KnowledgeTree Team  
353 - * @param none  
354 - * @access public  
355 - * @return boolean  
356 - */  
357 - public function storeInSession() {  
358 - return $this->storeInSession;  
359 - }  
360 -  
361 - /**  
362 - * Return whether or not to a step has to be installed  
363 - *  
364 - * @author KnowledgeTree Team  
365 - * @param none  
366 - * @access public  
367 - * @return boolean  
368 - */  
369 - public function runInstall() {  
370 - return $this->runInstall;  
371 - }  
372 -  
373 - public function setPostConfig() {  
374 - return '';  
375 - }  
376 -  
377 - /**  
378 - * Return whether or not to a step has to be in silent mode  
379 - *  
380 - * @author KnowledgeTree Team  
381 - * @param none  
382 - * @access public  
383 - * @return boolean  
384 - */  
385 - public function silentMode() {  
386 - return $this->silent;  
387 - }  
388 -  
389 - /**  
390 - * Set step errors  
391 - *  
392 - * @author KnowledgeTree Team  
393 - * @param none  
394 - * @access public  
395 - * @return array  
396 - */  
397 - public function setErrors($error) {  
398 - $this->error = $error;  
399 - }  
400 -}  
401 - 1 +<?php
  2 +/**
  3 +* Step .
  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 Step
  43 +{
  44 + /**
  45 + * List of variables to be loaded to template
  46 + *
  47 + * @author KnowledgeTree Team
  48 + * @access protected
  49 + * @var array
  50 + */
  51 + protected $temp_variables = array();
  52 +
  53 + /**
  54 + * List of errors encountered by step
  55 + *
  56 + * @author KnowledgeTree Team
  57 + * @access protected
  58 + * @var array
  59 + */
  60 + protected $error = array();
  61 +
  62 + /**
  63 + * List of warnings encountered by step
  64 + *
  65 + * @author KnowledgeTree Team
  66 + * @access protected
  67 + * @var array
  68 + */
  69 + protected $warnings = array();
  70 +
  71 + /**
  72 + * Flag to store class information in session
  73 + *
  74 + * @author KnowledgeTree Team
  75 + * @access public
  76 + * @var array
  77 + */
  78 + protected $storeInSession = false;
  79 +
  80 + /**
  81 + * Flag if step needs to be installed
  82 + *
  83 + * @author KnowledgeTree Team
  84 + * @access public
  85 + * @var array
  86 + */
  87 + protected $runInstall = false;
  88 +
  89 + /**
  90 + * Step order
  91 + *
  92 + * @author KnowledgeTree Team
  93 + * @access public
  94 + * @var string
  95 + */
  96 + protected $order = false;
  97 +
  98 + /**
  99 + * Flag if step needs to run silently
  100 + *
  101 + * @author KnowledgeTree Team
  102 + * @access public
  103 + * @var boolean
  104 + */
  105 + protected $silent = false;
  106 +
  107 + public $displayFirst = false;
  108 +
  109 + private $salt = 'install';
  110 + /**
  111 + * Returns step state
  112 + *
  113 + * @author KnowledgeTree Team
  114 + * @param none
  115 + * @access public
  116 + * @return string
  117 + */
  118 + public function doStep()
  119 + {
  120 + return '';
  121 + }
  122 +
  123 + public function displayFirst() {
  124 + return $this->displayFirst;
  125 + }
  126 +
  127 + /**
  128 + * Returns step variables
  129 + *
  130 + * @author KnowledgeTree Team
  131 + * @param none
  132 + * @access public
  133 + * @return array
  134 + */
  135 + public function getStepVars()
  136 + {
  137 + return $this->temp_variables;
  138 + }
  139 +
  140 + /**
  141 + * Returns step errors
  142 + *
  143 + * @author KnowledgeTree Team
  144 + * @param none
  145 + * @access public
  146 + * @return array
  147 + */
  148 + public function getErrors() {
  149 + return $this->error;
  150 + }
  151 +
  152 + /**
  153 + * Returns step errors
  154 + *
  155 + * @author KnowledgeTree Team
  156 + * @param none
  157 + * @access public
  158 + * @return array
  159 + */
  160 + public function getWarnings() {
  161 + return $this->warnings;
  162 + }
  163 +
  164 + /**
  165 + * Load default step values
  166 + *
  167 + * @author KnowledgeTree Team
  168 + * @param none
  169 + * @access public
  170 + * @return void
  171 + */
  172 + public function loadDefaults() {
  173 +
  174 + }
  175 +
  176 + /**
  177 + * Return default step values
  178 + *
  179 + * @author KnowledgeTree Team
  180 + * @param none
  181 + * @access public
  182 + * @return array
  183 + */
  184 + public function getDefaults() {
  185 + return array();
  186 + }
  187 +
  188 + /**
  189 + * Checks if edit button has been clicked
  190 + *
  191 + * @author KnowledgeTree Team
  192 + * @param none
  193 + * @access public
  194 + * @return boolean
  195 + */
  196 + public function edit() {
  197 + if(isset($_POST['Edit'])) {
  198 + return true;
  199 + }
  200 +
  201 + return false;
  202 + }
  203 +
  204 + /**
  205 + * Checks if next button has been clicked
  206 + *
  207 + * @author KnowledgeTree Team
  208 + * @param none
  209 + * @access public
  210 + * @return boolean
  211 + */
  212 + public function next() {
  213 + if(isset($_POST['Next'])) {
  214 + return true;
  215 + }
  216 +
  217 + return false;
  218 + }
  219 +
  220 + /**
  221 + * Checks if previous button has been clicked
  222 + *
  223 + * @author KnowledgeTree Team
  224 + * @param none
  225 + * @access public
  226 + * @return boolean
  227 + */
  228 + public function previous() {
  229 + if(isset($_POST['Previous'])) {
  230 + return true;
  231 + }
  232 +
  233 + return false;
  234 + }
  235 +
  236 + /**
  237 + * Checks if Confirm button has been clicked
  238 + *
  239 + * @author KnowledgeTree Team
  240 + * @param none
  241 + * @access public
  242 + * @return boolean
  243 + */
  244 + function confirm() {
  245 + if(isset($_POST['Confirm'])) {
  246 + return true;
  247 + }
  248 +
  249 + return false;
  250 + }
  251 +
  252 + /**
  253 + * Checks if Confirm button has been clicked
  254 + *
  255 + * @author KnowledgeTree Team
  256 + * @param none
  257 + * @access public
  258 + * @return boolean
  259 + */
  260 + function install() {
  261 + if(isset($_POST['Install'])) {
  262 + return true;
  263 + }
  264 +
  265 + return false;
  266 + }
  267 +
  268 + /**
  269 + * Checks if we are currently in this class step
  270 + *
  271 + * @author KnowledgeTree Team
  272 + * @param string
  273 + * @access public
  274 + * @return boolean
  275 + */
  276 + public function inStep($name) {
  277 + if($_GET['step_name'] == $name)
  278 + return true;
  279 + return false;
  280 + }
  281 +
  282 + /**
  283 + * Load session data to post
  284 + *
  285 + * @author KnowledgeTree Team
  286 + * @params none
  287 + * @access private
  288 + * @return boolean
  289 + */
  290 + public function setDataFromSession($class) {
  291 + if(empty($_SESSION[$this->salt][$class])) {
  292 + return false;
  293 + }
  294 + $_POST = $_SESSION[$this->salt][$class];
  295 +
  296 + return true;
  297 + }
  298 +
  299 + /**
  300 + * Get session data from post
  301 + *
  302 + * @author KnowledgeTree Team
  303 + * @params none
  304 + * @access private
  305 + * @return boolean
  306 + */
  307 + public function getDataFromSession($class) {
  308 + if(empty($_SESSION[$this->salt][$class])) {
  309 + return false;
  310 + }
  311 +
  312 + return $_SESSION[$this->salt][$class];
  313 + }
  314 +
  315 + /**
  316 + * Safer way to return post data
  317 + *
  318 + * @author KnowledgeTree Team
  319 + * @params SimpleXmlObject $simplexml
  320 + * @access public
  321 + * @return void
  322 + */
  323 + public function getPostSafe($key) {
  324 + return isset($_POST[$key]) ? $_POST[$key] : "";
  325 + }
  326 +
  327 + /**
  328 + * Safer way to return post data
  329 + *
  330 + * @author KnowledgeTree Team
  331 + * @params SimpleXmlObject $simplexml
  332 + * @access public
  333 + * @return void
  334 + */
  335 + public function getPostBoolean($key) {
  336 + return isset($_POST[$key]) ? $_POST[$key] : false;
  337 + }
  338 +
  339 + /**
  340 + * Runs step install if required
  341 + *
  342 + * @author KnowledgeTree Team
  343 + * @param none
  344 + * @access public
  345 + * @return void
  346 + */
  347 + public function installStep() {
  348 + return '';
  349 + }
  350 +
  351 + /**
  352 + * Return whether or not to store a step information in session
  353 + *
  354 + * @author KnowledgeTree Team
  355 + * @param none
  356 + * @access public
  357 + * @return boolean
  358 + */
  359 + public function storeInSession() {
  360 + return $this->storeInSession;
  361 + }
  362 +
  363 + /**
  364 + * Return whether or not to a step has to be installed
  365 + *
  366 + * @author KnowledgeTree Team
  367 + * @param none
  368 + * @access public
  369 + * @return boolean
  370 + */
  371 + public function runInstall() {
  372 + return $this->runInstall;
  373 + }
  374 +
  375 + public function setPostConfig() {
  376 + return '';
  377 + }
  378 +
  379 + /**
  380 + * Return whether or not to a step has to be in silent mode
  381 + *
  382 + * @author KnowledgeTree Team
  383 + * @param none
  384 + * @access public
  385 + * @return boolean
  386 + */
  387 + public function silentMode() {
  388 + return $this->silent;
  389 + }
  390 +
  391 + /**
  392 + * Set step errors
  393 + *
  394 + * @author KnowledgeTree Team
  395 + * @param none
  396 + * @access public
  397 + * @return array
  398 + */
  399 + public function setErrors($error) {
  400 + $this->error = $error;
  401 + }
  402 +}
  403 +
402 ?> 404 ?>
403 \ No newline at end of file 405 \ No newline at end of file
setup/wizard/steps/database.php
1 -<?php  
2 -/**  
3 -* Database 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 -  
43 -class database extends Step  
44 -{  
45 - /**  
46 - * Reference to Database object  
47 - *  
48 - * @author KnowledgeTree Team  
49 - * @access public  
50 - * @var object  
51 - */  
52 - public $_dbhandler = null;  
53 -  
54 - /**  
55 - * Reference to Database object  
56 - *  
57 - * @author KnowledgeTree Team  
58 - * @access public  
59 - * @var object  
60 - */  
61 - public $_util = null;  
62 -  
63 - /**  
64 - * Database type  
65 - *  
66 - * @author KnowledgeTree Team  
67 - * @access private  
68 - * @var array  
69 - */  
70 - private $dtype = '';  
71 -  
72 - /**  
73 - * Database types  
74 - *  
75 - * @author KnowledgeTree Team  
76 - * @access private  
77 - * @var array  
78 - */  
79 - private $dtypes = array();  
80 -  
81 - /**  
82 - * Database host  
83 - *  
84 - * @author KnowledgeTree Team  
85 - * @access private  
86 - * @var string  
87 - */  
88 - private $dhost = '';  
89 -  
90 - /**  
91 - * Database port  
92 - *  
93 - * @author KnowledgeTree Team  
94 - * @access private  
95 - * @var string  
96 - */  
97 - private $dport = '';  
98 -  
99 - /**  
100 - * Database name  
101 - *  
102 - * @author KnowledgeTree Team  
103 - * @access private  
104 - * @var string  
105 - */  
106 - private $dname = '';  
107 -  
108 - /**  
109 - * Database root username  
110 - *  
111 - * @author KnowledgeTree Team  
112 - * @access private  
113 - * @var string  
114 - */  
115 - private $duname = '';  
116 -  
117 - /**  
118 - * Database root password  
119 - *  
120 - * @author KnowledgeTree Team  
121 - * @access private  
122 - * @var string  
123 - */  
124 - private $dpassword = '';  
125 -  
126 - /**  
127 - * Database dms username  
128 - *  
129 - * @author KnowledgeTree Team  
130 - * @access private  
131 - * @var string  
132 - */  
133 - private $dmsname = '';  
134 -  
135 - /**  
136 - * Database dms password  
137 - *  
138 - * @author KnowledgeTree Team  
139 - * @access private  
140 - * @var string  
141 - */  
142 - private $dmspassword = '';  
143 -  
144 - /**  
145 - * Default dms user username  
146 - *  
147 - * @author KnowledgeTree Team  
148 - * @access private  
149 - * @var boolean  
150 - */  
151 - private $dmsusername = '';  
152 -  
153 - /**  
154 - * Default dms user password  
155 - *  
156 - * @author KnowledgeTree Team  
157 - * @access private  
158 - * @var boolean  
159 - */  
160 - private $dmsuserpassword = '';  
161 -  
162 - /**  
163 - * Location of database binaries.  
164 - *  
165 - * @author KnowledgeTree Team  
166 - * @access private  
167 - * @var string  
168 - */  
169 - private $mysqlDir; // TODO:multiple databases  
170 -  
171 - /**  
172 - * Name of database binary.  
173 - *  
174 - * @author KnowledgeTree Team  
175 - * @access private  
176 - * @var string  
177 - */  
178 - private $dbbinary = ''; // TODO:multiple databases  
179 -  
180 - /**  
181 - * Database table prefix  
182 - *  
183 - * @author KnowledgeTree Team  
184 - * @access private  
185 - * @var string  
186 - */  
187 - private $tprefix = '';  
188 -  
189 - /**  
190 - * Flag to drop database  
191 - *  
192 - * @author KnowledgeTree Team  
193 - * @access private  
194 - * @var boolean  
195 - */  
196 - private $ddrop = false;  
197 -  
198 - /**  
199 - * List of errors encountered  
200 - *  
201 - * @author KnowledgeTree Team  
202 - * @access public  
203 - * @var array  
204 - */  
205 - public $error = array();  
206 -  
207 - /**  
208 - * List of errors used in template  
209 - *  
210 - * @author KnowledgeTree Team  
211 - * @access public  
212 - * @var array  
213 - */  
214 - public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');  
215 -  
216 - /**  
217 - * Flag to store class information in session  
218 - *  
219 - * @author KnowledgeTree Team  
220 - * @access public  
221 - * @var array  
222 - */  
223 - public $storeInSession = true;  
224 -  
225 - /**  
226 - * Flag if step needs to be installed  
227 - *  
228 - * @author KnowledgeTree Team  
229 - * @access public  
230 - * @var array  
231 - */  
232 - protected $runInstall = true;  
233 -  
234 - /**  
235 - * Flag if step needs to run silently  
236 - *  
237 - * @author KnowledgeTree Team  
238 - * @access public  
239 - * @var array  
240 - */  
241 - protected $silent = true;  
242 -  
243 - /**  
244 - * Constructs database object  
245 - *  
246 - * @author KnowledgeTree Team  
247 - * @access public  
248 - * @param none  
249 - */  
250 - public function __construct() {  
251 - $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent);  
252 - $this->_dbhandler = new dbUtil();  
253 - $this->_util = new InstallUtil();  
254 - if(WINDOWS_OS)  
255 - $this->mysqlDir = MYSQL_BIN;  
256 - }  
257 -  
258 - /**  
259 - * Main control of database setup  
260 - *  
261 - * @author KnowledgeTree Team  
262 - * @param none  
263 - * @access public  
264 - * @return string  
265 - */  
266 - public function doStep() {  
267 - $this->setErrorsFromSession();  
268 - $this->initErrors(); // Load template errors  
269 - if($this->inStep("database")) {  
270 - $res = $this->doProcess();  
271 - if($res) { // If theres a response, return it  
272 - return $res;  
273 - }  
274 - }  
275 - if($this->setDataFromSession("database")) { // Attempt to set values from session  
276 - $this->setDetails(); // Set any posted variables  
277 - } else {  
278 - $this->temp_variables['state'] = '';  
279 - $this->loadDefaults($this->readXml()); // Load default variables from file  
280 - }  
281 -  
282 - return 'landing';  
283 - }  
284 -  
285 - /**  
286 - * Controls setup helper  
287 - *  
288 - * @author KnowledgeTree Team  
289 - * @param none  
290 - * @access public  
291 - * @return string  
292 - */  
293 - public function doProcess() {  
294 - if($this->next()) {  
295 - $this->setPostConfig(); // Set any posted variables  
296 - $this->setDetails();  
297 - if($this->doTest()) { // Test  
298 - return 'confirm';  
299 - } else {  
300 - return 'error';  
301 - }  
302 - } else if($this->previous()) {  
303 - return 'previous';  
304 - } else if($this->confirm()) {  
305 - $this->setDataFromSession("database"); // Set Session Information  
306 - $this->setPostConfig(); // Set any posted variables  
307 - return 'next';  
308 - } else if($this->edit()) {  
309 - $this->setDataFromSession("database"); // Set Session Information, since its an edit  
310 - $this->temp_variables['state'] = 'edit';  
311 -  
312 - return 'landing';  
313 - }  
314 - }  
315 -  
316 - /**  
317 - * Test database connectivity  
318 - *  
319 - * @author KnowledgeTree Team  
320 - * @param none  
321 - * @access public  
322 - * @return boolean  
323 - */  
324 - public function doTest() {  
325 - if($this->match($this->dmspassword, $this->getPassword1()) != 0) {  
326 - $this->error['dmspassword'] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();  
327 - return false;  
328 - }  
329 - if($this->match($this->dmsuserpassword, $this->getPassword2()) != 0) {  
330 - $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();  
331 - return false;  
332 - }  
333 - if($this->dport == '') {  
334 - $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);  
335 - } else {  
336 - $con = $this->_dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);  
337 - }  
338 - if (!$con) {  
339 - $this->error['con'] = "Could not connect to the database, please check username and password";  
340 - return false;  
341 - } else {  
342 - if ($this->dbExists()) { // Check if database Exists  
343 - $this->error['dname'] = 'Database Already Exists, please specify a different name'; // Reset usage errors  
344 - return false;  
345 - } else {  
346 - $this->error = array(); // Reset usage errors  
347 - return true;  
348 - }  
349 - }  
350 - }  
351 -  
352 - public function dbExists() {  
353 - return $this->_dbhandler->useDb();  
354 - }  
355 -  
356 - public function match($str1, $str2) {  
357 - return strcmp($str1, $str2);  
358 - }  
359 -  
360 - public function getPassword1() {  
361 - return $_POST['dmspassword2'];  
362 - }  
363 -  
364 - public function getPassword2() {  
365 - return $_POST['dmsuserpassword2'];  
366 - }  
367 - /**  
368 - * Check if theres a database type  
369 - *  
370 - * @author KnowledgeTree Team  
371 - * @params none  
372 - * @access private  
373 - * @return boolean database type or false  
374 - */  
375 - private function getType() {  
376 - if(isset($_POST['dtype'])) {  
377 - return $_POST['dtype'];  
378 - }  
379 -  
380 - return false;  
381 - }  
382 -  
383 - /**  
384 - * Set Errors if any were encountered  
385 - *  
386 - * @author KnowledgeTree Team  
387 - * @params none  
388 - * @access private  
389 - * @return boolean  
390 - */  
391 - private function setErrorsFromSession() {  
392 - if(isset($_SESSION['database']['errors'])) {  
393 - $this->error[] = $_SESSION['database']['errors'];  
394 -  
395 - return true;  
396 - }  
397 -  
398 - return false;  
399 - }  
400 -  
401 - /**  
402 - * Set POST information  
403 - *  
404 - * @author KnowledgeTree Team  
405 - * @params none  
406 - * @access public  
407 - * @return void  
408 - */  
409 - public function setPostConfig() {  
410 - $this->dtype = $this->getPostSafe("dtype");  
411 - $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases  
412 - $this->dhost = $this->getPostSafe("dhost");  
413 - $this->dport = $this->getPostSafe("dport");  
414 - $this->dname = $this->getPostSafe("dname");  
415 - $this->duname = $this->getPostSafe("duname");  
416 - $this->dpassword = $this->getPostSafe("dpassword");  
417 - $this->dmsname = $this->getPostSafe("dmsname");  
418 - $this->dmsusername = $this->getPostSafe("dmsusername");  
419 - $this->dmspassword = $this->getPostSafe("dmspassword");  
420 - $this->dmsuserpassword = $this->getPostSafe("dmsuserpassword");  
421 - $this->dbbinary = $this->getPostSafe("dbbinary");  
422 - $this->tprefix = $this->getPostSafe("tprefix");  
423 - $this->ddrop = $this->getPostBoolean("ddrop");  
424 - }  
425 -  
426 - /**  
427 - * Load default options on template from xml file  
428 - *  
429 - * @author KnowledgeTree Team  
430 - * @params object SimpleXmlObject  
431 - * @access public  
432 - * @return void  
433 - */  
434 - public function loadDefaults($simplexml) {  
435 - if($simplexml) {  
436 - $this->temp_variables['dtype'] = "";  
437 - $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases  
438 - $this->temp_variables['dname'] = (string) $simplexml->dname;  
439 - $this->temp_variables['duname'] = (string) $simplexml->duname;  
440 - $this->temp_variables['dhost'] = (string) $simplexml->dhost;  
441 - $this->temp_variables['dport'] = (string) $simplexml->dport;  
442 - $this->temp_variables['dpassword'] = '';  
443 - $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;  
444 - $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser;  
445 - $this->temp_variables['dmspassword'] = (string) $simplexml->dmsaupass;  
446 - $this->temp_variables['dmsuserpassword'] = (string) $simplexml->dmsupass;  
447 - if(WINDOWS_OS) {  
448 - $this->temp_variables['dbbinary'] = 'mysql.exe';  
449 - } else {  
450 - $this->temp_variables['dbbinary'] = 'mysql';  
451 - }  
452 - $this->temp_variables['tprefix'] = '';  
453 - $this->temp_variables['ddrop'] = false;  
454 - }  
455 - }  
456 -  
457 - /**  
458 - * Store options  
459 - *  
460 - * @author KnowledgeTree Team  
461 - * @params object SimpleXmlObject  
462 - * @access private  
463 - * @return void  
464 - */  
465 - private function setDetails() {  
466 - if($this->edit()) {  
467 - $this->temp_variables['state'] = 'edit';  
468 - } else {  
469 - $this->temp_variables['state'] = '';  
470 - }  
471 - $this->temp_variables['dtype'] = $this->getPostSafe('dtype');  
472 - $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;  
473 - $this->temp_variables['dhost'] = $this->getPostSafe('dhost');  
474 - $this->temp_variables['dport'] = $this->getPostSafe('dport');  
475 - $this->temp_variables['dname'] = $this->getPostSafe('dname');  
476 - $this->temp_variables['duname'] = $this->getPostSafe('duname');  
477 - $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');  
478 - $this->temp_variables['dmsname'] = $this->getPostSafe('dmsname');  
479 - $this->temp_variables['dmsusername'] = $this->getPostSafe('dmsusername');  
480 - $this->temp_variables['dmspassword'] = $this->getPostSafe('dmspassword');  
481 - $this->temp_variables['dmsuserpassword'] = $this->getPostSafe('dmsuserpassword');;  
482 - $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary');  
483 - $this->temp_variables['tprefix'] = $this->getPostSafe('tprefix');  
484 - $this->temp_variables['ddrop'] = $this->getPostBoolean('ddrop');  
485 - }  
486 -  
487 - /**  
488 - * Extract database types  
489 - *  
490 - * @author KnowledgeTree Team  
491 - * @access private  
492 - * @params object SimpleXmlObject  
493 - * @return array  
494 - */  
495 - private function getTypes($xmlTypes) {  
496 - $t = array();  
497 - foreach ($xmlTypes->dtype as $key=>$val) {  
498 - $t[] = (string) $val;  
499 - }  
500 - return $t;  
501 - }  
502 -  
503 - /**  
504 - * Read xml config file  
505 - *  
506 - * @author KnowledgeTree Team  
507 - * @access private  
508 - * @params none  
509 - * @return object SimpleXmlObject  
510 - */  
511 - private function readXml() {  
512 - $simplexml = simplexml_load_file(CONF_DIR."databases.xml");  
513 -  
514 - return $simplexml;  
515 - }  
516 -  
517 - /**  
518 - * Stores varibles used by template  
519 - *  
520 - * @author KnowledgeTree Team  
521 - * @params none  
522 - * @access public  
523 - * @return array  
524 - */  
525 - public function getStepVars() {  
526 - return $this->temp_variables;  
527 - }  
528 -  
529 - /**  
530 - * Runs step install if required  
531 - *  
532 - * @author KnowledgeTree Team  
533 - * @param none  
534 - * @access public  
535 - * @return void  
536 - */  
537 - public function installStep() {  
538 - return $this->installDatabase();  
539 - }  
540 -  
541 - /**  
542 - * Helper  
543 - *  
544 - * @author KnowledgeTree Team  
545 - * @params none  
546 - * @access private  
547 - * @return void  
548 - */  
549 - private function installDatabase() {  
550 - if($this->dtype == '') {  
551 - $this->error['dtype'] = 'No database type selected';  
552 - return 'error';  
553 - }  
554 - if(!$this->{$this->dtype}()) {  
555 - return 'error';  
556 - }  
557 - }  
558 -  
559 - /**  
560 - * Helper  
561 - *  
562 - * @author KnowledgeTree Team  
563 - * @params none  
564 - * @access private  
565 - * @return void  
566 - */  
567 - private function mysql() {  
568 - $con = $this->connectMysql();  
569 - if($con) {  
570 - if(!$this->createDB($con)) {  
571 - $this->error['con'] = "Could not Create Database: ";  
572 - return false;  
573 - }  
574 - $this->closeMysql($con);  
575 - }  
576 - }  
577 -  
578 - /**  
579 - * Connect to mysql  
580 - *  
581 - * @author KnowledgeTree Team  
582 - * @params none  
583 - * @access private  
584 - * @return object mysql connection  
585 - */  
586 - private function connectMysql() {  
587 - $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);  
588 - if (!$con) {  
589 - $this->error['con'] = "Could not connect: ";  
590 -  
591 - return false;  
592 - }  
593 -  
594 - return $con;  
595 - }  
596 -  
597 - /**  
598 - * Helper  
599 - *  
600 - * @author KnowledgeTree Team  
601 - * @params object mysql connection object $con  
602 - * @access private  
603 - * @return object mysql connection  
604 - */  
605 - private function createDB($con) {  
606 - if($this->usedb($con)) { // attempt to use the db  
607 - if($this->dropdb($con)) { // attempt to drop the db  
608 - if(!$this->create($con)) { // attempt to create the db  
609 - $this->error['con'] = "Could not create database: ";  
610 - return false;// cannot overwrite database  
611 - }  
612 - } else {  
613 - $this->error['con'] = "Could not drop database: ";  
614 - return false;// cannot overwrite database  
615 - }  
616 - } else {  
617 - if(!$this->create($con)) { // attempt to create the db  
618 - $this->error['con'] = "Could not create database: ";  
619 - return false;// cannot overwrite database  
620 - }  
621 - }  
622 - if(!$this->createDmsUser($con)) {  
623 -  
624 - }  
625 - if(!$this->createSchema($con)) {  
626 - $this->error['con'] = "Could not create schema ";  
627 - }  
628 - if(!$this->populateSchema($con)) {  
629 - $this->error['con'] = "Could not populate schema ";  
630 - }  
631 - if(!$this->applyUpgrades($con)) {  
632 - $this->error['con'] = "Could not apply updates ";  
633 - }  
634 -  
635 - return true;  
636 - }  
637 -  
638 - /**  
639 - * Create database  
640 - *  
641 - * @author KnowledgeTree Team  
642 - * @params object mysql connection object $con  
643 - * @access private  
644 - * @return boolean  
645 - */  
646 - private function create($con) {  
647 - $sql = "CREATE DATABASE {$this->dname}";  
648 - if ($this->_dbhandler->query($sql, $con)) {  
649 -  
650 - return true;  
651 - }  
652 -  
653 - return false;  
654 - }  
655 -  
656 - /**  
657 - * Attempts to use a db  
658 - *  
659 - * @author KnowledgeTree Team  
660 - * @params mysql connection object $con  
661 - * @access private  
662 - * @return boolean  
663 - */  
664 - private function usedb($con) {  
665 - if($this->_dbhandler->useDb($this->dname)) {  
666 - return true;  
667 - } else {  
668 - $this->error['con'] = "Error using database: {$this->dname}";  
669 - return false;  
670 - }  
671 - }  
672 -  
673 - /**  
674 - * Attempts to drop table  
675 - *  
676 - * @author KnowledgeTree Team  
677 - * @access private  
678 - * @params mysql connection object $con  
679 - * @return boolean  
680 - */  
681 - private function dropdb($con) {  
682 - if($this->ddrop) {  
683 - $sql = "DROP DATABASE {$this->dname};";  
684 - if(!$this->_dbhandler->query($sql)) {  
685 - $this->error['con'] = "Cannot drop database: {$this->dname}";  
686 - return false;  
687 - }  
688 - } else {  
689 - $this->error['con'] = "Cannot drop database: {$this->dname}";  
690 - return false;  
691 - }  
692 - return true;  
693 - }  
694 -  
695 - /**  
696 - * Create dms user  
697 - *  
698 - * @author KnowledgeTree Team  
699 - * @access private  
700 - * @params none  
701 - * @return boolean  
702 - */  
703 - private function createDmsUser($con) {  
704 - if($this->dmsname == '' || $this->dmspassword == '') {  
705 - if($this->dpassword == '') {  
706 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."user.sql\"";  
707 - } else {  
708 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."user.sql\"";  
709 - }  
710 - $response = $this->_util->pexec($command);  
711 - return $response;  
712 - } else {  
713 - $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";";  
714 - $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";";  
715 - if ($this->_dbhandler->execute($user1) && $this->_dbhandler->execute($user2)) {  
716 - return true;  
717 - } else {  
718 - $this->error['con'] = "Could not create users for database: {$this->dname}";  
719 - return false;  
720 - }  
721 - }  
722 -  
723 - }  
724 -  
725 - /**  
726 - * Create schema  
727 - *  
728 - * @author KnowledgeTree Team  
729 - * @access private  
730 - * @params none  
731 - * @return boolean  
732 - */  
733 - private function createSchema($con) {  
734 - if($this->dpassword == '') {  
735 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."structure.sql\"";  
736 - } else {  
737 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."structure.sql\"";  
738 - }  
739 - $response = $this->_util->pexec($command);  
740 - return $response;  
741 - }  
742 -  
743 - /**  
744 - * Populate database  
745 - *  
746 - * @author KnowledgeTree Team  
747 - * @access private  
748 - * @params none  
749 - * @return boolean  
750 - */  
751 - private function populateSchema($con) {  
752 - if($this->dpassword == '') {  
753 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."data.sql\"";  
754 - } else {  
755 - $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."data.sql\"";  
756 - }  
757 - $response = $this->_util->pexec($command);  
758 - return $response;  
759 - }  
760 -  
761 - /**  
762 - * Ammend any known database upgrades  
763 - *  
764 - * @author KnowledgeTree Team  
765 - * @access private  
766 - * @params none  
767 - * @return boolean  
768 - */  
769 - private function applyUpgrades($con) {  
770 - // Database upgrade to version 3.6.1: Search ranking  
771 - return true;  
772 - }  
773 -  
774 - /**  
775 - * Close connection if it exists  
776 - *  
777 - * @author KnowledgeTree Team  
778 - * @access private  
779 - * @params mysql connection object $con  
780 - * @return void  
781 - */  
782 - private function closeMysql($con) {  
783 - try {  
784 - $this->_dbhandler->close();  
785 - } catch (Exeption $e) {  
786 - $this->error['con'] = "Could not close: " . $e;  
787 - }  
788 - }  
789 -  
790 - /**  
791 - * Returns database errors  
792 - *  
793 - * @author KnowledgeTree Team  
794 - * @access public  
795 - * @params none  
796 - * @return array  
797 - */  
798 - public function getErrors() {  
799 -  
800 - return $this->error;  
801 - }  
802 -  
803 - /**  
804 - * Test database connectivity  
805 - *  
806 - * @author KnowledgeTree Team  
807 - * @param none  
808 - * @access public  
809 - * @return boolean  
810 - */  
811 - public function doAjaxTest($host, $uname, $dname) {  
812 -  
813 - }  
814 -  
815 - /**  
816 - * Initialize errors to false  
817 - *  
818 - * @author KnowledgeTree Team  
819 - * @param none  
820 - * @access private  
821 - * @return boolean  
822 - */  
823 - private function initErrors() {  
824 - foreach ($this->templateErrors as $e) {  
825 - $this->error[$e] = false;  
826 - }  
827 - }  
828 -} 1 +<?php
  2 +/**
  3 +* Database 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 +
  43 +class database extends Step
  44 +{
  45 + /**
  46 + * Reference to Database object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + * @var object
  51 + */
  52 + public $_dbhandler = null;
  53 +
  54 + /**
  55 + * Reference to Database object
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access public
  59 + * @var object
  60 + */
  61 + public $_util = null;
  62 +
  63 + /**
  64 + * Database type
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access private
  68 + * @var array
  69 + */
  70 + private $dtype = '';
  71 +
  72 + /**
  73 + * Database types
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access private
  77 + * @var array
  78 + */
  79 + private $dtypes = array();
  80 +
  81 + /**
  82 + * Database host
  83 + *
  84 + * @author KnowledgeTree Team
  85 + * @access private
  86 + * @var string
  87 + */
  88 + private $dhost = '';
  89 +
  90 + /**
  91 + * Database port
  92 + *
  93 + * @author KnowledgeTree Team
  94 + * @access private
  95 + * @var string
  96 + */
  97 + private $dport = '';
  98 +
  99 + /**
  100 + * Database name
  101 + *
  102 + * @author KnowledgeTree Team
  103 + * @access private
  104 + * @var string
  105 + */
  106 + private $dname = '';
  107 +
  108 + /**
  109 + * Database root username
  110 + *
  111 + * @author KnowledgeTree Team
  112 + * @access private
  113 + * @var string
  114 + */
  115 + private $duname = '';
  116 +
  117 + /**
  118 + * Database root password
  119 + *
  120 + * @author KnowledgeTree Team
  121 + * @access private
  122 + * @var string
  123 + */
  124 + private $dpassword = '';
  125 +
  126 + /**
  127 + * Database dms username
  128 + *
  129 + * @author KnowledgeTree Team
  130 + * @access private
  131 + * @var string
  132 + */
  133 + private $dmsname = '';
  134 +
  135 + /**
  136 + * Database dms password
  137 + *
  138 + * @author KnowledgeTree Team
  139 + * @access private
  140 + * @var string
  141 + */
  142 + private $dmspassword = '';
  143 +
  144 + /**
  145 + * Default dms user username
  146 + *
  147 + * @author KnowledgeTree Team
  148 + * @access private
  149 + * @var boolean
  150 + */
  151 + private $dmsusername = '';
  152 +
  153 + /**
  154 + * Default dms user password
  155 + *
  156 + * @author KnowledgeTree Team
  157 + * @access private
  158 + * @var boolean
  159 + */
  160 + private $dmsuserpassword = '';
  161 +
  162 + /**
  163 + * Location of database binaries.
  164 + *
  165 + * @author KnowledgeTree Team
  166 + * @access private
  167 + * @var string
  168 + */
  169 + private $mysqlDir; // TODO:multiple databases
  170 +
  171 + /**
  172 + * Name of database binary.
  173 + *
  174 + * @author KnowledgeTree Team
  175 + * @access private
  176 + * @var string
  177 + */
  178 + private $dbbinary = ''; // TODO:multiple databases
  179 +
  180 + /**
  181 + * Database table prefix
  182 + *
  183 + * @author KnowledgeTree Team
  184 + * @access private
  185 + * @var string
  186 + */
  187 + private $tprefix = '';
  188 +
  189 + /**
  190 + * Flag to drop database
  191 + *
  192 + * @author KnowledgeTree Team
  193 + * @access private
  194 + * @var boolean
  195 + */
  196 + private $ddrop = false;
  197 +
  198 + /**
  199 + * List of errors encountered
  200 + *
  201 + * @author KnowledgeTree Team
  202 + * @access public
  203 + * @var array
  204 + */
  205 + public $error = array();
  206 +
  207 + /**
  208 + * List of errors used in template
  209 + *
  210 + * @author KnowledgeTree Team
  211 + * @access public
  212 + * @var array
  213 + */
  214 + public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');
  215 +
  216 + /**
  217 + * Flag to store class information in session
  218 + *
  219 + * @author KnowledgeTree Team
  220 + * @access public
  221 + * @var array
  222 + */
  223 + public $storeInSession = true;
  224 +
  225 + /**
  226 + * Flag if step needs to be installed
  227 + *
  228 + * @author KnowledgeTree Team
  229 + * @access public
  230 + * @var array
  231 + */
  232 + protected $runInstall = true;
  233 +
  234 + /**
  235 + * Flag if step needs to run silently
  236 + *
  237 + * @author KnowledgeTree Team
  238 + * @access public
  239 + * @var array
  240 + */
  241 + protected $silent = true;
  242 +
  243 + private $salt = 'install';
  244 +
  245 + /**
  246 + * Constructs database object
  247 + *
  248 + * @author KnowledgeTree Team
  249 + * @access public
  250 + * @param none
  251 + */
  252 + public function __construct() {
  253 + $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent);
  254 + $this->_dbhandler = new dbUtil();
  255 + $this->_util = new InstallUtil();
  256 + if(WINDOWS_OS)
  257 + $this->mysqlDir = MYSQL_BIN;
  258 + }
  259 +
  260 + /**
  261 + * Main control of database setup
  262 + *
  263 + * @author KnowledgeTree Team
  264 + * @param none
  265 + * @access public
  266 + * @return string
  267 + */
  268 + public function doStep() {
  269 + $this->setErrorsFromSession();
  270 + $this->initErrors(); // Load template errors
  271 + if($this->inStep("database")) {
  272 + $res = $this->doProcess();
  273 + if($res) { // If theres a response, return it
  274 + return $res;
  275 + }
  276 + }
  277 + if($this->setDataFromSession("database")) { // Attempt to set values from session
  278 + $this->setDetails(); // Set any posted variables
  279 + } else {
  280 + $this->temp_variables['state'] = '';
  281 + $this->loadDefaults($this->readXml()); // Load default variables from file
  282 + }
  283 +
  284 + return 'landing';
  285 + }
  286 +
  287 + /**
  288 + * Controls setup helper
  289 + *
  290 + * @author KnowledgeTree Team
  291 + * @param none
  292 + * @access public
  293 + * @return string
  294 + */
  295 + public function doProcess() {
  296 + if($this->next()) {
  297 + $this->setPostConfig(); // Set any posted variables
  298 + $this->setDetails();
  299 + if($this->doTest()) { // Test
  300 + return 'confirm';
  301 + } else {
  302 + return 'error';
  303 + }
  304 + } else if($this->previous()) {
  305 + return 'previous';
  306 + } else if($this->confirm()) {
  307 + $this->setDataFromSession("database"); // Set Session Information
  308 + $this->setPostConfig(); // Set any posted variables
  309 + return 'next';
  310 + } else if($this->edit()) {
  311 + $this->setDataFromSession("database"); // Set Session Information, since its an edit
  312 + $this->temp_variables['state'] = 'edit';
  313 +
  314 + return 'landing';
  315 + }
  316 + }
  317 +
  318 + /**
  319 + * Test database connectivity
  320 + *
  321 + * @author KnowledgeTree Team
  322 + * @param none
  323 + * @access public
  324 + * @return boolean
  325 + */
  326 + public function doTest() {
  327 + if($this->match($this->dmspassword, $this->getPassword1()) != 0) {
  328 + $this->error['dmspassword'] = "Passwords do not match: " . $this->dmspassword." ". $this->getPassword1();
  329 + return false;
  330 + }
  331 + if($this->match($this->dmsuserpassword, $this->getPassword2()) != 0) {
  332 + $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2();
  333 + return false;
  334 + }
  335 + if($this->dport == '') {
  336 + $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
  337 + } else {
  338 + $con = $this->_dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname);
  339 + }
  340 + if (!$con) {
  341 + $this->error['con'] = "Could not connect to the database, please check username and password";
  342 + return false;
  343 + } else {
  344 + if ($this->dbExists()) { // Check if database Exists
  345 + $this->error['dname'] = 'Database Already Exists, please specify a different name'; // Reset usage errors
  346 + return false;
  347 + } else {
  348 + $this->error = array(); // Reset usage errors
  349 + return true;
  350 + }
  351 + }
  352 + }
  353 +
  354 + public function dbExists() {
  355 + return $this->_dbhandler->useDb();
  356 + }
  357 +
  358 + public function match($str1, $str2) {
  359 + return strcmp($str1, $str2);
  360 + }
  361 +
  362 + public function getPassword1() {
  363 + return $_POST['dmspassword2'];
  364 + }
  365 +
  366 + public function getPassword2() {
  367 + return $_POST['dmsuserpassword2'];
  368 + }
  369 + /**
  370 + * Check if theres a database type
  371 + *
  372 + * @author KnowledgeTree Team
  373 + * @params none
  374 + * @access private
  375 + * @return boolean database type or false
  376 + */
  377 + private function getType() {
  378 + if(isset($_POST['dtype'])) {
  379 + return $_POST['dtype'];
  380 + }
  381 +
  382 + return false;
  383 + }
  384 +
  385 + /**
  386 + * Set Errors if any were encountered
  387 + *
  388 + * @author KnowledgeTree Team
  389 + * @params none
  390 + * @access private
  391 + * @return boolean
  392 + */
  393 + private function setErrorsFromSession() {
  394 + if(isset($_SESSION[$this->salt]['database']['errors'])) {
  395 + $this->error[] = $_SESSION[$this->salt]['database']['errors'];
  396 +
  397 + return true;
  398 + }
  399 +
  400 + return false;
  401 + }
  402 +
  403 + /**
  404 + * Set POST information
  405 + *
  406 + * @author KnowledgeTree Team
  407 + * @params none
  408 + * @access public
  409 + * @return void
  410 + */
  411 + public function setPostConfig() {
  412 + $this->dtype = $this->getPostSafe("dtype");
  413 + $this->dtypes = array("0"=>"mysql"); // TODO:multiple databases
  414 + $this->dhost = $this->getPostSafe("dhost");
  415 + $this->dport = $this->getPostSafe("dport");
  416 + $this->dname = $this->getPostSafe("dname");
  417 + $this->duname = $this->getPostSafe("duname");
  418 + $this->dpassword = $this->getPostSafe("dpassword");
  419 + $this->dmsname = $this->getPostSafe("dmsname");
  420 + $this->dmsusername = $this->getPostSafe("dmsusername");
  421 + $this->dmspassword = $this->getPostSafe("dmspassword");
  422 + $this->dmsuserpassword = $this->getPostSafe("dmsuserpassword");
  423 + $this->dbbinary = $this->getPostSafe("dbbinary");
  424 + $this->tprefix = $this->getPostSafe("tprefix");
  425 + $this->ddrop = $this->getPostBoolean("ddrop");
  426 + }
  427 +
  428 + /**
  429 + * Load default options on template from xml file
  430 + *
  431 + * @author KnowledgeTree Team
  432 + * @params object SimpleXmlObject
  433 + * @access public
  434 + * @return void
  435 + */
  436 + public function loadDefaults($simplexml) {
  437 + if($simplexml) {
  438 + $this->temp_variables['dtype'] = "";
  439 + $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases
  440 + $this->temp_variables['dname'] = (string) $simplexml->dname;
  441 + $this->temp_variables['duname'] = (string) $simplexml->duname;
  442 + $this->temp_variables['dhost'] = (string) $simplexml->dhost;
  443 + $this->temp_variables['dport'] = (string) $simplexml->dport;
  444 + $this->temp_variables['dpassword'] = '';
  445 + $this->temp_variables['dmsname'] = (string) $simplexml->dmsadminuser;
  446 + $this->temp_variables['dmsusername'] = (string) $simplexml->dmsuser;
  447 + $this->temp_variables['dmspassword'] = (string) $simplexml->dmsaupass;
  448 + $this->temp_variables['dmsuserpassword'] = (string) $simplexml->dmsupass;
  449 + if(WINDOWS_OS) {
  450 + $this->temp_variables['dbbinary'] = 'mysql.exe';
  451 + } else {
  452 + $this->temp_variables['dbbinary'] = 'mysql';
  453 + }
  454 + $this->temp_variables['tprefix'] = '';
  455 + $this->temp_variables['ddrop'] = false;
  456 + }
  457 + }
  458 +
  459 + /**
  460 + * Store options
  461 + *
  462 + * @author KnowledgeTree Team
  463 + * @params object SimpleXmlObject
  464 + * @access private
  465 + * @return void
  466 + */
  467 + private function setDetails() {
  468 + if($this->edit()) {
  469 + $this->temp_variables['state'] = 'edit';
  470 + } else {
  471 + $this->temp_variables['state'] = '';
  472 + }
  473 + $this->temp_variables['dtype'] = $this->getPostSafe('dtype');
  474 + $this->temp_variables['dtypes'] = array("0"=>"mysql"); // TODO:multiple databases;
  475 + $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
  476 + $this->temp_variables['dport'] = $this->getPostSafe('dport');
  477 + $this->temp_variables['dname'] = $this->getPostSafe('dname');
  478 + $this->temp_variables['duname'] = $this->getPostSafe('duname');
  479 + $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');
  480 + $this->temp_variables['dmsname'] = $this->getPostSafe('dmsname');
  481 + $this->temp_variables['dmsusername'] = $this->getPostSafe('dmsusername');
  482 + $this->temp_variables['dmspassword'] = $this->getPostSafe('dmspassword');
  483 + $this->temp_variables['dmsuserpassword'] = $this->getPostSafe('dmsuserpassword');;
  484 + $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary');
  485 + $this->temp_variables['tprefix'] = $this->getPostSafe('tprefix');
  486 + $this->temp_variables['ddrop'] = $this->getPostBoolean('ddrop');
  487 + }
  488 +
  489 + /**
  490 + * Extract database types
  491 + *
  492 + * @author KnowledgeTree Team
  493 + * @access private
  494 + * @params object SimpleXmlObject
  495 + * @return array
  496 + */
  497 + private function getTypes($xmlTypes) {
  498 + $t = array();
  499 + foreach ($xmlTypes->dtype as $key=>$val) {
  500 + $t[] = (string) $val;
  501 + }
  502 + return $t;
  503 + }
  504 +
  505 + /**
  506 + * Read xml config file
  507 + *
  508 + * @author KnowledgeTree Team
  509 + * @access private
  510 + * @params none
  511 + * @return object SimpleXmlObject
  512 + */
  513 + private function readXml() {
  514 + $simplexml = simplexml_load_file(CONF_DIR."databases.xml");
  515 +
  516 + return $simplexml;
  517 + }
  518 +
  519 + /**
  520 + * Stores varibles used by template
  521 + *
  522 + * @author KnowledgeTree Team
  523 + * @params none
  524 + * @access public
  525 + * @return array
  526 + */
  527 + public function getStepVars() {
  528 + return $this->temp_variables;
  529 + }
  530 +
  531 + /**
  532 + * Runs step install if required
  533 + *
  534 + * @author KnowledgeTree Team
  535 + * @param none
  536 + * @access public
  537 + * @return void
  538 + */
  539 + public function installStep() {
  540 + return $this->installDatabase();
  541 + }
  542 +
  543 + /**
  544 + * Helper
  545 + *
  546 + * @author KnowledgeTree Team
  547 + * @params none
  548 + * @access private
  549 + * @return void
  550 + */
  551 + private function installDatabase() {
  552 + if($this->dtype == '') {
  553 + $this->error['dtype'] = 'No database type selected';
  554 + return 'error';
  555 + }
  556 + if(!$this->{$this->dtype}()) {
  557 + return 'error';
  558 + }
  559 + }
  560 +
  561 + /**
  562 + * Helper
  563 + *
  564 + * @author KnowledgeTree Team
  565 + * @params none
  566 + * @access private
  567 + * @return void
  568 + */
  569 + private function mysql() {
  570 + $con = $this->connectMysql();
  571 + if($con) {
  572 + if(!$this->createDB($con)) {
  573 + $this->error['con'] = "Could not Create Database: ";
  574 + return false;
  575 + }
  576 + $this->closeMysql($con);
  577 + }
  578 + }
  579 +
  580 + /**
  581 + * Connect to mysql
  582 + *
  583 + * @author KnowledgeTree Team
  584 + * @params none
  585 + * @access private
  586 + * @return object mysql connection
  587 + */
  588 + private function connectMysql() {
  589 + $con = $this->_dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
  590 + if (!$con) {
  591 + $this->error['con'] = "Could not connect: ";
  592 +
  593 + return false;
  594 + }
  595 +
  596 + return $con;
  597 + }
  598 +
  599 + /**
  600 + * Helper
  601 + *
  602 + * @author KnowledgeTree Team
  603 + * @params object mysql connection object $con
  604 + * @access private
  605 + * @return object mysql connection
  606 + */
  607 + private function createDB($con) {
  608 + if($this->usedb($con)) { // attempt to use the db
  609 + if($this->dropdb($con)) { // attempt to drop the db
  610 + if(!$this->create($con)) { // attempt to create the db
  611 + $this->error['con'] = "Could not create database: ";
  612 + return false;// cannot overwrite database
  613 + }
  614 + } else {
  615 + $this->error['con'] = "Could not drop database: ";
  616 + return false;// cannot overwrite database
  617 + }
  618 + } else {
  619 + if(!$this->create($con)) { // attempt to create the db
  620 + $this->error['con'] = "Could not create database: ";
  621 + return false;// cannot overwrite database
  622 + }
  623 + }
  624 + if(!$this->createDmsUser($con)) {
  625 +
  626 + }
  627 + if(!$this->createSchema($con)) {
  628 + $this->error['con'] = "Could not create schema ";
  629 + }
  630 + if(!$this->populateSchema($con)) {
  631 + $this->error['con'] = "Could not populate schema ";
  632 + }
  633 + if(!$this->applyUpgrades($con)) {
  634 + $this->error['con'] = "Could not apply updates ";
  635 + }
  636 +
  637 + return true;
  638 + }
  639 +
  640 + /**
  641 + * Create database
  642 + *
  643 + * @author KnowledgeTree Team
  644 + * @params object mysql connection object $con
  645 + * @access private
  646 + * @return boolean
  647 + */
  648 + private function create($con) {
  649 + $sql = "CREATE DATABASE {$this->dname}";
  650 + if ($this->_dbhandler->query($sql, $con)) {
  651 +
  652 + return true;
  653 + }
  654 +
  655 + return false;
  656 + }
  657 +
  658 + /**
  659 + * Attempts to use a db
  660 + *
  661 + * @author KnowledgeTree Team
  662 + * @params mysql connection object $con
  663 + * @access private
  664 + * @return boolean
  665 + */
  666 + private function usedb($con) {
  667 + if($this->_dbhandler->useDb($this->dname)) {
  668 + return true;
  669 + } else {
  670 + $this->error['con'] = "Error using database: {$this->dname}";
  671 + return false;
  672 + }
  673 + }
  674 +
  675 + /**
  676 + * Attempts to drop table
  677 + *
  678 + * @author KnowledgeTree Team
  679 + * @access private
  680 + * @params mysql connection object $con
  681 + * @return boolean
  682 + */
  683 + private function dropdb($con) {
  684 + if($this->ddrop) {
  685 + $sql = "DROP DATABASE {$this->dname};";
  686 + if(!$this->_dbhandler->query($sql)) {
  687 + $this->error['con'] = "Cannot drop database: {$this->dname}";
  688 + return false;
  689 + }
  690 + } else {
  691 + $this->error['con'] = "Cannot drop database: {$this->dname}";
  692 + return false;
  693 + }
  694 + return true;
  695 + }
  696 +
  697 + /**
  698 + * Create dms user
  699 + *
  700 + * @author KnowledgeTree Team
  701 + * @access private
  702 + * @params none
  703 + * @return boolean
  704 + */
  705 + private function createDmsUser($con) {
  706 + if($this->dmsname == '' || $this->dmspassword == '') {
  707 + if($this->dpassword == '') {
  708 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."user.sql\"";
  709 + } else {
  710 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."user.sql\"";
  711 + }
  712 + $response = $this->_util->pexec($command);
  713 + return $response;
  714 + } else {
  715 + $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";";
  716 + $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";";
  717 + if ($this->_dbhandler->execute($user1) && $this->_dbhandler->execute($user2)) {
  718 + return true;
  719 + } else {
  720 + $this->error['con'] = "Could not create users for database: {$this->dname}";
  721 + return false;
  722 + }
  723 + }
  724 +
  725 + }
  726 +
  727 + /**
  728 + * Create schema
  729 + *
  730 + * @author KnowledgeTree Team
  731 + * @access private
  732 + * @params none
  733 + * @return boolean
  734 + */
  735 + private function createSchema($con) {
  736 + if($this->dpassword == '') {
  737 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."structure.sql\"";
  738 + } else {
  739 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."structure.sql\"";
  740 + }
  741 + $response = $this->_util->pexec($command);
  742 + return $response;
  743 + }
  744 +
  745 + /**
  746 + * Populate database
  747 + *
  748 + * @author KnowledgeTree Team
  749 + * @access private
  750 + * @params none
  751 + * @return boolean
  752 + */
  753 + private function populateSchema($con) {
  754 + if($this->dpassword == '') {
  755 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} {$this->dname} < \"".SQL_DIR."data.sql\"";
  756 + } else {
  757 + $command = "\"".$this->mysqlDir."{$this->dbbinary}\" -u{$this->duname} -p{$this->dpassword} {$this->dname} < \"".SQL_DIR."data.sql\"";
  758 + }
  759 + $response = $this->_util->pexec($command);
  760 + return $response;
  761 + }
  762 +
  763 + /**
  764 + * Ammend any known database upgrades
  765 + *
  766 + * @author KnowledgeTree Team
  767 + * @access private
  768 + * @params none
  769 + * @return boolean
  770 + */
  771 + private function applyUpgrades($con) {
  772 + // Database upgrade to version 3.6.1: Search ranking
  773 + return true;
  774 + }
  775 +
  776 + /**
  777 + * Close connection if it exists
  778 + *
  779 + * @author KnowledgeTree Team
  780 + * @access private
  781 + * @params mysql connection object $con
  782 + * @return void
  783 + */
  784 + private function closeMysql($con) {
  785 + try {
  786 + $this->_dbhandler->close();
  787 + } catch (Exeption $e) {
  788 + $this->error['con'] = "Could not close: " . $e;
  789 + }
  790 + }
  791 +
  792 + /**
  793 + * Returns database errors
  794 + *
  795 + * @author KnowledgeTree Team
  796 + * @access public
  797 + * @params none
  798 + * @return array
  799 + */
  800 + public function getErrors() {
  801 +
  802 + return $this->error;
  803 + }
  804 +
  805 + /**
  806 + * Test database connectivity
  807 + *
  808 + * @author KnowledgeTree Team
  809 + * @param none
  810 + * @access public
  811 + * @return boolean
  812 + */
  813 + public function doAjaxTest($host, $uname, $dname) {
  814 +
  815 + }
  816 +
  817 + /**
  818 + * Initialize errors to false
  819 + *
  820 + * @author KnowledgeTree Team
  821 + * @param none
  822 + * @access private
  823 + * @return boolean
  824 + */
  825 + private function initErrors() {
  826 + foreach ($this->templateErrors as $e) {
  827 + $this->error[$e] = false;
  828 + }
  829 + }
  830 +}
829 ?> 831 ?>
830 \ No newline at end of file 832 \ No newline at end of file
setup/wizard/steps/services.php
1 -<?php  
2 -/**  
3 -* Services 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 -  
43 -if(isset($_GET['action'])) {  
44 - $func = $_GET['action'];  
45 - if($func != '') {  
46 - require_once("../step.php");  
47 - require_once("../installUtil.php");  
48 - require_once("../path.php");  
49 - }  
50 -}  
51 -  
52 -class services extends Step  
53 -{  
54 - /**  
55 - * List of errors encountered  
56 - *  
57 - * @author KnowledgeTree Team  
58 - * @access protected  
59 - * @var array  
60 - */  
61 - protected $error = array();  
62 -  
63 - /**  
64 - * Flag if step needs to be installed  
65 - *  
66 - * @author KnowledgeTree Team  
67 - * @access protected  
68 - * @var array  
69 - */  
70 - protected $runInstall = true;  
71 -  
72 - /**  
73 - * List of services to be installed  
74 - *  
75 - * @author KnowledgeTree Team  
76 - * @access private  
77 - * @var array  
78 - */  
79 - private $services = array('Lucene', 'Scheduler', 'OpenOffice');  
80 -  
81 - /**  
82 - * Path to php executable  
83 - *  
84 - * @author KnowledgeTree Team  
85 - * @access protected  
86 - * @var string  
87 - */  
88 - protected $php;  
89 -  
90 - /**  
91 - * Flag if php already provided  
92 - *  
93 - * @author KnowledgeTree Team  
94 - * @access private  
95 - * @var mixed  
96 - */  
97 - public $providedPhp = false;  
98 -  
99 - /**  
100 - * PHP Installed  
101 - *  
102 - * @author KnowledgeTree Team  
103 - * @access private  
104 - * @var mixed  
105 - */  
106 - private $phpCheck = 'cross_orange';  
107 -  
108 - /**  
109 - * Flag, if php is specified and an error has been encountered  
110 - *  
111 - * @author KnowledgeTree Team  
112 - * @access public  
113 - * @var boolean  
114 - */  
115 - private $phpExeError = false;  
116 -  
117 - /**  
118 - * Holds path error, if php is specified  
119 - *  
120 - * @author KnowledgeTree Team  
121 - * @access public  
122 - * @var string  
123 - */  
124 - private $phpExeMessage = '';  
125 -  
126 - /**  
127 - * Path to open office executable  
128 - *  
129 - * @author KnowledgeTree Team  
130 - * @access protected  
131 - * @var string  
132 - */  
133 - protected $soffice;  
134 -  
135 - /**  
136 - * Flag if open office already provided  
137 - *  
138 - * @author KnowledgeTree Team  
139 - * @access private  
140 - * @var mixed  
141 - */  
142 - public $providedOpenOffice = false;  
143 -  
144 - /**  
145 - * Flag, if open office is specified and an error has been encountered  
146 - *  
147 - * @author KnowledgeTree Team  
148 - * @access public  
149 - * @var boolean  
150 - */  
151 - private $openOfficeExeError = false;  
152 -  
153 - /**  
154 - * Holds path error, if open office is specified  
155 - *  
156 - * @author KnowledgeTree Team  
157 - * @access public  
158 - * @var string  
159 - */  
160 - private $openOfficeExeMessage = '';  
161 -  
162 - /**  
163 - * Path to java executable  
164 - *  
165 - * @author KnowledgeTree Team  
166 - * @access protected  
167 - * @var string  
168 - */  
169 - protected $java = "";  
170 -  
171 - /**  
172 - * Minumum Java Version  
173 - *  
174 - * @author KnowledgeTree Team  
175 - * @access protected  
176 - * @var string  
177 - */  
178 - private $javaVersion = '1.5';  
179 -  
180 - /**  
181 - * Java Installed  
182 - *  
183 - * @author KnowledgeTree Team  
184 - * @access private  
185 - * @var mixed  
186 - */  
187 - private $javaCheck = 'cross';  
188 -  
189 - /**  
190 - * Open Office Installed  
191 - *  
192 - * @author KnowledgeTree Team  
193 - * @access private  
194 - * @var mixed  
195 - */  
196 - private $openOfficeCheck = 'cross';  
197 -  
198 - /**  
199 - * Flag if java already provided  
200 - *  
201 - * @author KnowledgeTree Team  
202 - * @access private  
203 - * @var mixed  
204 - */  
205 - public $providedJava = false;  
206 -  
207 - /**  
208 - * Java Bridge Installed  
209 - *  
210 - * @author KnowledgeTree Team  
211 - * @access private  
212 - * @var mixed  
213 - */  
214 - private $javaExtCheck = 'cross_orange';  
215 -  
216 - /**  
217 - * Flag if bridge extension needs to be disabled  
218 - *  
219 - * @author KnowledgeTree Team  
220 - * @access public  
221 - * @var boolean  
222 - */  
223 - private $disableExtension = false;  
224 -  
225 - /**  
226 - * Flag, if java is specified and an error has been encountered  
227 - *  
228 - * @author KnowledgeTree Team  
229 - * @access public  
230 - * @var booelean  
231 - */  
232 - private $javaExeError = false;  
233 -  
234 - /**  
235 - * Holds path error, if java is specified  
236 - *  
237 - * @author KnowledgeTree Team  
238 - * @access public  
239 - * @var string  
240 - */  
241 - private $javaExeMessage = '';  
242 -  
243 - /**  
244 - * Flag if services are already Installed  
245 - *  
246 - * @author KnowledgeTree Team  
247 - * @access private  
248 - * @var mixed  
249 - */  
250 - private $alreadyInstalled = false;  
251 -  
252 - /**  
253 - * Flag if services are already Installed  
254 - *  
255 - * @author KnowledgeTree Team  
256 - * @access private  
257 - * @var mixed  
258 - */  
259 - private $luceneInstalled = false;  
260 -  
261 - /**  
262 - * Flag if services are already Installed  
263 - *  
264 - * @author KnowledgeTree Team  
265 - * @access private  
266 - * @var mixed  
267 - */  
268 - private $schedulerInstalled = false;  
269 -  
270 - /**  
271 - * Path to php executable  
272 - *  
273 - * @author KnowledgeTree Team  
274 - * @access protected  
275 - * @var string  
276 - */  
277 - private $openOfficeInstalled;  
278 -  
279 - /**  
280 - * Service Installed  
281 - *  
282 - * @author KnowledgeTree Team  
283 - * @access private  
284 - * @var array  
285 - */  
286 - private $serviceCheck = 'tick';  
287 -  
288 - /**  
289 - * Flag to store class information in session  
290 - *  
291 - * @author KnowledgeTree Team  
292 - * @access public  
293 - * @var boolean  
294 - */  
295 - protected $storeInSession = true;  
296 -  
297 - /**  
298 - * List of variables to be loaded to template  
299 - *  
300 - * @author KnowledgeTree Team  
301 - * @access public  
302 - * @var array  
303 - */  
304 - protected $temp_variables;  
305 -  
306 - /**  
307 - * Flag if step needs to run silently  
308 - *  
309 - * @author KnowledgeTree Team  
310 - * @access public  
311 - * @var array  
312 - */  
313 - protected $silent = true;  
314 -  
315 - /**  
316 - * Reference to utility object  
317 - *  
318 - * @author KnowledgeTree Team  
319 - * @access protected  
320 - * @var string  
321 - */  
322 - protected $util;  
323 -  
324 - /**  
325 - * Constructs services object  
326 - *  
327 - * @author KnowledgeTree Team  
328 - * @access public  
329 - * @param none  
330 - */  
331 - public function __construct() {  
332 - $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent);  
333 - $this->util = new InstallUtil();  
334 - }  
335 -  
336 - /**  
337 - * Main control of services setup  
338 - *  
339 - * @author KnowledgeTree Team  
340 - * @param none  
341 - * @access public  
342 - * @return string  
343 - */  
344 - public function doStep()  
345 - {  
346 - if(!$this->inStep("services")) {  
347 - $this->doRun();  
348 - return 'landing';  
349 - }  
350 - if($this->next()) {  
351 - // Check dependencies  
352 - $passed = $this->doRun();  
353 - $serv = $this->getDataFromSession("services");  
354 - if($passed || $serv['providedJava'])  
355 - return 'next';  
356 - else  
357 - return 'error';  
358 - } else if($this->previous()) {  
359 - return 'previous';  
360 - }  
361 - $passed = $this->doRun();  
362 - return 'landing';  
363 - }  
364 -  
365 - /**  
366 - * Get service names  
367 - *  
368 - * @author KnowledgeTree Team  
369 - * @param none  
370 - * @access public  
371 - * @return array  
372 - */  
373 - public function getServices() {  
374 - return $this->services;  
375 - }  
376 -  
377 - /**  
378 - * Check if java executable was found  
379 - *  
380 - * @author KnowledgeTree Team  
381 - * @param none  
382 - * @access private  
383 - * @return array  
384 - */  
385 - private function setJava() {  
386 - if($this->java != '') { // Java JRE Found  
387 - $this->javaCheck = 'tick';  
388 - $this->javaInstalled();  
389 - $this->temp_variables['java']['location'] = $this->java;  
390 - }  
391 - }  
392 -  
393 - /**  
394 - * Run step  
395 - *  
396 - * @author KnowledgeTree Team  
397 - * @param none  
398 - * @access private  
399 - * @return boolean  
400 - */  
401 - private function doRun() {  
402 - if($this->alreadyInstalled()) {  
403 - $this->alreadyInstalled = true;  
404 - $this->serviceCheck = 'tick';  
405 - } else {  
406 - $this->presetJava();  
407 - $this->presetOpenOffice();  
408 - if(!$this->schedulerInstalled) {  
409 - $this->php = $this->util->getPhp(); // Get java, if it exists  
410 - $passedPhp = $this->phpChecks(); // Run Java Pre Checks  
411 - if ($passedPhp) { // Install Scheduler  
412 - $this->installService('Scheduler');  
413 - }  
414 - } else {  
415 - $this->schedulerInstalled();  
416 - }  
417 - if(!$this->luceneInstalled) {  
418 - $this->java = $this->util->getJava(); // Get java, if it exists  
419 - $passedJava = $this->javaChecks(); // Run Java Pre Checks  
420 - if ($passedJava) { // Install Lucene  
421 - $this->installService('Lucene');  
422 - }  
423 - } else {  
424 - $this->luceneInstalled();  
425 - }  
426 - if(!$this->openOfficeInstalled) {  
427 - $this->soffice = $this->util->getOpenOffice(); // Get java, if it exists  
428 - $passedOpenOffice = $this->openOfficeChecks(); // Run Java Pre Checks  
429 - if ($passedOpenOffice) { //Install OpenOffice  
430 -// $this->temp_variables['openOfficeExe'] = $this->soffice;  
431 - // TODO : Why, O, why?  
432 - $this->openOfficeExeError = false;  
433 - $_SESSION['services']['openOfficeExe'] = $this->soffice;  
434 - $this->installService('OpenOffice');  
435 - }  
436 - } else {  
437 - $this->openOfficeInstalled();  
438 - }  
439 - }  
440 - $this->checkServiceStatus();  
441 - $this->storeSilent(); // Store info needed for silent mode  
442 - if(!empty($errors))  
443 - return false;  
444 - return true;  
445 - }  
446 -  
447 - private function openOfficeInstalled() {  
448 -  
449 - }  
450 -  
451 - private function schedulerInstalled() {  
452 -  
453 - }  
454 -  
455 - private function luceneInstalled() {  
456 - $this->disableExtension = true; // Disable the use of the php bridge extension  
457 - $this->javaVersionCorrect();  
458 - $this->javaInstalled();  
459 - $this->javaCheck = 'tick';  
460 - }  
461 -  
462 - /**  
463 - * A final check to see if services are still running,  
464 - * incase they switched on and turned off.  
465 - *  
466 - * @author KnowledgeTree Team  
467 - * @param none  
468 - * @access private  
469 - * @return void  
470 - */  
471 - private function checkServiceStatus() {  
472 - $serverDetails = $this->getServices();  
473 - foreach ($serverDetails as $serviceName) {  
474 - $className = OS.$serviceName;  
475 - $service = new $className();  
476 - $service->load();  
477 - $status = $this->serviceInstalled($service);  
478 - if($status != 'STARTED') {  
479 - $msg = $service->getName()." Could not be added as a Service";  
480 - $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$msg);  
481 - $this->serviceCheck = 'cross_orange';  
482 - $this->warnings[] = $msg;  
483 - } else {  
484 - if(WINDOWS_OS) {  
485 - $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); }  
486 - else {  
487 - $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added and Started as a Service");  
488 - }  
489 - }  
490 - }  
491 - }  
492 -  
493 - /**  
494 - * Checks if all services have been started already,  
495 - * incase the user lands on service page multiple times  
496 - *  
497 - * @author KnowledgeTree Team  
498 - * @param none  
499 - * @access public  
500 - * @return boolean  
501 - */  
502 - public function alreadyInstalled() {  
503 - $allInstalled = true;  
504 - $serverDetails = $this->getServices();  
505 - foreach ($serverDetails as $serviceName) {  
506 - $className = OS.$serviceName;  
507 - $service = new $className();  
508 - $status = $this->serviceInstalled($service);  
509 - $flag = strtolower(substr($serviceName,0,1)).substr($serviceName,1)."Installed";  
510 - if(!$status) {  
511 - $allInstalled = false;  
512 - $this->$flag = false;  
513 - } else {  
514 - $this->$flag = true;  
515 - }  
516 - }  
517 -  
518 - return $allInstalled;  
519 - }  
520 -  
521 - private function presetJava() {  
522 - $this->zendBridgeNotInstalled(); // Set bridge not installed  
523 - $this->javaVersionInCorrect(); // Set version to incorrect  
524 - $this->javaNotInstalled(); // Set java to not installed  
525 - $this->setJava(); // Check if java has been auto detected  
526 - }  
527 -  
528 - private function presetOpenOffice() {  
529 - $this->specifyOpenOffice();  
530 - }  
531 -  
532 - private function setOpenOffice() {  
533 -  
534 - }  
535 - /**  
536 - * Do some basic checks to help the user overcome java problems  
537 - *  
538 - * @author KnowledgeTree Team  
539 - * @param none  
540 - * @access private  
541 - * @return boolean  
542 - */  
543 - private function javaChecks() {  
544 - if($this->util->javaSpecified()) {  
545 - $this->disableExtension = true; // Disable the use of the php bridge extension  
546 - if($this->detSettings(true)) { // AutoDetect java settings  
547 - return true;  
548 - } else {  
549 - $this->specifyJava(); // Ask for settings  
550 - }  
551 - } else {  
552 - $auto = $this->useBridge(); // Use Bridge to get java settings  
553 - if($auto) {  
554 - return $auto;  
555 - } else {  
556 - $auto = $this->useDetected(); // Check if auto detected java works  
557 - if($auto) {  
558 - $this->disableExtension = true; // Disable the use of the php bridge extension  
559 - return $auto;  
560 - } else {  
561 - $this->specifyJava(); // Ask for settings  
562 - }  
563 - }  
564 - return $auto;  
565 - }  
566 - }  
567 -  
568 - private function openOfficeChecks() {  
569 - if($this->util->openOfficeSpecified()) {  
570 - $this->soffice = $this->util->openOfficeSpecified();  
571 -  
572 - return true;  
573 - } else {  
574 - return false;  
575 - }  
576 - }  
577 -  
578 - /**  
579 - * Attempt detection without logging errors  
580 - *  
581 - * @author KnowledgeTree Team  
582 - * @param none  
583 - * @access private  
584 - * @return boolean  
585 - */  
586 - private function useDetected() {  
587 - return $this->detSettings();  
588 - }  
589 -  
590 - /**  
591 - * Set template view to specify java  
592 - *  
593 - * @author KnowledgeTree Team  
594 - * @param none  
595 - * @access private  
596 - * @return boolean  
597 - */  
598 - private function specifyJava() {  
599 - $this->javaExeError = true;  
600 - }  
601 -  
602 - /**  
603 - * Set template view to specify php  
604 - *  
605 - * @author KnowledgeTree Team  
606 - * @param none  
607 - * @access private  
608 - * @return boolean  
609 - */  
610 - private function specifyPhp() {  
611 - $this->phpExeError = true;  
612 - }  
613 -  
614 - /**  
615 - * Set template view to specify open office  
616 - *  
617 - * @author KnowledgeTree Team  
618 - * @param none  
619 - * @access private  
620 - * @return boolean  
621 - */  
622 - private function specifyOpenOffice() {  
623 - $this->openOfficeExeError = true;  
624 - }  
625 -  
626 - private function phpChecks() {  
627 - // TODO: Better detection  
628 - return true;  
629 - $this->setPhp();  
630 - if($this->util->phpSpecified()) {  
631 - return $this->detPhpSettings();  
632 - } else {  
633 - $this->specifyPhp();// Ask for settings  
634 - return false;  
635 - }  
636 - }  
637 -  
638 -  
639 -  
640 - /**  
641 - * Attempts to use user input and configure java settings  
642 - *  
643 - * @author KnowledgeTree Team  
644 - * @param none  
645 - * @access private  
646 - * @return boolean  
647 - */  
648 - private function detSettings($attempt = false) {  
649 - $javaExecutable = $this->util->javaSpecified();// Retrieve java bin  
650 - if($javaExecutable == '') {  
651 - if($this->java == '') {  
652 - return false;  
653 - }  
654 - $javaExecutable = $this->java;  
655 - }  
656 - $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!";  
657 - $response = $this->util->pexec($cmd);  
658 - if(file_exists(OUTPUT_DIR.'outJV')) {  
659 - $tmp = file_get_contents(OUTPUT_DIR.'outJV');  
660 - preg_match('/"(.*)"/',$tmp, $matches);  
661 - if($matches) {  
662 - if($matches[1] < $this->javaVersion) { // Check Version of java  
663 - $this->javaVersionInCorrect();  
664 - $this->javaCheck = 'cross';  
665 - $this->error[] = "Requires Java 1.5+ to be installed";  
666 -  
667 - return false;  
668 - } else {  
669 - $this->javaVersionCorrect();  
670 - $this->javaInstalled();  
671 - $this->javaCheck = 'tick';  
672 - $this->providedJava = true;  
673 -  
674 - return true;  
675 - }  
676 - } else {  
677 - $this->javaVersionWarning();  
678 - $this->javaCheck = 'cross_orange';  
679 - if($attempt) {  
680 - $this->javaExeMessage = "Incorrect java path specified";  
681 - $this->javaExeError = true;  
682 - $this->error[] = "Requires Java 1.5+ to be installed";  
683 - }  
684 -  
685 -  
686 - return false;  
687 - }  
688 - }  
689 -  
690 - $this->javaVersionInCorrect();  
691 - $this->javaCheck = 'cross';  
692 - $this->error[] = "Requires Java 1.5+ to be installed";  
693 - return false;  
694 - }  
695 -  
696 - function detPhpSettings() {  
697 - // TODO: Better php handling  
698 - return true;  
699 - $phpExecutable = $this->util->phpSpecified();// Retrieve java bin  
700 - $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!";  
701 - $response = $this->util->pexec($cmd);  
702 - if(file_exists(OUTPUT_DIR.'outPHP')) {  
703 - $tmp = file_get_contents(OUTPUT_DIR.'outPHP');  
704 - preg_match('/PHP/',$tmp, $matches);  
705 - if($matches) {  
706 - $this->phpCheck = 'tick';  
707 -  
708 - return true;  
709 - } else {  
710 - $this->phpCheck = 'cross_orange';  
711 - $this->phpExeError = "PHP : Incorrect path specified";  
712 - $this->error[] = "PHP executable required";  
713 -  
714 - return false;  
715 - }  
716 - }  
717 - }  
718 - /**  
719 - * Attempts to use bridge and configure java settings  
720 - *  
721 - * @author KnowledgeTree Team  
722 - * @param none  
723 - * @access private  
724 - * @return boolean  
725 - */  
726 - private function useBridge() {  
727 - $zendBridge = $this->util->zendBridge(); // Find Zend Bridge  
728 - if($zendBridge) { // Bridge installed implies java exists  
729 - $this->zendBridgeInstalled();  
730 - if($this->checkZendBridge()) { // Make sure the Zend Bridge is functional  
731 - $this->javaExtCheck = 'tick'; // Set bridge to functional  
732 - $this->javaInstalled(); // Set java to installed  
733 - $javaSystem = new Java('java.lang.System');  
734 - $version = $javaSystem->getProperty('java.version');  
735 - $ver = substr($version, 0, 3);  
736 - if($ver < $this->javaVersion) {  
737 - $this->javaVersionInCorrect();  
738 - $this->error[] = "Requires Java 1.5+ to be installed";  
739 - return false;  
740 - } else {  
741 - $this->javaVersionCorrect(); // Set version to correct  
742 - $this->javaCheck = 'tick';  
743 - return true;  
744 - }  
745 - } else {  
746 - $this->javaCheck = 'cross_orange';  
747 - $this->javaVersionWarning();  
748 - $this->zendBridgeWarning();  
749 - $this->warnings[] = "Zend Java Bridge Not Functional";  
750 - $this->javaExtCheck = 'cross_orange';  
751 - return false;  
752 - }  
753 - } else {  
754 - $this->warnings[] = "Zend Java Bridge Not Found";  
755 - return false;  
756 - }  
757 - }  
758 -  
759 - /**  
760 - * Check if Zend Bridge is functional  
761 - *  
762 - * @author KnowledgeTree Team  
763 - * @param none  
764 - * @access public  
765 - * @return boolean  
766 - */  
767 - public function checkZendBridge() {  
768 - if($this->util->javaBridge()) { // Check if java bridge is functional  
769 - return true;  
770 - } else {  
771 - return false;  
772 - }  
773 - }  
774 -  
775 -  
776 - /**  
777 - * Installs services  
778 - *  
779 - * @author KnowledgeTree Team  
780 - * @param none  
781 - * @access private  
782 - * @return boolean  
783 - */  
784 - private function installServices() {  
785 - foreach ($this->getServices() as $serviceName) {  
786 - $this->installService($serviceName);  
787 - }  
788 -  
789 - return true;  
790 - }  
791 -  
792 - /**  
793 - * Installs services helper  
794 - *  
795 - * @author KnowledgeTree Team  
796 - * @param none  
797 - * @access private  
798 - * @return boolean  
799 - */  
800 - private function installService($serviceName) {  
801 - $className = OS.$serviceName;  
802 - $service = new $className();  
803 - $status = $this->serviceHelper($service);  
804 - if (!$status) {  
805 - $this->serviceCheck = 'cross_orange';  
806 - }  
807 - }  
808 -  
809 - /**  
810 - * Installs services  
811 - *  
812 - * @author KnowledgeTree Team  
813 - * @param object  
814 - * @access private  
815 - * @return string  
816 - */  
817 - private function serviceHelper($service) {  
818 - $service->load(); // Load Defaults  
819 - $response = $service->install(); // Install service  
820 - $statusCheck = OS."ServiceInstalled";  
821 - return $this->$statusCheck($service);  
822 - }  
823 -  
824 - /**  
825 - * Helper to check if service is installed  
826 - *  
827 - * @author KnowledgeTree Team  
828 - * @param object  
829 - * @access public  
830 - * @return string  
831 - */  
832 - public function serviceInstalled($service) {  
833 - $statusCheck = OS."ServiceInstalled";  
834 - return $this->$statusCheck($service);  
835 - }  
836 -  
837 - /**  
838 - * Helper to check if service is started  
839 - *  
840 - * @author KnowledgeTree Team  
841 - * @param object  
842 - * @access public  
843 - * @return string  
844 - */  
845 - public function serviceStarted($service) {  
846 - $statusCheck = OS."ServiceStarted";  
847 - return $this->$statusCheck($service);  
848 - }  
849 -  
850 - /**  
851 - * Check if windows service installed  
852 - *  
853 - * @author KnowledgeTree Team  
854 - * @param object  
855 - * @access public  
856 - * @return boolean  
857 - */  
858 - public function windowsServiceStarted($service) {  
859 - $status = $service->status(); // Check if service has been installed  
860 - if($status != 'RUNNING') { // Check service status  
861 - return false;  
862 - }  
863 - return true;  
864 - }  
865 -  
866 - /**  
867 - * Check if unix service installed  
868 - *  
869 - * @author KnowledgeTree Team  
870 - * @param object  
871 - * @access public  
872 - * @return boolean  
873 - */  
874 - public function unixServiceStarted($service) {  
875 - $status = $service->status(); // Check if service has been installed  
876 - if($status != 'STARTED') { // Check service status  
877 - return false;  
878 - }  
879 - return true;  
880 - }  
881 -  
882 - /**  
883 - * Check if windows service installed  
884 - *  
885 - * @author KnowledgeTree Team  
886 - * @param object  
887 - * @access public  
888 - * @return boolean  
889 - */  
890 - public function windowsServiceInstalled($service) {  
891 - $status = $service->status(); // Check if service has been installed  
892 - if($status == '') { // Check service status  
893 - return false;  
894 - }  
895 - return true;  
896 - }  
897 -  
898 - /**  
899 - * Check if unix service installed  
900 - *  
901 - * @author KnowledgeTree Team  
902 - * @param object  
903 - * @access public  
904 - * @return boolean  
905 - */  
906 - public function unixServiceInstalled($service) {  
907 - $status = $service->status(); // Check if service has been installed  
908 - if($status != 'STARTED') { // Check service status  
909 - return false;  
910 - }  
911 - return true;  
912 - }  
913 -  
914 - /**  
915 - * Starts all services  
916 - *  
917 - * @author KnowledgeTree Team  
918 - * @param object  
919 - * @access public  
920 - * @return mixed  
921 - */  
922 - public function installStep() {  
923 - foreach ($this->getServices() as $serviceName) {  
924 - $className = OS.$serviceName;  
925 - $service = new $className();  
926 - $status = $this->serviceStart($service);  
927 - }  
928 - return true;  
929 - }  
930 -  
931 - /**  
932 - * Starts service  
933 - *  
934 - * @author KnowledgeTree Team  
935 - * @param object  
936 - * @access private  
937 - * @return string  
938 - */  
939 - private function serviceStart($service) {  
940 - if(OS == 'windows') {  
941 - $service->load(); // Load Defaults  
942 - $service->start(); // Start Service  
943 - return $service->status(); // Get service status  
944 - }  
945 - }  
946 -  
947 - /**  
948 - * Returns services errors  
949 - *  
950 - * @author KnowledgeTree Team  
951 - * @access public  
952 - * @params none  
953 - * @return array  
954 - */  
955 - public function getErrors() {  
956 - return $this->error;  
957 - }  
958 -  
959 - /**  
960 - * Returns services warnings  
961 - *  
962 - * @author KnowledgeTree Team  
963 - * @access public  
964 - * @params none  
965 - * @return array  
966 - */  
967 - public function getWarnings() {  
968 - return $this->warnings;  
969 - }  
970 -  
971 - /**  
972 - * Get the variables to be passed to the template  
973 - *  
974 - * @author KnowledgeTree Team  
975 - * @access public  
976 - * @return array  
977 - */  
978 - public function getStepVars()  
979 - {  
980 - return $this->temp_variables;  
981 - }  
982 -  
983 - /**  
984 - * Store Java state as installed  
985 - *  
986 - * @author KnowledgeTree Team  
987 - * @param none  
988 - * @access private  
989 - * @return void  
990 - */  
991 - private function javaInstalled() {  
992 - $this->temp_variables['java']['class'] = 'tick';  
993 - $this->temp_variables['java']['found'] = "Java Runtime Installed";  
994 - }  
995 -  
996 - /**  
997 - * Store Java state as not installed  
998 - *  
999 - * @author KnowledgeTree Team  
1000 - * @param none  
1001 - * @access private  
1002 - * @return void  
1003 - */  
1004 - private function javaNotInstalled() {  
1005 - $this->temp_variables['java']['class'] = 'cross';  
1006 - $this->temp_variables['java']['found'] = "Java runtime environment required";  
1007 - }  
1008 -  
1009 - /**  
1010 - * Store Java version state as correct  
1011 - *  
1012 - * @author KnowledgeTree Team  
1013 - * @param none  
1014 - * @access private  
1015 - * @return void  
1016 - */  
1017 - private function javaVersionCorrect() {  
1018 - $this->temp_variables['version']['class'] = 'tick';  
1019 - $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";  
1020 - }  
1021 -  
1022 - /**  
1023 - * Store Java version state as warning  
1024 - * @author KnowledgeTree Team  
1025 - * @param none  
1026 - * @access private  
1027 - * @return void  
1028 - */  
1029 - private function javaVersionWarning() {  
1030 - $this->temp_variables['version']['class'] = 'cross_orange';  
1031 - $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";  
1032 - }  
1033 -  
1034 - /**  
1035 - * Store Java version as state incorrect  
1036 - *  
1037 - * @author KnowledgeTree Team  
1038 - * @param none  
1039 - * @access private  
1040 - * @return void  
1041 - */  
1042 - private function javaVersionInCorrect() {  
1043 - $this->temp_variables['version']['class'] = 'cross';  
1044 - $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";  
1045 - }  
1046 -  
1047 - /**  
1048 - * Store Zend Bridge state as installed  
1049 - *  
1050 - * @author KnowledgeTree Team  
1051 - * @param none  
1052 - * @access private  
1053 - * @return void  
1054 - */  
1055 - private function zendBridgeInstalled() {  
1056 - $this->temp_variables['extensions']['class'] = 'tick';  
1057 - $this->temp_variables['extensions']['found'] = "Java Bridge Installed";  
1058 - }  
1059 -  
1060 - /**  
1061 - * Store Zend Bridge state as not installed  
1062 - *  
1063 - * @author KnowledgeTree Team  
1064 - * @param none  
1065 - * @access private  
1066 - * @return void  
1067 - */  
1068 - private function zendBridgeNotInstalled() {  
1069 - $this->temp_variables['extensions']['class'] = 'cross_orange';  
1070 - $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Installed";  
1071 - }  
1072 -  
1073 - /**  
1074 - * Store Zend Bridge state as warning  
1075 - *  
1076 - * @author KnowledgeTree Team  
1077 - * @param none  
1078 - * @access private  
1079 - * @return void  
1080 - */  
1081 - private function zendBridgeWarning() {  
1082 - $this->temp_variables['extensions']['class'] = 'cross_orange';  
1083 - $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Functional";  
1084 - }  
1085 -  
1086 - /**  
1087 - * Set all silent mode varibles  
1088 - *  
1089 - * @author KnowledgeTree Team  
1090 - * @param none  
1091 - * @access private  
1092 - * @return void  
1093 - */  
1094 - private function storeSilent() {  
1095 - // Servics  
1096 - $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled;  
1097 - $this->temp_variables['luceneInstalled'] = $this->luceneInstalled;  
1098 - $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled;  
1099 - $this->temp_variables['openOfficeInstalled'] = $this->openOfficeInstalled;  
1100 - // Java  
1101 - $this->temp_variables['javaExeError'] = $this->javaExeError;  
1102 - $this->temp_variables['javaExeMessage'] = $this->javaExeMessage;  
1103 - $this->temp_variables['javaCheck'] = $this->javaCheck;  
1104 - $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;  
1105 - // Open Office  
1106 - $this->temp_variables['openOfficeExeError'] = $this->openOfficeExeError;  
1107 - $this->temp_variables['openOfficeExeMessage'] = $this->openOfficeExeMessage;  
1108 - // TODO : PHP detection  
1109 - $this->temp_variables['phpCheck'] = 'tick';//$this->phpCheck;  
1110 - $this->temp_variables['phpExeError'] = '';//$this->phpExeError;  
1111 - $this->temp_variables['serviceCheck'] = $this->serviceCheck;  
1112 - $this->temp_variables['disableExtension'] = $this->disableExtension;  
1113 - // TODO: Java checks are gettign intense  
1114 - $this->temp_variables['providedJava'] = $this->providedJava;  
1115 - }  
1116 -  
1117 - private function setPhp() {  
1118 - if($this->php != '') { // PHP Found  
1119 - $this->phpCheck = 'tick';  
1120 - } elseif (PHP_DIR != '') { // Use System Defined Settings  
1121 - $this->php = PHP_DIR;  
1122 - } else {  
1123 -  
1124 - }  
1125 - $this->temp_variables['php']['location'] = $this->php;  
1126 - }  
1127 -  
1128 - public function getPhpDir() {  
1129 - return $this->php;  
1130 - }  
1131 -  
1132 - public function doDeleteAll() {  
1133 - $serverDetails = $this->getServices();  
1134 - foreach ($serverDetails as $serviceName) {  
1135 - $className = OS.$serviceName;  
1136 - require_once("../lib/services/service.php");  
1137 - require_once("../lib/services/".OS."Service.php");  
1138 - require_once("../lib/services/$className.php");  
1139 - $service = new $className();  
1140 - $service->uninstall();  
1141 - echo "Delete Service {$service->getName()}<br/>";  
1142 - echo "Status of service ".$service->status()."<br/>";  
1143 - }  
1144 - }  
1145 -  
1146 - public function doInstallAll() {  
1147 - $serverDetails = $this->getServices();  
1148 - foreach ($serverDetails as $serviceName) {  
1149 - $className = OS.$serviceName;  
1150 - require_once("../lib/services/service.php");  
1151 - require_once("../lib/services/".OS."Service.php");  
1152 - require_once("../lib/services/$className.php");  
1153 - $service = new $className();  
1154 - $service->load();  
1155 - $service->install();  
1156 - echo "Install Service {$service->getName()}<br/>";  
1157 - echo "Status of service ".$service->status()."<br/>";  
1158 - }  
1159 - }  
1160 -  
1161 - public function doStatusAll() {  
1162 - $serverDetails = $this->getServices();  
1163 - foreach ($serverDetails as $serviceName) {  
1164 - $className = OS.$serviceName;  
1165 - require_once("../lib/services/service.php");  
1166 - require_once("../lib/services/".OS."Service.php");  
1167 - require_once("../lib/services/$className.php");  
1168 - $service = new $className();  
1169 - $service->load();  
1170 - echo "{$service->getName()} : Status of service = ".$service->status()."<br/>";  
1171 - }  
1172 - }  
1173 -}  
1174 -  
1175 -if(isset($_GET['action'])) {  
1176 - $func = $_GET['action'];  
1177 - if($func != '') {  
1178 - $serv = new services();  
1179 - $func_call = strtoupper(substr($func,0,1)).substr($func,1);  
1180 - $method = "do$func";  
1181 - $serv->$method();  
1182 - }  
1183 -} 1 +<?php
  2 +/**
  3 +* Services 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 +
  43 +if(isset($_GET['action'])) {
  44 + $func = $_GET['action'];
  45 + if($func != '') {
  46 + require_once("../step.php");
  47 + require_once("../installUtil.php");
  48 + require_once("../path.php");
  49 + }
  50 +}
  51 +
  52 +class services extends Step
  53 +{
  54 + /**
  55 + * List of errors encountered
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access protected
  59 + * @var array
  60 + */
  61 + protected $error = array();
  62 +
  63 + /**
  64 + * Flag if step needs to be installed
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access protected
  68 + * @var array
  69 + */
  70 + protected $runInstall = true;
  71 +
  72 + /**
  73 + * List of services to be installed
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access private
  77 + * @var array
  78 + */
  79 + private $services = array('Lucene', 'Scheduler', 'OpenOffice');
  80 +
  81 + /**
  82 + * Path to php executable
  83 + *
  84 + * @author KnowledgeTree Team
  85 + * @access protected
  86 + * @var string
  87 + */
  88 + protected $php;
  89 +
  90 + /**
  91 + * Flag if php already provided
  92 + *
  93 + * @author KnowledgeTree Team
  94 + * @access private
  95 + * @var mixed
  96 + */
  97 + public $providedPhp = false;
  98 +
  99 + /**
  100 + * PHP Installed
  101 + *
  102 + * @author KnowledgeTree Team
  103 + * @access private
  104 + * @var mixed
  105 + */
  106 + private $phpCheck = 'cross_orange';
  107 +
  108 + /**
  109 + * Flag, if php is specified and an error has been encountered
  110 + *
  111 + * @author KnowledgeTree Team
  112 + * @access public
  113 + * @var boolean
  114 + */
  115 + private $phpExeError = false;
  116 +
  117 + /**
  118 + * Holds path error, if php is specified
  119 + *
  120 + * @author KnowledgeTree Team
  121 + * @access public
  122 + * @var string
  123 + */
  124 + private $phpExeMessage = '';
  125 +
  126 + /**
  127 + * Path to open office executable
  128 + *
  129 + * @author KnowledgeTree Team
  130 + * @access protected
  131 + * @var string
  132 + */
  133 + protected $soffice;
  134 +
  135 + /**
  136 + * Flag if open office already provided
  137 + *
  138 + * @author KnowledgeTree Team
  139 + * @access private
  140 + * @var mixed
  141 + */
  142 + public $providedOpenOffice = false;
  143 +
  144 + /**
  145 + * Flag, if open office is specified and an error has been encountered
  146 + *
  147 + * @author KnowledgeTree Team
  148 + * @access public
  149 + * @var boolean
  150 + */
  151 + private $openOfficeExeError = false;
  152 +
  153 + /**
  154 + * Holds path error, if open office is specified
  155 + *
  156 + * @author KnowledgeTree Team
  157 + * @access public
  158 + * @var string
  159 + */
  160 + private $openOfficeExeMessage = '';
  161 +
  162 + /**
  163 + * Path to java executable
  164 + *
  165 + * @author KnowledgeTree Team
  166 + * @access protected
  167 + * @var string
  168 + */
  169 + protected $java = "";
  170 +
  171 + /**
  172 + * Minumum Java Version
  173 + *
  174 + * @author KnowledgeTree Team
  175 + * @access protected
  176 + * @var string
  177 + */
  178 + private $javaVersion = '1.5';
  179 +
  180 + /**
  181 + * Java Installed
  182 + *
  183 + * @author KnowledgeTree Team
  184 + * @access private
  185 + * @var mixed
  186 + */
  187 + private $javaCheck = 'cross';
  188 +
  189 + /**
  190 + * Open Office Installed
  191 + *
  192 + * @author KnowledgeTree Team
  193 + * @access private
  194 + * @var mixed
  195 + */
  196 + private $openOfficeCheck = 'cross';
  197 +
  198 + /**
  199 + * Flag if java already provided
  200 + *
  201 + * @author KnowledgeTree Team
  202 + * @access private
  203 + * @var mixed
  204 + */
  205 + public $providedJava = false;
  206 +
  207 + /**
  208 + * Java Bridge Installed
  209 + *
  210 + * @author KnowledgeTree Team
  211 + * @access private
  212 + * @var mixed
  213 + */
  214 + private $javaExtCheck = 'cross_orange';
  215 +
  216 + /**
  217 + * Flag if bridge extension needs to be disabled
  218 + *
  219 + * @author KnowledgeTree Team
  220 + * @access public
  221 + * @var boolean
  222 + */
  223 + private $disableExtension = false;
  224 +
  225 + /**
  226 + * Flag, if java is specified and an error has been encountered
  227 + *
  228 + * @author KnowledgeTree Team
  229 + * @access public
  230 + * @var booelean
  231 + */
  232 + private $javaExeError = false;
  233 +
  234 + /**
  235 + * Holds path error, if java is specified
  236 + *
  237 + * @author KnowledgeTree Team
  238 + * @access public
  239 + * @var string
  240 + */
  241 + private $javaExeMessage = '';
  242 +
  243 + /**
  244 + * Flag if services are already Installed
  245 + *
  246 + * @author KnowledgeTree Team
  247 + * @access private
  248 + * @var mixed
  249 + */
  250 + private $alreadyInstalled = false;
  251 +
  252 + /**
  253 + * Flag if services are already Installed
  254 + *
  255 + * @author KnowledgeTree Team
  256 + * @access private
  257 + * @var mixed
  258 + */
  259 + private $luceneInstalled = false;
  260 +
  261 + /**
  262 + * Flag if services are already Installed
  263 + *
  264 + * @author KnowledgeTree Team
  265 + * @access private
  266 + * @var mixed
  267 + */
  268 + private $schedulerInstalled = false;
  269 +
  270 + /**
  271 + * Path to php executable
  272 + *
  273 + * @author KnowledgeTree Team
  274 + * @access protected
  275 + * @var string
  276 + */
  277 + private $openOfficeInstalled;
  278 +
  279 + /**
  280 + * Service Installed
  281 + *
  282 + * @author KnowledgeTree Team
  283 + * @access private
  284 + * @var array
  285 + */
  286 + private $serviceCheck = 'tick';
  287 +
  288 + /**
  289 + * Flag to store class information in session
  290 + *
  291 + * @author KnowledgeTree Team
  292 + * @access public
  293 + * @var boolean
  294 + */
  295 + protected $storeInSession = true;
  296 +
  297 + /**
  298 + * List of variables to be loaded to template
  299 + *
  300 + * @author KnowledgeTree Team
  301 + * @access public
  302 + * @var array
  303 + */
  304 + protected $temp_variables;
  305 +
  306 + /**
  307 + * Flag if step needs to run silently
  308 + *
  309 + * @author KnowledgeTree Team
  310 + * @access public
  311 + * @var array
  312 + */
  313 + protected $silent = true;
  314 +
  315 + /**
  316 + * Reference to utility object
  317 + *
  318 + * @author KnowledgeTree Team
  319 + * @access protected
  320 + * @var string
  321 + */
  322 + protected $util;
  323 + private $salt = 'install';
  324 +
  325 + /**
  326 + * Constructs services object
  327 + *
  328 + * @author KnowledgeTree Team
  329 + * @access public
  330 + * @param none
  331 + */
  332 + public function __construct() {
  333 + $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent);
  334 + $this->util = new InstallUtil();
  335 + }
  336 +
  337 + /**
  338 + * Main control of services setup
  339 + *
  340 + * @author KnowledgeTree Team
  341 + * @param none
  342 + * @access public
  343 + * @return string
  344 + */
  345 + public function doStep()
  346 + {
  347 + if(!$this->inStep("services")) {
  348 + $this->doRun();
  349 + return 'landing';
  350 + }
  351 + if($this->next()) {
  352 + // Check dependencies
  353 + $passed = $this->doRun();
  354 + $serv = $this->getDataFromSession("services");
  355 + if($passed || $serv['providedJava'])
  356 + return 'next';
  357 + else
  358 + return 'error';
  359 + } else if($this->previous()) {
  360 + return 'previous';
  361 + }
  362 + $passed = $this->doRun();
  363 + return 'landing';
  364 + }
  365 +
  366 + /**
  367 + * Get service names
  368 + *
  369 + * @author KnowledgeTree Team
  370 + * @param none
  371 + * @access public
  372 + * @return array
  373 + */
  374 + public function getServices() {
  375 + return $this->services;
  376 + }
  377 +
  378 + /**
  379 + * Check if java executable was found
  380 + *
  381 + * @author KnowledgeTree Team
  382 + * @param none
  383 + * @access private
  384 + * @return array
  385 + */
  386 + private function setJava() {
  387 + if($this->java != '') { // Java JRE Found
  388 + $this->javaCheck = 'tick';
  389 + $this->javaInstalled();
  390 + $this->temp_variables['java']['location'] = $this->java;
  391 + return ;
  392 + }
  393 +
  394 + $this->temp_variables['java']['location'] = $this->java;
  395 + }
  396 +
  397 + /**
  398 + * Run step
  399 + *
  400 + * @author KnowledgeTree Team
  401 + * @param none
  402 + * @access private
  403 + * @return boolean
  404 + */
  405 + private function doRun() {
  406 + if($this->alreadyInstalled()) {
  407 + $this->alreadyInstalled = true;
  408 + $this->serviceCheck = 'tick';
  409 + } else {
  410 + $this->presetJava();
  411 + $this->presetOpenOffice();
  412 + if(!$this->schedulerInstalled) {
  413 + $this->php = $this->util->getPhp(); // Get java, if it exists
  414 + $passedPhp = $this->phpChecks(); // Run Java Pre Checks
  415 + if ($passedPhp) { // Install Scheduler
  416 + $this->installService('Scheduler');
  417 + }
  418 + } else {
  419 + $this->schedulerInstalled();
  420 + }
  421 + if(!$this->luceneInstalled) {
  422 + $this->java = $this->util->getJava(); // Get java, if it exists
  423 + $passedJava = $this->javaChecks(); // Run Java Pre Checks
  424 + if ($passedJava) { // Install Lucene
  425 + $this->installService('Lucene');
  426 + }
  427 + } else {
  428 + $this->luceneInstalled();
  429 + }
  430 + if(!$this->openOfficeInstalled) {
  431 + $this->soffice = $this->util->getOpenOffice(); // Get java, if it exists
  432 + $passedOpenOffice = $this->openOfficeChecks(); // Run Java Pre Checks
  433 + if ($passedOpenOffice) { //Install OpenOffice
  434 +// $this->temp_variables['openOfficeExe'] = $this->soffice;
  435 + // TODO : Why, O, why?
  436 + $this->openOfficeExeError = false;
  437 + $_SESSION[$this->salt]['services']['openOfficeExe'] = $this->soffice;
  438 + $this->installService('OpenOffice');
  439 + }
  440 + } else {
  441 + $this->openOfficeInstalled();
  442 + }
  443 + }
  444 + $this->checkServiceStatus();
  445 + $this->storeSilent(); // Store info needed for silent mode
  446 + if(!empty($errors))
  447 + return false;
  448 + return true;
  449 + }
  450 +
  451 + private function openOfficeInstalled() {
  452 +
  453 + }
  454 +
  455 + private function schedulerInstalled() {
  456 +
  457 + }
  458 +
  459 + private function luceneInstalled() {
  460 + $this->disableExtension = true; // Disable the use of the php bridge extension
  461 + $this->javaVersionCorrect();
  462 + $this->javaInstalled();
  463 + $this->javaCheck = 'tick';
  464 + }
  465 +
  466 + /**
  467 + * A final check to see if services are still running,
  468 + * incase they switched on and turned off.
  469 + *
  470 + * @author KnowledgeTree Team
  471 + * @param none
  472 + * @access private
  473 + * @return void
  474 + */
  475 + private function checkServiceStatus() {
  476 + $serverDetails = $this->getServices();
  477 + foreach ($serverDetails as $serviceName) {
  478 + $className = OS.$serviceName;
  479 + $service = new $className();
  480 + $service->load();
  481 + $status = $this->serviceInstalled($service);
  482 + if($status != 'STARTED') {
  483 + $msg = $service->getName()." Could not be added as a Service";
  484 + $this->temp_variables['services'][] = array('class'=>'cross_orange', 'msg'=>$msg);
  485 + $this->serviceCheck = 'cross_orange';
  486 + $this->warnings[] = $msg;
  487 + } else {
  488 + if(WINDOWS_OS) {
  489 + $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service"); }
  490 + else {
  491 + $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added and Started as a Service");
  492 + }
  493 + }
  494 + }
  495 + }
  496 +
  497 + /**
  498 + * Checks if all services have been started already,
  499 + * incase the user lands on service page multiple times
  500 + *
  501 + * @author KnowledgeTree Team
  502 + * @param none
  503 + * @access public
  504 + * @return boolean
  505 + */
  506 + public function alreadyInstalled() {
  507 + $allInstalled = true;
  508 + $serverDetails = $this->getServices();
  509 + foreach ($serverDetails as $serviceName) {
  510 + $className = OS.$serviceName;
  511 + $service = new $className();
  512 + $status = $this->serviceInstalled($service);
  513 + $flag = strtolower(substr($serviceName,0,1)).substr($serviceName,1)."Installed";
  514 + if(!$status) {
  515 + $allInstalled = false;
  516 + $this->$flag = false;
  517 + } else {
  518 + $this->$flag = true;
  519 + }
  520 + }
  521 +
  522 + return $allInstalled;
  523 + }
  524 +
  525 + private function presetJava() {
  526 + $this->zendBridgeNotInstalled(); // Set bridge not installed
  527 + $this->javaVersionInCorrect(); // Set version to incorrect
  528 + $this->javaNotInstalled(); // Set java to not installed
  529 + $this->setJava(); // Check if java has been auto detected
  530 + }
  531 +
  532 + private function presetOpenOffice() {
  533 + $this->specifyOpenOffice();
  534 + }
  535 +
  536 + private function setOpenOffice() {
  537 +
  538 + }
  539 + /**
  540 + * Do some basic checks to help the user overcome java problems
  541 + *
  542 + * @author KnowledgeTree Team
  543 + * @param none
  544 + * @access private
  545 + * @return boolean
  546 + */
  547 + private function javaChecks() {
  548 + if($this->util->javaSpecified()) {
  549 + $this->disableExtension = true; // Disable the use of the php bridge extension
  550 + if($this->detSettings(true)) { // AutoDetect java settings
  551 + return true;
  552 + } else {
  553 + $this->specifyJava(); // Ask for settings
  554 + }
  555 + } else {
  556 + $auto = $this->useBridge(); // Use Bridge to get java settings
  557 + if($auto) {
  558 + return $auto;
  559 + } else {
  560 + $auto = $this->useDetected(); // Check if auto detected java works
  561 + if($auto) {
  562 + $this->disableExtension = true; // Disable the use of the php bridge extension
  563 + return $auto;
  564 + } else {
  565 + $this->specifyJava(); // Ask for settings
  566 + }
  567 + }
  568 + return $auto;
  569 + }
  570 + }
  571 +
  572 + private function openOfficeChecks() {
  573 + if($this->util->openOfficeSpecified()) {
  574 + $this->soffice = $this->util->openOfficeSpecified();
  575 + if(file_exists($this->soffice))
  576 + return true;
  577 + else
  578 + return false;
  579 + } else {
  580 + return false;
  581 + }
  582 + }
  583 +
  584 + /**
  585 + * Attempt detection without logging errors
  586 + *
  587 + * @author KnowledgeTree Team
  588 + * @param none
  589 + * @access private
  590 + * @return boolean
  591 + */
  592 + private function useDetected() {
  593 + return $this->detSettings();
  594 + }
  595 +
  596 + /**
  597 + * Set template view to specify java
  598 + *
  599 + * @author KnowledgeTree Team
  600 + * @param none
  601 + * @access private
  602 + * @return boolean
  603 + */
  604 + private function specifyJava() {
  605 + $this->javaExeError = true;
  606 + }
  607 +
  608 + /**
  609 + * Set template view to specify php
  610 + *
  611 + * @author KnowledgeTree Team
  612 + * @param none
  613 + * @access private
  614 + * @return boolean
  615 + */
  616 + private function specifyPhp() {
  617 + $this->phpExeError = true;
  618 + }
  619 +
  620 + /**
  621 + * Set template view to specify open office
  622 + *
  623 + * @author KnowledgeTree Team
  624 + * @param none
  625 + * @access private
  626 + * @return boolean
  627 + */
  628 + private function specifyOpenOffice() {
  629 + $this->openOfficeExeError = true;
  630 + }
  631 +
  632 + private function phpChecks() {
  633 + // TODO: Better detection
  634 + return true;
  635 + $this->setPhp();
  636 + if($this->util->phpSpecified()) {
  637 + return $this->detPhpSettings();
  638 + } else {
  639 + $this->specifyPhp();// Ask for settings
  640 + return false;
  641 + }
  642 + }
  643 +
  644 +
  645 +
  646 + /**
  647 + * Attempts to use user input and configure java settings
  648 + *
  649 + * @author KnowledgeTree Team
  650 + * @param none
  651 + * @access private
  652 + * @return boolean
  653 + */
  654 + private function detSettings($attempt = false) {
  655 + $javaExecutable = $this->util->javaSpecified();// Retrieve java bin
  656 + if($javaExecutable == '') {
  657 + if($this->java == '') {
  658 + return false;
  659 + }
  660 + $javaExecutable = $this->java;
  661 + }
  662 + $cmd = "\"$javaExecutable\" -version > output/outJV 2>&1 echo $!";
  663 + $response = $this->util->pexec($cmd);
  664 + if(file_exists(OUTPUT_DIR.'outJV')) {
  665 + $tmp = file_get_contents(OUTPUT_DIR.'outJV');
  666 + preg_match('/"(.*)"/',$tmp, $matches);
  667 + if($matches) {
  668 + if($matches[1] < $this->javaVersion) { // Check Version of java
  669 + $this->javaVersionInCorrect();
  670 + $this->javaCheck = 'cross';
  671 + $this->error[] = "Requires Java 1.5+ to be installed";
  672 +
  673 + return false;
  674 + } else {
  675 + $this->javaVersionCorrect();
  676 + $this->javaInstalled();
  677 + $this->javaCheck = 'tick';
  678 + $this->providedJava = true;
  679 +
  680 + return true;
  681 + }
  682 + } else {
  683 + $this->javaVersionWarning();
  684 + $this->javaCheck = 'cross_orange';
  685 + if($attempt) {
  686 + $this->javaExeMessage = "Incorrect java path specified";
  687 + $this->javaExeError = true;
  688 + $this->error[] = "Requires Java 1.5+ to be installed";
  689 + }
  690 +
  691 +
  692 + return false;
  693 + }
  694 + }
  695 +
  696 + $this->javaVersionInCorrect();
  697 + $this->javaCheck = 'cross';
  698 + $this->error[] = "Requires Java 1.5+ to be installed";
  699 + return false;
  700 + }
  701 +
  702 + function detPhpSettings() {
  703 + // TODO: Better php handling
  704 + return true;
  705 + $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
  706 + $cmd = "$phpExecutable -version > output/outPHP 2>&1 echo $!";
  707 + $response = $this->util->pexec($cmd);
  708 + if(file_exists(OUTPUT_DIR.'outPHP')) {
  709 + $tmp = file_get_contents(OUTPUT_DIR.'outPHP');
  710 + preg_match('/PHP/',$tmp, $matches);
  711 + if($matches) {
  712 + $this->phpCheck = 'tick';
  713 +
  714 + return true;
  715 + } else {
  716 + $this->phpCheck = 'cross_orange';
  717 + $this->phpExeError = "PHP : Incorrect path specified";
  718 + $this->error[] = "PHP executable required";
  719 +
  720 + return false;
  721 + }
  722 + }
  723 + }
  724 + /**
  725 + * Attempts to use bridge and configure java settings
  726 + *
  727 + * @author KnowledgeTree Team
  728 + * @param none
  729 + * @access private
  730 + * @return boolean
  731 + */
  732 + private function useBridge() {
  733 + $zendBridge = $this->util->zendBridge(); // Find Zend Bridge
  734 + if($zendBridge) { // Bridge installed implies java exists
  735 + $this->zendBridgeInstalled();
  736 + if($this->checkZendBridge()) { // Make sure the Zend Bridge is functional
  737 + $this->javaExtCheck = 'tick'; // Set bridge to functional
  738 + $this->javaInstalled(); // Set java to installed
  739 + $javaSystem = new Java('java.lang.System');
  740 + $version = $javaSystem->getProperty('java.version');
  741 + $ver = substr($version, 0, 3);
  742 + if($ver < $this->javaVersion) {
  743 + $this->javaVersionInCorrect();
  744 + $this->error[] = "Requires Java 1.5+ to be installed";
  745 + return false;
  746 + } else {
  747 + $this->javaVersionCorrect(); // Set version to correct
  748 + $this->javaCheck = 'tick';
  749 + return true;
  750 + }
  751 + } else {
  752 + $this->javaCheck = 'cross_orange';
  753 + $this->javaVersionWarning();
  754 + $this->zendBridgeWarning();
  755 + $this->warnings[] = "Zend Java Bridge Not Functional";
  756 + $this->javaExtCheck = 'cross_orange';
  757 + return false;
  758 + }
  759 + } else {
  760 + $this->warnings[] = "Zend Java Bridge Not Found";
  761 + return false;
  762 + }
  763 + }
  764 +
  765 + /**
  766 + * Check if Zend Bridge is functional
  767 + *
  768 + * @author KnowledgeTree Team
  769 + * @param none
  770 + * @access public
  771 + * @return boolean
  772 + */
  773 + public function checkZendBridge() {
  774 + if($this->util->javaBridge()) { // Check if java bridge is functional
  775 + return true;
  776 + } else {
  777 + return false;
  778 + }
  779 + }
  780 +
  781 +
  782 + /**
  783 + * Installs services
  784 + *
  785 + * @author KnowledgeTree Team
  786 + * @param none
  787 + * @access private
  788 + * @return boolean
  789 + */
  790 + private function installServices() {
  791 + foreach ($this->getServices() as $serviceName) {
  792 + $this->installService($serviceName);
  793 + }
  794 +
  795 + return true;
  796 + }
  797 +
  798 + /**
  799 + * Installs services helper
  800 + *
  801 + * @author KnowledgeTree Team
  802 + * @param none
  803 + * @access private
  804 + * @return boolean
  805 + */
  806 + private function installService($serviceName) {
  807 + $className = OS.$serviceName;
  808 + $service = new $className();
  809 + $status = $this->serviceHelper($service);
  810 + if (!$status) {
  811 + $this->serviceCheck = 'cross_orange';
  812 + }
  813 + }
  814 +
  815 + /**
  816 + * Installs services
  817 + *
  818 + * @author KnowledgeTree Team
  819 + * @param object
  820 + * @access private
  821 + * @return string
  822 + */
  823 + private function serviceHelper($service) {
  824 + $service->load(); // Load Defaults
  825 + $response = $service->install(); // Install service
  826 + $statusCheck = OS."ServiceInstalled";
  827 + return $this->$statusCheck($service);
  828 + }
  829 +
  830 + /**
  831 + * Helper to check if service is installed
  832 + *
  833 + * @author KnowledgeTree Team
  834 + * @param object
  835 + * @access public
  836 + * @return string
  837 + */
  838 + public function serviceInstalled($service) {
  839 + $statusCheck = OS."ServiceInstalled";
  840 + return $this->$statusCheck($service);
  841 + }
  842 +
  843 + /**
  844 + * Helper to check if service is started
  845 + *
  846 + * @author KnowledgeTree Team
  847 + * @param object
  848 + * @access public
  849 + * @return string
  850 + */
  851 + public function serviceStarted($service) {
  852 + $statusCheck = OS."ServiceStarted";
  853 + return $this->$statusCheck($service);
  854 + }
  855 +
  856 + /**
  857 + * Check if windows service installed
  858 + *
  859 + * @author KnowledgeTree Team
  860 + * @param object
  861 + * @access public
  862 + * @return boolean
  863 + */
  864 + public function windowsServiceStarted($service) {
  865 + $status = $service->status(); // Check if service has been installed
  866 + if($status != 'RUNNING') { // Check service status
  867 + return false;
  868 + }
  869 + return true;
  870 + }
  871 +
  872 + /**
  873 + * Check if unix service installed
  874 + *
  875 + * @author KnowledgeTree Team
  876 + * @param object
  877 + * @access public
  878 + * @return boolean
  879 + */
  880 + public function unixServiceStarted($service) {
  881 + $status = $service->status(); // Check if service has been installed
  882 + if($status != 'STARTED') { // Check service status
  883 + return false;
  884 + }
  885 + return true;
  886 + }
  887 +
  888 + /**
  889 + * Check if windows service installed
  890 + *
  891 + * @author KnowledgeTree Team
  892 + * @param object
  893 + * @access public
  894 + * @return boolean
  895 + */
  896 + public function windowsServiceInstalled($service) {
  897 + $status = $service->status(); // Check if service has been installed
  898 + if($status == '') { // Check service status
  899 + return false;
  900 + }
  901 + return true;
  902 + }
  903 +
  904 + /**
  905 + * Check if unix service installed
  906 + *
  907 + * @author KnowledgeTree Team
  908 + * @param object
  909 + * @access public
  910 + * @return boolean
  911 + */
  912 + public function unixServiceInstalled($service) {
  913 + $status = $service->status(); // Check if service has been installed
  914 + if($status != 'STARTED') { // Check service status
  915 + return false;
  916 + }
  917 + return true;
  918 + }
  919 +
  920 + /**
  921 + * Starts all services
  922 + *
  923 + * @author KnowledgeTree Team
  924 + * @param object
  925 + * @access public
  926 + * @return mixed
  927 + */
  928 + public function installStep() {
  929 + foreach ($this->getServices() as $serviceName) {
  930 + $className = OS.$serviceName;
  931 + $service = new $className();
  932 + $status = $this->serviceStart($service);
  933 + }
  934 + return true;
  935 + }
  936 +
  937 + /**
  938 + * Starts service
  939 + *
  940 + * @author KnowledgeTree Team
  941 + * @param object
  942 + * @access private
  943 + * @return string
  944 + */
  945 + private function serviceStart($service) {
  946 + if(OS == 'windows') {
  947 + $service->load(); // Load Defaults
  948 + $service->start(); // Start Service
  949 + return $service->status(); // Get service status
  950 + }
  951 + }
  952 +
  953 + /**
  954 + * Returns services errors
  955 + *
  956 + * @author KnowledgeTree Team
  957 + * @access public
  958 + * @params none
  959 + * @return array
  960 + */
  961 + public function getErrors() {
  962 + return $this->error;
  963 + }
  964 +
  965 + /**
  966 + * Returns services warnings
  967 + *
  968 + * @author KnowledgeTree Team
  969 + * @access public
  970 + * @params none
  971 + * @return array
  972 + */
  973 + public function getWarnings() {
  974 + return $this->warnings;
  975 + }
  976 +
  977 + /**
  978 + * Get the variables to be passed to the template
  979 + *
  980 + * @author KnowledgeTree Team
  981 + * @access public
  982 + * @return array
  983 + */
  984 + public function getStepVars()
  985 + {
  986 + return $this->temp_variables;
  987 + }
  988 +
  989 + /**
  990 + * Store Java state as installed
  991 + *
  992 + * @author KnowledgeTree Team
  993 + * @param none
  994 + * @access private
  995 + * @return void
  996 + */
  997 + private function javaInstalled() {
  998 + $this->temp_variables['java']['class'] = 'tick';
  999 + $this->temp_variables['java']['found'] = "Java Runtime Installed";
  1000 + }
  1001 +
  1002 + /**
  1003 + * Store Java state as not installed
  1004 + *
  1005 + * @author KnowledgeTree Team
  1006 + * @param none
  1007 + * @access private
  1008 + * @return void
  1009 + */
  1010 + private function javaNotInstalled() {
  1011 + $this->temp_variables['java']['class'] = 'cross';
  1012 + $this->temp_variables['java']['found'] = "Java runtime environment required";
  1013 + }
  1014 +
  1015 + /**
  1016 + * Store Java version state as correct
  1017 + *
  1018 + * @author KnowledgeTree Team
  1019 + * @param none
  1020 + * @access private
  1021 + * @return void
  1022 + */
  1023 + private function javaVersionCorrect() {
  1024 + $this->temp_variables['version']['class'] = 'tick';
  1025 + $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
  1026 + }
  1027 +
  1028 + /**
  1029 + * Store Java version state as warning
  1030 + * @author KnowledgeTree Team
  1031 + * @param none
  1032 + * @access private
  1033 + * @return void
  1034 + */
  1035 + private function javaVersionWarning() {
  1036 + $this->temp_variables['version']['class'] = 'cross_orange';
  1037 + $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";
  1038 + }
  1039 +
  1040 + /**
  1041 + * Store Java version as state incorrect
  1042 + *
  1043 + * @author KnowledgeTree Team
  1044 + * @param none
  1045 + * @access private
  1046 + * @return void
  1047 + */
  1048 + private function javaVersionInCorrect() {
  1049 + $this->temp_variables['version']['class'] = 'cross';
  1050 + $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
  1051 + }
  1052 +
  1053 + /**
  1054 + * Store Zend Bridge state as installed
  1055 + *
  1056 + * @author KnowledgeTree Team
  1057 + * @param none
  1058 + * @access private
  1059 + * @return void
  1060 + */
  1061 + private function zendBridgeInstalled() {
  1062 + $this->temp_variables['extensions']['class'] = 'tick';
  1063 + $this->temp_variables['extensions']['found'] = "Java Bridge Installed";
  1064 + }
  1065 +
  1066 + /**
  1067 + * Store Zend Bridge state as not installed
  1068 + *
  1069 + * @author KnowledgeTree Team
  1070 + * @param none
  1071 + * @access private
  1072 + * @return void
  1073 + */
  1074 + private function zendBridgeNotInstalled() {
  1075 + $this->temp_variables['extensions']['class'] = 'cross_orange';
  1076 + $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Installed";
  1077 + }
  1078 +
  1079 + /**
  1080 + * Store Zend Bridge state as warning
  1081 + *
  1082 + * @author KnowledgeTree Team
  1083 + * @param none
  1084 + * @access private
  1085 + * @return void
  1086 + */
  1087 + private function zendBridgeWarning() {
  1088 + $this->temp_variables['extensions']['class'] = 'cross_orange';
  1089 + $this->temp_variables['extensions']['found'] = "Zend Java Bridge Not Functional";
  1090 + }
  1091 +
  1092 + /**
  1093 + * Set all silent mode varibles
  1094 + *
  1095 + * @author KnowledgeTree Team
  1096 + * @param none
  1097 + * @access private
  1098 + * @return void
  1099 + */
  1100 + private function storeSilent() {
  1101 + // Servics
  1102 + $this->temp_variables['alreadyInstalled'] = $this->alreadyInstalled;
  1103 + $this->temp_variables['luceneInstalled'] = $this->luceneInstalled;
  1104 + $this->temp_variables['schedulerInstalled'] = $this->schedulerInstalled;
  1105 + $this->temp_variables['openOfficeInstalled'] = $this->openOfficeInstalled;
  1106 + // Java
  1107 + $this->temp_variables['javaExeError'] = $this->javaExeError;
  1108 + $this->temp_variables['javaExeMessage'] = $this->javaExeMessage;
  1109 + $this->temp_variables['javaCheck'] = $this->javaCheck;
  1110 + $this->temp_variables['javaExtCheck'] = $this->javaExtCheck;
  1111 + // Open Office
  1112 + $this->temp_variables['openOfficeExeError'] = $this->openOfficeExeError;
  1113 + $this->temp_variables['openOfficeExeMessage'] = $this->openOfficeExeMessage;
  1114 + // TODO : PHP detection
  1115 + $this->temp_variables['phpCheck'] = 'tick';//$this->phpCheck;
  1116 + $this->temp_variables['phpExeError'] = '';//$this->phpExeError;
  1117 + $this->temp_variables['serviceCheck'] = $this->serviceCheck;
  1118 + $this->temp_variables['disableExtension'] = $this->disableExtension;
  1119 + // TODO: Java checks are gettign intense
  1120 + $this->temp_variables['providedJava'] = $this->providedJava;
  1121 + }
  1122 +
  1123 + private function setPhp() {
  1124 + if($this->php != '') { // PHP Found
  1125 + $this->phpCheck = 'tick';
  1126 + } elseif (PHP_DIR != '') { // Use System Defined Settings
  1127 + $this->php = PHP_DIR;
  1128 + } else {
  1129 +
  1130 + }
  1131 + $this->temp_variables['php']['location'] = $this->php;
  1132 + }
  1133 +
  1134 + public function getPhpDir() {
  1135 + return $this->php;
  1136 + }
  1137 +
  1138 + public function doDeleteAll() {
  1139 + $serverDetails = $this->getServices();
  1140 + foreach ($serverDetails as $serviceName) {
  1141 + $className = OS.$serviceName;
  1142 + require_once("../lib/services/service.php");
  1143 + require_once("../lib/services/".OS."Service.php");
  1144 + require_once("../lib/services/$className.php");
  1145 + $service = new $className();
  1146 + $service->uninstall();
  1147 + echo "Delete Service {$service->getName()}<br/>";
  1148 + echo "Status of service ".$service->status()."<br/>";
  1149 + }
  1150 + }
  1151 +
  1152 + public function doInstallAll() {
  1153 + $serverDetails = $this->getServices();
  1154 + foreach ($serverDetails as $serviceName) {
  1155 + $className = OS.$serviceName;
  1156 + require_once("../lib/services/service.php");
  1157 + require_once("../lib/services/".OS."Service.php");
  1158 + require_once("../lib/services/$className.php");
  1159 + $service = new $className();
  1160 + $service->load();
  1161 + $service->install();
  1162 + echo "Install Service {$service->getName()}<br/>";
  1163 + echo "Status of service ".$service->status()."<br/>";
  1164 + }
  1165 + }
  1166 +
  1167 + public function doStatusAll() {
  1168 + $serverDetails = $this->getServices();
  1169 + foreach ($serverDetails as $serviceName) {
  1170 + $className = OS.$serviceName;
  1171 + require_once("../lib/services/service.php");
  1172 + require_once("../lib/services/".OS."Service.php");
  1173 + require_once("../lib/services/$className.php");
  1174 + $service = new $className();
  1175 + $service->load();
  1176 + echo "{$service->getName()} : Status of service = ".$service->status()."<br/>";
  1177 + }
  1178 + }
  1179 +}
  1180 +
  1181 +if(isset($_GET['action'])) {
  1182 + $func = $_GET['action'];
  1183 + if($func != '') {
  1184 + $serv = new services();
  1185 + $func_call = strtoupper(substr($func,0,1)).substr($func,1);
  1186 + $method = "do$func";
  1187 + $serv->$method();
  1188 + }
  1189 +}
1184 ?> 1190 ?>
1185 \ No newline at end of file 1191 \ No newline at end of file
setup/wizard/templates/complete.tpl
1 -<form id="install_complete_none">  
2 - <p class="title">Installation Completed</p>  
3 -  
4 - <p class="description">This allows you to check that your KnowledgeTree configuration is set  
5 - up correctly. You can run this at any time after configuration to check  
6 - that things are still set up correctly.</p>  
7 -  
8 - <?php  
9 - if($errors || $warnings){  
10 - echo '<div>'  
11 - . '<a href="http://wiki.knowledgetree.com/Web_Based_Installer#Post_Install" target="_blank">'  
12 - . 'Click Here for help on overcoming post install issues</a></div><br/>';  
13 - }  
14 - ?>  
15 - <div id="step_content_complete" class="step">  
16 -<!-- Paths and Permissions -->  
17 - <div>  
18 - <h3><?php echo "<span class='{$paths_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Paths and Permissions</h3>  
19 - <?php if($silent) { ?>  
20 - <div id="option8" class="onclick" onclick="javascript:{w.toggleClass('paths_check', 'option8');}">Show Details</div>  
21 - <div class="paths_check" style="display:none">  
22 - <?php } ?>  
23 - <table>  
24 - <tr><?php echo $varDirectory; ?></tr>  
25 - <tr><?php echo $documentRoot; ?></tr>  
26 - <tr><?php echo $logDirectory; ?></tr>  
27 - <tr><?php echo $tmpDirectory; ?></tr>  
28 - <tr><?php echo $uploadDirectory; ?></tr>  
29 - <tr><?php echo $config; ?></tr>  
30 - <tr><?php echo $docLocation; ?></tr>  
31 - </table>  
32 - <?php if($silent) { ?>  
33 - </div>  
34 - <?php } ?>  
35 - </div>  
36 - <br/><br/>  
37 - <div>  
38 -<!-- Database connectivity -->  
39 - <h3><?php echo "<span class='{$database_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Database connectivity</h3>  
40 - <?php if($silent) { ?>  
41 - <div id="option9" class="onclick" onclick="javascript:{w.toggleClass('database_check', 'option9');}">Show Details</div>  
42 - <div class="database_check" style="display:none">  
43 - <?php } ?>  
44 - <table>  
45 - <tr><?php echo $dbConnectAdmin; ?></tr>  
46 - <tr><?php echo $dbConnectUser; ?></tr>  
47 - </table>  
48 - <?php if($silent) { ?>  
49 - </div>  
50 -<!-- Privileges -->  
51 - <br/><br/>  
52 - <?php } ?>  
53 - <h3><?php echo "<span class='{$privileges_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Privileges</h3>  
54 - <?php if($silent) { ?>  
55 - <div id="option1" class="onclick" onclick="javascript:{w.toggleClass('privileges_check', 'option1');}">Show Details</div>  
56 - <div class="privileges_check" style="display:none">  
57 - <?php } ?>  
58 - <table style="width:265px;">  
59 - <tr><?php echo $dbPrivileges; ?></tr>  
60 - <tr><?php echo $dbTransaction; ?></tr>  
61 - </table>  
62 - <?php if($silent) { ?>  
63 - </div>  
64 - <?php } ?>  
65 - </div>  
66 -<!-- Services -->  
67 - <br/><br/>  
68 - <div>  
69 - <h3><?php echo "<span class='{$services_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Services</h3>  
70 - <?php if($silent) { ?>  
71 - <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div>  
72 - <div class="services_check" style="display:none">  
73 - <?php } ?>  
74 - <table style="width:755px;">  
75 - <tr>  
76 - <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>  
77 - <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>  
78 - <?php if ($LuceneStatus != 'tick') { ?>  
79 - <td>  
80 - <?php if (AJAX) { ?>  
81 - <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>  
82 - <?php } else { ?>  
83 - <a href="javascript:this.location.reload();" class="refresh">Refresh</a>  
84 - <?php } ?>  
85 - </td>  
86 - <?php } ?>  
87 - </tr>  
88 - <tr>  
89 - <td> <?php echo "<span class='{$SchedulerStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>  
90 - <td> Scheduler Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>  
91 - <?php if ($SchedulerStatus != 'tick') { ?>  
92 - <td>  
93 - <?php if (AJAX) { ?>  
94 - <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>  
95 - <?php } else { ?>  
96 - <a href="javascript:this.location.reload();" class="refresh">Refresh</a>  
97 - <?php } ?>  
98 - </td>  
99 - <?php } ?>  
100 - </tr>  
101 - <tr>  
102 - <td> <?php echo "<span class='{$OpenOfficeStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>  
103 - <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>  
104 - <?php if ($OpenOfficeStatus != 'tick') { ?>  
105 - <td>  
106 - <?php if (AJAX) { ?>  
107 - <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>  
108 - <?php } else { ?>  
109 - <a href="javascript:this.location.reload();" class="refresh">Refresh</a>  
110 - <?php } ?>  
111 - </td>  
112 - <?php } ?>  
113 - </tr>  
114 - </table>  
115 - <?php if($silent) { ?>  
116 - </div>  
117 - <?php } ?>  
118 - </div>  
119 - </div>  
120 - <a href="../../" class="buttons back" style="width:80px;">Goto Login</a>  
121 - <?php  
122 - if (INSTALL_TYPE == 'Zend') {  
123 - ?>  
124 - <a href="<?php echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank">Zend Server Configuration</a>  
125 - <?php  
126 - }  
127 - ?>  
128 -</form> 1 +<form id="install_complete_none">
  2 + <p class="title">Installation Completed</p>
  3 +
  4 + <p class="description">This allows you to check that your KnowledgeTree configuration is set
  5 + up correctly. You can run this at any time after configuration to check
  6 + that things are still set up correctly.</p>
  7 +
  8 + <?php
  9 + if($errors || $warnings){
  10 + echo '<div>'
  11 + . '<a href="http://wiki.knowledgetree.com/Web_Based_Installer#Post_Install" target="_blank">'
  12 + . 'Click Here for help on overcoming post install issues</a></div><br/>';
  13 + }
  14 + ?>
  15 + <div id="step_content_complete" class="step">
  16 + <!-- Paths and Permissions -->
  17 + <div>
  18 + <h3><?php echo "<span class='{$paths_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Paths and Permissions</h3>
  19 + <?php if($silent) { ?>
  20 + <div id="option8" class="onclick" onclick="javascript:{w.toggleClass('paths_check', 'option8');}">Show Details</div>
  21 + <div class="paths_check" style="display:none">
  22 + <?php } ?>
  23 + <table>
  24 + <tr><?php echo $varDirectory; ?></tr>
  25 + <tr><?php echo $documentRoot; ?></tr>
  26 + <tr><?php echo $logDirectory; ?></tr>
  27 + <tr><?php echo $tmpDirectory; ?></tr>
  28 + <tr><?php echo $uploadDirectory; ?></tr>
  29 + <tr><?php echo $config; ?></tr>
  30 + <tr><?php echo $docLocation; ?></tr>
  31 + </table>
  32 + <?php if($silent) { ?>
  33 + </div>
  34 + <?php } ?>
  35 + </div>
  36 + <br/><br/>
  37 + <div>
  38 + <!-- Database connectivity -->
  39 + <h3><?php echo "<span class='{$database_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Database connectivity</h3>
  40 + <?php if($silent) { ?>
  41 + <div id="option9" class="onclick" onclick="javascript:{w.toggleClass('database_check', 'option9');}">Show Details</div>
  42 + <div class="database_check" style="display:none">
  43 + <?php } ?>
  44 + <table>
  45 + <tr><?php echo $dbConnectAdmin; ?></tr>
  46 + <tr><?php echo $dbConnectUser; ?></tr>
  47 + </table>
  48 + <?php if($silent) { ?>
  49 + </div>
  50 + <!-- Privileges -->
  51 + <br/><br/>
  52 + <?php } ?>
  53 + <h3><?php echo "<span class='{$privileges_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Privileges</h3>
  54 + <?php if($silent) { ?>
  55 + <div id="option1" class="onclick" onclick="javascript:{w.toggleClass('privileges_check', 'option1');}">Show Details</div>
  56 + <div class="privileges_check" style="display:none">
  57 + <?php } ?>
  58 + <table style="width:265px;">
  59 + <tr><?php echo $dbPrivileges; ?></tr>
  60 + <tr><?php echo $dbTransaction; ?></tr>
  61 + </table>
  62 + <?php if($silent) { ?>
  63 + </div>
  64 + <?php } ?>
  65 + </div>
  66 + <!-- Services -->
  67 + <br/><br/>
  68 + <div>
  69 + <h3><?php echo "<span class='{$services_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Services</h3>
  70 + <?php if($silent) { ?>
  71 + <div id="option2" class="onclick" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div>
  72 + <div class="services_check" style="display:none">
  73 + <?php } ?>
  74 + <table style="width:755px;">
  75 + <tr>
  76 + <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
  77 + <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
  78 + <?php if ($LuceneStatus != 'tick') { ?>
  79 + <td>
  80 + <?php if (AJAX) { ?>
  81 + <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>
  82 + <?php } else { ?>
  83 + <a href="javascript:this.location.reload();" class="refresh">Refresh</a>
  84 + <?php } ?>
  85 + </td>
  86 + <?php } ?>
  87 + </tr>
  88 + <tr>
  89 + <td> <?php echo "<span class='{$SchedulerStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
  90 + <td> Scheduler Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
  91 + <?php if ($SchedulerStatus != 'tick') { ?>
  92 + <td>
  93 + <?php if (AJAX) { ?>
  94 + <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>
  95 + <?php } else { ?>
  96 + <a href="javascript:this.location.reload();" class="refresh">Refresh</a>
  97 + <?php } ?>
  98 + </td>
  99 + <?php } ?>
  100 + </tr>
  101 + <tr>
  102 + <td> <?php echo "<span class='{$OpenOfficeStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
  103 + <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
  104 + <?php if ($OpenOfficeStatus != 'tick') { ?>
  105 + <td>
  106 + <?php if (AJAX) { ?>
  107 + <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>
  108 + <?php } else { ?>
  109 + <a href="javascript:this.location.reload();" class="refresh">Refresh</a>
  110 + <?php } ?>
  111 + </td>
  112 + <?php } ?>
  113 + </tr>
  114 + </table>
  115 + <?php if($silent) { ?>
  116 + </div>
  117 + <?php } ?>
  118 + </div>
  119 + </div>
  120 + <a href="../../" class="buttons back" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  121 + <?php
  122 + if (INSTALL_TYPE == 'Zend') {
  123 + ?>
  124 + <a href="<?php echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a>
  125 + <?php
  126 + }
  127 + ?>
  128 +</form>
129 <?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?> 129 <?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?>
130 \ No newline at end of file 130 \ No newline at end of file
setup/wizard/templates/configuration.tpl
@@ -118,4 +118,4 @@ @@ -118,4 +118,4 @@
118 <input type="submit" name="Previous" value="Previous" class="button_previous"/> 118 <input type="submit" name="Previous" value="Previous" class="button_previous"/>
119 <input type="submit" name="Next" value="Next" class="button_next"/> 119 <input type="submit" name="Next" value="Next" class="button_next"/>
120 </form> 120 </form>
121 -<?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?>  
122 \ No newline at end of file 121 \ No newline at end of file
  122 +<?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?>
setup/wizard/templates/configuration_confirm.tpl
@@ -94,4 +94,4 @@ @@ -94,4 +94,4 @@
94 <input type="submit" name="Edit" value="Edit" class="button_previous"/> 94 <input type="submit" name="Edit" value="Edit" class="button_previous"/>
95 <input type="submit" name="Confirm" value="Confirm" class="button_next"/> 95 <input type="submit" name="Confirm" value="Confirm" class="button_next"/>
96 </form> 96 </form>
97 -<?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?>  
98 \ No newline at end of file 97 \ No newline at end of file
  98 +<?php if (AJAX) { ?> <script type="text/javascript" src="resources/form.js"></script> <?php } ?>
setup/wizard/templates/registration.tpl
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 <?php } else { ?> 3 <?php } else { ?>
4 <form id="registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post" onsubmit="javascript:{ if(w.validateRegistration()) { w.sendRegistration() };return false;}"> 4 <form id="registration" action="index.php?step_name=<?php echo $step_name; ?>" method="post" onsubmit="javascript:{ if(w.validateRegistration()) { w.sendRegistration() };return false;}">
5 <?php } ?> 5 <?php } ?>
  6 +
6 <p class="title">Registering KnowledgeTree</p> 7 <p class="title">Registering KnowledgeTree</p>
7 <?php 8 <?php
8 //echo $sel_country; 9 //echo $sel_country;