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