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