[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); |
---|
| 31 | |
---|
[2549] | 32 | include_once(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 | |
---|
| 66 | /* Make sure the header.inc.php is current. */ |
---|
| 67 | if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header']) |
---|
| 68 | { |
---|
[1333] | 69 | header("location:setup/manageheader.php"); |
---|
[2] | 70 | } |
---|
| 71 | |
---|
| 72 | /* Make sure the developer is following the rules. */ |
---|
| 73 | if (!isset($GLOBALS['phpgw_info']['flags']['currentapp'])) |
---|
| 74 | { |
---|
| 75 | /* This object does not exist yet. */ |
---|
| 76 | /* $GLOBALS['phpgw']->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));*/ |
---|
| 77 | |
---|
| 78 | echo '<b>!!! YOU DO NOT HAVE YOUR $GLOBALS[\'phpgw_info\'][\'flags\'][\'currentapp\'] SET !!!'; |
---|
| 79 | echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>'; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | magic_quotes_runtime(false); |
---|
| 83 | print_debug('sane environment','messageonly','api'); |
---|
| 84 | |
---|
| 85 | /****************************************************************************\ |
---|
| 86 | * Multi-Domain support * |
---|
| 87 | \****************************************************************************/ |
---|
[440] | 88 | |
---|
[2] | 89 | /* make them fix their header */ |
---|
| 90 | if (!isset($GLOBALS['phpgw_domain'])) |
---|
| 91 | { |
---|
| 92 | echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>'; |
---|
| 93 | exit; |
---|
| 94 | } |
---|
| 95 | if (!isset($GLOBALS['phpgw_info']['server']['default_domain']) || // allow to overwrite the default domain |
---|
| 96 | !isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']])) |
---|
| 97 | { |
---|
| 98 | reset($GLOBALS['phpgw_domain']); |
---|
| 99 | list($GLOBALS['phpgw_info']['server']['default_domain']) = each($GLOBALS['phpgw_domain']); |
---|
| 100 | } |
---|
| 101 | if (isset($_POST['login'])) // on login |
---|
| 102 | { |
---|
| 103 | $GLOBALS['login'] = $_POST['login']; |
---|
| 104 | if (strstr($GLOBALS['login'],'@') === False || count($GLOBALS['phpgw_domain']) == 1) |
---|
| 105 | { |
---|
| 106 | $GLOBALS['login'] .= '@' . get_var('logindomain',array('POST'),$GLOBALS['phpgw_info']['server']['default_domain']); |
---|
| 107 | } |
---|
| 108 | $parts = explode('@',$GLOBALS['login']); |
---|
| 109 | $GLOBALS['phpgw_info']['user']['domain'] = array_pop($parts); |
---|
| 110 | } |
---|
| 111 | else // on "normal" pageview |
---|
| 112 | { |
---|
| 113 | $GLOBALS['phpgw_info']['user']['domain'] = get_var('domain', array('GET', 'COOKIE'), FALSE); |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']])) |
---|
| 117 | { |
---|
| 118 | $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host']; |
---|
| 119 | $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_port']; |
---|
| 120 | $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_name']; |
---|
| 121 | $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_user']; |
---|
| 122 | $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_pass']; |
---|
| 123 | $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_type']; |
---|
| 124 | } |
---|
| 125 | else |
---|
| 126 | { |
---|
| 127 | $GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host']; |
---|
| 128 | $GLOBALS['phpgw_info']['server']['db_port'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_port']; |
---|
| 129 | $GLOBALS['phpgw_info']['server']['db_name'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_name']; |
---|
| 130 | $GLOBALS['phpgw_info']['server']['db_user'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_user']; |
---|
| 131 | $GLOBALS['phpgw_info']['server']['db_pass'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_pass']; |
---|
| 132 | $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_type']; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox']) |
---|
| 136 | { |
---|
| 137 | unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | print_debug('domain',@$GLOBALS['phpgw_info']['user']['domain'],'api'); |
---|
| 141 | |
---|
| 142 | /****************************************************************************\ |
---|
| 143 | * These lines load up the API, fill up the $phpgw_info array, etc * |
---|
| 144 | \****************************************************************************/ |
---|
| 145 | /* Load main class */ |
---|
| 146 | $GLOBALS['phpgw'] = CreateObject('phpgwapi.phpgw'); |
---|
| 147 | /************************************************************************\ |
---|
| 148 | * Load up the main instance of the db class. * |
---|
| 149 | \************************************************************************/ |
---|
| 150 | $GLOBALS['phpgw']->db = CreateObject('phpgwapi.db'); |
---|
| 151 | if ($GLOBALS['phpgw']->debug) |
---|
| 152 | { |
---|
| 153 | $GLOBALS['phpgw']->db->Debug = 1; |
---|
| 154 | } |
---|
| 155 | $GLOBALS['phpgw']->db->Halt_On_Error = 'no'; |
---|
[440] | 156 | /* jakjr: ExpressoLivre: We do not count the config table. */ |
---|
| 157 | if (! |
---|
[2] | 158 | $GLOBALS['phpgw']->db->connect( |
---|
| 159 | $GLOBALS['phpgw_info']['server']['db_name'], |
---|
| 160 | $GLOBALS['phpgw_info']['server']['db_host'], |
---|
| 161 | $GLOBALS['phpgw_info']['server']['db_port'], |
---|
| 162 | $GLOBALS['phpgw_info']['server']['db_user'], |
---|
| 163 | $GLOBALS['phpgw_info']['server']['db_pass'], |
---|
| 164 | $GLOBALS['phpgw_info']['server']['db_type'] |
---|
[440] | 165 | ) ) |
---|
| 166 | //@$GLOBALS['phpgw']->db->query("SELECT COUNT(config_name) FROM phpgw_config"); |
---|
| 167 | //if(!@$GLOBALS['phpgw']->db->next_record()) |
---|
[2] | 168 | { |
---|
[440] | 169 | |
---|
[2] | 170 | /* BEGIN - CELEPAR - jakjr - 05/06/2006 */ |
---|
[440] | 171 | /* $setup_dir = str_replace($_SERVER['PHP_SELF'],'index.php','setup/'); */ |
---|
[2] | 172 | /*echo '<center><b>Fatal Error:</b> It appears that you have not created the database tables for ' |
---|
| 173 | .'eGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';*/ |
---|
[440] | 174 | echo '<center><b>'.lang("ExpressoLivre is unavailable at this moment. Code %1<br>Please, try later.","001").'</b></center>'; |
---|
[2] | 175 | /* END - CELEPAR - jakjr - 05/06/2006 */ |
---|
| 176 | exit; |
---|
| 177 | } |
---|
| 178 | $GLOBALS['phpgw']->db->Halt_On_Error = 'yes'; |
---|
| 179 | |
---|
| 180 | /* Fill phpgw_info["server"] array */ |
---|
| 181 | // An Attempt to speed things up using cache premise |
---|
| 182 | |
---|
[440] | 183 | /* |
---|
[2419] | 184 | $GLOBALS['phpgw']->db->query( |
---|
| 185 | "select content from phpgw_app_sessions" |
---|
| 186 | . " where sessionid = '0' and loginid = '0'" |
---|
| 187 | . " and app = 'phpgwapi' and location = 'config'", |
---|
| 188 | __LINE__, __FILE__ ); |
---|
| 189 | |
---|
| 190 | if ( $GLOBALS['phpgw']->db->num_rows( ) ) |
---|
[2] | 191 | { |
---|
| 192 | $GLOBALS['phpgw']->db->next_record(); |
---|
| 193 | $GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content'))); |
---|
| 194 | } |
---|
| 195 | else |
---|
[440] | 196 | {*/ |
---|
| 197 | $GLOBALS['phpgw']->db->query("SELECT * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__); |
---|
[2] | 198 | while ($GLOBALS['phpgw']->db->next_record()) |
---|
| 199 | { |
---|
| 200 | $GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value')); |
---|
| 201 | } |
---|
| 202 | |
---|
[440] | 203 | /* |
---|
[2419] | 204 | $GLOBALS['phpgw']->db->query( |
---|
| 205 | 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content)' |
---|
| 206 | . " VALUES('0','0','phpgwapi','config','" |
---|
| 207 | . addslashes( serialize( $GLOBALS['phpgw_info']['server'] ) ) . "')", |
---|
| 208 | __LINE__, __FILE__ ); |
---|
| 209 | }*/ |
---|
| 210 | |
---|
[2] | 211 | if(@isset($GLOBALS['phpgw_info']['server']['enforce_ssl']) && !$_SERVER['HTTPS']) |
---|
| 212 | { |
---|
| 213 | Header('Location: https://' . $GLOBALS['phpgw_info']['server']['hostname'] . $GLOBALS['phpgw_info']['server']['webserver_url'] . $_SERVER['REQUEST_URI']); |
---|
| 214 | exit; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | /****************************************************************************\ |
---|
| 218 | * This is a global constant that should be used * |
---|
| 219 | * instead of / or \ in file paths * |
---|
| 220 | \****************************************************************************/ |
---|
| 221 | define('SEP',filesystem_separator()); |
---|
| 222 | |
---|
| 223 | /************************************************************************\ |
---|
| 224 | * Required classes * |
---|
| 225 | \************************************************************************/ |
---|
| 226 | $GLOBALS['phpgw']->log = CreateObject('phpgwapi.errorlog'); |
---|
| 227 | $GLOBALS['phpgw']->translation = CreateObject('phpgwapi.translation'); |
---|
| 228 | $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common'); |
---|
| 229 | $GLOBALS['phpgw']->hooks = CreateObject('phpgwapi.hooks'); |
---|
| 230 | $GLOBALS['phpgw']->auth = CreateObject('phpgwapi.auth'); |
---|
| 231 | $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts'); |
---|
| 232 | $GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl'); |
---|
| 233 | $GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions'); |
---|
| 234 | $GLOBALS['phpgw']->preferences = CreateObject('phpgwapi.preferences'); |
---|
| 235 | $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications'); |
---|
[2549] | 236 | $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript'); |
---|
[2645] | 237 | $GLOBALS['phpgw']->css = CreateObject('phpgwapi.css'); |
---|
| 238 | |
---|
[2] | 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 | { |
---|
[1463] | 243 | include_once(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php'); |
---|
[2] | 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 | } |
---|
[2674] | 311 | |
---|
| 312 | $relpath = str_replace( 'index.php', '', $relpath ); |
---|
| 313 | if ( $relpath[ 0 ] == '/' ) |
---|
| 314 | $relpath = substr( $relpath, 1 ); |
---|
| 315 | $relpath = '#' . $relpath; |
---|
| 316 | |
---|
[2] | 317 | // this removes the sessiondata if its saved in the URL |
---|
| 318 | $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']); |
---|
| 319 | Header('Location: '.$GLOBALS['phpgw_info']['server']['webserver_url'].'/login.php?cd=10&phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : ''))); |
---|
| 320 | exit; |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); |
---|
| 324 | |
---|
| 325 | /* A few hacker resistant constants that will be used throught the program */ |
---|
| 326 | define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi')); |
---|
| 327 | define('PHPGW_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_path', 'phpgwapi')); |
---|
| 328 | define('PHPGW_IMAGES_FILEDIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir', 'phpgwapi')); |
---|
| 329 | define('PHPGW_APP_ROOT', ExecMethod('phpgwapi.phpgw.common.get_app_dir')); |
---|
| 330 | define('PHPGW_APP_INC', ExecMethod('phpgwapi.phpgw.common.get_inc_dir')); |
---|
| 331 | define('PHPGW_APP_TPL', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir')); |
---|
| 332 | define('PHPGW_IMAGES', ExecMethod('phpgwapi.phpgw.common.get_image_path')); |
---|
| 333 | define('PHPGW_APP_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_dir')); |
---|
| 334 | |
---|
| 335 | /* define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir()); */ |
---|
| 336 | |
---|
| 337 | /* Moved outside of this logic |
---|
| 338 | define('PHPGW_ACL_READ',1); |
---|
| 339 | define('PHPGW_ACL_ADD',2); |
---|
| 340 | define('PHPGW_ACL_EDIT',4); |
---|
| 341 | define('PHPGW_ACL_DELETE',8); |
---|
| 342 | define('PHPGW_ACL_PRIVATE',16); |
---|
| 343 | */ |
---|
| 344 | |
---|
| 345 | /********* This sets the user variables *********/ |
---|
| 346 | $GLOBALS['phpgw_info']['user']['private_dir'] = $GLOBALS['phpgw_info']['server']['files_dir'] |
---|
| 347 | . '/users/'.$GLOBALS['phpgw_info']['user']['userid']; |
---|
| 348 | |
---|
| 349 | /* This will make sure that a user has the basic default prefs. If not it will add them */ |
---|
| 350 | $GLOBALS['phpgw']->preferences->verify_basic_settings(); |
---|
| 351 | |
---|
[2191] | 352 | /********* Optional classes, which can be disabled for performance increases *********/ |
---|
| 353 | while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags'])) |
---|
| 354 | { |
---|
| 355 | if (ereg('enable_',$phpgw_class_name[0])) |
---|
| 356 | { |
---|
| 357 | $enable_class = str_replace('enable_','',$phpgw_class_name[0]); |
---|
| 358 | $enable_class = str_replace('_class','',$enable_class); |
---|
| 359 | eval('$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');'); |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | unset($enable_class); |
---|
| 363 | |
---|
| 364 | |
---|
[2] | 365 | reset($GLOBALS['phpgw_info']['flags']); |
---|
| 366 | |
---|
[2205] | 367 | |
---|
| 368 | if(!include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme')) |
---|
| 369 | { |
---|
| 370 | /* Hope we don't get to this point. Better then the user seeing a */ |
---|
| 371 | /* complety back screen and not know whats going on */ |
---|
| 372 | echo '<body bgcolor="FFFFFF">'; |
---|
| 373 | $GLOBALS['phpgw']->log->write(array('text'=>'F-Abort, No themes found')); |
---|
| 374 | |
---|
| 375 | exit; |
---|
| 376 | } |
---|
| 377 | |
---|
[2] | 378 | /*************************************************************************\ |
---|
| 379 | * These lines load up the templates class * |
---|
| 380 | \*************************************************************************/ |
---|
| 381 | if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class']) |
---|
| 382 | { |
---|
| 383 | $GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); |
---|
[790] | 384 | preg_match('/(.*)\/(.*)/', PHPGW_APP_TPL, $matches); |
---|
| 385 | |
---|
[889] | 386 | if ( $GLOBALS['phpgw_info']['flags']['currentapp'] != "jabberit_messenger" ) |
---|
| 387 | $_SESSION['phpgw_info'][$GLOBALS['phpgw_info']['flags']['currentapp']]['user']['preferences']['common']['template_set'] = $matches[2]; |
---|
[2] | 388 | } |
---|
| 389 | |
---|
| 390 | |
---|
| 391 | /*************************************************************************\ |
---|
| 392 | * If they are using frames, we need to set some variables * |
---|
| 393 | \*************************************************************************/ |
---|
| 394 | if (((isset($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && |
---|
| 395 | $GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && |
---|
| 396 | $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') || |
---|
| 397 | ($GLOBALS['phpgw_info']['server']['useframes'] == 'always')) |
---|
| 398 | { |
---|
| 399 | $GLOBALS['phpgw_info']['flags']['navbar_target'] = 'phpgw_body'; |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | /*************************************************************************\ |
---|
| 403 | * Verify that the users session is still active otherwise kick them out * |
---|
| 404 | \*************************************************************************/ |
---|
| 405 | if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && |
---|
[411] | 406 | $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about' && |
---|
| 407 | $GLOBALS['phpgw_info']['flags']['currentapp'] != 'mobile') |
---|
[2] | 408 | { |
---|
| 409 | // This will need to use ACL in the future |
---|
| 410 | if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] || |
---|
| 411 | (@$GLOBALS['phpgw_info']['flags']['admin_only'] && |
---|
| 412 | ! $GLOBALS['phpgw_info']['user']['apps']['admin'])) |
---|
| 413 | { |
---|
[2549] | 414 | //$GLOBALS['phpgw']->common->phpgw_header(); |
---|
[2] | 415 | |
---|
| 416 | $GLOBALS['phpgw']->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp'])); |
---|
| 417 | |
---|
| 418 | echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; |
---|
| 419 | $GLOBALS['phpgw']->common->phpgw_exit(True); |
---|
| 420 | } |
---|
| 421 | } |
---|
| 422 | |
---|
| 423 | if(!is_object($GLOBALS['phpgw']->datetime)) |
---|
| 424 | { |
---|
| 425 | $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.date_time'); |
---|
| 426 | } |
---|
[2549] | 427 | |
---|
[2] | 428 | $GLOBALS['phpgw']->applications->read_installed_apps(); // to get translated app-titles |
---|
| 429 | } |
---|