1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare API - phpgwapi loader * |
---|
4 | * This file written by Dan Kuykendall <seek3r@phpgroupware.org> * |
---|
5 | * and Joseph Engo <jengo@phpgroupware.org> * |
---|
6 | * Has a few functions, but primary role is to load the phpgwapi * |
---|
7 | * Copyright (C) 2000, 2001 Dan Kuykendall * |
---|
8 | * -------------------------------------------------------------------------* |
---|
9 | * This library is part of the eGroupWare API * |
---|
10 | * http://www.egroupware.org/api * |
---|
11 | * ------------------------------------------------------------------------ * |
---|
12 | * This library is free software; you can redistribute it and/or modify it * |
---|
13 | * under the terms of the GNU Lesser General Public License as published by * |
---|
14 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
15 | * or any later version. * |
---|
16 | * This library is distributed in the hope that it will be useful, but * |
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
19 | * See the GNU Lesser General Public License for more details. * |
---|
20 | * You should have received a copy of the GNU Lesser General Public License * |
---|
21 | * along with this library; if not, write to the Free Software Foundation, * |
---|
22 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
23 | \**************************************************************************/ |
---|
24 | |
---|
25 | |
---|
26 | /***************************************************************************\ |
---|
27 | * If running in PHP3, then force admin to upgrade * |
---|
28 | \***************************************************************************/ |
---|
29 | |
---|
30 | error_reporting(error_reporting() & ~E_NOTICE); |
---|
31 | |
---|
32 | include(PHPGW_API_INC.'/common_functions.inc.php'); |
---|
33 | |
---|
34 | /*! |
---|
35 | @function lang |
---|
36 | @abstract function to handle multilanguage support |
---|
37 | */ |
---|
38 | function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='') |
---|
39 | { |
---|
40 | if(is_array($m1)) |
---|
41 | { |
---|
42 | $vars = $m1; |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | $vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10); |
---|
47 | } |
---|
48 | // Get the translation from Lang File, if the database is down. |
---|
49 | if(!$GLOBALS['phpgw']->translation){ |
---|
50 | $fn = PHPGW_SERVER_ROOT.'/phpgwapi/setup/phpgw_'.$GLOBALS['_SERVER']['HTTP_ACCEPT_LANGUAGE'].'.lang'; |
---|
51 | if (file_exists($fn)){ |
---|
52 | $fp = fopen($fn,'r'); |
---|
53 | while ($data = fgets($fp,16000)){ |
---|
54 | list($message_id,$app_name,$null,$content) = explode("\t",substr($data,0,-1)); |
---|
55 | $GLOBALS['phpgw_info']['phpgwapi']['lang'][$message_id] = $content; |
---|
56 | } |
---|
57 | fclose($fp); |
---|
58 | } |
---|
59 | $return = str_replace('%1',$vars[0],$GLOBALS['phpgw_info']['phpgwapi']['lang'][$key]); |
---|
60 | return $return; |
---|
61 | } |
---|
62 | $value = $GLOBALS['phpgw']->translation->translate("$key",$vars); |
---|
63 | return $value; |
---|
64 | } |
---|
65 | |
---|
66 | /* Make sure the header.inc.php is current. */ |
---|
67 | if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header']) |
---|
68 | { |
---|
69 | header("location:setup/manageheader.php"); |
---|
70 | } |
---|
71 | |
---|
72 | /* Make sure the developer is following the rules. */ |
---|
73 | if (!isset($GLOBALS['phpgw_info']['flags']['currentapp'])) |
---|
74 | { |
---|
75 | /* This object does not exist yet. */ |
---|
76 | /* $GLOBALS['phpgw']->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));*/ |
---|
77 | |
---|
78 | echo '<b>!!! YOU DO NOT HAVE YOUR $GLOBALS[\'phpgw_info\'][\'flags\'][\'currentapp\'] SET !!!'; |
---|
79 | echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>'; |
---|
80 | } |
---|
81 | |
---|
82 | magic_quotes_runtime(false); |
---|
83 | print_debug('sane environment','messageonly','api'); |
---|
84 | |
---|
85 | /****************************************************************************\ |
---|
86 | * Multi-Domain support * |
---|
87 | \****************************************************************************/ |
---|
88 | |
---|
89 | /* make them fix their header */ |
---|
90 | if (!isset($GLOBALS['phpgw_domain'])) |
---|
91 | { |
---|
92 | echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>'; |
---|
93 | exit; |
---|
94 | } |
---|
95 | if (!isset($GLOBALS['phpgw_info']['server']['default_domain']) || // allow to overwrite the default domain |
---|
96 | !isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']])) |
---|
97 | { |
---|
98 | reset($GLOBALS['phpgw_domain']); |
---|
99 | list($GLOBALS['phpgw_info']['server']['default_domain']) = each($GLOBALS['phpgw_domain']); |
---|
100 | } |
---|
101 | if (isset($_POST['login'])) // on login |
---|
102 | { |
---|
103 | $GLOBALS['login'] = $_POST['login']; |
---|
104 | if (strstr($GLOBALS['login'],'@') === False || count($GLOBALS['phpgw_domain']) == 1) |
---|
105 | { |
---|
106 | $GLOBALS['login'] .= '@' . get_var('logindomain',array('POST'),$GLOBALS['phpgw_info']['server']['default_domain']); |
---|
107 | } |
---|
108 | $parts = explode('@',$GLOBALS['login']); |
---|
109 | $GLOBALS['phpgw_info']['user']['domain'] = array_pop($parts); |
---|
110 | } |
---|
111 | else // on "normal" pageview |
---|
112 | { |
---|
113 | $GLOBALS['phpgw_info']['user']['domain'] = get_var('domain', array('GET', 'COOKIE'), FALSE); |
---|
114 | } |
---|
115 | |
---|
116 | if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']])) |
---|
117 | { |
---|
118 | $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host']; |
---|
119 | $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_port']; |
---|
120 | $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_name']; |
---|
121 | $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_user']; |
---|
122 | $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_pass']; |
---|
123 | $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_type']; |
---|
124 | } |
---|
125 | else |
---|
126 | { |
---|
127 | $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host']; |
---|
128 | $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_port']; |
---|
129 | $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_name']; |
---|
130 | $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_user']; |
---|
131 | $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass']; |
---|
132 | $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_type']; |
---|
133 | } |
---|
134 | |
---|
135 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox']) |
---|
136 | { |
---|
137 | unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons |
---|
138 | } |
---|
139 | |
---|
140 | print_debug('domain',@$GLOBALS['phpgw_info']['user']['domain'],'api'); |
---|
141 | |
---|
142 | /****************************************************************************\ |
---|
143 | * These lines load up the API, fill up the $phpgw_info array, etc * |
---|
144 | \****************************************************************************/ |
---|
145 | /* Load main class */ |
---|
146 | $GLOBALS['phpgw'] = CreateObject('phpgwapi.phpgw'); |
---|
147 | /************************************************************************\ |
---|
148 | * Load up the main instance of the db class. * |
---|
149 | \************************************************************************/ |
---|
150 | $GLOBALS['phpgw']->db = CreateObject('phpgwapi.db'); |
---|
151 | if ($GLOBALS['phpgw']->debug) |
---|
152 | { |
---|
153 | $GLOBALS['phpgw']->db->Debug = 1; |
---|
154 | } |
---|
155 | $GLOBALS['phpgw']->db->Halt_On_Error = 'no'; |
---|
156 | /* jakjr: ExpressoLivre: We do not count the config table. */ |
---|
157 | if (! |
---|
158 | $GLOBALS['phpgw']->db->connect( |
---|
159 | $GLOBALS['phpgw_info']['server']['db_name'], |
---|
160 | $GLOBALS['phpgw_info']['server']['db_host'], |
---|
161 | $GLOBALS['phpgw_info']['server']['db_port'], |
---|
162 | $GLOBALS['phpgw_info']['server']['db_user'], |
---|
163 | $GLOBALS['phpgw_info']['server']['db_pass'], |
---|
164 | $GLOBALS['phpgw_info']['server']['db_type'] |
---|
165 | ) ) |
---|
166 | //@$GLOBALS['phpgw']->db->query("SELECT COUNT(config_name) FROM phpgw_config"); |
---|
167 | //if(!@$GLOBALS['phpgw']->db->next_record()) |
---|
168 | { |
---|
169 | |
---|
170 | /* BEGIN - CELEPAR - jakjr - 05/06/2006 */ |
---|
171 | /* $setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/'); */ |
---|
172 | /*echo '<center><b>Fatal Error:</b> It appears that you have not created the database tables for ' |
---|
173 | .'eGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';*/ |
---|
174 | echo '<center><b>'.lang("ExpressoLivre is unavailable at this moment. Code %1<br>Please, try later.","001").'</b></center>'; |
---|
175 | /* END - CELEPAR - jakjr - 05/06/2006 */ |
---|
176 | exit; |
---|
177 | } |
---|
178 | $GLOBALS['phpgw']->db->Halt_On_Error = 'yes'; |
---|
179 | |
---|
180 | /* Fill phpgw_info["server"] array */ |
---|
181 | // An Attempt to speed things up using cache premise |
---|
182 | /* jakjr: ExpressoLivre does not use cache. */ |
---|
183 | /* |
---|
184 | $GLOBALS['phpgw']->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__); |
---|
185 | if ($GLOBALS['phpgw']->db->num_rows()) |
---|
186 | { |
---|
187 | $GLOBALS['phpgw']->db->next_record(); |
---|
188 | $GLOBALS['phpgw_info']['server']['cache_phpgw_info'] = stripslashes($GLOBALS['phpgw']->db->f('config_value')); |
---|
189 | }*/ |
---|
190 | |
---|
191 | /* jakjr: ExpressoLivre does not use cache. */ |
---|
192 | /* |
---|
193 | $cache_query = "select content from phpgw_app_sessions where" |
---|
194 | ." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'"; |
---|
195 | |
---|
196 | $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); |
---|
197 | $server_info_cache = $GLOBALS['phpgw']->db->num_rows(); |
---|
198 | */ |
---|
199 | /* |
---|
200 | if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache) |
---|
201 | { |
---|
202 | $GLOBALS['phpgw']->db->next_record(); |
---|
203 | $GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content'))); |
---|
204 | } |
---|
205 | else |
---|
206 | {*/ |
---|
207 | $GLOBALS['phpgw']->db->query("SELECT * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__); |
---|
208 | while ($GLOBALS['phpgw']->db->next_record()) |
---|
209 | { |
---|
210 | $GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value')); |
---|
211 | } |
---|
212 | |
---|
213 | /* |
---|
214 | if(@isset($GLOBALS['phpgw_info']['server']['cache_phpgw_info'])) |
---|
215 | { |
---|
216 | if($server_info_cache) |
---|
217 | { |
---|
218 | $cache_query = "DELETE FROM phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and location='config'"; |
---|
219 | $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); |
---|
220 | } |
---|
221 | $cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES(' |
---|
222 | . "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')"; |
---|
223 | $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); |
---|
224 | }*/ |
---|
225 | //} |
---|
226 | unset($cache_query); |
---|
227 | unset($server_info_cache); |
---|
228 | if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) && !$_SERVER['HTTPS']) |
---|
229 | { |
---|
230 | Header('Location: https://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . $_SERVER['REQUEST_URI']); |
---|
231 | exit; |
---|
232 | } |
---|
233 | |
---|
234 | /****************************************************************************\ |
---|
235 | * This is a global constant that should be used * |
---|
236 | * instead of / or \ in file paths * |
---|
237 | \****************************************************************************/ |
---|
238 | define('SEP',filesystem_separator()); |
---|
239 | |
---|
240 | /************************************************************************\ |
---|
241 | * Required classes * |
---|
242 | \************************************************************************/ |
---|
243 | $GLOBALS['phpgw']->log = CreateObject('phpgwapi.errorlog'); |
---|
244 | $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation'); |
---|
245 | $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common'); |
---|
246 | $GLOBALS['phpgw']->hooks = CreateObject('phpgwapi.hooks'); |
---|
247 | $GLOBALS['phpgw']->auth = CreateObject('phpgwapi.auth'); |
---|
248 | $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts'); |
---|
249 | $GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl'); |
---|
250 | $GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions'); |
---|
251 | $GLOBALS['phpgw']->preferences = CreateObject('phpgwapi.preferences'); |
---|
252 | $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications'); |
---|
253 | print_debug('main class loaded', 'messageonly','api'); |
---|
254 | if (! isset($GLOBALS['phpgw_info']['flags']['included_classes']['error']) || |
---|
255 | ! $GLOBALS['phpgw_info']['flags']['included_classes']['error']) |
---|
256 | { |
---|
257 | include_once(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php'); |
---|
258 | $GLOBALS['phpgw_info']['flags']['included_classes']['error'] = True; |
---|
259 | } |
---|
260 | |
---|
261 | /*****************************************************************************\ |
---|
262 | * ACL defines - moved here to work for xml-rpc/soap, also * |
---|
263 | \*****************************************************************************/ |
---|
264 | define('PHPGW_ACL_READ',1); |
---|
265 | define('PHPGW_ACL_ADD',2); |
---|
266 | define('PHPGW_ACL_EDIT',4); |
---|
267 | define('PHPGW_ACL_DELETE',8); |
---|
268 | define('PHPGW_ACL_PRIVATE',16); |
---|
269 | define('PHPGW_ACL_GROUP_MANAGERS',32); |
---|
270 | define('PHPGW_ACL_CUSTOM_1',64); |
---|
271 | define('PHPGW_ACL_CUSTOM_2',128); |
---|
272 | define('PHPGW_ACL_CUSTOM_3',256); |
---|
273 | |
---|
274 | /****************************************************************************\ |
---|
275 | * Forcing the footer to run when the rest of the script is done. * |
---|
276 | \****************************************************************************/ |
---|
277 | register_shutdown_function(array($GLOBALS['phpgw']->common, 'phpgw_final')); |
---|
278 | |
---|
279 | /****************************************************************************\ |
---|
280 | * Stuff to use if logging in or logging out * |
---|
281 | \****************************************************************************/ |
---|
282 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout') |
---|
283 | { |
---|
284 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login') |
---|
285 | { |
---|
286 | if (@$_POST['login'] != '') |
---|
287 | { |
---|
288 | if (count($GLOBALS['phpgw_domain']) > 1) |
---|
289 | { |
---|
290 | list($login) = explode('@',$_POST['login']); |
---|
291 | } |
---|
292 | else |
---|
293 | { |
---|
294 | $login = $_POST['login']; |
---|
295 | } |
---|
296 | print_debug('LID',$login,'app'); |
---|
297 | $login_id = $GLOBALS['phpgw']->accounts->name2id($login); |
---|
298 | print_debug('User ID',$login_id,'app'); |
---|
299 | $GLOBALS['phpgw']->accounts->accounts($login_id); |
---|
300 | $GLOBALS['phpgw']->preferences->preferences($login_id); |
---|
301 | $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); |
---|
302 | } |
---|
303 | } |
---|
304 | /**************************************************************************\ |
---|
305 | * Everything from this point on will ONLY happen if * |
---|
306 | * the currentapp is not login or logout * |
---|
307 | \**************************************************************************/ |
---|
308 | } |
---|
309 | else |
---|
310 | { |
---|
311 | if (! $GLOBALS['phpgw']->session->verify()) |
---|
312 | { |
---|
313 | // we forward to the same place after the re-login |
---|
314 | if ($GLOBALS['phpgw_info']['server']['webserver_url'] && $GLOBALS['phpgw_info']['server']['webserver_url'] != '/') |
---|
315 | { |
---|
316 | list(,$relpath) = explode($GLOBALS['phpgw_info']['server']['webserver_url'],$_SERVER['PHP_SELF'],2); |
---|
317 | } |
---|
318 | else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given) |
---|
319 | { |
---|
320 | if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches)) |
---|
321 | { |
---|
322 | $relpath = $matches[1]; |
---|
323 | } |
---|
324 | } |
---|
325 | // this removes the sessiondata if its saved in the URL |
---|
326 | $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']); |
---|
327 | Header('Location: '.$GLOBALS['phpgw_info']['server']['webserver_url'].'/login.php?cd=10&phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : ''))); |
---|
328 | exit; |
---|
329 | } |
---|
330 | |
---|
331 | $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); |
---|
332 | |
---|
333 | /* A few hacker resistant constants that will be used throught the program */ |
---|
334 | define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi')); |
---|
335 | define('PHPGW_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_path', 'phpgwapi')); |
---|
336 | define('PHPGW_IMAGES_FILEDIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir', 'phpgwapi')); |
---|
337 | define('PHPGW_APP_ROOT', ExecMethod('phpgwapi.phpgw.common.get_app_dir')); |
---|
338 | define('PHPGW_APP_INC', ExecMethod('phpgwapi.phpgw.common.get_inc_dir')); |
---|
339 | define('PHPGW_APP_TPL', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir')); |
---|
340 | define('PHPGW_IMAGES', ExecMethod('phpgwapi.phpgw.common.get_image_path')); |
---|
341 | define('PHPGW_APP_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir')); |
---|
342 | |
---|
343 | /* define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir()); */ |
---|
344 | |
---|
345 | /* Moved outside of this logic |
---|
346 | define('PHPGW_ACL_READ',1); |
---|
347 | define('PHPGW_ACL_ADD',2); |
---|
348 | define('PHPGW_ACL_EDIT',4); |
---|
349 | define('PHPGW_ACL_DELETE',8); |
---|
350 | define('PHPGW_ACL_PRIVATE',16); |
---|
351 | */ |
---|
352 | |
---|
353 | /********* This sets the user variables *********/ |
---|
354 | $GLOBALS['phpgw_info']['user']['private_dir'] = $GLOBALS['phpgw_info']['server']['files_dir'] |
---|
355 | . '/users/'.$GLOBALS['phpgw_info']['user']['userid']; |
---|
356 | |
---|
357 | /* This will make sure that a user has the basic default prefs. If not it will add them */ |
---|
358 | $GLOBALS['phpgw']->preferences->verify_basic_settings(); |
---|
359 | |
---|
360 | /********* Optional classes, which can be disabled for performance increases *********/ |
---|
361 | while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags'])) |
---|
362 | { |
---|
363 | if (ereg('enable_',$phpgw_class_name[0])) |
---|
364 | { |
---|
365 | $enable_class = str_replace('enable_','',$phpgw_class_name[0]); |
---|
366 | $enable_class = str_replace('_class','',$enable_class); |
---|
367 | eval('$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');'); |
---|
368 | } |
---|
369 | } |
---|
370 | unset($enable_class); |
---|
371 | |
---|
372 | |
---|
373 | reset($GLOBALS['phpgw_info']['flags']); |
---|
374 | |
---|
375 | |
---|
376 | if(!include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme')) |
---|
377 | { |
---|
378 | /* Hope we don't get to this point. Better then the user seeing a */ |
---|
379 | /* complety back screen and not know whats going on */ |
---|
380 | echo '<body bgcolor="FFFFFF">'; |
---|
381 | $GLOBALS['phpgw']->log->write(array('text'=>'F-Abort, No themes found')); |
---|
382 | |
---|
383 | exit; |
---|
384 | } |
---|
385 | |
---|
386 | /*************************************************************************\ |
---|
387 | * These lines load up the templates class * |
---|
388 | \*************************************************************************/ |
---|
389 | if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class']) |
---|
390 | { |
---|
391 | $GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
392 | preg_match('/(.*)\/(.*)/', PHPGW_APP_TPL, $matches); |
---|
393 | |
---|
394 | if ( $GLOBALS['phpgw_info']['flags']['currentapp'] != "jabberit_messenger" ) |
---|
395 | $_SESSION['phpgw_info'][$GLOBALS['phpgw_info']['flags']['currentapp']]['user']['preferences']['common']['template_set'] = $matches[2]; |
---|
396 | } |
---|
397 | |
---|
398 | |
---|
399 | /*************************************************************************\ |
---|
400 | * If they are using frames, we need to set some variables * |
---|
401 | \*************************************************************************/ |
---|
402 | if (((isset($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && |
---|
403 | $GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && |
---|
404 | $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') || |
---|
405 | ($GLOBALS['phpgw_info']['server']['useframes'] == 'always')) |
---|
406 | { |
---|
407 | $GLOBALS['phpgw_info']['flags']['navbar_target'] = 'phpgw_body'; |
---|
408 | } |
---|
409 | |
---|
410 | /*************************************************************************\ |
---|
411 | * Verify that the users session is still active otherwise kick them out * |
---|
412 | \*************************************************************************/ |
---|
413 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && |
---|
414 | $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about' && |
---|
415 | $GLOBALS['phpgw_info']['flags']['currentapp'] != 'mobile') |
---|
416 | { |
---|
417 | // This will need to use ACL in the future |
---|
418 | if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] || |
---|
419 | (@$GLOBALS['phpgw_info']['flags']['admin_only'] && |
---|
420 | ! $GLOBALS['phpgw_info']['user']['apps']['admin'])) |
---|
421 | { |
---|
422 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
423 | |
---|
424 | $GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp'])); |
---|
425 | |
---|
426 | echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; |
---|
427 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
428 | } |
---|
429 | } |
---|
430 | |
---|
431 | if(!is_object($GLOBALS['phpgw']->datetime)) |
---|
432 | { |
---|
433 | $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); |
---|
434 | } |
---|
435 | $GLOBALS['phpgw']->applications->read_installed_apps(); // to get translated app-titles |
---|
436 | |
---|
437 | /*************************************************************************\ |
---|
438 | * Load the header unless the developer turns it off * |
---|
439 | \*************************************************************************/ |
---|
440 | if (!@$GLOBALS['phpgw_info']['flags']['noheader']) |
---|
441 | { |
---|
442 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
443 | } |
---|
444 | } |
---|