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

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