source: trunk/phpgwapi/inc/functions.inc.php @ 1463

Revision 1463, 23.0 KB checked in by rodsouza, 15 years ago (diff)

Ticket #667 - Alterada a declaração 'include' para 'include_once' para evitar erros fatais.

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