thomascube
2010-04-01 1d773d71414316e0b9836a15c35576593427ee21
commit | author | age
47124c 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
197601 5  | program/include/iniset.php                                            |
47124c 6  |                                                                       |
T 7  | This file is part of the RoundCube Webmail client                     |
cbbef3 8  | Copyright (C) 2008-2009, RoundCube Dev, - Switzerland                 |
47124c 9  | Licensed under the GNU GPL                                            |
T 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
af58c3 19  $Id$
47124c 20
T 21 */
22
23
24 // application constants
a07ab6 25 define('RCMAIL_VERSION', '0.3-trunk');
47124c 26 define('RCMAIL_CHARSET', 'UTF-8');
T 27 define('JS_OBJECT_NAME', 'rcmail');
2b35c5 28 define('RCMAIL_START', microtime(true));
47124c 29
T 30 if (!defined('INSTALL_PATH')) {
31   define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
32 }
33
bba657 34 define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
T 35
47124c 36 // make sure path_separator is defined
T 37 if (!defined('PATH_SEPARATOR')) {
23a2ee 38   define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
47124c 39 }
T 40
41 // RC include folders MUST be included FIRST to avoid other
42 // possible not compatible libraries (i.e PEAR) to be included
43 // instead the ones provided by RC
44 $include_path = INSTALL_PATH . PATH_SEPARATOR;
45 $include_path.= INSTALL_PATH . 'program' . PATH_SEPARATOR;
46 $include_path.= INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
47 $include_path.= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
48 $include_path.= ini_get('include_path');
49
50 if (set_include_path($include_path) === false) {
51   die('Fatal error: ini_set/set_include_path does not work.');
52 }
53
b99bf4 54 ini_set('error_reporting', E_ALL&~E_NOTICE);
47124c 55
T 56 // increase maximum execution time for php scripts
57 // (does not work in safe mode)
6d479a 58 @set_time_limit(120);
47124c 59
d99b93 60 // set internal encoding for mbstring extension
A 61 if(extension_loaded('mbstring'))
62   mb_internal_encoding(RCMAIL_CHARSET);
63           
64
47124c 65 /**
T 66  * Use PHP5 autoload for dynamic class loading
67  * 
68  * @todo Make Zend, PEAR etc play with this
b99bf4 69  * @todo Make our classes conform to a more straight forward CS.
47124c 70  */
588135 71 function rcube_autoload($classname)
47124c 72 {
T 73   $filename = preg_replace(
588135 74       array(
T 75         '/MDB2_(.+)/',
76         '/Mail_(.+)/',
77         '/Net_(.+)/',
78         '/^html_.+/',
79         '/^utf8$/',
80         '/html2text/'
81       ),
82       array(
83         'MDB2/\\1',
84         'Mail/\\1',
85         'Net/\\1',
86         'html',
87         'utf8.class',
88         'lib/html2text'  // see #1485505
89       ),
47124c 90       $classname
T 91   );
c762c0 92   include $filename. '.php';
47124c 93 }
T 94
588135 95 spl_autoload_register('rcube_autoload');
T 96
47124c 97 /**
T 98  * Local callback function for PEAR errors
99  */
100 function rcube_pear_error($err)
101 {
102   error_log(sprintf("%s (%s): %s",
103     $err->getMessage(),
104     $err->getCode(),
105     $err->getUserinfo()), 0);
106 }
107
108 // include global functions
109 require_once 'include/bugs.inc';
110 require_once 'include/main.inc';
111 require_once 'include/rcube_shared.inc';
112
113
114 // set PEAR error handling (will also load the PEAR main class)
115 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');