Dann mal hier der code der meinen Patch enthält, evtl ist da immer noch etwas mit falschem Port.
Code: Select all
<?php
include 'serendipity_config.inc.php';
function test_serendipity_send($loc, $data, $contenttype = null) {
global $serendipity;
$target = parse_url($loc);
if ($target['query'] != '') {
$target['query'] = '?' . str_replace('&', '&', $target['query']);
}
echo "Parts: " . print_r($target, true) . "<br />\n";
if ($target['scheme'] == 'https' && empty($target['port'])) {
$target['port'] = 443;
echo "FIXED port to 443<br />\n";
}
if (!is_numeric($target['port'])) {
$target['port'] = 80;
}
$uri = $target['scheme'] . '://' . $target['host'] . ':' . $target['port'] . $target['path'] . $target['query'];
echo "Sending TB to: " . $uri . "<br />\n";
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'POST');
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_send');
serendipity_request_start();
$req = new HTTP_Request($uri, $options);
if (isset($contenttype)){
$req->addHeader('Content-Type', $contenttype);
}
$req->addRawPostData($data, true);
echo "RAW POST DATA: <pre>" . print_r($data, true) . "</pre><br />\n";
$res = $req->sendRequest();
echo 'Sent to: ' . print_r($res, true) . "<br />\n";
if (PEAR::isError($res)) {
echo "PEAR FAILRUE!<br />\n";
serendipity_request_end();
return false;
}
$fContent = $req->getResponseBody();
serendipity_request_end();
echo "Returned " . strlen($fContent) . " Bytes.<br />\n";
print_r($fContent);
return $fContent;
}
function test_serendipity_trackback_autodiscover($res, $loc, $url, $author, $title, $text, $loc2 = '') {
$is_wp = false;
$wp_check = false;
if (preg_match('@((' . preg_quote($loc, '@') . '|' . preg_quote($loc2, '@') . ')/?trackback/)@i', $res, $wp_loc)) {
// We found a WP-blog that may not advertise RDF-Tags!
$is_wp = true;
}
if (!preg_match('@trackback:ping(\s*rdf:resource)?\s*=\s*["\'](https?:[^"\']+)["\']@i', $res, $matches)) {
echo "RDF-XML not found!<br />\n";
$matches = array();
serendipity_plugin_api::hook_event('backend_trackback_check', $matches, $loc);
// Plugins may say that a URI is valid, in situations where a blog has no valid RDF metadata
if (empty($matches[2])) {
if ($is_wp) {
$wp_check = true;
} else {
echo '<div>• ' . sprintf(TRACKBACK_FAILED, TRACKBACK_NOT_FOUND) . '</div>';
return false;
}
}
}
$trackURI = trim($matches[2]);
echo "TB-URI resolved to " . $trackURI . "<br />\n";
if (preg_match('@dc:identifier\s*=\s*["\'](https?:[^\'"]+)["\']@i', $res, $test)) {
if ($loc != $test[1] && $loc2 != $test[1]) {
if ($is_wp) {
$wp_check = true;
} else {
echo '<div>• ' . sprintf(TRACKBACK_FAILED, TRACKBACK_URI_MISMATCH) . '</div>';
return false;
}
}
}
// If $wp_check is set it means no RDF metadata was found, and we simply try the /trackback/ url.
if ($wp_check) {
$trackURI = $wp_loc[0];
}
$data = 'url=' . rawurlencode($url)
. '&title=' . rawurlencode($title)
. '&blog_name=' . rawurlencode($author)
. '&excerpt=' . rawurlencode(strip_tags($text));
printf(TRACKBACK_SENDING, htmlspecialchars($trackURI));
$sent = test_serendipity_send($trackURI, $data);
$response = serendipity_trackback_is_success($sent);
if ($response === true) {
echo '<div>• ' . TRACKBACK_SENT .'</div>';
} else {
echo '<div>• ' . sprintf(TRACKBACK_FAILED, $response) . '</div>';
}
return $response;
}
$loc = 'https://bernd.distler.ws/archives/1385-Probleme-mit-Serendipity-und-https-URLs.html';
$u = parse_url($loc);
if ($u['scheme'] != 'http' && $u['scheme'] != 'https') {
echo "SCHEME != http(s)<br />\n";
return;
} elseif ($u['scheme'] == 'https' && !extension_loaded('openssl')) {
echo "HTTPS not supported!<br />\n";
return; // Trackbacks to HTTPS URLs can only be performed with openssl activated
}
if (empty($u['port'])) {
$u['port'] = 80;
$port = '';
} else {
$port = ':' . $u['port'];
}
if (!empty($u['query'])) {
$u['path'] .= '?' . $u['query'];
}
$parsed_loc = $u['scheme'] . '://' . $u['host'] . $port . $u['path'];
echo "Checking: " . $parsed_loc . "<br />\n";
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'GET');
serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_detect');
serendipity_request_start();
$req = new HTTP_Request($loc, $options);
$res = $req->sendRequest();
echo 'Ziehe HTTP-Request aus: ' . S9Y_PEAR_PATH . '<br />';
echo 'LOC: ' . $parsed_loc . '<br />';
echo '<pre>' . print_r($options, true) . '</pre>';
#echo '<pre>' . print_r($res, true) . '</pre>';
#echo '<pre>' . print_r($req, true) . '</pre>';
if (PEAR::isError($res)) {
echo '<div>• ' . sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']) .'</div>';
serendipity_request_end();
return;
}
$fContent = $req->getResponseBody();
serendipity_request_end();
echo strlen($fContent) . " Bytes erhalten.<br />\n";
$tb = test_serendipity_trackback_autodiscover($fContent, $parsed_loc, $parsed_loc, 'Author', 'Title', 'Text');
echo '<pre>' . print_r($tb, true) . '</pre>';