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