vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Hide Images from Guests? class_bbcode.php (https://vborg.vbsupport.ru/showthread.php?t=269723)

Baumeister900 09-05-2011 08:34 PM

Hide Images from Guests? class_bbcode.php
 
Hi,

I would like to hide images from my guests - I tried many different ideas such as this one that comes pretty close: https://vborg.vbsupport.ru/showpost....44&postcount=5

But after all it doesn't work because my code is different.

So basically we have to modify "inlcudes/class_bbcode.php"

Then the interesting part looks like this:

Code:

                // If you wanted to be able to edit [img] when editing a post instead of seeing the image, add the get_class() check from above
                if ($has_img_code & BBCODE_HAS_IMG)
                {
                        if ($do_imgcode AND ($this->registry->userinfo['userid'] == 0 OR $this->registry->userinfo['showimages']))
                        {
                                // do [img]xxx[/img]
                                $bbcode = preg_replace('#\[img\]\s*(https?://([^*\r\n]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_img_match('\\1')", $bbcode);
                        }
                        else
                        {
                                $bbcode = preg_replace('#\[img\]\s*(https?://([^*\r\n]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $bbcode);
                        }
                }

So how do I modify this part in order to show my guests a message like " Only registered users can see images" ?

HMBeaty 09-05-2011 08:38 PM

Try this:
PHP Code:

        // If you wanted to be able to edit [img] when editing a post instead of seeing the image, add the get_class() check from above
        
if ($has_img_code BBCODE_HAS_IMG $vbulletin->userinfo['userid'])
        {
            if (
$do_imgcode AND ($this->registry->userinfo['userid'] == OR $this->registry->userinfo['showimages']))
            {
                
// do [img]xxx[/img]
                
$bbcode preg_replace('#\[img\]\s*(https?://([^*\r\n]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"\$this->handle_bbcode_img_match('\\1')"$bbcode);
            }
            else
            {
                
$bbcode preg_replace('#\[img\]\s*(https?://([^*\r\n]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')"$bbcode);
            }
        } 


Baumeister900 09-05-2011 08:47 PM

That stops converting img in general - so both guests and registered users can not view imgs anymore - in addition it shows the url to the image to guests - But I would like to replace the url and the img tag with a text such as "please register ..."

HMBeaty 09-05-2011 08:53 PM

Hmm ok, see if this one works, just change please register ... to what you want
PHP Code:

        // If you wanted to be able to edit [img] when editing a post instead of seeing the image, add the get_class() check from above
        
if ($has_img_code BBCODE_HAS_IMG)
        {
            if (
$do_imgcode AND ($this->registry->userinfo['userid'] == OR $this->registry->userinfo['showimages']))
            {
                
// do [img]xxx[/img]
                
$bbcode "please register ...";
            }
            else
            {
                
$bbcode preg_replace('#\[img\]\s*(https?://([^*\r\n]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')"$bbcode);
            }
        } 


Baumeister900 09-05-2011 08:58 PM

That replaces all img tag including guests and registered users ...

HMBeaty 09-05-2011 09:05 PM

Have you tried this? https://vborg.vbsupport.ru/showthread.php?t=256054

Baumeister900 09-05-2011 09:12 PM

No but I tried this one for vb3 and it worked:
https://vborg.vbsupport.ru/showthread.php?t=219631

I saw this mod before but some user said it doesn't work - but in fact it works :) - Thanks anyway for your immediate help :)

HMBeaty 09-05-2011 09:16 PM

Ah ok, good! :D lol


All times are GMT. The time now is 01:37 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01139 seconds
  • Memory Usage 1,740KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete