Twitter, Statusnet: Supress profile link of user whose message was repeated
authorMichael Vogel <icarus@dabo.de>
Sat, 23 Jun 2012 10:50:48 +0000 (12:50 +0200)
committerMichael Vogel <icarus@dabo.de>
Sat, 23 Jun 2012 10:50:48 +0000 (12:50 +0200)
libertree: Design improvement of exported messages
privacy_image_cache: quickfix for double encoded urls

libertree/libertree.php
privacy_image_cache/privacy_image_cache.php
statusnet/statusnet.php
twitter/twitter.php

index fc9dcc44d0b6af0823b505a1647bc6b28af5735e..c117fa811363765dc19174c2bf7b4594e5fdcec5 100755 (executable)
@@ -118,7 +118,7 @@ function libertree_post_local(&$a,&$b) {
        if($b['private'] || $b['parent'])
                return;
 
-    $ltree_post   = intval(get_pconfig(local_user(),'libertree','post'));
+       $ltree_post   = intval(get_pconfig(local_user(),'libertree','post'));
 
        $ltree_enable = (($ltree_post && x($_REQUEST,'libertree_enable')) ? intval($_REQUEST['libertree_enable']) : 0);
 
@@ -176,6 +176,12 @@ function libertree_send(&$a,&$b) {
                $body = str_ireplace("[quote", "\n\n[quote", $body);
                $body = str_ireplace("[/quote]", "[/quote]\n\n", $body);
 
+               // Removal of tags and mentions
+               // #-tags
+               $body = preg_replace('/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $body);
+               // @-mentions
+               $body = preg_replace('/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $body);
+
                // remove multiple newlines
                do {
                        $oldbody = $body;
index d3202c4d751d9222e2b88f9e90e4495544b60cbe..b7236d09d0bb249abd31598976412650ea77074f 100644 (file)
@@ -36,16 +36,18 @@ function privacy_image_cache_init() {
        }
 
        $urlhash = 'pic:' . sha1($_REQUEST['url']);
-    $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash );
-    if (count($r)) {
-        $img_str = $r[0]['data'];
+       // Double encoded url - happens with Diaspora
+       $urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url']));
+
+       $r = q("SELECT * FROM `photo` WHERE `resource-id` in ('%s', '%s') LIMIT 1", $urlhash, $urlhash2);
+       if (count($r)) {
+               $img_str = $r[0]['data'];
                $mime = $r[0]["desc"];
                if ($mime == "") $mime = "image/jpeg";
-    }
-    else {
-        require_once("Photo.php");
+       } else {
+               require_once("Photo.php");
 
-        $img_str = fetch_url($_REQUEST['url'],true);
+               $img_str = fetch_url($_REQUEST['url'],true);
                if (substr($img_str, 0, 6) == "GIF89a") {
                        $mime = "image/gif";
                        $image = @imagecreatefromstring($img_str);
@@ -77,16 +79,16 @@ function privacy_image_cache_init() {
                        }
                        $mime = "image/jpeg";
                }
-    }
+       }
 
 
-    header("Content-type: $mime");
-    header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
-    header("Cache-Control: max-age=" . (3600*24));
+       header("Content-type: $mime");
+       header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
+       header("Cache-Control: max-age=" . (3600*24));
 
-    echo $img_str;
+       echo $img_str;
 
-    killme();
+       killme();
 }
 
 /**
@@ -210,4 +212,4 @@ function privacy_image_cache_plugin_admin_post(&$a = null, &$o = null){
     if (isset($_REQUEST['delete_all'])) {
         q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%"');
     }
-}
\ No newline at end of file
+}
index d7ec4abb3948e89016abe026157d8d3ac2fbcffd..99e84475276d4e5c775d15cd7d689d368be903db 100755 (executable)
@@ -453,10 +453,16 @@ function statusnet_post_hook(&$a,&$b) {
                 // that is, don't send if the option is not set in the 
                 // connector settings
                 if ($linksenabled=='0') {
-                    // #-tags
-                    $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
-                    // @-mentions
-                    $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+                       // #-tags
+                       $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+                       // @-mentions
+                       $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+                       // recycle 1
+                       $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
+                       $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+                       // recycle 2
+                       //$recycle = html_entity_decode("&#x267B; ", ENT_QUOTES, 'UTF-8');
+                       //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
                 }
                 // preserve links to webpages
                 $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
index 8de7d06d6f16235cf628763290f724873a6a6d8d..9984f3695885774547ef31850e097887e6cc4e8c 100755 (executable)
@@ -316,18 +316,24 @@ function twitter_post_hook(&$a,&$b) {
                 $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
                 $linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks');
                 // if a #tag is linked, don't send the [url] over to SN
-                // that is, don't send if the option is not set in the 
+                // that is, don't send if the option is not set in the
                 // connector settings
                 if ($linksenabled=='0') {
-                    // #-tags
-                    $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
-                    // @-mentions
-                    $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+                       // #-tags
+                       $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+                       // @-mentions
+                       $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+                       // recycle 1
+                       $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
+                       $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+                       // recycle 2
+                       //$recycle = html_entity_decode("&#x267B; ", ENT_QUOTES, 'UTF-8');
+                       //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
                 }
                 $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
                 $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
-                // find all http or https links in the body of the entry and 
-                // apply the shortener if the link is longer then 20 characters 
+                // find all http or https links in the body of the entry and
+                // apply the shortener if the link is longer then 20 characters
                 if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
                     preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls  );
                     foreach ($allurls as $url) {