Archived
Workaround PHP < 5.6 bug, not verifying certs, stopping Request2
See http://board.s9y.org/viewtopic.php?f=10&t=20773 and #399
This commit is contained in:
@@ -271,6 +271,10 @@ switch ($serendipity['GET']['adminAction']) {
|
||||
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'image');
|
||||
serendipity_request_start();
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1
|
||||
$options['ssl_verify_peer'] = false;
|
||||
}
|
||||
$req = new HTTP_Request2($serendipity['POST']['imageurl'], HTTP_Request2::METHOD_GET, $options);
|
||||
|
||||
// Try to get the URL
|
||||
|
||||
@@ -56,7 +56,12 @@ class Serendipity_Import_Blogger extends Serendipity_Import {
|
||||
if (!empty($_REQUEST['token'])) {
|
||||
|
||||
// Prepare session token request
|
||||
$req = new HTTP_Request2('https://www.google.com/accounts/AuthSubSessionToken');
|
||||
$options = array();
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1
|
||||
$options['ssl_verify_peer'] = false;
|
||||
}
|
||||
$req = new HTTP_Request2('https://www.google.com/accounts/AuthSubSessionToken', HTTP_Request2::METHOD_GET, $options);
|
||||
$req->setHeader('Authorization', 'AuthSub token="'. $_REQUEST['token'] .'"');
|
||||
|
||||
// Request token
|
||||
|
||||
@@ -141,7 +141,12 @@ class Serendipity_Import_Generic extends Serendipity_Import {
|
||||
$uri = $this->data['url'];
|
||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||
serendipity_request_start();
|
||||
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_GET, array('follow_redirects' => true, 'max_redirects' => 5));
|
||||
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
||||
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the functionality we had with HTTP/Request1
|
||||
$options['ssl_verify_peer'] = false;
|
||||
}
|
||||
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_GET, $options);
|
||||
try {
|
||||
$res = $req->send();
|
||||
if ($res->getStatus() != '200') {
|
||||
|
||||
Reference in New Issue
Block a user