Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

requirements.php 4.9KB

před 8 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. array(
  82. 'name' => 'APC extension',
  83. 'mandatory' => false,
  84. 'condition' => extension_loaded('apc'),
  85. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
  86. ),
  87. // CAPTCHA:
  88. array(
  89. 'name' => 'GD PHP extension with FreeType support',
  90. 'mandatory' => false,
  91. 'condition' => $gdOK,
  92. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  93. 'memo' => $gdMemo,
  94. ),
  95. array(
  96. 'name' => 'ImageMagick PHP extension with PNG support',
  97. 'mandatory' => false,
  98. 'condition' => $imagickOK,
  99. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  100. 'memo' => $imagickMemo,
  101. ),
  102. // PHP ini :
  103. 'phpExposePhp' => array(
  104. 'name' => 'Expose PHP',
  105. 'mandatory' => false,
  106. 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
  107. 'by' => 'Security reasons',
  108. 'memo' => '"expose_php" should be disabled at php.ini',
  109. ),
  110. 'phpAllowUrlInclude' => array(
  111. 'name' => 'PHP allow url include',
  112. 'mandatory' => false,
  113. 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
  114. 'by' => 'Security reasons',
  115. 'memo' => '"allow_url_include" should be disabled at php.ini',
  116. ),
  117. 'phpSmtp' => array(
  118. 'name' => 'PHP mail SMTP',
  119. 'mandatory' => false,
  120. 'condition' => strlen(ini_get('SMTP')) > 0,
  121. 'by' => 'Email sending',
  122. 'memo' => 'PHP mail SMTP server required',
  123. ),
  124. );
  125. $requirementsChecker->checkYii()->check($requirements)->render();