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