Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1180 → Rev 1181

/trunk/includes/functions.inc.php
333,11 → 333,20
}
 
/**
* @param bool $require_ssl
* @param string|null $reason
* @return bool
* @throws OIDplusException
* @throws \ViaThinkSoft\OIDplus\OIDplusConfigInitializationException
*/
function url_post_contents_available(): bool {
return function_exists('curl_init');
function url_post_contents_available(bool $require_ssl=true, string &$reason=null): bool {
if (function_exists('curl_init')) {
return true;
} else {
$reason = _L('Please install the PHP extension %1, so that OIDplus can connect to the Internet.', '<code>php_curl</code>');
return false;
}
}
 
/**
* @param string $url
384,6 → 393,32
}
 
/**
* @param bool $require_ssl
* @param string|null $reason
* @return bool
* @throws OIDplusException
* @throws \ViaThinkSoft\OIDplus\OIDplusConfigInitializationException
*/
function url_get_contents_available(bool $require_ssl=true, string &$reason=null): bool {
if (function_exists('curl_init')) {
// Via cURL
return true;
} else {
// Via file_get_contents()
if (!ini_get('allow_url_fopen')) {
$reason = _L('Please install the PHP extension %1 and/or enable %2 in your PHP configuration, so that OIDplus can connect to the Internet.', '<code>php_curl</code>', '<code>allow_url_fopen</code>');
return false;
}
// Use extension_loaded() instead of function_exists(), because our supplement does not help...
if ($require_ssl && !extension_loaded('openssl')) {
$reason = _L('Please install the PHP extension %1 and/or %2, so that OIDplus can connect to the Internet.', '<code>php_curl</code>', '<code>php_openssl</code>');
return false;
}
return true;
}
}
 
/**
* @param string $url
* @param array $extraHeaders
* @param string $userAgent