From 520c2514f2f22e419de7f5825670e7aca0686e17 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 25 Jul 2014 00:26:13 +0200 Subject: [PATCH 1/6] Removing of PHP warnings --- convpath/convpath.php | 3 ++- jappixmini/jappixmini.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/convpath/convpath.php b/convpath/convpath.php index 95093694..8deb46cf 100644 --- a/convpath/convpath.php +++ b/convpath/convpath.php @@ -34,7 +34,8 @@ function convpath_page_header(&$a, &$o){ function convpath_page_end(&$a, &$o){ $o = convpath_convert($o); - $a->page['aside'] = convpath_convert($a->page['aside']); + if (isset($a->page['aside'])) + $a->page['aside'] = convpath_convert($a->page['aside']); } function convpath_prepare_body_hook(&$a, &$o) { diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php index f998acd1..73062aae 100644 --- a/jappixmini/jappixmini.php +++ b/jappixmini/jappixmini.php @@ -485,7 +485,8 @@ function jappixmini_script(&$a,&$s) { dbesc($dfrn_id), dbesc($dfrn_id) ); - $name = $r[0]["name"]; + if (count($r)) + $name = $r[0]["name"]; $value = $row['v']; $pos = strpos($value, ":"); From d3fa9a7b2136102a4ce8dabd93382ace2f712dbb Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 25 Jul 2014 00:26:34 +0200 Subject: [PATCH 2/6] fbpost/gpluspost: New design for shared content --- fbpost/fbpost.php | 2 +- gpluspost/gpluspost.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index f4f29f1e..b0e383e4 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -564,7 +564,7 @@ function fbpost_post_hook(&$a,&$b) { if ($toplevel) { require_once("include/plaintext.php"); - $msgarr = plaintext($a, $b, 0, false); + $msgarr = plaintext($a, $b, 0, false, 9); $msg = $msgarr["text"]; $link = $msgarr["url"]; $linkname = $msgarr["title"]; diff --git a/gpluspost/gpluspost.php b/gpluspost/gpluspost.php index 415e031b..1df6e750 100644 --- a/gpluspost/gpluspost.php +++ b/gpluspost/gpluspost.php @@ -271,7 +271,7 @@ function gpluspost_send(&$a,&$b) { $item["body"] = preg_replace("(\[i\](.*?)\[\/i\])ism",'_$1_',$item["body"]); $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]); - $data = plaintext($a, $item, 0, false); + $data = plaintext($a, $item, 0, false, 9); logger('gpluspost_send: data: '.print_r($data, true), LOGGER_DEBUG); From 1b41f6581b56d4bc762f59cfed5deab77d1fe894 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 27 Jul 2014 16:06:18 +0200 Subject: [PATCH 3/6] appnet: Now more links are removed, if they are used in the attached data --- appnet/appnet.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appnet/appnet.php b/appnet/appnet.php index b74e29ff..db3422e4 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -975,6 +975,9 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th if (($removedlink == "") OR strstr($postarray['body'], $removedlink)) $postarray['body'] = $removedlink; + if (($removedlink == "") OR strstr("[url]".$postarray['body']."[/url]", $removedlink)) + $postarray['body'] = $removedlink; + $page_info = add_page_info($link, false, $photo["url"]); } From 31ab2a3cbf02592eee2292435d36207fea0d32c9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 27 Jul 2014 16:07:30 +0200 Subject: [PATCH 4/6] fbpost/fbsync: Better picture support for facebook. Now the highest resolution is fetched. --- fbpost/fbpost.php | 24 ++++++++++++++++----- fbsync/fbsync.php | 16 +++++++++++++- privacy_image_cache/privacy_image_cache.php | 4 ++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index b0e383e4..c5b79183 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -1050,11 +1050,25 @@ function fbpost_fetchwall($a, $uid) { $type = $item->type; - if(isset($item->picture) && isset($item->link)) - $content .= "\n".'[url='.$item->link.'][img]'.fpost_cleanpicture($item->picture).'[/img][/url]'; + if (isset($item->picture)) + $picture = $item->picture; + + if (($type == "photo") AND isset($item->object_id)) { + logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG); + $url = "https://graph.facebook.com/v2.0/".$item->object_id."/?access_token=".$access_token; + $feed = fetch_url($url); + $data = json_decode($feed); + if (isset($data->images)) { + $picture = $data->images[0]->source; + logger('fbpost_fetchwall: got fbid image '.$preview, LOGGER_DEBUG); + } + } + + if(($picture != "") && isset($item->link)) + $content .= "\n".'[url='.$item->link.'][img]'.$picture.'[/img][/url]'; else { - if (isset($item->picture)) - $content .= "\n".'[img]'.fpost_cleanpicture($item->picture).'[/img]'; + if ($picture != "") + $content .= "\n".'[img]'.$picture.'[/img]'; // if just a link, it may be a wall photo - check if(isset($item->link)) $content .= fbpost_get_photo($uid,$item->link); @@ -1125,7 +1139,7 @@ function fbpost_get_photo($uid,$link) { $x = fetch_url('https://graph.facebook.com/'.$photo_id.'?access_token='.$access_token); $j = json_decode($x); if($j->picture) - return "\n\n".'[url='.$link.'][img]'.fpost_cleanpicture($j->picture).'[/img][/url]'; + return "\n\n".'[url='.$link.'][img]'.$j->picture.'[/img][/url]'; return ""; } diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index fc9d7c18..e558cb9a 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -213,6 +213,8 @@ function fbsync_expire($a,$b) { function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) { + $access_token = get_pconfig($uid,'facebook','access_token'); + require_once("include/oembed.php"); // check if it was already imported @@ -365,10 +367,22 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr if (isset($media->src)) $preview = $media->src; - if (isset($media->photo)) + if (isset($media->photo)) { if (isset($media->photo->images) AND (count($media->photo->images) > 1)) $preview = $media->photo->images[1]->src; + if (isset($media->photo->fbid)) { + logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG); + $url = "https://graph.facebook.com/v2.0/".$media->photo->fbid."/?access_token=".$access_token; + $feed = fetch_url($url); + $data = json_decode($feed); + if (isset($data->images)) { + $preview = $data->images[0]->source; + logger('fbsync_createpost: got fbid image '.$preview, LOGGER_DEBUG); + } + } + } + if (isset($media->href) AND ($preview != "") AND ($media->href != "")) $content .= "\n".'[url='.$media->href.'][img]'.$preview.'[/img][/url]'; else { diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php index 0a6d8be1..930fab53 100644 --- a/privacy_image_cache/privacy_image_cache.php +++ b/privacy_image_cache/privacy_image_cache.php @@ -307,8 +307,8 @@ function privacy_image_cache_img_cb($matches) { $matches[2] = urldecode($queryvar['url']); // if fetching facebook pictures don't fetch the thumbnail but the big one - if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg")) - $matches[2] = substr($matches[2], 0, -6)."_n.jpg"; + //if (((strpos($matches[2], ".fbcdn.net/") OR strpos($matches[2], "/fbcdn-photos-"))) and (substr($matches[2], -6) == "_s.jpg")) + // $matches[2] = substr($matches[2], 0, -6)."_n.jpg"; // following line changed per bug #431 if (privacy_image_cache_is_local_image($matches[2])) From 24de6d38a90a3e03bbac2a3d6ef6446492b72eac Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 27 Jul 2014 22:04:04 +0200 Subject: [PATCH 5/6] appnet/statusnet/twitter: Better detection for removable links. --- appnet/appnet.php | 8 ++------ statusnet/statusnet.php | 2 +- twitter/twitter.php | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/appnet/appnet.php b/appnet/appnet.php index db3422e4..3a6046b3 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -968,16 +968,12 @@ function appnet_createpost($a, $uid, $post, $me, $user, $ownid, $createuser, $th if (sizeof($links)) { $link = array_pop($links); - $url = "[url=".$link."]".$link."[/url]"; - - $removedlink = trim(str_replace($url, "", $postarray['body'])); + $url = str_replace(array('/', '.'), array('\/', '\.'), $link); + $removedlink = preg_replace("/\[url\=".$url."\](.*?)\[\/url\]/ism", '', $postarray['body']); if (($removedlink == "") OR strstr($postarray['body'], $removedlink)) $postarray['body'] = $removedlink; - if (($removedlink == "") OR strstr("[url]".$postarray['body']."[/url]", $removedlink)) - $postarray['body'] = $removedlink; - $page_info = add_page_info($link, false, $photo["url"]); } diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 0cabbca8..b7ba8d7d 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1538,7 +1538,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) { if (($footerlink != "") AND (trim($footer) != "")) { $removedlink = trim(str_replace($footerlink, "", $body)); - if (strstr($body, $removedlink)) + if (($removedlink == "") OR strstr($body, $removedlink)) $body = $removedlink; $body .= $footer; diff --git a/twitter/twitter.php b/twitter/twitter.php index 25c64b48..c961b6a9 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -1142,7 +1142,7 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $picture) { if (($footerlink != "") AND (trim($footer) != "")) { $removedlink = trim(str_replace($footerlink, "", $body)); - if (strstr($body, $removedlink)) + if (($removedlink == "") OR strstr($body, $removedlink)) $body = $removedlink; $body .= $footer; From 225bb0ea3ffc02480edcd49b4b6269f406290b35 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 7 Aug 2014 08:06:23 +0200 Subject: [PATCH 6/6] fbsync/fbpost: Trying to be able to more often fetch pictures in its original size. --- fbpost/fbpost.php | 2 +- fbsync/fbsync.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index c5b79183..579fb148 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -1055,7 +1055,7 @@ function fbpost_fetchwall($a, $uid) { if (($type == "photo") AND isset($item->object_id)) { logger('fbpost_fetchwall: fetching fbid '.$item->object_id, LOGGER_DEBUG); - $url = "https://graph.facebook.com/v2.0/".$item->object_id."/?access_token=".$access_token; + $url = "https://graph.facebook.com/".$item->object_id."?access_token=".$access_token; $feed = fetch_url($url); $data = json_decode($feed); if (isset($data->images)) { diff --git a/fbsync/fbsync.php b/fbsync/fbsync.php index e558cb9a..fe5b6faf 100644 --- a/fbsync/fbsync.php +++ b/fbsync/fbsync.php @@ -373,13 +373,14 @@ function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $cr if (isset($media->photo->fbid)) { logger('fbsync_createpost: fetching fbid '.$media->photo->fbid, LOGGER_DEBUG); - $url = "https://graph.facebook.com/v2.0/".$media->photo->fbid."/?access_token=".$access_token; + $url = "https://graph.facebook.com/".$media->photo->fbid."?access_token=".$access_token; $feed = fetch_url($url); $data = json_decode($feed); if (isset($data->images)) { $preview = $data->images[0]->source; - logger('fbsync_createpost: got fbid image '.$preview, LOGGER_DEBUG); - } + logger('fbsync_createpost: got fbid '.$media->photo->fbid.' image '.$preview, LOGGER_DEBUG); + } else + logger('fbsync_createpost: error fetching fbid '.$media->photo->fbid.' '.print_r($data, true), LOGGER_DEBUG); } }