thomascube
2009-10-31 7e76b00fec07bf5cb799065aedfeb1266f76481b
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
7e76b0 25 define('RCMAIL_VERSION', '0.3.1');
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')) {
23a2ee 37   define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':');
47124c 38 }
T 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);
191354 61 ini_set('session.use_only_cookies', 1);
47124c 62
T 63 // increase maximum execution time for php scripts
64 // (does not work in safe mode)
6d479a 65 @set_time_limit(120);
47124c 66
d99b93 67 // set internal encoding for mbstring extension
A 68 if(extension_loaded('mbstring'))
69   mb_internal_encoding(RCMAIL_CHARSET);
70           
71
47124c 72 /**
T 73  * Use PHP5 autoload for dynamic class loading
74  * 
75  * @todo Make Zend, PEAR etc play with this
b99bf4 76  * @todo Make our classes conform to a more straight forward CS.
47124c 77  */
588135 78 function rcube_autoload($classname)
47124c 79 {
T 80   $filename = preg_replace(
588135 81       array(
T 82         '/MDB2_(.+)/',
83         '/Mail_(.+)/',
84         '/Net_(.+)/',
85         '/^html_.+/',
86         '/^utf8$/',
87         '/html2text/'
88       ),
89       array(
90         'MDB2/\\1',
91         'Mail/\\1',
92         'Net/\\1',
93         'html',
94         'utf8.class',
95         'lib/html2text'  // see #1485505
96       ),
47124c 97       $classname
T 98   );
c762c0 99   include $filename. '.php';
47124c 100 }
T 101
588135 102 spl_autoload_register('rcube_autoload');
T 103
47124c 104 /**
T 105  * Local callback function for PEAR errors
106  */
107 function rcube_pear_error($err)
108 {
109   error_log(sprintf("%s (%s): %s",
110     $err->getMessage(),
111     $err->getCode(),
112     $err->getUserinfo()), 0);
113 }
114
115 // include global functions
116 require_once 'include/bugs.inc';
117 require_once 'include/main.inc';
118 require_once 'include/rcube_shared.inc';
119
120
121 // set PEAR error handling (will also load the PEAR main class)
122 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error');