Log in

View Full Version : Hide Images from Guests? class_bbcode.php


Baumeister900
09-05-2011, 08:34 PM
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.php?p=580244&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:

// If you wanted to be able to edit 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
$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:
// If you wanted to be able to edit 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'] == 0 OR $this->registry->userinfo['showimages']))
{
// do [img]xxx
$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
// If you wanted to be able to edit 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
$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