Aleksander Machniak
2014-03-22 8cc567c00423a343f3b785ee4dd856111b985fe7
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(
A 31     'PEAR'      => 'PEAR.php',
32     'Net_SMTP'  => 'Net/SMTP.php',
e6bb83 33     'Net_IDNA2' => 'Net/IDNA2.php',
59c216 34     'Mail_mime' => 'Mail/mime.php',
A 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
8cc567 86 define('MIN_PHP_VERSION', '5.3.7');
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)) {
8cc567 141         $RCI->pass($database);
AM 142         $found_db_driver = true;
6557d3 143     }
T 144     else {
3e2bc6 145         $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
398bff 146         $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
AM 147         $RCI->na($database, $msg, $source_urls[$ext]);
6557d3 148     }
T 149     echo '<br />';
150 }
e7fa2c 151 if (empty($found_db_driver)) {
AM 152   $RCI->failures++;
153 }
6557d3 154
T 155 ?>
156
157
158 <h3>Check for required 3rd party libs</h3>
159 <p class="hint">This also checks if the include path is set correctly.</p>
160
161 <?php
162
163 foreach ($required_libs as $classname => $file) {
164     @include_once $file;
165     if (class_exists($classname)) {
166         $RCI->pass($classname);
167     }
168     else {
169         $RCI->fail($classname, "Failed to load $file", $source_urls[$classname]);
170     }
171     echo "<br />";
172 }
173
c5042d 174
T 175 ?>
176
177 <h3>Checking php.ini/.htaccess settings</h3>
e019f2 178 <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
c5042d 179
T 180 <?php
181
182 foreach ($ini_checks as $var => $val) {
183     $status = ini_get($var);
f7df6c 184     if ($val === '-NOTEMPTY-') {
T 185         if (empty($status)) {
c22a52 186             $RCI->fail($var, "empty value detected");
7a7c25 187         }
AM 188         else {
f7df6c 189             $RCI->pass($var);
T 190         }
191     }
7a7c25 192     else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
c5042d 193         $RCI->pass($var);
7a7c25 194     }
AM 195     else {
c5042d 196       $RCI->fail($var, "is '$status', should be '$val'");
T 197     }
198     echo '<br />';
199 }
200 ?>
201
11e670 202 <p class="hint">The following settings are <em>optional</em> and recommended:</p>
A 203
204 <?php
205
206 foreach ($optional_checks as $var => $val) {
207     $status = ini_get($var);
208     if ($val === '-NOTEMPTY-') {
209         if (empty($status)) {
210             $RCI->optfail($var, "Could be set");
211         } else {
212             $RCI->pass($var);
213         }
214         echo '<br />';
215         continue;
216     }
7a7c25 217     if ($val === '-VALID-') {
AM 218         if ($var == 'date.timezone') {
219             try {
220                 $tz = new DateTimeZone($status);
221                 $RCI->pass($var);
222             }
223             catch (Exception $e) {
224                 $RCI->optfail($var, empty($status) ? "not set" : "invalid value detected: $status");
225             }
226         }
227         else {
228             $RCI->pass($var);
229         }
230     }
231     else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
11e670 232         $RCI->pass($var);
7a7c25 233     }
AM 234     else {
11e670 235       $RCI->optfail($var, "is '$status', could be '$val'");
A 236     }
237     echo '<br />';
238 }
239 ?>
240
c5042d 241 <?php
T 242
019b5d 243 if ($RCI->failures) {
e019f2 244   echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
4a2765 245             Please install the missing modules or fix the php.ini settings according to the above check results.<br />
T 246             Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
019b5d 247 }
6557d3 248 echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
T 249
250 ?>
251
354978 252 </form>