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