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