comparison installer/check.php @ 0:4681f974d28b

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:52:31 -0500
parents
children bf99236cc5cd
comparison
equal deleted inserted replaced
-1:000000000000 0:4681f974d28b
1 <?php
2
3 if (!class_exists('rcmail_install', false) || !is_object($RCI)) {
4 die("Not allowed! Please open installer/index.php instead.");
5 }
6
7 ?>
8 <form action="index.php" method="get">
9 <?php
10
11 $required_php_exts = array(
12 'PCRE' => 'pcre',
13 'DOM' => 'dom',
14 'Session' => 'session',
15 'XML' => 'xml',
16 'JSON' => 'json',
17 'PDO' => 'PDO',
18 );
19
20 $optional_php_exts = array(
21 'FileInfo' => 'fileinfo',
22 'Libiconv' => 'iconv',
23 'Multibyte' => 'mbstring',
24 'OpenSSL' => 'openssl',
25 'Mcrypt' => 'mcrypt',
26 'Intl' => 'intl',
27 'Exif' => 'exif',
28 'LDAP' => 'ldap',
29 );
30
31 $required_libs = array(
32 'PEAR' => 'pear.php.net',
33 'Auth_SASL' => 'pear.php.net',
34 'Net_SMTP' => 'pear.php.net',
35 'Net_IDNA2' => 'pear.php.net',
36 'Mail_mime' => 'pear.php.net',
37 );
38
39 $optional_libs = array(
40 'Net_LDAP3' => 'git.kolab.org',
41 );
42
43 $ini_checks = array(
44 'file_uploads' => 1,
45 'session.auto_start' => 0,
46 'mbstring.func_overload' => 0,
47 'suhosin.session.encrypt' => 0,
48 'magic_quotes_runtime' => 0,
49 'magic_quotes_sybase' => 0,
50 );
51
52 $optional_checks = array(
53 // required for utils/modcss.inc, should we require this?
54 'allow_url_fopen' => 1,
55 'date.timezone' => '-VALID-',
56 'register_globals' => 0, // #1489157
57 );
58
59 $source_urls = array(
60 'Sockets' => 'http://www.php.net/manual/en/book.sockets.php',
61 'Session' => 'http://www.php.net/manual/en/book.session.php',
62 'PCRE' => 'http://www.php.net/manual/en/book.pcre.php',
63 'FileInfo' => 'http://www.php.net/manual/en/book.fileinfo.php',
64 'Libiconv' => 'http://www.php.net/manual/en/book.iconv.php',
65 'Multibyte' => 'http://www.php.net/manual/en/book.mbstring.php',
66 'Mcrypt' => 'http://www.php.net/manual/en/book.mcrypt.php',
67 'OpenSSL' => 'http://www.php.net/manual/en/book.openssl.php',
68 'JSON' => 'http://www.php.net/manual/en/book.json.php',
69 'DOM' => 'http://www.php.net/manual/en/book.dom.php',
70 'Intl' => 'http://www.php.net/manual/en/book.intl.php',
71 'Exif' => 'http://www.php.net/manual/en/book.exif.php',
72 'oci8' => 'http://www.php.net/manual/en/book.oci8.php',
73 'PDO' => 'http://www.php.net/manual/en/book.pdo.php',
74 'LDAP' => 'http://www.php.net/manual/en/book.ldap.php',
75 'pdo_mysql' => 'http://www.php.net/manual/en/ref.pdo-mysql.php',
76 'pdo_pgsql' => 'http://www.php.net/manual/en/ref.pdo-pgsql.php',
77 'pdo_sqlite' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
78 'pdo_sqlite2' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
79 'pdo_sqlsrv' => 'http://www.php.net/manual/en/ref.pdo-sqlsrv.php',
80 'pdo_dblib' => 'http://www.php.net/manual/en/ref.pdo-dblib.php',
81 'PEAR' => 'http://pear.php.net',
82 'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
83 'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
84 'Net_IDNA2' => 'http://pear.php.net/package/Net_IDNA2',
85 'Net_LDAP3' => 'https://git.kolab.org/diffusion/PNL',
86 );
87
88 echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';
89 ?>
90
91 <h3>Checking PHP version</h3>
92 <?php
93
94 define('MIN_PHP_VERSION', '5.3.7');
95 if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
96 if (PHP_MAJOR_VERSION != 5) {
97 $RCI->fail('Version', 'PHP5 is required, ' . PHP_VERSION . ' detected');
98 }
99 else {
100 $RCI->pass('Version', 'PHP ' . PHP_VERSION . ' detected');
101 }
102 }
103 else {
104 $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . PHP_VERSION . ' detected');
105 }
106 ?>
107
108 <h3>Checking PHP extensions</h3>
109 <p class="hint">The following modules/extensions are <em>required</em> to run Roundcube:</p>
110 <?php
111
112 // get extensions location
113 $ext_dir = ini_get('extension_dir');
114
115 $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
116 foreach ($required_php_exts as $name => $ext) {
117 if (extension_loaded($ext)) {
118 $RCI->pass($name);
119 } else {
120 $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
121 $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
122 $RCI->fail($name, $msg, $source_urls[$name]);
123 }
124 echo '<br />';
125 }
126
127 ?>
128
129 <p class="hint">The next couple of extensions are <em>optional</em> and recommended to get the best performance:</p>
130 <?php
131
132 foreach ($optional_php_exts as $name => $ext) {
133 if (extension_loaded($ext)) {
134 $RCI->pass($name);
135 }
136 else {
137 $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
138 $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
139 $RCI->na($name, $msg, $source_urls[$name]);
140 }
141 echo '<br />';
142 }
143
144 ?>
145
146
147 <h3>Checking available databases</h3>
148 <p class="hint">Check which of the supported extensions are installed. At least one of them is required.</p>
149
150 <?php
151
152 $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
153 foreach ($RCI->supported_dbs as $database => $ext) {
154 if (extension_loaded($ext)) {
155 $RCI->pass($database);
156 $found_db_driver = true;
157 }
158 else {
159 $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
160 $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
161 $RCI->na($database, $msg, $source_urls[$ext]);
162 }
163 echo '<br />';
164 }
165 if (empty($found_db_driver)) {
166 $RCI->failures++;
167 }
168
169 ?>
170
171
172 <h3>Check for required 3rd party libs</h3>
173 <p class="hint">This also checks if the include path is set correctly.</p>
174
175 <?php
176
177 foreach ($required_libs as $classname => $vendor) {
178 if (class_exists($classname)) {
179 $RCI->pass($classname);
180 }
181 else {
182 $RCI->fail($classname, "Failed to load class $classname from $vendor", $source_urls[$classname]);
183 }
184 echo "<br />";
185 }
186
187 foreach ($optional_libs as $classname => $vendor) {
188 if (class_exists($classname)) {
189 $RCI->pass($classname);
190 }
191 else {
192 $RCI->na($classname, "Recommended to install $classname from $vendor", $source_urls[$classname]);
193 }
194 echo "<br />";
195 }
196
197 ?>
198
199 <h3>Checking php.ini/.htaccess settings</h3>
200 <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
201
202 <?php
203
204 foreach ($ini_checks as $var => $val) {
205 $status = ini_get($var);
206 if ($val === '-NOTEMPTY-') {
207 if (empty($status)) {
208 $RCI->fail($var, "empty value detected");
209 }
210 else {
211 $RCI->pass($var);
212 }
213 }
214 else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
215 $RCI->pass($var);
216 }
217 else {
218 $RCI->fail($var, "is '$status', should be '$val'");
219 }
220 echo '<br />';
221 }
222 ?>
223
224 <p class="hint">The following settings are <em>optional</em> and recommended:</p>
225
226 <?php
227
228 foreach ($optional_checks as $var => $val) {
229 $status = ini_get($var);
230 if ($val === '-NOTEMPTY-') {
231 if (empty($status)) {
232 $RCI->optfail($var, "Could be set");
233 } else {
234 $RCI->pass($var);
235 }
236 echo '<br />';
237 continue;
238 }
239 if ($val === '-VALID-') {
240 if ($var == 'date.timezone') {
241 try {
242 $tz = new DateTimeZone($status);
243 $RCI->pass($var);
244 }
245 catch (Exception $e) {
246 $RCI->optfail($var, empty($status) ? "not set" : "invalid value detected: $status");
247 }
248 }
249 else {
250 $RCI->pass($var);
251 }
252 }
253 else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
254 $RCI->pass($var);
255 }
256 else {
257 $RCI->optfail($var, "is '$status', could be '$val'");
258 }
259 echo '<br />';
260 }
261 ?>
262
263 <?php
264
265 if ($RCI->failures) {
266 echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
267 Please install the missing modules or fix the php.ini settings according to the above check results.<br />
268 Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
269 }
270 echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
271
272 ?>
273
274 </form>