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