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