]> git.donarmstrong.com Git - roundcube.git/blob - installer/check.php
New upstream version.
[roundcube.git] / installer / check.php
1 <form action="index.php" method="get">
2 <?php
3
4 $required_php_exts = array(
5     'PCRE'      => 'pcre',
6     'DOM'       => 'dom',
7     'Session'   => 'session',
8     'XML'       => 'xml',
9     'JSON'      => 'json'
10 );
11
12 $optional_php_exts = array(
13     'FileInfo'  => 'fileinfo',
14     'Libiconv'  => 'iconv',
15     'Multibyte' => 'mbstring',
16     'OpenSSL'   => 'openssl',
17     'Mcrypt'    => 'mcrypt',
18     'Intl'      => 'intl',
19 );
20
21 $required_libs = array(
22     'PEAR'      => 'PEAR.php',
23     'MDB2'      => 'MDB2.php',
24     'Net_SMTP'  => 'Net/SMTP.php',
25     'Net_IDNA2' => 'Net/IDNA2.php',
26     'Mail_mime' => 'Mail/mime.php',
27 );
28
29 $supported_dbs = array(
30     'MySQL'         => 'mysql',
31     'MySQLi'        => 'mysqli',
32     'PostgreSQL'    => 'pgsql',
33     'SQLite (v2)'   => 'sqlite',
34 );
35
36 $ini_checks = array(
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 );
47
48 $source_urls = array(
49     'Sockets'   => 'http://www.php.net/manual/en/book.sockets.php',
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',
54     'Multibyte' => 'http://www.php.net/manual/en/book.mbstring.php',
55     'Mcrypt'    => 'http://www.php.net/manual/en/book.mcrypt.php',
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',
63     'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
64 );
65
66 echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';
67 ?>
68
69 <h3>Checking PHP version</h3>
70 <?php
71
72 define('MIN_PHP_VERSION', '5.2.1');
73 if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
74     $RCI->pass('Version', 'PHP ' . PHP_VERSION . ' detected');
75 } else {
76     $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . PHP_VERSION . ' detected');
77 }
78 ?>
79
80 <h3>Checking PHP extensions</h3>
81 <p class="hint">The following modules/extensions are <em>required</em> to run Roundcube:</p>
82 <?php
83
84 // get extensions location
85 $ext_dir = ini_get('extension_dir');
86
87 $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
88 foreach ($required_php_exts as $name => $ext) {
89     if (extension_loaded($ext)) {
90         $RCI->pass($name);
91     } else {
92         $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
93         $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
94         $RCI->fail($name, $msg, $source_urls[$name]);
95     }
96     echo '<br />';
97 }
98
99 ?>
100
101 <p class="hint">The next couple of extensions are <em>optional</em> and recommended to get the best performance:</p>
102 <?php
103
104 foreach ($optional_php_exts as $name => $ext) {
105     if (extension_loaded($ext)) {
106         $RCI->pass($name);
107     }
108     else {
109         $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
110         $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
111         $RCI->na($name, $msg, $source_urls[$name]);
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_' : '';
125 foreach ($supported_dbs as $database => $ext) {
126     if (extension_loaded($ext)) {
127         $RCI->pass($database);
128     }
129     else {
130         $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
131         $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : 'Not installed';
132         $RCI->na($database, $msg, $source_urls[$database]);
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
156
157 ?>
158
159 <h3>Checking php.ini/.htaccess settings</h3>
160 <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
161
162 <?php
163
164 foreach ($ini_checks as $var => $val) {
165     $status = ini_get($var);
166     if ($val === '-NOTEMPTY-') {
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     }
175     if ($status == $val) {
176         $RCI->pass($var);
177     } else {
178       $RCI->fail($var, "is '$status', should be '$val'");
179     }
180     echo '<br />';
181 }
182 ?>
183
184 <p class="hint">The following settings are <em>optional</em> and recommended:</p>
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
208 <?php
209
210 if ($RCI->failures) {
211   echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
212             Please install the missing modules or fix the php.ini settings according to the above check results.<br />
213             Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
214 }
215 echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
216
217 ?>
218
219 </form>