source: subversion/trunk/roundcubemail/installer/check.php @ 2867

Last change on this file since 2867 was 2867, checked in by alec, 4 years ago
File size: 5.3 KB
Line 
1<form action="index.php" method="get">
2<?php
3
4$required_php_exts = array('PCRE' => 'pcre', 'DOM' => 'dom',
5    'Session' => 'session', 'XML' => 'xml');
6
7$optional_php_exts = array('FileInfo' => 'fileinfo', 'Libiconv' => 'iconv',
8    'Multibyte' => 'mbstring', 'OpenSSL' => 'openssl', 'Mcrypt' => 'mcrypt',
9    'GD' => 'gd');
10
11$required_libs = array('PEAR' => 'PEAR.php', 'MDB2' => 'MDB2.php',
12    'Net_SMTP' => 'Net/SMTP.php', 'Mail_mime' => 'Mail/mime.php',
13    'iilConnection' => 'lib/imap.inc');
14
15$supported_dbs = array('MySQL' => 'mysql', 'MySQLi' => 'mysqli',
16    'PostgreSQL' => 'pgsql', 'SQLite (v2)' => 'sqlite');
17
18$ini_checks = array('file_uploads' => 1, 'session.auto_start' => 0,
19    'zend.ze1_compatibility_mode' => 0, 'mbstring.func_overload' => 0,
20    'suhosin.session.encrypt' => 0, 'date.timezone' => '-NOTEMPTY-');
21
22$source_urls = array(
23    'Sockets' => 'http://www.php.net/manual/en/ref.sockets.php',
24    'Session' => 'http://www.php.net/manual/en/ref.session.php',
25    'PCRE' => 'http://www.php.net/manual/en/ref.pcre.php',
26    'FileInfo' => 'http://www.php.net/manual/en/ref.fileinfo.php',
27    'Libiconv' => 'http://www.php.net/manual/en/ref.iconv.php',
28    'Multibyte' => 'http://www.php.net/manual/en/ref.mbstring.php',
29    'Mcrypt' => 'http://www.php.net/manual/en/ref.mcrypt.php',
30    'OpenSSL' => 'http://www.php.net/manual/en/ref.openssl.php',
31    'GD' => 'http://www.php.net/manual/en/ref.image.php',
32    'PEAR' => 'http://pear.php.net',
33    'MDB2' => 'http://pear.php.net/package/MDB2',
34    'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
35    'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
36    'DOM' => 'http://www.php.net/manual/en/intro.dom.php'
37);
38
39echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';
40?>
41
42<h3>Checking PHP version</h3>
43<?php
44
45define('MIN_PHP_VERSION', '5.2.0');
46if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
47    $RCI->pass('Version', 'PHP ' . PHP_VERSION . ' detected');
48} else {
49    $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . PHP_VERSION . ' detected');
50}
51?>
52
53<h3>Checking PHP extensions</h3>
54<p class="hint">The following modules/extensions are <em>required</em> to run RoundCube:</p>
55<?php
56   
57$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
58foreach ($required_php_exts AS $name => $ext) {
59    if (extension_loaded($ext)) {
60        $RCI->pass($name);
61    } else {
62        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
63        $msg = @dl($_ext) ? 'Could be loaded. Please add in php.ini' : '';
64        $RCI->fail($name, $msg, $source_urls[$name]);
65    }
66    echo '<br />';
67}
68
69?>
70
71<p class="hint">The next couple of extensions are <em>optional</em> but recommended to get the best performance:</p>
72<?php
73
74foreach ($optional_php_exts AS $name => $ext) {
75    if (extension_loaded($ext)) {
76        $RCI->pass($name);
77    }
78    else {
79        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
80        $msg = @dl($_ext) ? 'Could be loaded. Please add in php.ini' : '';
81        $RCI->na($name, $msg, $source_urls[$name]);
82    }
83    echo '<br />';
84}
85
86?>
87
88
89<h3>Checking available databases</h3>
90<p class="hint">Check which of the supported extensions are installed. At least one of them is required.</p>
91
92<?php
93
94$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
95foreach ($supported_dbs AS $database => $ext) {
96    if (extension_loaded($ext)) {
97        $RCI->pass($database);
98    }
99    else {
100        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
101        $msg = @dl($_ext) ? 'Could be loaded. Please add in php.ini' : 'Not installed';
102        $RCI->na($database, $msg, $source_urls[$database]);
103    }
104    echo '<br />';
105}
106
107?>
108
109
110<h3>Check for required 3rd party libs</h3>
111<p class="hint">This also checks if the include path is set correctly.</p>
112
113<?php
114
115foreach ($required_libs as $classname => $file) {
116    @include_once $file;
117    if (class_exists($classname)) {
118        $RCI->pass($classname);
119    }
120    else {
121        $RCI->fail($classname, "Failed to load $file", $source_urls[$classname]);
122    }
123    echo "<br />";
124}
125
126
127?>
128
129<h3>Checking php.ini/.htaccess settings</h3>
130
131<?php
132
133foreach ($ini_checks as $var => $val) {
134    $status = ini_get($var);
135    if ($val === '-NOTEMPTY-') {
136        if (empty($status)) {
137            $RCI->fail($var, "cannot be empty and needs to be set");
138        } else {
139            switch ($var) {
140                case 'date.timezone':
141                    if (date_default_timezone_set($status) === false) {
142                        $RCI->fail($var, "is '$status', but the settings is wrong");
143                        echo '<br />';
144                        continue;
145                    }
146                    break;
147            }
148            $RCI->pass($var);
149        }
150        echo '<br />';
151        continue;
152    }
153    if ($status == $val) {
154        $RCI->pass($var);
155    } else {
156      $RCI->fail($var, "is '$status', should be '$val'");
157    }
158    echo '<br />';
159}
160?>
161
162<?php
163
164if ($RCI->failures) {
165  echo '<p class="warning">Sorry but your webserver does not meet the requirements for RoundCube!<br />
166            Please install the missing modules or fix the php.ini settings according to the above check results.<br />
167            Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
168}
169echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
170
171?>
172
173</form>
Note: See TracBrowser for help on using the repository browser.