[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
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 meets 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 // Check for mbstring support 75 $this->check_mbstring(); 76 77 // XML extension support check 78 $this->check_xml(); 79 80 // Check for dbms support 81 $this->check_available_dbms(); 82 83 return $this->tests_passed; 84 } 85 86 /** 87 * Sets $this->tests_passed 88 * 89 * @param bool $is_passed 90 */ 91 protected function set_test_passed($is_passed) 92 { 93 // If one test failed, tests_passed should be false 94 $this->tests_passed = (!$this->tests_passed) ? false : $is_passed; 95 } 96 97 /** 98 * Check if the requirements for PHP version is met 99 */ 100 protected function check_php_version() 101 { 102 if (version_compare(PHP_VERSION, '7.2.0', '<')) 103 { 104 $this->response_helper->add_error_message('PHP_VERSION_REQD', 'PHP_VERSION_REQD_EXPLAIN'); 105 106 $this->set_test_passed(false); 107 return; 108 } 109 110 $this->set_test_passed(true); 111 } 112 113 /** 114 * Checks if the installed PHP has getimagesize() available 115 */ 116 protected function check_image_size() 117 { 118 if (!@function_exists('getimagesize')) 119 { 120 $this->response_helper->add_error_message('PHP_GETIMAGESIZE_SUPPORT', 'PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'); 121 122 $this->set_test_passed(false); 123 return; 124 } 125 126 $this->set_test_passed(true); 127 } 128 129 /** 130 * Checks if the installed PHP supports PCRE 131 */ 132 protected function check_pcre() 133 { 134 if (@preg_match('//u', '')) 135 { 136 $this->set_test_passed(true); 137 return; 138 } 139 140 $this->response_helper->add_error_message('PCRE_UTF_SUPPORT', 'PCRE_UTF_SUPPORT_EXPLAIN'); 141 142 $this->set_test_passed(false); 143 } 144 145 /** 146 * Checks whether PHP's JSON extension is available or not 147 */ 148 protected function check_json() 149 { 150 if (@extension_loaded('json')) 151 { 152 $this->set_test_passed(true); 153 return; 154 } 155 156 $this->response_helper->add_error_message('PHP_JSON_SUPPORT', 'PHP_JSON_SUPPORT_EXPLAIN'); 157 158 $this->set_test_passed(false); 159 } 160 161 /** 162 * Checks whether PHP's mbstring extension is available or not 163 */ 164 protected function check_mbstring() 165 { 166 if (@extension_loaded('mbstring')) 167 { 168 $this->set_test_passed(true); 169 return; 170 } 171 172 $this->response_helper->add_error_message('PHP_MBSTRING_SUPPORT', 'PHP_MBSTRING_SUPPORT_EXPLAIN'); 173 174 $this->set_test_passed(false); 175 } 176 177 /** 178 * Checks whether or not the XML PHP extension is available (Required by the text formatter) 179 */ 180 protected function check_xml() 181 { 182 if (class_exists('DOMDocument')) 183 { 184 $this->set_test_passed(true); 185 return; 186 } 187 188 $this->response_helper->add_error_message('PHP_XML_SUPPORT', 'PHP_XML_SUPPORT_EXPLAIN'); 189 190 $this->set_test_passed(false); 191 } 192 193 /** 194 * Check if any supported DBMS is available 195 */ 196 protected function check_available_dbms() 197 { 198 $available_dbms = $this->database_helper->get_available_dbms(false, true); 199 200 if ($available_dbms['ANY_DB_SUPPORT']) 201 { 202 $this->set_test_passed(true); 203 return; 204 } 205 206 $this->response_helper->add_error_message('PHP_SUPPORTED_DB', 'PHP_SUPPORTED_DB_EXPLAIN'); 207 208 $this->set_test_passed(false); 209 } 210 211 /** 212 * {@inheritdoc} 213 */ 214 static public function get_step_count() 215 { 216 return 0; 217 } 218 219 /** 220 * {@inheritdoc} 221 */ 222 public function get_task_lang_name() 223 { 224 return ''; 225 } 226 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |