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:
parent
b39bf70345
commit
d973e99933
@ -125,7 +125,12 @@ class ONYX_RSS
|
|||||||
|
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
serendipity_request_start();
|
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 {
|
try {
|
||||||
$res = $req->send();
|
$res = $req->send();
|
||||||
|
|
||||||
@ -348,7 +353,12 @@ class ONYX_RSS
|
|||||||
{
|
{
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
serendipity_request_start();
|
serendipity_request_start();
|
||||||
$req = new HTTP_Request2($uri);
|
$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($uri, HTTP_Request2::METHOD_GET, $options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
|
@ -271,6 +271,10 @@ switch ($serendipity['GET']['adminAction']) {
|
|||||||
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
||||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'image');
|
serendipity_plugin_api::hook_event('backend_http_request', $options, 'image');
|
||||||
serendipity_request_start();
|
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);
|
$req = new HTTP_Request2($serendipity['POST']['imageurl'], HTTP_Request2::METHOD_GET, $options);
|
||||||
|
|
||||||
// Try to get the URL
|
// Try to get the URL
|
||||||
|
@ -56,7 +56,12 @@ class Serendipity_Import_Blogger extends Serendipity_Import {
|
|||||||
if (!empty($_REQUEST['token'])) {
|
if (!empty($_REQUEST['token'])) {
|
||||||
|
|
||||||
// Prepare session token request
|
// 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'] .'"');
|
$req->setHeader('Authorization', 'AuthSub token="'. $_REQUEST['token'] .'"');
|
||||||
|
|
||||||
// Request token
|
// Request token
|
||||||
|
@ -141,7 +141,12 @@ class Serendipity_Import_Generic extends Serendipity_Import {
|
|||||||
$uri = $this->data['url'];
|
$uri = $this->data['url'];
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
serendipity_request_start();
|
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 {
|
try {
|
||||||
$res = $req->send();
|
$res = $req->send();
|
||||||
if ($res->getStatus() != '200') {
|
if ($res->getStatus() != '200') {
|
||||||
|
@ -130,6 +130,10 @@ function _serendipity_send($loc, $data, $contenttype = null) {
|
|||||||
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
||||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_send');
|
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_send');
|
||||||
serendipity_request_start();
|
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($uri, HTTP_Request2::METHOD_POST, $options);
|
$req = new HTTP_Request2($uri, HTTP_Request2::METHOD_POST, $options);
|
||||||
if (isset($contenttype)){
|
if (isset($contenttype)){
|
||||||
@ -273,6 +277,10 @@ function serendipity_reference_autodiscover($loc, $url, $author, $title, $text)
|
|||||||
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
$options = array('follow_redirects' => true, 'max_redirects' => 5);
|
||||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_detect');
|
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_detect');
|
||||||
serendipity_request_start();
|
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($parsed_loc, HTTP_Request2::METHOD_GET, $options);
|
$req = new HTTP_Request2($parsed_loc, HTTP_Request2::METHOD_GET, $options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -541,7 +549,12 @@ function fetchPingbackData(&$comment) {
|
|||||||
if (function_exists('serendipity_request_start')) serendipity_request_start();
|
if (function_exists('serendipity_request_start')) serendipity_request_start();
|
||||||
|
|
||||||
// Request the page
|
// Request the page
|
||||||
$req = new HTTP_Request2($url, array('follow_redirects' => true, 'max_redirects' => 5, 'timeout' => 20));
|
$options = array('follow_redirects' => true, 'max_redirects' => 5, 'timeout' => 20);
|
||||||
|
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($url, HTTP_Request2::METHOD_GET, $options);
|
||||||
|
|
||||||
// code 200: OK, code 30x: REDIRECTION
|
// code 200: OK, code 30x: REDIRECTION
|
||||||
$responses = "/(200)|(30[0-9])/"; // |(30[0-9] Moved)
|
$responses = "/(200)|(30[0-9])/"; // |(30[0-9] Moved)
|
||||||
|
@ -8,7 +8,7 @@ if (IN_serendipity !== true) {
|
|||||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||||
|
|
||||||
// Actual version of this plugin
|
// Actual version of this plugin
|
||||||
@define('PLUGIN_EVENT_GRAVATAR_VERSION', '1.61'); // NOTE: This plugin is also in the central repository. Commit changes to the core, too :)
|
@define('PLUGIN_EVENT_GRAVATAR_VERSION', '1.61.1'); // NOTE: This plugin is also in the central repository. Commit changes to the core, too :)
|
||||||
|
|
||||||
// Defines the maximum available method slots in the configuration.
|
// Defines the maximum available method slots in the configuration.
|
||||||
@define('PLUGIN_EVENT_GRAVATAR_METHOD_MAX', 6);
|
@define('PLUGIN_EVENT_GRAVATAR_METHOD_MAX', 6);
|
||||||
@ -759,7 +759,12 @@ class serendipity_event_gravatar extends serendipity_event
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate URL of P/Favatar
|
// Evaluate URL of P/Favatar
|
||||||
$req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, array('follow_redirects' => true, 'max_redirects' => 3));
|
$options = array('follow_redirects' => true, 'max_redirects' => 3);
|
||||||
|
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($url, HTTP_Request2::METHOD_GET, $options);
|
||||||
$favicon = false;
|
$favicon = false;
|
||||||
// code 200: OK, code 30x: REDIRECTION
|
// code 200: OK, code 30x: REDIRECTION
|
||||||
$responses = "/(200 OK)|(30[0-9] Found)/"; // |(30[0-9] Moved)
|
$responses = "/(200 OK)|(30[0-9] Found)/"; // |(30[0-9] Moved)
|
||||||
@ -893,7 +898,12 @@ class serendipity_event_gravatar extends serendipity_event
|
|||||||
|
|
||||||
$twitter_search = 'http://search.twitter.com/search.atom?q=from%3A' . $twittername . '&rpp=1';
|
$twitter_search = 'http://search.twitter.com/search.atom?q=from%3A' . $twittername . '&rpp=1';
|
||||||
serendipity_request_start();
|
serendipity_request_start();
|
||||||
$req = new HTTP_Request2($twitter_search);
|
$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($twitter_search, HTTP_Request2::METHOD_GET, $options);
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
|
|
||||||
@ -951,7 +961,12 @@ class serendipity_event_gravatar extends serendipity_event
|
|||||||
$status_id = $matches[1];
|
$status_id = $matches[1];
|
||||||
$search = "http://identi.ca/api/statuses/show/$status_id.xml";
|
$search = "http://identi.ca/api/statuses/show/$status_id.xml";
|
||||||
serendipity_request_start();
|
serendipity_request_start();
|
||||||
$req = new HTTP_Request2($search);
|
$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($search, HTTP_Request2::METHOD_GET, $options);
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
$this->last_error = $response->getStatus();
|
$this->last_error = $response->getStatus();
|
||||||
@ -1128,6 +1143,11 @@ class serendipity_event_gravatar extends serendipity_event
|
|||||||
$request_pars['follow_redirects'] = false;
|
$request_pars['follow_redirects'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
$request_pars['ssl_verify_peer'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
$req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $request_pars);
|
$req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $request_pars);
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
|
@ -25,7 +25,7 @@ class serendipity_event_spamblock extends serendipity_event
|
|||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
$propbag->add('version', '1.86');
|
$propbag->add('version', '1.86.1');
|
||||||
$propbag->add('event_hooks', array(
|
$propbag->add('event_hooks', array(
|
||||||
'frontend_saveComment' => true,
|
'frontend_saveComment' => true,
|
||||||
'external_plugin' => true,
|
'external_plugin' => true,
|
||||||
@ -482,6 +482,10 @@ class serendipity_event_spamblock extends serendipity_event
|
|||||||
'follow_redirects' => true,
|
'follow_redirects' => true,
|
||||||
'max_redirects' => 3,
|
'max_redirects' => 3,
|
||||||
);
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// Default server type to akismet, in case user has an older version of the plugin
|
// Default server type to akismet, in case user has an older version of the plugin
|
||||||
// where no server was set
|
// where no server was set
|
||||||
@ -1053,7 +1057,12 @@ class serendipity_event_spamblock extends serendipity_event
|
|||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
|
|
||||||
if (function_exists('serendipity_request_start')) serendipity_request_start();
|
if (function_exists('serendipity_request_start')) serendipity_request_start();
|
||||||
$req = new HTTP_Request2($addData['url'], HTTP_Request2::METHOD_GET, array('follow_redirects' => true, 'max_redirects' => 5, 'timeout' => 10));
|
$options = array('follow_redirects' => true, 'max_redirects' => 5, 'timeout' => 10);
|
||||||
|
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
||||||
|
// On earlier PHP versions, the certificate validation fails. We deactivate it on them to restore the funcitonality we had with HTTP/Request1
|
||||||
|
$options['ssl_verify_peer'] = false;
|
||||||
|
}
|
||||||
|
$req = new HTTP_Request2($addData['url'], HTTP_Request2::METHOD_GET, $options);
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
|
@ -27,11 +27,9 @@ class serendipity_event_spartacus extends serendipity_event
|
|||||||
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
|
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Garvin Hicking');
|
$propbag->add('author', 'Garvin Hicking');
|
||||||
$propbag->add('version', '2.37');
|
$propbag->add('version', '2.37.1');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '1.6',
|
'serendipity' => '1.6',
|
||||||
'smarty' => '2.6.7',
|
|
||||||
'php' => '4.1.0'
|
|
||||||
));
|
));
|
||||||
$propbag->add('event_hooks', array(
|
$propbag->add('event_hooks', array(
|
||||||
'backend_plugins_fetchlist' => true,
|
'backend_plugins_fetchlist' => true,
|
||||||
@ -419,6 +417,10 @@ class serendipity_event_spartacus extends serendipity_event
|
|||||||
} else {
|
} else {
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
$options = 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;
|
||||||
|
}
|
||||||
serendipity_plugin_api::hook_event('backend_http_request', $options, 'spartacus');
|
serendipity_plugin_api::hook_event('backend_http_request', $options, 'spartacus');
|
||||||
serendipity_request_start();
|
serendipity_request_start();
|
||||||
|
|
||||||
|
@ -49,7 +49,12 @@ class s9y_remoterss_XMLTree
|
|||||||
{
|
{
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
||||||
serendipity_request_start();
|
serendipity_request_start();
|
||||||
$req = new HTTP_Request2($file);
|
$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($file, HTTP_Request2::METHOD_GET, $options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
@ -273,7 +278,7 @@ class serendipity_plugin_remoterss extends serendipity_plugin
|
|||||||
$propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
|
$propbag->add('description', PLUGIN_REMOTERSS_BLAHBLAH);
|
||||||
$propbag->add('stackable', true);
|
$propbag->add('stackable', true);
|
||||||
$propbag->add('author', 'Udo Gerhards, Richard Thomas Harrison');
|
$propbag->add('author', 'Udo Gerhards, Richard Thomas Harrison');
|
||||||
$propbag->add('version', '1.22');
|
$propbag->add('version', '1.22.1');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '1.7',
|
'serendipity' => '1.7',
|
||||||
'smarty' => '3.1.0',
|
'smarty' => '3.1.0',
|
||||||
@ -440,21 +445,6 @@ class serendipity_plugin_remoterss extends serendipity_plugin
|
|||||||
|
|
||||||
// Disabled by now. May get enabled in the future, but for now the extra HTTP call isn't worth trying.
|
// Disabled by now. May get enabled in the future, but for now the extra HTTP call isn't worth trying.
|
||||||
return true;
|
return true;
|
||||||
require_once S9Y_PEAR_PATH . 'HTTP/Request2.php';
|
|
||||||
serendipity_request_start();
|
|
||||||
$req = new HTTP_Request2($uri);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$response = $req->send();
|
|
||||||
if (!preg_match('@^[23]..@', $req->getStatus)) {
|
|
||||||
throw new HTTP_Request2_Exception('Status code says url not reachable');
|
|
||||||
}
|
|
||||||
serendipity_request_end();
|
|
||||||
return true;
|
|
||||||
} catch (HTTP_Request2_Exception $e) {
|
|
||||||
serendipity_request_end();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug($msg)
|
function debug($msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user