thomascube
2009-05-15 068f235b91ac463dd6dd9365e85bafae4a28e6bf
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
19  $Id: cache.inc 88 2005-12-03 16:54:12Z roundcube $
20
21 */
22
23
24 // application constants
068f23 25 define('RCMAIL_VERSION', '0.2.2');
47124c 26 define('RCMAIL_CHARSET', 'UTF-8');
T 27 define('JS_OBJECT_NAME', 'rcmail');
28
29 if (!defined('INSTALL_PATH')) {
30   define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/');
31 }
32
bba657 33 define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
T 34
47124c 35 // make sure path_separator is defined
T 36 if (!defined('PATH_SEPARATOR')) {
37   define('PATH_SEPARATOR', (eregi('win', PHP_OS) ? ';' : ':'));
38 }
39
40 // RC include folders MUST be included FIRST to avoid other
41 // possible not compatible libraries (i.e PEAR) to be included
42 // instead the ones provided by RC
43 $include_path = INSTALL_PATH . PATH_SEPARATOR;
44 $include_path.= INSTALL_PATH . 'program' . PATH_SEPARATOR;
45 $include_path.= INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
46 $include_path.= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
47 $include_path.= ini_get('include_path');
48
49 if (set_include_path($include_path) === false) {
50   die('Fatal error: ini_set/set_include_path does not work.');
51 }
52
b99bf4 53 ini_set('error_reporting', E_ALL&~E_NOTICE);
T 54 if  (isset($_SERVER['HTTPS'])) {
55    ini_set('session.cookie_secure', ($_SERVER['HTTPS'] && ($_SERVER['HTTPS'] != 'off'))?1:0);
56 } else {
57    ini_set('session.cookie_secure', 0);
58 }
47124c 59 ini_set('session.name', 'roundcube_sessid');
T 60 ini_set('session.use_cookies', 1);
cefd1d 61 ini_set('session.only_use_cookies', 1);
47124c 62 set_magic_quotes_runtime(0);
T 63
64 // increase maximum execution time for php scripts
65 // (does not work in safe mode)
66 if (!ini_get('safe_mode')) {
67   set_time_limit(120);
68 }
69
d99b93 70 // set internal encoding for mbstring extension
A 71 if(extension_loaded('mbstring'))
72   mb_internal_encoding(RCMAIL_CHARSET);
73           
74
47124c 75 /**
T 76  * Use PHP5 autoload for dynamic class loading
77  * 
78  * @todo Make Zend, PEAR etc play with this
b99bf4 79  * @todo Make our classes conform to a more straight forward CS.
47124c 80  */
T 81 function __autoload($classname)
82 {
83   $filename = preg_replace(
bfdbcf 84       array('/MDB2_(.+)/',
A 85             '/Mail_(.+)/',
86         '/^html_.+/',
87         '/^utf8$/',
88         '/html2text/'
89     ),
90       array('MDB2/\\1',
91             'Mail/\\1',
92         'html',
93         'utf8.class',
94         'lib/html2text'    // see #1485505
95     ),
47124c 96       $classname
T 97   );
123300 98   include $filename. '.php';
47124c 99 }
T 100
101 /**
102  * Local callback function for PEAR errors
103  */
104 function rcube_pear_error($err)
105 {
106   error_log(sprintf("%s (%s): %s",
107     $err->getMessage(),
108     $err->getCode(),
109     $err->getUserinfo()), 0);
110 }
111
112 // include global functions
113 require_once 'include/bugs.inc';
114 require_once 'include/main.inc';
115 require_once 'include/rcube_shared.inc';
116
117
118 // set PEAR error handling (will also load the PEAR main class)
119 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');