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 |
|
cd96fd
|
23 |
// Some users are not using Installer, so we'll check some |
A |
24 |
// critical PHP settings here. Only these, which doesn't provide |
|
25 |
// an error/warning in the logs later. See (#1486307). |
|
26 |
$crit_opts = array( |
|
27 |
'mbstring.func_overload' => 0, |
|
28 |
'suhosin.session.encrypt' => 0, |
|
29 |
'session.auto_start' => 0, |
|
30 |
'file_uploads' => 1, |
|
31 |
); |
|
32 |
foreach ($crit_opts as $optname => $optval) { |
|
33 |
if ($optval != ini_get($optname)) { |
|
34 |
die("ERROR: Wrong '$optname' option value. Read REQUIREMENTS section in INSTALL file or use Roundcube Installer, please!"); |
|
35 |
} |
|
36 |
} |
47124c
|
37 |
|
T |
38 |
// application constants |
a07ab6
|
39 |
define('RCMAIL_VERSION', '0.3-trunk'); |
47124c
|
40 |
define('RCMAIL_CHARSET', 'UTF-8'); |
T |
41 |
define('JS_OBJECT_NAME', 'rcmail'); |
2b35c5
|
42 |
define('RCMAIL_START', microtime(true)); |
47124c
|
43 |
|
T |
44 |
if (!defined('INSTALL_PATH')) { |
2eb794
|
45 |
define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); |
47124c
|
46 |
} |
T |
47 |
|
bba657
|
48 |
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config'); |
T |
49 |
|
47124c
|
50 |
// make sure path_separator is defined |
T |
51 |
if (!defined('PATH_SEPARATOR')) { |
2eb794
|
52 |
define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':'); |
47124c
|
53 |
} |
T |
54 |
|
|
55 |
// RC include folders MUST be included FIRST to avoid other |
|
56 |
// possible not compatible libraries (i.e PEAR) to be included |
|
57 |
// instead the ones provided by RC |
|
58 |
$include_path = INSTALL_PATH . PATH_SEPARATOR; |
|
59 |
$include_path.= INSTALL_PATH . 'program' . PATH_SEPARATOR; |
|
60 |
$include_path.= INSTALL_PATH . 'program/lib' . PATH_SEPARATOR; |
|
61 |
$include_path.= INSTALL_PATH . 'program/include' . PATH_SEPARATOR; |
|
62 |
$include_path.= ini_get('include_path'); |
|
63 |
|
|
64 |
if (set_include_path($include_path) === false) { |
2eb794
|
65 |
die('Fatal error: ini_set/set_include_path does not work.'); |
47124c
|
66 |
} |
T |
67 |
|
b99bf4
|
68 |
ini_set('error_reporting', E_ALL&~E_NOTICE); |
47124c
|
69 |
|
T |
70 |
// increase maximum execution time for php scripts |
|
71 |
// (does not work in safe mode) |
6d479a
|
72 |
@set_time_limit(120); |
47124c
|
73 |
|
d99b93
|
74 |
// set internal encoding for mbstring extension |
A |
75 |
if(extension_loaded('mbstring')) |
2eb794
|
76 |
mb_internal_encoding(RCMAIL_CHARSET); |
d99b93
|
77 |
|
A |
78 |
|
47124c
|
79 |
/** |
T |
80 |
* Use PHP5 autoload for dynamic class loading |
|
81 |
* |
|
82 |
* @todo Make Zend, PEAR etc play with this |
b99bf4
|
83 |
* @todo Make our classes conform to a more straight forward CS. |
47124c
|
84 |
*/ |
588135
|
85 |
function rcube_autoload($classname) |
47124c
|
86 |
{ |
2eb794
|
87 |
$filename = preg_replace( |
A |
88 |
array( |
|
89 |
'/MDB2_(.+)/', |
|
90 |
'/Mail_(.+)/', |
|
91 |
'/Net_(.+)/', |
|
92 |
'/^html_.+/', |
|
93 |
'/^utf8$/', |
|
94 |
'/html2text/' |
|
95 |
), |
|
96 |
array( |
|
97 |
'MDB2/\\1', |
|
98 |
'Mail/\\1', |
|
99 |
'Net/\\1', |
|
100 |
'html', |
|
101 |
'utf8.class', |
|
102 |
'lib/html2text' // see #1485505 |
|
103 |
), |
|
104 |
$classname |
|
105 |
); |
|
106 |
include $filename. '.php'; |
47124c
|
107 |
} |
T |
108 |
|
588135
|
109 |
spl_autoload_register('rcube_autoload'); |
T |
110 |
|
47124c
|
111 |
/** |
T |
112 |
* Local callback function for PEAR errors |
|
113 |
*/ |
|
114 |
function rcube_pear_error($err) |
|
115 |
{ |
2eb794
|
116 |
error_log(sprintf("%s (%s): %s", |
A |
117 |
$err->getMessage(), |
|
118 |
$err->getCode(), |
|
119 |
$err->getUserinfo()), 0); |
47124c
|
120 |
} |
2eb794
|
121 |
|
A |
122 |
// set PEAR error handling (will also load the PEAR main class) |
|
123 |
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); |
47124c
|
124 |
|
T |
125 |
// include global functions |
|
126 |
require_once 'include/main.inc'; |
|
127 |
require_once 'include/rcube_shared.inc'; |