requirements.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * 洛阳赤炎鹰网络科技有限公司
  4. * https://www.cyyvip.com
  5. * Copyright (c) 2022 赤店商城 All rights reserved.
  6. */
  7. // you may need to adjust this path to the correct Yii framework path
  8. // uncomment and adjust the following line if Yii is not located at the default path
  9. //$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
  10. if (!isset($frameworkPath)) {
  11. $searchPaths = array(
  12. dirname(__FILE__) . '/vendor/yiisoft/yii2',
  13. dirname(__FILE__) . '/../vendor/yiisoft/yii2',
  14. );
  15. foreach ($searchPaths as $path) {
  16. if (is_dir($path)) {
  17. $frameworkPath = $path;
  18. break;
  19. }
  20. }
  21. }
  22. if (!isset($frameworkPath) || !is_dir($frameworkPath)) {
  23. $message = "<h1>Error</h1>\n\n"
  24. . "<p><strong>The path to yii framework seems to be incorrect.</strong></p>\n"
  25. . '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . "</abbr>.</p>\n"
  26. . '<p>Please refer to the <abbr title="' . dirname(__FILE__) . "/README.md\">README</abbr> on how to install Yii.</p>\n";
  27. if (!empty($_SERVER['argv'])) {
  28. // do not print HTML when used in console mode
  29. echo strip_tags($message);
  30. } else {
  31. echo $message;
  32. }
  33. exit(1);
  34. }
  35. require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');
  36. $requirementsChecker = new YiiRequirementChecker();
  37. $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.';
  38. $gdOK = $imagickOK = false;
  39. if (extension_loaded('imagick')) {
  40. $imagick = new Imagick();
  41. $imagickFormats = $imagick->queryFormats('PNG');
  42. if (in_array('PNG', $imagickFormats)) {
  43. $imagickOK = true;
  44. } else {
  45. $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.';
  46. }
  47. }
  48. if (extension_loaded('gd')) {
  49. $gdInfo = gd_info();
  50. if (!empty($gdInfo['FreeType Support'])) {
  51. $gdOK = true;
  52. } else {
  53. $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.';
  54. }
  55. }
  56. /**
  57. * Adjust requirements according to your application specifics.
  58. */
  59. $requirements = array(
  60. // Database :
  61. array(
  62. 'name' => 'PDO extension',
  63. 'mandatory' => true,
  64. 'condition' => extension_loaded('pdo'),
  65. 'by' => 'All DB-related classes',
  66. ),
  67. array(
  68. 'name' => 'PDO SQLite extension',
  69. 'mandatory' => false,
  70. 'condition' => extension_loaded('pdo_sqlite'),
  71. 'by' => 'All DB-related classes',
  72. 'memo' => 'Required for SQLite database.',
  73. ),
  74. array(
  75. 'name' => 'PDO MySQL extension',
  76. 'mandatory' => false,
  77. 'condition' => extension_loaded('pdo_mysql'),
  78. 'by' => 'All DB-related classes',
  79. 'memo' => 'Required for MySQL database.',
  80. ),
  81. array(
  82. 'name' => 'PDO PostgreSQL extension',
  83. 'mandatory' => false,
  84. 'condition' => extension_loaded('pdo_pgsql'),
  85. 'by' => 'All DB-related classes',
  86. 'memo' => 'Required for PostgreSQL database.',
  87. ),
  88. // Cache :
  89. array(
  90. 'name' => 'Memcache extension',
  91. 'mandatory' => false,
  92. 'condition' => extension_loaded('memcache') || extension_loaded('memcached'),
  93. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
  94. '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>.' : ''
  95. ),
  96. // CAPTCHA:
  97. array(
  98. 'name' => 'GD PHP extension with FreeType support',
  99. 'mandatory' => false,
  100. 'condition' => $gdOK,
  101. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  102. 'memo' => $gdMemo,
  103. ),
  104. array(
  105. 'name' => 'ImageMagick PHP extension with PNG support',
  106. 'mandatory' => false,
  107. 'condition' => $imagickOK,
  108. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
  109. 'memo' => $imagickMemo,
  110. ),
  111. // PHP ini :
  112. 'phpExposePhp' => array(
  113. 'name' => 'Expose PHP',
  114. 'mandatory' => false,
  115. 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"),
  116. 'by' => 'Security reasons',
  117. 'memo' => '"expose_php" should be disabled at php.ini',
  118. ),
  119. 'phpAllowUrlInclude' => array(
  120. 'name' => 'PHP allow url include',
  121. 'mandatory' => false,
  122. 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"),
  123. 'by' => 'Security reasons',
  124. 'memo' => '"allow_url_include" should be disabled at php.ini',
  125. ),
  126. 'phpSmtp' => array(
  127. 'name' => 'PHP mail SMTP',
  128. 'mandatory' => false,
  129. 'condition' => strlen(ini_get('SMTP')) > 0,
  130. 'by' => 'Email sending',
  131. 'memo' => 'PHP mail SMTP server required',
  132. ),
  133. );
  134. // OPcache check
  135. if (!version_compare(phpversion(), '5.5', '>=')) {
  136. $requirements[] = array(
  137. 'name' => 'APC extension',
  138. 'mandatory' => false,
  139. 'condition' => extension_loaded('apc'),
  140. 'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
  141. );
  142. }
  143. $result = $requirementsChecker->checkYii()->check($requirements)->getResult();
  144. $requirementsChecker->render();
  145. exit($result['summary']['errors'] === 0 ? 0 : 1);