]> git.mxchange.org Git - friendica-addons.git/commitdiff
fbpost: Only mirror posts from pages when they are from the page id
authorMichael Vogel <icarus@dabo.de>
Mon, 18 Feb 2013 22:39:27 +0000 (23:39 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 18 Feb 2013 22:39:27 +0000 (23:39 +0100)
privacy_image_cache: Save pictures with extensions

fbpost/fbpost.php
privacy_image_cache/privacy_image_cache.php

index 1486afdb2ba6efb802cf87075ccfd16c2c813d29..4270816402e37fc1559a5d73b8c9f251a923550d 100644 (file)
@@ -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;
 
index b38cd5e798df26b5128fae65dd9bc84857e61bf8..b0909e814e6791e2a32aea5b8873ce9af778a2e8 100644 (file)
@@ -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);
 }