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