Aleksander Machniak
2012-12-21 73899662952a1ae91167c070d2a38136a0200c67
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)) {
738996 133         // MySQL driver requires PHP >= 5.3 (#1488875)
AM 134         if ($ext == 'pdo_mysql' && version_compare(PHP_VERSION, '5.3.0', '<')) {
135             $RCI->fail($database, 'PHP >= 5.3 required');
136         }
137         else {
138             $RCI->pass($database);
139         }
6557d3 140     }
T 141     else {
3e2bc6 142         $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
398bff 143         $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
AM 144         $RCI->na($database, $msg, $source_urls[$ext]);
6557d3 145     }
T 146     echo '<br />';
147 }
148
149 ?>
150
151
152 <h3>Check for required 3rd party libs</h3>
153 <p class="hint">This also checks if the include path is set correctly.</p>
154
155 <?php
156
157 foreach ($required_libs as $classname => $file) {
158     @include_once $file;
159     if (class_exists($classname)) {
160         $RCI->pass($classname);
161     }
162     else {
163         $RCI->fail($classname, "Failed to load $file", $source_urls[$classname]);
164     }
165     echo "<br />";
166 }
167
c5042d 168
T 169 ?>
170
171 <h3>Checking php.ini/.htaccess settings</h3>
e019f2 172 <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
c5042d 173
T 174 <?php
175
176 foreach ($ini_checks as $var => $val) {
177     $status = ini_get($var);
f7df6c 178     if ($val === '-NOTEMPTY-') {
T 179         if (empty($status)) {
c22a52 180             $RCI->fail($var, "empty value detected");
AM 181         } else if ($var == 'date.timezone') {
182             try {
183                 $tz = new DateTimeZone($status);
184                 $RCI->pass($var);
185             }
186             catch (Exception $e) {
c563c2 187                 $RCI->fail($var, "invalid value detected: $status");
c22a52 188             }
f7df6c 189         } else {
T 190             $RCI->pass($var);
191         }
192         echo '<br />';
193         continue;
194     }
c5042d 195     if ($status == $val) {
T 196         $RCI->pass($var);
f7df6c 197     } else {
c5042d 198       $RCI->fail($var, "is '$status', should be '$val'");
T 199     }
200     echo '<br />';
201 }
202 ?>
203
11e670 204 <p class="hint">The following settings are <em>optional</em> and recommended:</p>
A 205
206 <?php
207
208 foreach ($optional_checks as $var => $val) {
209     $status = ini_get($var);
210     if ($val === '-NOTEMPTY-') {
211         if (empty($status)) {
212             $RCI->optfail($var, "Could be set");
213         } else {
214             $RCI->pass($var);
215         }
216         echo '<br />';
217         continue;
218     }
219     if ($status == $val) {
220         $RCI->pass($var);
221     } else {
222       $RCI->optfail($var, "is '$status', could be '$val'");
223     }
224     echo '<br />';
225 }
226 ?>
227
c5042d 228 <?php
T 229
019b5d 230 if ($RCI->failures) {
e019f2 231   echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
4a2765 232             Please install the missing modules or fix the php.ini settings according to the above check results.<br />
T 233             Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
019b5d 234 }
6557d3 235 echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
T 236
237 ?>
238
354978 239 </form>