[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/install/module/requirements/task/ -> check_server_environment.php (source)

   1  <?php
   2  /**
   3   *
   4   * This file is part of the phpBB Forum Software package.
   5   *
   6   * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7   * @license GNU General Public License, version 2 (GPL-2.0)
   8   *
   9   * For full copyright and license information, please see
  10   * the docs/CREDITS.txt file.
  11   *
  12   */
  13  
  14  namespace phpbb\install\module\requirements\task;
  15  
  16  /**
  17   * Installer task that checks if the server meats phpBB requirements
  18   */
  19  class check_server_environment extends \phpbb\install\task_base
  20  {
  21      /**
  22       * @var \phpbb\install\helper\database
  23       */
  24      protected $database_helper;
  25  
  26      /**
  27       * @var \phpbb\install\helper\iohandler\iohandler_interface
  28       */
  29      protected $response_helper;
  30  
  31      /**
  32       * @var bool
  33       */
  34      protected $tests_passed;
  35  
  36      /**
  37       * Constructor
  38       *
  39       * @param    \phpbb\install\helper\database    $database_helper
  40       * @param    \phpbb\install\helper\iohandler\iohandler_interface    $response
  41       */
  42  	public function __construct(\phpbb\install\helper\database $database_helper,
  43                                  \phpbb\install\helper\iohandler\iohandler_interface $response)
  44      {
  45          $this->database_helper    = $database_helper;
  46          $this->response_helper    = $response;
  47          $this->tests_passed        = true;
  48  
  49          parent::__construct(true);
  50      }
  51  
  52      /**
  53       * {@inheritdoc}
  54       */
  55  	public function run()
  56      {
  57          //
  58          // Check requirements
  59          // The error messages should be set in the check_ functions
  60          //
  61  
  62          // Check PHP version
  63          $this->check_php_version();
  64  
  65          // Check for getimagesize()
  66          $this->check_image_size();
  67  
  68          // Check for PCRE support
  69          $this->check_pcre();
  70  
  71          // Check for JSON support
  72          $this->check_json();
  73  
  74          // XML extension support check
  75          $this->check_xml();
  76  
  77          // Check for dbms support
  78          $this->check_available_dbms();
  79  
  80          return $this->tests_passed;
  81      }
  82  
  83      /**
  84       * Sets $this->tests_passed
  85       *
  86       * @param    bool    $is_passed
  87       */
  88  	protected function set_test_passed($is_passed)
  89      {
  90          // If one test failed, tests_passed should be false
  91          $this->tests_passed = (!$this->tests_passed) ? false : $is_passed;
  92      }
  93  
  94      /**
  95       * Check if the requirements for PHP version is met
  96       */
  97  	protected function check_php_version()
  98      {
  99          $php_version = PHP_VERSION;
 100  
 101          if (version_compare($php_version, '5.4') < 0)
 102          {
 103              $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN');
 104  
 105              $this->set_test_passed(false);
 106              return;
 107          }
 108  
 109          $this->set_test_passed(true);
 110      }
 111  
 112      /**
 113       * Checks if the installed PHP has getimagesize() available
 114       */
 115  	protected function check_image_size()
 116      {
 117          if (!@function_exists('getimagesize'))
 118          {
 119              $this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN');
 120  
 121              $this->set_test_passed(false);
 122              return;
 123          }
 124  
 125          $this->set_test_passed(true);
 126      }
 127  
 128      /**
 129       * Checks if the installed PHP supports PCRE
 130       */
 131  	protected function check_pcre()
 132      {
 133          if (@preg_match('//u', ''))
 134          {
 135              $this->set_test_passed(true);
 136              return;
 137          }
 138  
 139          $this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN');
 140  
 141          $this->set_test_passed(false);
 142      }
 143  
 144      /**
 145       * Checks whether PHP's JSON extension is available or not
 146       */
 147  	protected function check_json()
 148      {
 149          if (@extension_loaded('json'))
 150          {
 151              $this->set_test_passed(true);
 152              return;
 153          }
 154  
 155          $this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN');
 156  
 157          $this->set_test_passed(false);
 158      }
 159  
 160      /**
 161       * Checks whether or not the XML PHP extension is available (Required by the text formatter)
 162       */
 163  	protected function check_xml()
 164      {
 165          if (class_exists('DOMDocument'))
 166          {
 167              $this->set_test_passed(true);
 168              return;
 169          }
 170  
 171          $this->response_helper->add_error_message('PHP_XML_SUPPORT', 'PHP_XML_SUPPORT_EXPLAIN');
 172  
 173          $this->set_test_passed(false);
 174      }
 175  
 176      /**
 177       * Check if any supported DBMS is available
 178       */
 179  	protected function check_available_dbms()
 180      {
 181          $available_dbms = $this->database_helper->get_available_dbms(false, true);
 182  
 183          if ($available_dbms['ANY_DB_SUPPORT'])
 184          {
 185              $this->set_test_passed(true);
 186              return;
 187          }
 188  
 189          $this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN');
 190  
 191          $this->set_test_passed(false);
 192      }
 193  
 194      /**
 195       * {@inheritdoc}
 196       */
 197  	static public function get_step_count()
 198      {
 199          return 0;
 200      }
 201  
 202      /**
 203       * {@inheritdoc}
 204       */
 205  	public function get_task_lang_name()
 206      {
 207          return '';
 208      }
 209  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1