Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

check.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. 'GD' => 'gd',
  25. 'Imagick' => 'imagick',
  26. );
  27. $required_libs = array(
  28. 'PEAR' => 'pear.php.net',
  29. 'Auth_SASL' => 'pear.php.net',
  30. 'Net_SMTP' => 'pear.php.net',
  31. 'Net_IDNA2' => 'pear.php.net',
  32. 'Mail_mime' => 'pear.php.net',
  33. );
  34. $optional_libs = array(
  35. 'Net_LDAP3' => 'git.kolab.org',
  36. );
  37. $ini_checks = array(
  38. 'file_uploads' => 1,
  39. 'session.auto_start' => 0,
  40. 'mbstring.func_overload' => 0,
  41. 'suhosin.session.encrypt' => 0,
  42. );
  43. $optional_checks = array(
  44. // required for utils/modcss.inc, should we require this?
  45. 'allow_url_fopen' => 1,
  46. 'date.timezone' => '-VALID-',
  47. );
  48. $source_urls = array(
  49. 'Sockets' => 'http://www.php.net/manual/en/book.sockets.php',
  50. 'Session' => 'http://www.php.net/manual/en/book.session.php',
  51. 'PCRE' => 'http://www.php.net/manual/en/book.pcre.php',
  52. 'FileInfo' => 'http://www.php.net/manual/en/book.fileinfo.php',
  53. 'Libiconv' => 'http://www.php.net/manual/en/book.iconv.php',
  54. 'Multibyte' => 'http://www.php.net/manual/en/book.mbstring.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. 'Exif' => 'http://www.php.net/manual/en/book.exif.php',
  60. 'oci8' => 'http://www.php.net/manual/en/book.oci8.php',
  61. 'PDO' => 'http://www.php.net/manual/en/book.pdo.php',
  62. 'LDAP' => 'http://www.php.net/manual/en/book.ldap.php',
  63. 'GD' => 'http://www.php.net/manual/en/book.image.php',
  64. 'Imagick' => 'http://www.php.net/manual/en/book.imagick.php',
  65. 'pdo_mysql' => 'http://www.php.net/manual/en/ref.pdo-mysql.php',
  66. 'pdo_pgsql' => 'http://www.php.net/manual/en/ref.pdo-pgsql.php',
  67. 'pdo_sqlite' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
  68. 'pdo_sqlite2' => 'http://www.php.net/manual/en/ref.pdo-sqlite.php',
  69. 'pdo_sqlsrv' => 'http://www.php.net/manual/en/ref.pdo-sqlsrv.php',
  70. 'pdo_dblib' => 'http://www.php.net/manual/en/ref.pdo-dblib.php',
  71. 'PEAR' => 'http://pear.php.net',
  72. 'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
  73. 'Mail_mime' => 'http://pear.php.net/package/Mail_mime',
  74. 'Net_IDNA2' => 'http://pear.php.net/package/Net_IDNA2',
  75. 'Net_LDAP3' => 'https://git.kolab.org/diffusion/PNL',
  76. );
  77. echo '<input type="hidden" name="_step" value="' . ($RCI->configured ? 3 : 2) . '" />';
  78. ?>
  79. <h3>Checking PHP version</h3>
  80. <?php
  81. define('MIN_PHP_VERSION', '5.4.0');
  82. if (version_compare(PHP_VERSION, MIN_PHP_VERSION, '>=')) {
  83. $RCI->pass('Version', 'PHP ' . PHP_VERSION . ' detected');
  84. } else {
  85. $RCI->fail('Version', 'PHP Version ' . MIN_PHP_VERSION . ' or greater is required ' . PHP_VERSION . ' detected');
  86. }
  87. ?>
  88. <h3>Checking PHP extensions</h3>
  89. <p class="hint">The following modules/extensions are <em>required</em> to run Roundcube:</p>
  90. <?php
  91. // get extensions location
  92. $ext_dir = ini_get('extension_dir');
  93. $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
  94. foreach ($required_php_exts as $name => $ext) {
  95. if (extension_loaded($ext)) {
  96. $RCI->pass($name);
  97. } else {
  98. $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
  99. $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
  100. $RCI->fail($name, $msg, $source_urls[$name]);
  101. }
  102. echo '<br />';
  103. }
  104. ?>
  105. <p class="hint">The next couple of extensions are <em>optional</em> and recommended to get the best performance:</p>
  106. <?php
  107. foreach ($optional_php_exts as $name => $ext) {
  108. if (extension_loaded($ext)) {
  109. $RCI->pass($name);
  110. }
  111. else {
  112. $_ext = $ext_dir . '/' . $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
  113. $msg = @is_readable($_ext) ? 'Could be loaded. Please add in php.ini' : '';
  114. $RCI->na($name, $msg, $source_urls[$name]);
  115. }
  116. echo '<br />';
  117. }
  118. ?>
  119. <h3>Checking available databases</h3>
  120. <p class="hint">Check which of the supported extensions are installed. At least one of them is required.</p>
  121. <?php
  122. $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
  123. foreach ($RCI->supported_dbs as $database => $ext) {
  124. if (extension_loaded($ext)) {
  125. $RCI->pass($database);
  126. $found_db_driver = true;
  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' : '';
  131. $RCI->na($database, $msg, $source_urls[$ext]);
  132. }
  133. echo '<br />';
  134. }
  135. if (empty($found_db_driver)) {
  136. $RCI->failures++;
  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. <?php
  142. foreach ($required_libs as $classname => $vendor) {
  143. if (class_exists($classname)) {
  144. $RCI->pass($classname);
  145. }
  146. else {
  147. $RCI->fail($classname, "Failed to load class $classname from $vendor", $source_urls[$classname]);
  148. }
  149. echo "<br />";
  150. }
  151. foreach ($optional_libs as $classname => $vendor) {
  152. if (class_exists($classname)) {
  153. $RCI->pass($classname);
  154. }
  155. else {
  156. $RCI->na($classname, "Recommended to install $classname from $vendor", $source_urls[$classname]);
  157. }
  158. echo "<br />";
  159. }
  160. ?>
  161. <h3>Checking php.ini/.htaccess settings</h3>
  162. <p class="hint">The following settings are <em>required</em> to run Roundcube:</p>
  163. <?php
  164. foreach ($ini_checks as $var => $val) {
  165. $status = ini_get($var);
  166. if ($val === '-NOTEMPTY-') {
  167. if (empty($status)) {
  168. $RCI->fail($var, "empty value detected");
  169. }
  170. else {
  171. $RCI->pass($var);
  172. }
  173. }
  174. else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
  175. $RCI->pass($var);
  176. }
  177. else {
  178. $RCI->fail($var, "is '$status', should be '$val'");
  179. }
  180. echo '<br />';
  181. }
  182. ?>
  183. <p class="hint">The following settings are <em>optional</em> and recommended:</p>
  184. <?php
  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 ($val === '-VALID-') {
  197. if ($var == 'date.timezone') {
  198. try {
  199. $tz = new DateTimeZone($status);
  200. $RCI->pass($var);
  201. }
  202. catch (Exception $e) {
  203. $RCI->optfail($var, empty($status) ? "not set" : "invalid value detected: $status");
  204. }
  205. }
  206. else {
  207. $RCI->pass($var);
  208. }
  209. }
  210. else if (filter_var($status, FILTER_VALIDATE_BOOLEAN) == $val) {
  211. $RCI->pass($var);
  212. }
  213. else {
  214. $RCI->optfail($var, "is '$status', could be '$val'");
  215. }
  216. echo '<br />';
  217. }
  218. ?>
  219. <?php
  220. if ($RCI->failures) {
  221. echo '<p class="warning">Sorry but your webserver does not meet the requirements for Roundcube!<br />
  222. Please install the missing modules or fix the php.ini settings according to the above check results.<br />
  223. Hint: only checks showing <span class="fail">NOT OK</span> need to be fixed.</p>';
  224. }
  225. echo '<p><br /><input type="submit" value="NEXT" ' . ($RCI->failures ? 'disabled' : '') . ' /></p>';
  226. ?>
  227. </form>