* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class MWP_System_Environment { /** * @var MWP_ServiceContainer_Interface */ private $container; public function __construct(MWP_ServiceContainer_Interface $container) { $this->container = $container; } public function isPdoEnabled() { if ($this->container->getParameter('disable_pdo')) { return false; } return extension_loaded('pdo_mysql'); } public function isMysqliEnabled() { if ($this->container->getParameter('disable_mysqli')) { return false; } return extension_loaded('mysqli'); } public function isMysqlEnabled() { if ($this->container->getParameter('disable_mysql')) { return false; } return extension_loaded('mysql'); } public function isCurlEnabled() { // Some hosting providers disable only curl_exec(). return (function_exists('curl_init') && function_exists('curl_exec')); } public function isOpenSslLibraryEnabled() { if ($this->container->getParameter('prefer_phpseclib')) { return false; } if (!extension_loaded('openssl')) { return false; } $context = $this->container->getWordPressContext(); $openSslParameters = $context->optionGet('mwp_openssl_parameters'); if (isset($openSslParameters['time']) && time() - $openSslParameters['time'] < 86400) { return !empty($openSslParameters['working']); } $context->optionSet('mwp_openssl_parameters', array( 'time' => time(), 'working' => false, )); $workingOpenSsl = $this->verifyIsOpenSslWorking(); $context->optionSet('mwp_openssl_parameters', array( 'time' => time(), 'working' => $workingOpenSsl, )); return $workingOpenSsl; } private function verifyIsOpenSslWorking() { $publicKey = <<