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