Commit e947fa226368e9408487cd4428b8560b796901f3

Authored by Megan Watson
2 parents 87600c95 73850171

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

ktwebservice/KTDownloadManager.inc.php
... ... @@ -105,6 +105,8 @@ class KTDownloadManager
105 105 'document_id'=>$doc_id,
106 106 'session'=>$this->session,
107 107 'download_date'=>date('Y-m-d H:i:s'),
  108 + 'content_version'=>$document->document->getContentVersionId(),
  109 + 'filesize'=>$document->document->getFileSize(),
108 110 'hash'=>$hash
109 111 ),
110 112 array('noid'=>true)
... ...
lib/documentmanagement/Document.inc
... ... @@ -169,7 +169,7 @@ class Document {
169 169  
170 170 function getStoragePath() { return $this->_oDocumentContentVersion->getStoragePath(); }
171 171 function setStoragePath($sNewValue) { $this->_oDocumentContentVersion->setStoragePath($sNewValue); }
172   -
  172 +
173 173  
174 174  
175 175 /**
... ...
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   - 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 -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   -}
  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 -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 +}
244 244 ?>
245 245 \ 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   - private $salt = 'installers';
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   - if(!WINDOWS_OS) $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   - if(!WINDOWS_OS) $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   - if(!WINDOWS_OS) $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   - $this->openOfficeExeError = false;
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   -}
1190   -?>
  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 = 'installers';
  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 + if(!WINDOWS_OS) $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 + if(!WINDOWS_OS) $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 + if(!WINDOWS_OS) $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 + $this->openOfficeExeError = false;
  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 +}
  1190 +?>
... ...
var/proxies/.empty deleted
1   -Order deny,allow
2   -Deny from all
webservice/clienttools/services/3.6.1/kt.php
... ... @@ -482,7 +482,7 @@ class kt extends client_service {
482 482 */
483 483  
484 484 $response['status_code']=0;
485   - $response['message']=$url;
  485 + $response['message']=$url.'&apptype='.$params['app_type'];
486 486 $response['filename']=$docname;
487 487 $this->addDebug('effective params',$params);
488 488 $this->setResponse($response);
... ... @@ -651,8 +651,7 @@ class kt extends client_service {
651 651 $this->response= array('status_code'=>0, 'document_id'=>$document_id, 'content_id'=>$content_id);
652 652 }
653 653  
654   -
655   - function get_all_client_policies(){
  654 + function get_all_client_policies(){
656 655 $config=KTConfig::getSingleton();
657 656 $this->addDebug('KTConfig Singleton',$config);
658 657  
... ...