Drupal investigation

requirements.php 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * Application requirement checker script.
  4. *
  5. * In order to run this script use the following console command:
  6. * php requirements.php
  7. *
  8. * In order to run this script from the web, you should copy it to the web root.
  9. * If you are using Linux you can create a hard link instead, using the following command:
  10. * ln ../requirements.php requirements.php
  11. */
  12. // you may need to adjust this path to the correct Yii framework path
  13. $frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
  14. if (!is_dir($frameworkPath)) {
  15. echo '<h1>Error</h1>';
  16. echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
  17. echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
  18. echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
  19. }
  20. require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
  21. $requirementsChecker = new YiiRequirementChecker();
  22. $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.';
  23. $gdOK = $imagickOK = false;
  24. if (extension_loaded('imagick')) {
  25. $imagick = new Imagick();
  26. $imagickFormats = $imagick->queryFormats('PNG');
  27. if (in_array('PNG', $imagickFormats)) {
  28. $imagickOK = true;
  29. } else {
  30. $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
  31. }
  32. }
  33. if (extension_loaded('gd')) {
  34. $gdInfo = gd_info();
  35. if (!empty($gdInfo['FreeType Support'])) {
  36. $gdOK = true;
  37. } else {
  38. $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.';
  39. }
  40. }
  41. /**
  42. * Adjust requirements according to your application specifics.
  43. */
  44. $requirements = array(
  45. // Database :
  46. array(
  47. 'name' => 'PDO extension',
  48. 'mandatory' => true,
  49. 'condition' => extension_loaded('pdo'),
  50. 'by' => 'All DB-related classes',
  51. ),
  52. array(
  53. 'name' => 'PDO SQLite extension',
  54. 'mandatory' => false,
  55. 'condition' => extension_loaded('pdo_sqlite'),
  56. 'by' => 'All DB-related classes',
  57. 'memo' => 'Required for SQLite database.',
  58. ),
  59. array(
  60. 'name' => 'PDO MySQL extension',
  61. 'mandatory' => false,
  62. 'condition' => extension_loaded('pdo_mysql'),
  63. 'by' => 'All DB-related classes',
  64. 'memo' => 'Required for MySQL database.',
  65. ),
  66. array(
  67. 'name' => 'PDO PostgreSQL extension',
  68. 'mandatory' => false,
  69. 'condition' => extension_loaded('pdo_pgsql'),
  70. 'by' => 'All DB-related classes',
  71. 'memo' => 'Required for PostgreSQL database.',
  72. ),
  73. // Cache :
  74. array(
  75. 'name' => 'Memcache extension',
  76. 'mandatory' => false,
  77. 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
  78. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
  79. 'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
  80. ),
  81. // CAPTCHA:
  82. array(
  83. 'name' => 'GD PHP extension with FreeType support',
  84. 'mandatory' => false,
  85. 'condition' => $gdOK,
  86. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  87. 'memo' => $gdMemo,
  88. ),
  89. array(
  90. 'name' => 'ImageMagick PHP extension with PNG support',
  91. 'mandatory' => false,
  92. 'condition' => $imagickOK,
  93. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  94. 'memo' => $imagickMemo,
  95. ),
  96. // PHP ini :
  97. 'phpExposePhp' => array(
  98. 'name' => 'Expose PHP',
  99. 'mandatory' => false,
  100. 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
  101. 'by' => 'Security reasons',
  102. 'memo' => '"expose_php" should be disabled at php.ini',
  103. ),
  104. 'phpAllowUrlInclude' => array(
  105. 'name' => 'PHP allow url include',
  106. 'mandatory' => false,
  107. 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
  108. 'by' => 'Security reasons',
  109. 'memo' => '"allow_url_include" should be disabled at php.ini',
  110. ),
  111. 'phpSmtp' => array(
  112. 'name' => 'PHP mail SMTP',
  113. 'mandatory' => false,
  114. 'condition' => strlen(ini_get('SMTP')) > 0,
  115. 'by' => 'Email sending',
  116. 'memo' => 'PHP mail SMTP server required',
  117. ),
  118. );
  119. // OPcache check
  120. if (!version_compare(phpversion(), '5.5', '>=')) {
  121. $requirements[] = array(
  122. 'name' => 'APC extension',
  123. 'mandatory' => false,
  124. 'condition' => extension_loaded('apc'),
  125. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
  126. );
  127. }
  128. $requirementsChecker->checkYii()->check($requirements)->render();