[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Installation 5 * @subpackage Model 6 * 7 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\CMS\Installation\Model; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Form\Form; 15 use Joomla\CMS\Language\Text; 16 use Joomla\Database\DatabaseDriver; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Checks model for the Joomla Core Installer. 24 * 25 * @since 4.0.0 26 */ 27 class ChecksModel extends BaseInstallationModel 28 { 29 /** 30 * Checks the availability of the parse_ini_file and parse_ini_string functions. 31 * 32 * @return boolean True if the method exists. 33 * 34 * @since 3.1 35 */ 36 public function getIniParserAvailability() 37 { 38 $disabled_functions = ini_get('disable_functions'); 39 40 if (!empty($disabled_functions)) { 41 // Attempt to detect them in the PHP INI disable_functions variable. 42 $disabled_functions = explode(',', trim($disabled_functions)); 43 $number_of_disabled_functions = count($disabled_functions); 44 45 for ($i = 0, $l = $number_of_disabled_functions; $i < $l; $i++) { 46 $disabled_functions[$i] = trim($disabled_functions[$i]); 47 } 48 49 $result = !in_array('parse_ini_string', $disabled_functions); 50 } else { 51 // Attempt to detect their existence; even pure PHP implementation of them will trigger a positive response, though. 52 $result = function_exists('parse_ini_string'); 53 } 54 55 return $result; 56 } 57 58 /** 59 * Gets PHP options. 60 * 61 * @return array Array of PHP config options 62 * 63 * @since 3.1 64 */ 65 public function getPhpOptions() 66 { 67 $options = []; 68 69 // Check for zlib support. 70 $option = new \stdClass(); 71 $option->label = Text::_('INSTL_ZLIB_COMPRESSION_SUPPORT'); 72 $option->state = extension_loaded('zlib'); 73 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_ZLIB_COMPRESSION_SUPPORT'); 74 $options[] = $option; 75 76 // Check for XML support. 77 $option = new \stdClass(); 78 $option->label = Text::_('INSTL_XML_SUPPORT'); 79 $option->state = extension_loaded('xml'); 80 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_XML_SUPPORT'); 81 $options[] = $option; 82 83 // Check for database support. 84 // We are satisfied if there is at least one database driver available. 85 $available = DatabaseDriver::getConnectors(); 86 $option = new \stdClass(); 87 $option->label = Text::_('INSTL_DATABASE_SUPPORT'); 88 $option->label .= '<br>(' . implode(', ', $available) . ')'; 89 $option->state = count($available); 90 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_DATABASE_SUPPORT'); 91 $options[] = $option; 92 93 // Check for mbstring options. 94 if (extension_loaded('mbstring')) { 95 // Check for default MB language. 96 $option = new \stdClass(); 97 $option->label = Text::_('INSTL_MB_LANGUAGE_IS_DEFAULT'); 98 $option->state = (strtolower(ini_get('mbstring.language')) == 'neutral'); 99 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_MBLANG_NOTDEFAULT'); 100 $options[] = $option; 101 102 // Check for MB function overload. 103 $option = new \stdClass(); 104 $option->label = Text::_('INSTL_MB_STRING_OVERLOAD_OFF'); 105 $option->state = (ini_get('mbstring.func_overload') == 0); 106 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_MBSTRING_OVERLOAD_OFF'); 107 $options[] = $option; 108 } 109 110 // Check for a missing native parse_ini_file implementation. 111 $option = new \stdClass(); 112 $option->label = Text::_('INSTL_PARSE_INI_FILE_AVAILABLE'); 113 $option->state = $this->getIniParserAvailability(); 114 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_PARSE_INI_FILE_AVAILABLE'); 115 $options[] = $option; 116 117 // Check for missing native json_encode / json_decode support. 118 $option = new \stdClass(); 119 $option->label = Text::_('INSTL_JSON_SUPPORT_AVAILABLE'); 120 $option->state = function_exists('json_encode') && function_exists('json_decode'); 121 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_JSON_SUPPORT_AVAILABLE'); 122 $options[] = $option; 123 124 // Check for configuration file writable. 125 $writable = (is_writable(JPATH_CONFIGURATION . '/configuration.php') 126 || (!file_exists(JPATH_CONFIGURATION . '/configuration.php') && is_writable(JPATH_ROOT))); 127 128 $option = new \stdClass(); 129 $option->label = Text::sprintf('INSTL_WRITABLE', 'configuration.php'); 130 $option->state = $writable; 131 $option->notice = $option->state ? null : Text::_('INSTL_NOTICE_NEEDSTOBEWRITABLE'); 132 $options[] = $option; 133 134 return $options; 135 } 136 137 /** 138 * Checks if all of the mandatory PHP options are met. 139 * 140 * @return boolean True on success. 141 * 142 * @since 3.1 143 */ 144 public function getPhpOptionsSufficient() 145 { 146 $options = $this->getPhpOptions(); 147 148 foreach ($options as $option) { 149 if ($option->state === false) { 150 $result = $option->state; 151 } 152 } 153 154 return isset($result) ? false : true; 155 } 156 157 /** 158 * Gets PHP Settings. 159 * 160 * @return array 161 * 162 * @since 3.1 163 */ 164 public function getPhpSettings() 165 { 166 $settings = array(); 167 168 // Check for display errors. 169 $setting = new \stdClass(); 170 $setting->label = Text::_('INSTL_DISPLAY_ERRORS'); 171 $setting->state = (bool) ini_get('display_errors'); 172 $setting->recommended = false; 173 $settings[] = $setting; 174 175 // Check for file uploads. 176 $setting = new \stdClass(); 177 $setting->label = Text::_('INSTL_FILE_UPLOADS'); 178 $setting->state = (bool) ini_get('file_uploads'); 179 $setting->recommended = true; 180 $settings[] = $setting; 181 182 // Check for output buffering. 183 $setting = new \stdClass(); 184 $setting->label = Text::_('INSTL_OUTPUT_BUFFERING'); 185 $setting->state = (int) ini_get('output_buffering') !== 0; 186 $setting->recommended = false; 187 $settings[] = $setting; 188 189 // Check for session auto-start. 190 $setting = new \stdClass(); 191 $setting->label = Text::_('INSTL_SESSION_AUTO_START'); 192 $setting->state = (bool) ini_get('session.auto_start'); 193 $setting->recommended = false; 194 $settings[] = $setting; 195 196 // Check for native ZIP support. 197 $setting = new \stdClass(); 198 $setting->label = Text::_('INSTL_ZIP_SUPPORT_AVAILABLE'); 199 $setting->state = function_exists('zip_open') && function_exists('zip_read'); 200 $setting->recommended = true; 201 $settings[] = $setting; 202 203 // Check for GD support 204 $setting = new \stdClass(); 205 $setting->label = Text::sprintf('INSTL_EXTENSION_AVAILABLE', 'GD'); 206 $setting->state = extension_loaded('gd'); 207 $setting->recommended = true; 208 $settings[] = $setting; 209 210 // Check for iconv support 211 $setting = new \stdClass(); 212 $setting->label = Text::sprintf('INSTL_EXTENSION_AVAILABLE', 'iconv'); 213 $setting->state = function_exists('iconv'); 214 $setting->recommended = true; 215 $settings[] = $setting; 216 217 // Check for intl support 218 $setting = new \stdClass(); 219 $setting->label = Text::sprintf('INSTL_EXTENSION_AVAILABLE', 'intl'); 220 $setting->state = function_exists('transliterator_transliterate'); 221 $setting->recommended = true; 222 $settings[] = $setting; 223 224 return $settings; 225 } 226 227 /** 228 * Get the current setup options from the session. 229 * 230 * @return array An array of options from the session. 231 * 232 * @since 3.1 233 */ 234 public function getOptions() 235 { 236 if (!empty(Factory::getSession()->get('setup.options', array()))) { 237 return Factory::getSession()->get('setup.options', array()); 238 } 239 } 240 241 /** 242 * Method to get the form. 243 * 244 * @param string|null $view The view being processed. 245 * 246 * @return Form|boolean Form object on success, false on failure. 247 * 248 * @since 3.1 249 */ 250 public function getForm($view = null) 251 { 252 if (!$view) { 253 $view = Factory::getApplication()->input->getWord('view', 'setup'); 254 } 255 256 // Get the form. 257 Form::addFormPath(JPATH_COMPONENT . '/forms'); 258 259 try { 260 $form = Form::getInstance('jform', $view, array('control' => 'jform')); 261 } catch (\Exception $e) { 262 Factory::getApplication()->enqueueMessage($e->getMessage(), 'error'); 263 264 return false; 265 } 266 267 // Check the session for previously entered form data. 268 $data = (array) $this->getOptions(); 269 270 // Bind the form data if present. 271 if (!empty($data)) { 272 $form->bind($data); 273 } 274 275 return $form; 276 } 277 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |