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