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

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