commit | author | age
|
47124c
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
197601
|
5 |
| program/include/iniset.php | |
47124c
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
e224b0
|
8 |
| Copyright (C) 2008-2011, The Roundcube Dev Team | |
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, |
140abb
|
31 |
'magic_quotes_runtime' => 0, |
cd96fd
|
32 |
); |
A |
33 |
foreach ($crit_opts as $optname => $optval) { |
|
34 |
if ($optval != ini_get($optname)) { |
|
35 |
die("ERROR: Wrong '$optname' option value. Read REQUIREMENTS section in INSTALL file or use Roundcube Installer, please!"); |
|
36 |
} |
|
37 |
} |
47124c
|
38 |
|
T |
39 |
// application constants |
f5e7b3
|
40 |
define('RCMAIL_VERSION', '0.6-svn'); |
47124c
|
41 |
define('RCMAIL_CHARSET', 'UTF-8'); |
T |
42 |
define('JS_OBJECT_NAME', 'rcmail'); |
2b35c5
|
43 |
define('RCMAIL_START', microtime(true)); |
47124c
|
44 |
|
T |
45 |
if (!defined('INSTALL_PATH')) { |
2eb794
|
46 |
define('INSTALL_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); |
47124c
|
47 |
} |
T |
48 |
|
4859fe
|
49 |
if (!defined('RCMAIL_CONFIG_DIR')) { |
T |
50 |
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config'); |
|
51 |
} |
bba657
|
52 |
|
47124c
|
53 |
// make sure path_separator is defined |
T |
54 |
if (!defined('PATH_SEPARATOR')) { |
2eb794
|
55 |
define('PATH_SEPARATOR', (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') ? ';' : ':'); |
47124c
|
56 |
} |
T |
57 |
|
|
58 |
// RC include folders MUST be included FIRST to avoid other |
|
59 |
// possible not compatible libraries (i.e PEAR) to be included |
|
60 |
// instead the ones provided by RC |
926948
|
61 |
$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR; |
47124c
|
62 |
$include_path.= ini_get('include_path'); |
T |
63 |
|
|
64 |
if (set_include_path($include_path) === false) { |
e93c72
|
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 |
5c4c06
|
75 |
if (extension_loaded('mbstring')) { |
2eb794
|
76 |
mb_internal_encoding(RCMAIL_CHARSET); |
5c4c06
|
77 |
@mb_regex_encoding(RCMAIL_CHARSET); |
A |
78 |
} |
d99b93
|
79 |
|
47124c
|
80 |
/** |
T |
81 |
* Use PHP5 autoload for dynamic class loading |
|
82 |
* |
|
83 |
* @todo Make Zend, PEAR etc play with this |
b99bf4
|
84 |
* @todo Make our classes conform to a more straight forward CS. |
47124c
|
85 |
*/ |
588135
|
86 |
function rcube_autoload($classname) |
47124c
|
87 |
{ |
2eb794
|
88 |
$filename = preg_replace( |
A |
89 |
array( |
|
90 |
'/MDB2_(.+)/', |
|
91 |
'/Mail_(.+)/', |
|
92 |
'/Net_(.+)/', |
e31afb
|
93 |
'/Auth_(.+)/', |
2eb794
|
94 |
'/^html_.+/', |
A |
95 |
'/^utf8$/', |
|
96 |
), |
|
97 |
array( |
|
98 |
'MDB2/\\1', |
|
99 |
'Mail/\\1', |
|
100 |
'Net/\\1', |
e31afb
|
101 |
'Auth/\\1', |
2eb794
|
102 |
'html', |
A |
103 |
'utf8.class', |
|
104 |
), |
|
105 |
$classname |
|
106 |
); |
965ed0
|
107 |
|
T |
108 |
if ($fp = @fopen("$filename.php", 'r', true)) { |
|
109 |
fclose($fp); |
|
110 |
include_once("$filename.php"); |
|
111 |
return true; |
|
112 |
} |
|
113 |
|
|
114 |
return false; |
47124c
|
115 |
} |
T |
116 |
|
588135
|
117 |
spl_autoload_register('rcube_autoload'); |
T |
118 |
|
47124c
|
119 |
/** |
T |
120 |
* Local callback function for PEAR errors |
|
121 |
*/ |
|
122 |
function rcube_pear_error($err) |
|
123 |
{ |
2eb794
|
124 |
error_log(sprintf("%s (%s): %s", |
A |
125 |
$err->getMessage(), |
|
126 |
$err->getCode(), |
|
127 |
$err->getUserinfo()), 0); |
47124c
|
128 |
} |
2eb794
|
129 |
|
A |
130 |
// set PEAR error handling (will also load the PEAR main class) |
|
131 |
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'rcube_pear_error'); |
47124c
|
132 |
|
T |
133 |
// include global functions |
4351f7
|
134 |
require_once INSTALL_PATH . 'program/include/main.inc'; |
A |
135 |
require_once INSTALL_PATH . 'program/include/rcube_shared.inc'; |