]> git.mxchange.org Git - friendica.git/commitdiff
localise links to private photos inside messages
authorfriendica <info@friendica.com>
Wed, 15 Feb 2012 02:07:13 +0000 (18:07 -0800)
committerfriendica <info@friendica.com>
Wed, 15 Feb 2012 02:07:13 +0000 (18:07 -0800)
include/conversation.php

index 4eff0d088b70a77183bf5104ec3cc98aacb29a78..8a0fd00fb7513796b8a0add36cb80c08862ea091 100755 (executable)
@@ -4,6 +4,28 @@
  * Render actions localized
  */
 function localize_item(&$item){
+
+       $Text = $item['body'];
+       $saved_image = '';
+       $img_start = strpos($Text,'[img]data:');
+       $img_end = strpos($Text,'[/img]');
+
+       if($img_start !== false && $img_end !== false && $img_end > $img_start) {
+               $start_fragment = substr($Text,0,$img_start);
+               $img_start += strlen('[img]');
+               $saved_image = substr($Text,$img_start,$img_end - $img_start);
+               $end_fragment = substr($Text,$img_end + strlen('[/img]'));              
+               $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment;
+               $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is';
+               $replace = '[url=' . z_path() . '/redir/' . $item['contact-id'] 
+                       . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ;
+
+               $Text = preg_replace($search,$replace,$Text);
+
+               if(strlen($saved_image))
+                       $item['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text);
+       }
+
        $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
        if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){