Trackbacks und https (keine Eingangserkennung)

Hier können Probleme und alles andere in Deutscher Sprache gelöst werden.
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

Liefert mir die Seite als HTML zurück, sowohl bei Aufruf über https://.../test.php als auch http://.../test.php
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

Hi!

OK, dann bitte mal folgendes probieren:

Code: Select all

<?php

include 'serendipity_config.inc.php';

$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($url, $options);
$res = $req->sendRequest();

if (PEAR::isError($res)) {
    echo '<div>&#8226; ' . sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']) .'</div>';
    serendipity_request_end();
    return;
}

$fContent = $req->getResponseBody();
serendipity_request_end();
echo $fContent . "<br />\n";
Ich vermute, dass im oberen Teil (extension_loaded('openssl')) der Code abbricht. Was komisch wäre, denn openssl scheint bei Dir aktiviert zu sein. Naja, erstmal schauen was mit obigem test.php code bei dir passiert.

GRüße
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by onli »

Das war noch nicht im Forum: Ich hab gestern per IM mit Bernd ein paar Debugausgaben eingefügt und getestet. Demnach wird die Anfrage gestellt, der Code bricht also nicht ab, aber es kommt keine Antwort zurück. Ab da wusste ich nicht wirklich weiter und der Thread hier belebte sich.
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

garvinhicking wrote:Ich vermute, dass im oberen Teil (extension_loaded('openssl')) der Code abbricht. Was komisch wäre, denn openssl scheint bei Dir aktiviert zu sein. Naja, erstmal schauen was mit obigem test.php code bei dir passiert.
http://bernd.distler.ws/test2.php liefert

Code: Select all

Checking: https://bernd.distler.ws/archives/1385-Probleme-mit-Serendipity-und-https-URLs.html
• Kein Trackback: Konnte Verbindung zu bernd.distler.ws auf Port 80 nicht herstellen.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

Hi!

OK, dann kommt er zumindest bis zum Request, aber krieg da (wie onli gerade schrieb) wohl keine Daten herein.

Füg bitte nochmal folgende Zeilen ein nach der Zeile "$res= $req->sendRequest()"::

Code: Select all

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>';
Die Debuggingangaben sollten Details zum fehlgeschlagenen Request enthalten.

Nutzt Du evtl eines der Proxy-Eventplugins, diese könnten einen HTTP-Request beeinflussen.

Grüße,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

Hab den Code eingebaut, kannst du dir auf http://bernd.distler.ws/test2.php ansehen. Von Proxy-Plugins weiß ich nix :oops:
onli
Regular
Posts: 3044
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by onli »

$url exisitiert nicht, oder?
Sollte das

Code: Select all

$req = new HTTP_Request($loc, $options);
statt

Code: Select all

$req = new HTTP_Request($url, $options);
heißen?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

onli wrote:$url exisitiert nicht, oder?
Sollte das

Code: Select all

$req = new HTTP_Request($loc, $options);
statt

Code: Select all

$req = new HTTP_Request($url, $options);
heißen?
Argl. Ja. Danke dafür. Hier nochmal der angepasst komplette Code:

Code: Select all

<?php

include 'serendipity_config.inc.php';

$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>&#8226; ' . sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']) .'</div>';
    serendipity_request_end();
    return;
}

$fContent = $req->getResponseBody();
serendipity_request_end();
echo $fContent . "<br />\n";
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

OK, hab die test2.php aktualisiert.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

Hi!

Interessant. Der SSL-Request geht eigentlich durch um die URL zu holen. Als nächster Schritt würde s9y den HTML-Content auswerten um die Trackback-URL festzustellen.

Anbei ein neuer PHP-Code der diee Schritte weiter debugged:

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']);
    }

    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);
    $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>&#8226; ' . 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>&#8226; ' . 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>&#8226; ' . TRACKBACK_SENT .'</div>';
    } else {
        echo '<div>&#8226; ' . 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>&#8226; ' . 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>';
Grüße,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

test2 ist up-to-date.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

Hi!

OK. Fehler gefunden. Der Code setzt ein ":80" als Defaultport dran, was bei https natürlich falsch ist.

Folgneder Bugfix im s9y core behebt das:

https://github.com/s9y/Serendipity/comm ... 6701e3bcbf

Alternativ kannst Du das Trackback an https://bernd.distler.ws:443/URL...html verschicken, also 443 als Port mitgeben, dann müsste es auch ankommen.

Grüße,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Trackbacks und https (keine Eingangserkennung)

Post by Timbalu »

TB-URI resolved to https: //bernd.distler.ws/comment.php?type=trackback&entry_id=1385<br />
Sende Trackback zu URI https: //bernd.distler.ws/comment.php?type=trackback&amp;entry_id=1385 ...Sending TB to: https: //bernd.distler.ws:80/comment.php?type=trackback&entry_id=1385<br />
Wo kommt das zweite "amp;" ohne "&" und überhaupt das "Sende Trackback zu URI " her?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by garvinhicking »

Wo kommt das zweite "amp;" ohne "&" und überhaupt das "Sende Trackback zu URI " her?
Wg. htmlspecialchars() in der URL-Ausgabe zur Sicherheit um da kein XSS zu haben.

Grüße,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: Trackbacks und https (keine Eingangserkennung)

Post by bernd_d »

garvinhicking wrote:OK. Fehler gefunden. Der Code setzt ein ":80" als Defaultport dran, was bei https natürlich falsch ist.

Folgneder Bugfix im s9y core behebt das:

https://github.com/s9y/Serendipity/comm ... 6701e3bcbf

Alternativ kannst Du das Trackback an https://bernd.distler.ws:443/URL...html verschicken, also 443 als Port mitgeben, dann müsste es auch ankommen.
Ich habe den Patch eingebaut, aber beide Varianten funktionieren nicht. Es kommt leider kein Trackback an.
Post Reply