Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

149 satır
4.8 KiB

  1. <?php
  2. namespace Grav\Plugin\Problems;
  3. use Grav\Common\Grav;
  4. use Grav\Plugin\Problems\Base\Problem;
  5. /**
  6. * Class PHPModules
  7. * @package Grav\Plugin\Problems
  8. */
  9. class PHPModules extends Problem
  10. {
  11. public function __construct()
  12. {
  13. $this->id = 'PHP Modules';
  14. $this->class = get_class($this);
  15. $this->order = 101;
  16. $this->level = Problem::LEVEL_CRITICAL;
  17. $this->status = false;
  18. $this->help = 'https://learn.getgrav.org/basics/requirements#php-requirements';
  19. }
  20. /**
  21. * @return $this
  22. */
  23. public function process()
  24. {
  25. $modules_errors = [];
  26. $modules_success = [];
  27. // Check for PHP CURL library
  28. $msg = 'PHP Curl (Data Transfer Library) is %s installed';
  29. if (function_exists('curl_version')) {
  30. $modules_success['curl'] = sprintf($msg, 'successfully');
  31. } else {
  32. $modules_errors['curl'] = sprintf($msg, 'required but not');
  33. }
  34. // Check for PHP Ctype library
  35. $msg = 'PHP Ctype is %s installed';
  36. if (function_exists('ctype_print')) {
  37. $modules_success['ctype'] = sprintf($msg, 'successfully');
  38. } else {
  39. $modules_errors['ctype'] = sprintf($msg, 'required but not');
  40. }
  41. // Check for PHP Dom library
  42. $msg = 'PHP DOM is %s installed';
  43. if (class_exists('DOMDocument')) {
  44. $modules_success['dom'] = sprintf($msg, 'successfully');
  45. } else {
  46. $modules_errors['dom'] = sprintf($msg, 'required but not');
  47. }
  48. // Check for GD library
  49. $msg = 'PHP GD (Image Manipulation Library) is %s installed';
  50. if (defined('GD_VERSION') && function_exists('gd_info')) {
  51. $msg = $modules_success['gd'] = sprintf($msg, 'successfully');
  52. // Extra checks for Image support
  53. $ginfo = gd_info();
  54. $gda = array('PNG Support', 'JPEG Support', 'FreeType Support', 'GIF Read Support');
  55. $gda_msg = '';
  56. $problems_found = false;
  57. foreach ($gda as $image_type) {
  58. if (!$ginfo[$image_type]) {
  59. $problems_found = true;
  60. $gda_msg = "missing $image_type, but is ";
  61. break;
  62. }
  63. }
  64. if ($problems_found) {
  65. $msg .= ' but missing ' . $gda_msg;
  66. }
  67. $modules_success['gd'] = $msg;
  68. } else {
  69. $modules_errors['gd'] = sprintf($msg, 'required but not');
  70. }
  71. // Check for PHP MbString library
  72. $msg = 'PHP Mbstring (Multibyte String Library) is %s installed';
  73. if (extension_loaded('mbstring')) {
  74. $modules_success['mbstring'] = sprintf($msg, 'successfully');
  75. } else {
  76. $modules_errors['mbstring'] = sprintf($msg, 'required but not');
  77. }
  78. // Check for PHP Open SSL library
  79. $msg = 'PHP OpenSSL (Secure Sockets Library) is %s installed';
  80. if (defined('OPENSSL_VERSION_TEXT') && extension_loaded('openssl')) {
  81. $modules_success['openssl'] = sprintf($msg, 'successfully');
  82. } else {
  83. $modules_errors['openssl'] = sprintf($msg, 'required but not');
  84. }
  85. // Check for PHP XML library
  86. $msg = 'PHP JSON Library is %s installed';
  87. if (extension_loaded('json')) {
  88. $modules_success['json'] = sprintf($msg, 'successfully');
  89. } else {
  90. $modules_errors['json'] = sprintf($msg, 'required but not');
  91. }
  92. // Check for PHP XML library
  93. $msg = 'PHP XML Library is %s installed';
  94. if (extension_loaded('xml')) {
  95. $modules_success['xml'] = sprintf($msg, 'successfully');
  96. } else {
  97. $modules_errors['xml'] = sprintf($msg, 'required but not');
  98. }
  99. // Check for PHP Zip library
  100. $msg = 'PHP Zip extension is %s installed';
  101. if (extension_loaded('zip')) {
  102. $modules_success['zip'] = sprintf($msg, 'successfully');
  103. } else {
  104. $modules_errors['zip'] = sprintf($msg, 'required but not');
  105. }
  106. // Check Exif if enabled
  107. if (Grav::instance()['config']->get('system.media.auto_metadata_exif')) {
  108. $msg = 'PHP Exif (Exchangeable Image File Format) is %s installed';
  109. if (extension_loaded('exif')) {
  110. $modules_success['exif'] = sprintf($msg, 'successfully');
  111. } else {
  112. $modules_errors['exif'] = sprintf($msg, 'required but not');
  113. }
  114. }
  115. if (empty($modules_errors)) {
  116. $this->status = true;
  117. $this->msg = 'All modules look good!';
  118. } else {
  119. $this->status = false;
  120. $this->msg = 'There were problems with required modules:';
  121. }
  122. $this->details = ['errors' => $modules_errors, 'success' => $modules_success];
  123. return $this;
  124. }
  125. }