From 1754b58cd91729b75c038c2b2075df09307c1e3c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 2 Mar 2014 01:42:19 +0100 Subject: [PATCH] Added function "bb_CleanPictureLinks" ro all connectors --- appnetpost/appnetpost.php | 2 ++ fbpost/fbpost.php | 9 ++++++--- fromgplus/fromgplus.php | 2 +- gpluspost/gpluspost.php | 2 ++ statusnet/statusnet.php | 2 ++ twitter/twitter.php | 2 ++ 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/appnetpost/appnetpost.php b/appnetpost/appnetpost.php index d3f6c19a6..a5c5e8c5f 100644 --- a/appnetpost/appnetpost.php +++ b/appnetpost/appnetpost.php @@ -288,6 +288,8 @@ function appnetpost_feeditem($pid, $uid) { $items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid)); foreach ($items AS $item) { + $item['body'] = bb_CleanPictureLinks($item['body']); + // Looking for the first image $image = ''; if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches)) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index e6683282d..3b064a56a 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -363,6 +363,8 @@ function fbpost_createmsg($b) { require_once("include/bbcode.php"); require_once("include/html2plain.php"); + $b['body'] = bb_CleanPictureLinks($b['body']); + // Looking for the first image $image = ''; if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches)) @@ -632,6 +634,7 @@ function fbpost_post_hook(&$a,&$b) { logger('fbpost_post_hook: original msg=' . $msg, LOGGER_DATA); + // To-Do: if it is a reply, then only do a simple bbcode2plain conversion $msgarr = fbpost_createmsg($b); $msg = $msgarr["msg"]; $link = $msgarr["link"]; @@ -768,7 +771,7 @@ function fbpost_post_hook(&$a,&$b) { // If it is a special kind of failure the post was receiced // Although facebook said it wasn't received ... - if (!$likes AND (($retj->error->type != "OAuthException") OR ($retj->error->code != 2))) { + if (!$likes AND (($retj->error->type != "OAuthException") OR ($retj->error->code != 2)) AND ($x <> "")) { $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid'])); if (count($r)) $a->contact = $r[0]["id"]; @@ -920,7 +923,7 @@ function fbpost_queue_hook(&$a,&$b) { // If it is a special kind of failure the post was receiced // Although facebook said it wasn't received ... $ret = json_decode($j); - if (($ret->error->type != "OAuthException") OR ($ret->error->code != 2)) + if (($ret->error->type != "OAuthException") OR ($ret->error->code != 2) AND ($j <> "")) update_queue_time($x['id']); else logger('fbpost_queue_hook: Not requeued, since it seems to be received'); @@ -1109,7 +1112,7 @@ function fbpost_fetchwall($a, $uid) { $_REQUEST["body"] .= "[class=type-".$type."]"; if ($content) - $_REQUEST["body"] .= $content; + $_REQUEST["body"] .= trim($content); if ($quote) $_REQUEST["body"] .= "\n[quote]".$quote."[/quote]"; diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index 1c047663f..343edae7c 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -271,7 +271,7 @@ function fromgplus_handleattachments($item, $displaytext) { //elseif ($images["full"] != "") // $post .= "\n[img]".$images["full"]."[/img]\n"; if ($images["full"] != "") - $post .= "\n[img]".$images["full"]."[/img]\n"; + $post .= "\n[img]".$images["full"]."[/img]"; //$post .= "[quote]".trim(fromgplus_html2bbcode($attachment->content))."[/quote]"; $quote = trim(fromgplus_html2bbcode($attachment->content)); diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index 5a638ed9f..a66e1e45f 100644 --- a/gpluspost/gpluspost.php +++ b/gpluspost/gpluspost.php @@ -284,6 +284,8 @@ function gpluspost_feeditem($pid, $uid) { $items = q("SELECT `uri`, `plink`, `author-link`, `author-name`, `created`, `edited`, `id`, `title`, `body` from `item` WHERE id=%d", intval($pid)); foreach ($items AS $item) { + $item['body'] = bb_CleanPictureLinks($item['body']); + // Looking for the first image $image = ''; if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$item['body'],$matches)) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 5286657b4..a159e87ad 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -452,6 +452,8 @@ function statusnet_shortenmsg($b, $max_char) { require_once("include/bbcode.php"); require_once("include/html2plain.php"); + $b['body'] = bb_CleanPictureLinks($b['body']); + // Looking for the first image $cleaned_body = api_clean_plain_items($b['body']); $image = ''; diff --git a/twitter/twitter.php b/twitter/twitter.php index ef6974042..711a33fe0 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -378,6 +378,8 @@ function twitter_shortenmsg($b, $shortlink = false) { $max_char = 140; + $b['body'] = bb_CleanPictureLinks($b['body']); + // Looking for the first image $cleaned_body = api_clean_plain_items($b['body']); $image = '';