[geeklog-cvs] geeklog: When creating a Pingback excerpt, we may need to conver...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Jul 26 04:57:51 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/53a369a4935f
changeset: 7191:53a369a4935f
user: Dirk Haun <dirk at haun-online.de>
date: Sun Jul 26 10:46:30 2009 +0200
description:
When creating a Pingback excerpt, we may need to convert the other site's content to our character set
diffstat:
public_html/pingback.php | 39 ++++++++++++++++++++++++++++++++++-----
1 files changed, 34 insertions(+), 5 deletions(-)
diffs (68 lines):
diff -r 6efd092fe26b -r 53a369a4935f public_html/pingback.php
--- a/public_html/pingback.php Sun Jul 26 09:51:34 2009 +0200
+++ b/public_html/pingback.php Sun Jul 26 10:46:30 2009 +0200
@@ -2,13 +2,13 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.4 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | pingback.php |
// | |
// | Handle pingbacks for stories and plugins. |
// +---------------------------------------------------------------------------+
-// | Copyright (C) 2005-2007 by the following authors: |
+// | Copyright (C) 2005-2009 by the following authors: |
// | |
// | Author: Dirk Haun - dirk AT haun-online DOT de |
// +---------------------------------------------------------------------------+
@@ -28,8 +28,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: pingback.php,v 1.19 2007/09/02 07:50:56 dhaun Exp $
require_once 'lib-common.php';
@@ -157,7 +155,38 @@
$title = trim (COM_undoSpecialChars ($content[1]));
}
- if (isset($_CONF['pingback_excerpt']) && $_CONF['pingback_excerpt']) {
+ if ($_CONF['pingback_excerpt']) {
+
+ // Check which character set the site that sent the Pingback
+ // is using
+ $charset = 'ISO-8859-1'; // default, see RFC 2616, 3.7.1
+ $ctype = $req->getResponseHeader('Content-Type');
+ if (!empty($ctype)) {
+ // e.g. text/html; charset=utf-8
+ $c = explode(';', $ctype);
+ foreach ($c as $ct) {
+ $ch = explode('=', trim($ct));
+ if (count($ch) == 2) {
+ if(trim($ch[0]) == 'charset') {
+ $charset = trim($ch[1]);
+ break;
+ }
+ }
+ }
+ }
+
+ if (!empty($charset) &&
+ (strcasecmp($charset, COM_getCharset()) != 0)) {
+
+ if (function_exists('mb_convert_encoding')) {
+ $body = @mb_convert_encoding($body, COM_getCharset(),
+ $charset);
+ } elseif (function_exists('iconv')) {
+ $body = @iconv($charset, COM_getCharset(), $body);
+ }
+ // else: tough luck ...
+ }
+
$excerpt = PNB_makeExcerpt($body, $oururl);
}
More information about the geeklog-cvs
mailing list