From d34c78296e744b87d45d9953323fbc020efab9f6 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 18 Feb 2013 23:39:27 +0100 Subject: [PATCH 1/2] fbpost: Only mirror posts from pages when they are from the page id privacy_image_cache: Save pictures with extensions --- fbpost/fbpost.php | 3 ++ privacy_image_cache/privacy_image_cache.php | 31 +++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 1486afdb..42708164 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -1042,6 +1042,9 @@ function fbpost_fetchwall($a, $uid) { if(isset($item->privacy) && ($item->privacy->value !== 'EVERYONE') && ($item->privacy->value !== '')) continue; + if (($post_to_page != $item->from->id) AND ((int)$post_to_page != 0)) + continue; + $_SESSION["authenticated"] = true; $_SESSION["uid"] = $uid; diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php index b38cd5e7..b0909e81 100644 --- a/privacy_image_cache/privacy_image_cache.php +++ b/privacy_image_cache/privacy_image_cache.php @@ -56,20 +56,24 @@ function privacy_image_cache_init() { $thumb = false; // Look for filename in the arguments - if (isset($a->argv[1]) OR isset($a->argv[2])) { - if (isset($a->argv[2])) + if (isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) { + if (isset($a->argv[3])) + $url = $a->argv[3]; + elseif (isset($a->argv[2])) $url = $a->argv[2]; else $url = $a->argv[1]; - $pos = strrpos($url, "==."); + $pos = strrpos($url, "=."); if ($pos) - $url = substr($url, 0, $pos+2); + $url = substr($url, 0, $pos+1); + + $url = str_replace(array(".jpg", ".jpeg", ".gif", ".png"), array("","","",""), $url); $url = base64_decode(strtr($url, '-_', '+/'), true); + if ($url) $_REQUEST['url'] = $url; - $thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb")); } @@ -201,9 +205,15 @@ function privacy_image_cache_init() { function privacy_image_cache_cachename($url, $writemode = false) { global $_SERVER; -// echo $url; -// $mime = image_type_to_mime_type(exif_imagetype($url)); -// echo $mime; + + $pos = strrpos($url, "."); + if ($pos) { + $extension = strtolower(substr($url, $pos+1)); + $pos = strpos($extension, "?"); + if ($pos) + $extension = substr($extension, 0, $pos); + } + $basepath = $_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache"; $path = substr(hash("md5", $url), 0, 2); @@ -216,6 +226,11 @@ function privacy_image_cache_cachename($url, $writemode = false) { $path .= "/".strtr(base64_encode($url), '+/', '-_'); + $extensions = array("jpg", "jpeg", "gif", "png"); + + if (in_array($extension, $extensions)) + $path .= ".".$extension; + return($path); } From e48fb47d620b6d2ecb04e0938a0d2a4b40174ee9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 20 Feb 2013 21:46:19 +0100 Subject: [PATCH 2/2] checking if a variable is an array before doing array_reverse. --- fbpost/fbpost.php | 4 ++++ fromgplus/fromgplus.php | 6 ++++++ statusnet/statusnet.php | 4 ++++ twitter/twitter.php | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php index 42708164..ba60f4e6 100644 --- a/fbpost/fbpost.php +++ b/fbpost/fbpost.php @@ -1027,6 +1027,10 @@ function fbpost_fetchwall($a, $uid) { $feed = fetch_url($url); $data = json_decode($feed); + + if (!is_array($data->data)) + return; + $items = array_reverse($data->data); foreach ($items as $item) { diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php index f7841300..5bd82ed8 100644 --- a/fromgplus/fromgplus.php +++ b/fromgplus/fromgplus.php @@ -275,6 +275,9 @@ function fromgplus_handleattachments($item) { $post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n"; } break; + case "audio": + $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n"; + break; //default: // die($attachment->objectType); } @@ -298,6 +301,9 @@ function fromgplus_fetch($a, $uid) { $lastdate = 0; + if (!is_array($activities->items)) + return; + $reversed = array_reverse($activities->items); foreach($reversed as $item) { diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 393bbfe5..0ffbae6b 100755 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -806,6 +806,10 @@ function statusnet_fetchtimeline($a, $uid) { $parameters["since_id"] = $lastid; $items = $connection->get('statuses/user_timeline', $parameters); + + if (!is_array($items)) + return; + $posts = array_reverse($items); if (count($posts)) { diff --git a/twitter/twitter.php b/twitter/twitter.php index 808768f8..e4848f9d 100755 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -613,6 +613,10 @@ function twitter_fetchtimeline($a, $uid) { $parameters["since_id"] = $lastid; $items = $connection->get('statuses/user_timeline', $parameters); + + if (!is_array($items)) + return; + $posts = array_reverse($items); if (count($posts)) {