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