]> git.mxchange.org Git - friendica.git/commitdiff
allow admin to prevent private image embedding on hub
authorZach Prezkuta <fermion@gmx.com>
Sun, 3 Mar 2013 16:44:41 +0000 (09:44 -0700)
committerZach Prezkuta <fermion@gmx.com>
Sun, 3 Mar 2013 16:44:41 +0000 (09:44 -0700)
include/items.php
include/text.php
mod/admin.php
view/admin_site.tpl
view/smarty3/admin_site.tpl
view/theme/decaf-mobile/admin_site.tpl
view/theme/decaf-mobile/smarty3/admin_site.tpl
view/theme/frost-mobile/admin_site.tpl
view/theme/frost-mobile/smarty3/admin_site.tpl
view/theme/frost/admin_site.tpl
view/theme/frost/smarty3/admin_site.tpl

index b7be27932f6a1c215b136356bdf8977b63cdec66..29f4d7256feb548d292539b68490233102964fdf 100755 (executable)
@@ -3644,9 +3644,13 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
 }
 
 function fix_private_photos($s, $uid, $item = null, $cid = 0) {
+
+       if(get_config('system','disable_embedded'))
+               return $s;
+
        $a = get_app();
 
-       logger('fix_private_photos', LOGGER_DEBUG);
+       logger('fix_private_photos: check for photos', LOGGER_DEBUG);
        $site = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://'));
 
        $orig_body = $s;
index 97cf6ac2030f5d7cbfd0ed39c258b99060580976..9dc90ac50ae19723f5803fd1e44e645f1dea9819 100644 (file)
@@ -1047,10 +1047,34 @@ function link_compare($a,$b) {
        return false;
 }}
 
+
+// Find any non-embedded images in private items and add redir links to them
+
+if(! function_exists('redir_private_images')) {
+function redir_private_images($a, &$item) {
+
+       $matches = false;
+       $cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
+       if($cnt) {
+               //logger("redir_private_images: matches = " . print_r($matches, true));
+               foreach($matches as $mtch) {
+                       if(strpos($mtch[1], '/redir') !== false)
+                               continue;
+
+                       if((local_user() == $item['uid']) && ($item['private'] != 0) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN)) {
+                               //logger("redir_private_images: redir");
+                               $img_url = $a->get_baseurl() . '/redir?f=1&quiet=1&url=' . $mtch[1] . '&conurl=' . $item['author-link'];
+                               $item['body'] = str_replace($mtch[0], "[img]".$img_url."[/img]", $item['body']);
+                       }
+               }
+       }
+
+}}
+
+
 // Given an item array, convert the body element from bbcode to html and add smilie icons.
 // If attach is true, also add icons for item attachments
 
-
 if(! function_exists('prepare_body')) {
 function prepare_body($item,$attach = false) {
 
@@ -1066,14 +1090,19 @@ function prepare_body($item,$attach = false) {
                        $s = file_get_contents($cachefile);
                        $a->save_timestamp($stamp1, "file");
                } else {
+                       redir_private_images($a, $item);
                        $s = prepare_text($item['body']);
+
                        $stamp1 = microtime(true);
                        file_put_contents($cachefile, $s);
                        $a->save_timestamp($stamp1, "file");
+
                        logger('prepare_body: put item '.$item["id"].' into cachefile '.$cachefile);
                }
-       } else
+       } else {
+               redir_private_images($a, $item);
                $s = prepare_text($item['body']);
+       }
 
 
        $prep_arr = array('item' => $item, 'html' => $s);
index 48cc4b1510afc9c54e4e2741574a83c202473f03..e4677b29c8b4136e0af6bbccc93b3d90165a522a 100644 (file)
@@ -256,7 +256,8 @@ function admin_page_site_post(&$a){
        $thread_allow           =       ((x($_POST,'thread_allow'))             ? True                                          : False);
        $newuser_private                =       ((x($_POST,'newuser_private'))          ? True                                          : False);
        $enotify_no_content             =       ((x($_POST,'enotify_no_content'))       ? True                                          : False);
-       $private_addons         =       ((x($_POST,'private_addons'))           ? True                                          : False);
+       $private_addons                 =       ((x($_POST,'private_addons'))           ? True                                          : False);
+       $disable_embedded               =       ((x($_POST,'disable_embedded'))         ? True                                          : False);
        
        $no_multi_reg           =       ((x($_POST,'no_multi_reg'))             ? True                                          : False);
        $no_openid              =       !((x($_POST,'no_openid'))               ? True                                          : False);
@@ -374,6 +375,7 @@ function admin_page_site_post(&$a){
        set_config('system','thread_allow', $thread_allow);
        set_config('system','newuser_private', $newuser_private);
        set_config('system','enotify_no_content', $enotify_no_content);
+       set_config('system','disable_embedded', $disable_embedded);
 
        set_config('system','block_extended_register', $no_multi_reg);
        set_config('system','no_openid', $no_openid);
@@ -510,6 +512,7 @@ function admin_page_site(&$a) {
                '$newuser_private'      => array('newuser_private', t("Private posts by default for new users"), get_config('system','newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")),
                '$enotify_no_content'   => array('enotify_no_content', t("Don't include post content in email notifications"), get_config('system','enotify_no_content'), t("Don't include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.")),
                '$private_addons'       => array('private_addons', t("Disallow public access to addons listed in the apps menu."), get_config('config','private_addons'), t("Checking this box will restrict addons listed in the apps menu to members only.")),
+               '$disable_embedded'     => array('disable_embedded', t("Don't embed private images in posts"), get_config('system','disable_embedded'), t("Don't replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos won't be able to see them unless they first visit the owner's profile page, or unless they have the redir_private_img plugin enabled.")),
                
                '$no_multi_reg'         => array('no_multi_reg', t("Block multiple registrations"),  get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
                '$no_openid'            => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
index 0d3d451b1c459e4ee89b2018020adb91d6709a6f..f66d31cdcc38708d6247f1209e1f3b63fde0bc4c 100644 (file)
@@ -86,6 +86,7 @@
        {{ inc field_checkbox.tpl with $field=$newuser_private }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$enotify_no_content }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$private_addons }}{{ endinc }}    
+       {{ inc field_checkbox.tpl with $field=$disable_embedded }}{{ endinc }}
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
        
        <h3>$advanced</h3>
index 30678f1bf2ea2bfe0dfecc371db417af9aacd927..8d5b72a46ebd734a2545dce025a1cc156b5b31c1 100644 (file)
@@ -91,6 +91,7 @@
        {{include file="field_checkbox.tpl" field=$newuser_private}}
        {{include file="field_checkbox.tpl" field=$enotify_no_content}}
        {{include file="field_checkbox.tpl" field=$private_addons}}     
+       {{include file="field_checkbox.tpl" field=$disable_embedded}}
        <div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
        
        <h3>{{$advanced}}</h3>
index a419cd9a57a3ad78bb1036995528edfd8026423f..349c8e5a99a8a2f64888c341edef220a13612ba3 100644 (file)
@@ -42,7 +42,8 @@
        {{ inc field_checkbox.tpl with $field=$thread_allow }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$newuser_private }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$enotify_no_content }}{{ endinc }}
-       
+       {{ inc field_checkbox.tpl with $field=$private_addons }}{{ endinc }}    
+       {{ inc field_checkbox.tpl with $field=$disable_embedded }}{{ endinc }}  
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
        
        <h3>$advanced</h3>
index 40580c48609bc54efc518630cebf7fff9888f4e8..5856d9792e7550ebb04396fe48d2afb693ea0b79 100644 (file)
@@ -47,7 +47,8 @@
        {{include file="field_checkbox.tpl" field=$thread_allow}}
        {{include file="field_checkbox.tpl" field=$newuser_private}}
        {{include file="field_checkbox.tpl" field=$enotify_no_content}}
-       
+       {{include file="field_checkbox.tpl" field=$private_addons}}     
+       {{include file="field_checkbox.tpl" field=$disable_embedded}}   
        <div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
        
        <h3>{{$advanced}}</h3>
index a419cd9a57a3ad78bb1036995528edfd8026423f..349c8e5a99a8a2f64888c341edef220a13612ba3 100644 (file)
@@ -42,7 +42,8 @@
        {{ inc field_checkbox.tpl with $field=$thread_allow }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$newuser_private }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$enotify_no_content }}{{ endinc }}
-       
+       {{ inc field_checkbox.tpl with $field=$private_addons }}{{ endinc }}    
+       {{ inc field_checkbox.tpl with $field=$disable_embedded }}{{ endinc }}  
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
        
        <h3>$advanced</h3>
index 40580c48609bc54efc518630cebf7fff9888f4e8..5856d9792e7550ebb04396fe48d2afb693ea0b79 100644 (file)
@@ -47,7 +47,8 @@
        {{include file="field_checkbox.tpl" field=$thread_allow}}
        {{include file="field_checkbox.tpl" field=$newuser_private}}
        {{include file="field_checkbox.tpl" field=$enotify_no_content}}
-       
+       {{include file="field_checkbox.tpl" field=$private_addons}}     
+       {{include file="field_checkbox.tpl" field=$disable_embedded}}   
        <div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
        
        <h3>{{$advanced}}</h3>
index c57c14569cb9d1aaaa0d7e019151960d5e0bfd06..38cbdb3ce7b3a00301ba1e461f92f226ad879516 100644 (file)
@@ -44,7 +44,8 @@
        {{ inc field_checkbox.tpl with $field=$thread_allow }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$newuser_private }}{{ endinc }}
        {{ inc field_checkbox.tpl with $field=$enotify_no_content }}{{ endinc }}
-       
+       {{ inc field_checkbox.tpl with $field=$private_addons }}{{ endinc }}    
+       {{ inc field_checkbox.tpl with $field=$disable_embedded }}{{ endinc }}  
        <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>
        
        <h3>$advanced</h3>
index 2f51173591e15f8bcd5cd10b2aa61c98fd3db09e..247972712bd48294da2af6d5cb4e373d7c1de911 100644 (file)
@@ -49,7 +49,8 @@
        {{include file="field_checkbox.tpl" field=$thread_allow}}
        {{include file="field_checkbox.tpl" field=$newuser_private}}
        {{include file="field_checkbox.tpl" field=$enotify_no_content}}
-       
+       {{include file="field_checkbox.tpl" field=$private_addons}}     
+       {{include file="field_checkbox.tpl" field=$disable_embedded}}   
        <div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
        
        <h3>{{$advanced}}</h3>