| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /* |
|---|
| 4 | +-----------------------------------------------------------------------+ |
|---|
| 5 | | program/include/bootstrap.php | |
|---|
| 6 | | | |
|---|
| 7 | | This file is part of the RoundCube Webmail client | |
|---|
| 8 | | Copyright (C) 2007, RoundCube Dev, - Switzerland | |
|---|
| 9 | | Licensed under the GNU GPL | |
|---|
| 10 | | | |
|---|
| 11 | | PURPOSE: | |
|---|
| 12 | | Setup the application envoronment required to process | |
|---|
| 13 | | any request. | |
|---|
| 14 | +-----------------------------------------------------------------------+ |
|---|
| 15 | | Author: Till Klampaeckel <till@php.net> | |
|---|
| 16 | | Thomas Bruederli <roundcube@gmail.com> | |
|---|
| 17 | +-----------------------------------------------------------------------+ |
|---|
| 18 | |
|---|
| 19 | $Id: cache.inc 88 2005-12-03 16:54:12Z roundcube $ |
|---|
| 20 | |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | // application constants |
|---|
| 25 | define('RCMAIL_VERSION', 'devel-vnext (0.1-rc1)'); |
|---|
| 26 | define('RCMAIL_CHARSET', 'UTF-8'); |
|---|
| 27 | define('JS_OBJECT_NAME', 'rcmail'); |
|---|
| 28 | |
|---|
| 29 | if (!defined('INSTALL_PATH')) |
|---|
| 30 | define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); |
|---|
| 31 | |
|---|
| 32 | // make sure path_separator is defined |
|---|
| 33 | if (!defined('PATH_SEPARATOR')) { |
|---|
| 34 | define('PATH_SEPARATOR', (eregi('win', PHP_OS) ? ';' : ':')); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | // RC include folders MUST be included FIRST to avoid other |
|---|
| 38 | // possible not compatible libraries (i.e PEAR) to be included |
|---|
| 39 | // instead the ones provided by RC |
|---|
| 40 | $include_path = INSTALL_PATH . PATH_SEPARATOR; |
|---|
| 41 | $include_path.= INSTALL_PATH . 'program' . PATH_SEPARATOR; |
|---|
| 42 | $include_path.= INSTALL_PATH . 'program/lib' . PATH_SEPARATOR; |
|---|
| 43 | $include_path.= ini_get('include_path'); |
|---|
| 44 | |
|---|
| 45 | if (set_include_path($include_path) === false) { |
|---|
| 46 | die('Fatal error: ini_set/set_include_path does not work.'); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | ini_set('session.name', 'roundcube_sessid'); |
|---|
| 50 | ini_set('session.use_cookies', 1); |
|---|
| 51 | ini_set('session.gc_maxlifetime', 21600); |
|---|
| 52 | ini_set('session.gc_divisor', 500); |
|---|
| 53 | ini_set('error_reporting', E_ALL|E_STRICT); |
|---|
| 54 | set_magic_quotes_runtime(0); |
|---|
| 55 | |
|---|
| 56 | // increase maximum execution time for php scripts |
|---|
| 57 | // (does not work in safe mode) |
|---|
| 58 | if (!ini_get('safe_mode')) { |
|---|
| 59 | set_time_limit(120); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * Use PHP5 autoload for dynamic class loading |
|---|
| 64 | * |
|---|
| 65 | * @todo Make Zend, PEAR etc play with this |
|---|
| 66 | */ |
|---|
| 67 | function __autoload($classname) { |
|---|
| 68 | $filename = preg_replace( |
|---|
| 69 | array('/MDB2_(.+)/', '/Mail_(.+)/', '/^html_.+/'), |
|---|
| 70 | array("MDB2/\\1", "Mail/\\1", "html"), |
|---|
| 71 | $classname |
|---|
| 72 | ); |
|---|
| 73 | include_once $filename. '.php'; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | // include global functions |
|---|
| 77 | require_once 'globals.php'; |
|---|
| 78 | |
|---|
| 79 | /** |
|---|
| 80 | * Local callback function for PEAR errors |
|---|
| 81 | */ |
|---|
| 82 | function rcube_pear_error($err) { |
|---|
| 83 | error_log(sprintf("%s (%s): %s", |
|---|
| 84 | $err->getMessage(), |
|---|
| 85 | $err->getCode(), |
|---|
| 86 | $err->getUserinfo()), 0); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | // set PEAR error handling |
|---|
| 90 | PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); |
|---|
| 91 | |
|---|
| 92 | // create registry and set some global properties |
|---|
| 93 | $registry = rcube_registry::get_instance(); |
|---|
| 94 | $registry->set('mbstring_loaded', null, 'core'); |
|---|