Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25614
Modified Files:
serendipity_admin_entries.inc.php
serendipity_functions.inc.php
Log Message:
- Fixed error detection when trackbacking. Previously we did not properly detect errors sent by the trackbacked blog
- Made the trackback page a little more pretty
- Changed how trackback errors are displayed
- Fixed problem when a trackback URI contained excess newlines
- Send LANG_CHARSET when trackbacking
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.410
retrieving revision 1.411
diff -u -d -r1.410 -r1.411
--- serendipity_functions.inc.php 1 Sep 2004 14:15:07 -0000 1.410
+++ serendipity_functions.inc.php 1 Sep 2004 17:17:41 -0000 1.411
@@ -2154,9 +2154,9 @@
*/
function serendipity_trackback_is_success($resp)
{
- if (preg_match('@<error>(\d)+</error>@', $resp, $matches)) {
- if ((int) $matches[1] || (string) $matches[1] === "0") {
- return 1;
+ if (preg_match('@<error>(\d+)</error>@', $resp, $matches)) {
+ if ((int) $matches[1] === 0) {
+ return true;
} else {
if (preg_match('@<message>([^<]+)</message>@', $resp, $matches)) {
return $matches[1];
@@ -2166,7 +2166,7 @@
}
}
}
- return 1;
+ return true;
}
function serendipity_pingback_autodiscover($loc, $body) {
@@ -2202,6 +2202,7 @@
*/
function _serendipity_send($loc, $data) {
global $serendipity;
+
$target = parse_url($loc);
if ($target['query'] != '') {
$target['query'] = '?' . str_replace('&', '&', $target['query']);
@@ -2216,14 +2217,18 @@
return "Couldn't connect to $loc";
}
- fwrite($sock, "POST {$target['path']}{$target['query']} HTTP/1.1\r\n");
- fwrite($sock, "Host: {$target['host']}\r\n");
- fwrite($sock, "User-Agent: Serendipity/{$serendipity['version']}\r\n");
- fwrite($sock, "Content-type: application/x-www-form-urlencoded\r\n");
- fwrite($sock, "Content-length: " . strlen($data) . "\r\n");
- fwrite($sock, "Connection: close\r\n\r\n");
- fwrite($sock, $data);
+ $headers .= "POST {$target['path']}{$target['query']} HTTP/1.1\r\n";
+ $headers .= "Host: {$target['host']}\r\n";
+ $headers .= "User-Agent: Serendipity/{$serendipity['version']}\r\n";
+ $headers .= "Content-Type: application/x-www-form-urlencoded; charset=" . LANG_CHARSET . "\r\n";
+ $headers .= "Content-Length: " . strlen($data) . "\r\n";
+ $headers .= "Connection: close\r\n";
+ $headers .= "\r\n";
+ $headers .= $data;
+ fwrite($sock, $headers);
+
+ $res = '';
while (!feof($sock)) {
$res .= fgets($sock, 1024);
}
@@ -2235,13 +2240,15 @@
function serendipity_trackback_autodiscover($res, $loc, $url, $author, $title, $text)
{
if (!preg_match('@trackback:ping(\s*rdf:resource)?\s*=\s*"(http:[^"]+)"@i', $res, $matches)) {
- echo TRACKBACK_NOT_FOUND . '<br />';
+ echo '<div>• ' . sprintf(TRACKBACK_FAILED, TRACKBACK_NOT_FOUND) . '</div>';
return false;
}
+ $trackURI = trim($matches[2]);
+
if (preg_match('@dc:identifier\s*=\s*"(http:[^"]+)"@i', $res, $test)) {
if ($loc != $test[1]) {
- echo TRACKBACK_URI_MISMATCH . '<br />';
+ echo '<div>• ' . sprintf(TRACKBACK_FAILED, TRACKBACK_URI_MISMATCH) . '</div>';
return false;
}
}
@@ -2251,16 +2258,16 @@
. '&blog_name=' . rawurlencode($author)
. '&excerpt=' . rawurlencode(strip_tags($text));
- printf(TRACKBACK_SENDING, htmlspecialchars($matches[2]));
+ printf(TRACKBACK_SENDING, htmlspecialchars($trackURI));
flush();
- $response = serendipity_trackback_is_success(_serendipity_send($matches[2], $data));
+
+ $response = serendipity_trackback_is_success(_serendipity_send($trackURI, $data));
- if ($response == 1 || $response == true) {
- printf(TRACKBACK_SENT, SUCCESS);
+ if ($response === true) {
+ echo '<div>• ' . TRACKBACK_SENT .'</div>';
} else {
- printf(TRACKBACK_SENT, ERROR . ': ' . $response);
+ echo '<div>• ' . sprintf(TRACKBACK_FAILED, $response) . '</div>';
}
- echo '<br />';
return $response;
}
@@ -2275,9 +2282,7 @@
return;
}
- echo '<br />• ';
- printf(TRACKBACK_CHECKING, $loc);
- echo '<br /> ';
+ echo '<div>• '. sprintf(TRACKBACK_CHECKING, $loc) .'</div>';
flush();
if (empty($u['port'])) {
@@ -2296,13 +2301,12 @@
$fp = @fsockopen($u['host'], $u['port'], $err, $timeout);
if (!$fp) {
- echo sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']);
+ echo '<div>• ' . sprintf(TRACKBACK_COULD_NOT_CONNECT, $u['host'], $u['port']) .'</div>';
return;
} else {
fputs($fp, "GET {$u['path']} HTTP/1.0\r\n");
fputs($fp, "Host: {$u['host']}\r\n");
- fputs($fp, "User-Agent: Serendipity/{$GLOBALS['serendipity']['version']}\r\n");
- fputs($fp, "Referer: {$GLOBALS['serendipity']['baseURL']}\r\n");
+ fputs($fp, "User-Agent: Serendipity/{$serendipity['version']}\r\n");
fputs($fp, "Connection: close\r\n\r\n");
while ($fp && !feof($fp) && strlen($res) < $serendipity['trackback_filelimit']) {
@@ -2311,8 +2315,7 @@
fclose($fp);
if (strlen($res) >= $serendipity['trackback_filelimit']) {
- printf(TRACKBACK_SIZE, $serendipity['trackback_filelimit']);
- echo '<br />';
+ echo '<div>• ' . sprintf(TRACKBACK_SIZE, $serendipity['trackback_filelimit']) .'</div>';
return;
}
}
@@ -2320,8 +2323,9 @@
if (strlen($res) != 0) {
serendipity_trackback_autodiscover($res, $parsed_loc, $url, $author, $title, $text);
serendipity_pingback_autodiscover($loc, $res);
+ echo '<hr noshade="noshade">';
} else {
- echo TRACKBACK_NO_DATA . '<br />';
+ echo '<div>• ' . TRACKBACK_NO_DATA . '</div>';
}
}
@@ -2466,6 +2470,7 @@
$names = $matches[1];
$tmpid = serendipity_db_escape_string($id);
+
for ($i = 0, $j = count($locations); $i < $j; ++$i) {
if($locations[$i][0] == '/') {
$locations[$i] = 'http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $locations[$i];
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- serendipity_admin_entries.inc.php 30 Aug 2004 18:56:19 -0000 1.36
+++ serendipity_admin_entries.inc.php 1 Sep 2004 17:17:41 -0000 1.37
@@ -295,8 +295,7 @@
$entry,
ERROR . ': <b>' . $res . '</b>');
} else {
- echo '<br />• ';
- echo '<strong>' . ENTRY_SAVED . '</strong>';
+ echo '<div class="serendipity_msg_notice">' . ENTRY_SAVED . '</div>';
}
} else {
// Only display the preview
|