check.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?php
  2. if (!class_exists('rcmail_install', false) || !is_object($RCI)) {
  3. die("Not allowed! Please open installer/index.php instead.");
  4. }
  5. ?>
  6. <form action="index.php" method="get">
  7. <?php
  8. $required_php_exts = array(
  9. 'PCRE' => 'pcre',
  10. 'DOM' => 'dom',
  11. 'Session' => 'session',
  12. 'XML' => 'xml',
  13. 'JSON' => 'json',
  14. 'PDO' => 'PDO',
  15. 'Multibyte' => 'mbstring',
  16. 'OpenSSL' => 'openssl',
  17. );
  18. $optional_php_exts = array(
  19. 'FileInfo' => 'fileinfo',
  20. 'Libiconv' => 'iconv',
  21. 'Intl' => 'intl',
  22. 'Exif' => 'exif',
  23. 'LDAP' => 'ldap',
  24. );
  25. $required_libs = array(
  26. 'PEAR' => 'pear.php.net',
  27. 'Auth_SASL' => 'pear.php.net',
  28. 'Net_SMTP' => 'pear.php.net',
  29. 'Net_IDNA2' => 'pear.php.net',
  30. 'Mail_mime' => 'pear.php.net',
  31. );
  32. $optional_libs = array(
  33. 'Net_LDAP3' => 'git.kolab.org',
  34. );
  35. $ini_checks = array(
  36. 'file_uploads' => 1,
  37. 'session.auto_start' => 0,
  38. 'mbstring.func_overload' => 0,
  39. 'suhosin.session.encrypt' => 0,
  40. );
  41. $optional_checks = array(
  42. // required for utils/modcss.inc, should we require this?
  43. 'allow_url_fopen' => 1,
  44. 'date.timezone' => '-VALID-',
  45. );
  46. $source_urls = array(
  47. 'Sockets' => 'http://www.php.net/manual/en/book.sockets.php',
  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. 'OpenSSL' => 'http://www.php.net/manual/en/book.openssl.php',
  54. 'JSON' => 'http://www.php.net/manual/en/book.json.php',
  55. 'DOM' => 'http://www.php.net/manual/en/book.dom.php',
  56. 'Intl' => 'http://www.php.net/manual/en/book.intl.php',
  57. 'Exif' => 'http://www.php.net/manual/en/book.exif.php',
  58. 'oci8' => 'http://www.php.net/manual/en/book.oci8.php',
  59. 'PDO' => 'http://www.php.net/manual/en/book.pdo.php',
  60. 'LDAP' => 'http://www.php.net/manual/en/book.ldap.php',
  61. 'pdo_mysql' => 'http://www.php.net/manual/en/ref.pdo-mysql.php',
  62. 'pdo_pgsql' => 'http://www.php.net/manual/en/ref.pdo-pgsql.php',
  63. 'pdo_sqlite' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
  64. 'pdo_sqlite2' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
  65. 'pdo_sqlsrv' => 'http://www.php.net/manual/en/ref.pdo-sqlsrv.php',
  66. 'pdo_dblib' => 'http://www.php.net/manual/en/ref.pdo-dblib.php',
  67. 'PEAR' => 'http://pear.php.net',
  68. 'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
  69. 'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
  70. 'Net_IDNA2' => 'http://pear.php.net/package/Net_IDNA2',
  71. 'Net_LDAP3' => 'https://git.kolab.org/diffusion/PNL',
  72. );
  73. echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';
  74. ?>
  75. <h3>Checking PHP version</h3>
  76. <?php
  77. define('MIN_PHP_VERSION', '5.4.0');
  78. if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
  79. $RCI->pass('Version', 'PHP ' . PHP_VERSION . ' detected');
  80. } else {
  81. $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . PHP_VERSION . ' detected');
  82. }
  83. ?>
  84. <h3>Checking PHP extensions</h3>
  85. <p class="hint">The following modules/extensions are <em>required</em> to run Roundcube:</p>
  86. <?php
  87. // get extensions location
  88. $ext_dir = ini_get('extension_dir');
  89. $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
  90. foreach ($required_php_exts as $name => $ext) {
  91. if (extension_loaded($ext)) {
  92. $RCI->pass($name);
  93. } else {
  94. $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
  95. $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
  96. $RCI->fail($name, $msg, $source_urls[$name]);
  97. }
  98. echo '<br />';
  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. 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. <h3>Checking available databases</h3>
  116. <p class="hint">Check which of the supported extensions are installed. At least one of them is required.</p>
  117. <?php
  118. $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
  119. foreach ($RCI->supported_dbs as $database => $ext) {
  120. if (extension_loaded($ext)) {
  121. $RCI->pass($database);
  122. $found_db_driver = true;
  123. }
  124. else {
  125. $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
  126. $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
  127. $RCI->na($database, $msg, $source_urls[$ext]);
  128. }
  129. echo '<br />';
  130. }
  131. if (empty($found_db_driver)) {
  132. $RCI->failures++;
  133. }
  134. ?>
  135. <h3>Check for required 3rd party libs</h3>
  136. <p class="hint">This also checks if the include path is set correctly.</p>
  137. <?php
  138. foreach ($required_libs as $classname => $vendor) {
  139. if (class_exists($classname)) {
  140. $RCI->pass($classname);
  141. }
  142. else {
  143. $RCI->fail($classname, "Failed to load class $classname from $vendor", $source_urls[$classname]);
  144. }
  145. echo "<br />";
  146. }
  147. foreach ($optional_libs as $classname => $vendor) {
  148. if (class_exists($classname)) {
  149. $RCI->pass($classname);
  150. }
  151. else {
  152. $RCI->na($classname, "Recommended to install $classname from $vendor", $source_urls[$classname]);
  153. }
  154. echo "<br />";
  155. }
  156. ?>
  157. <h3>Checking php.ini/.htaccess settings</h3>
  158. <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
  159. <?php
  160. foreach ($ini_checks as $var => $val) {
  161. $status = ini_get($var);
  162. if ($val === '-NOTEMPTY-') {
  163. if (empty($status)) {
  164. $RCI->fail($var, "empty value detected");
  165. }
  166. else {
  167. $RCI->pass($var);
  168. }
  169. }
  170. else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
  171. $RCI->pass($var);
  172. }
  173. else {
  174. $RCI->fail($var, "is '$status', should be '$val'");
  175. }
  176. echo '<br />';
  177. }
  178. ?>
  179. <p class="hint">The following settings are <em>optional</em> and recommended:</p>
  180. <?php
  181. foreach ($optional_checks as $var => $val) {
  182. $status = ini_get($var);
  183. if ($val === '-NOTEMPTY-') {
  184. if (empty($status)) {
  185. $RCI->optfail($var, "Could be set");
  186. } else {
  187. $RCI->pass($var);
  188. }
  189. echo '<br />';
  190. continue;
  191. }
  192. if ($val === '-VALID-') {
  193. if ($var == 'date.timezone') {
  194. try {
  195. $tz = new DateTimeZone($status);
  196. $RCI->pass($var);
  197. }
  198. catch (Exception $e) {
  199. $RCI->optfail($var, empty($status) ? "not set" : "invalid value detected: $status");
  200. }
  201. }
  202. else {
  203. $RCI->pass($var);
  204. }
  205. }
  206. else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
  207. $RCI->pass($var);
  208. }
  209. else {
  210. $RCI->optfail($var, "is '$status', could be '$val'");
  211. }
  212. echo '<br />';
  213. }
  214. ?>
  215. <?php
  216. if ($RCI->failures) {
  217. echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
  218. Please install the missing modules or fix the php.ini settings according to the above check results.<br />
  219. Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
  220. }
  221. echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
  222. ?>
  223. </form>