vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Restrict [IMG] tag to registered members only (https://vborg.vbsupport.ru/showthread.php?t=66260)

atomic fireball 06-17-2004 08:54 PM

Restrict [IMG] tag to registered members only
 
1 Attachment(s)
This hack was already successfully created for vB2, isn't available for vB3. There seems to be some nice interest in this hack, and it would be a great addition (and a bandwidth saver) for sites with many guests and few members, etc.

The vB2 version has been discussed in this thread:
https://vborg.vbsupport.ru/showthread.php?t=57536

This hack was supplied by Lesane in the thread above, but sadly, last I heard is that he's banned and no longer here at vb.org. :(

Anyone want to pick this one up for vB3?

I'm looking for a hack that would allow an Admin the ability to "flip a switch" and make it so that any posts which include imbedded images (using the [IMG] tag) would be "disabled" for guests.

Instead of guests seeing the images within a post (as you normally would) they would see a replacement graphic that says something along the lines of "In order to view this image, you need to register." (Admins could make this any graphic they wish.)

I made a completely generic vb2 style graphic which could be used as a replacement. This is attached to this post. I'll be happy to update the graphic to a more vB3 style graphic if needed.

Any help with this hack would be appreciated, thanks.

eoc_Jason 06-18-2004 01:39 AM

Edit the functions_bbcodeparse.php file, look for the handle_bbcode_img function.

Just edit the conditionals and add one if no userid to display the image you posted instead...

easy as pie... ;)

atomic fireball 06-18-2004 07:00 AM

Quote:

Originally Posted by eoc_Jason
Edit the functions_bbcodeparse.php file, look for the handle_bbcode_img function.

Just edit the conditionals and add one if no userid to display the image you posted instead...

easy as pie... ;)

Ummm...errr...ah....my simple non-PHP skilled brain will need some help with this one. :)

If you don't mind, when you have some time, if you could list this as a step-by-step, I'm sure myself and a few others would really appreciate it.

eoc_Jason 06-18-2004 08:24 PM

Sure, I could probably whip something out in a few... lemme give it a test on my forum then I'll post some code.

atomic fireball 06-18-2004 10:25 PM

Awesome, thanks Jason!

eoc_Jason 06-19-2004 04:09 PM

Okay, as mentioned before, open the functions_bbcodeparse.php file.

Find the following code:
PHP Code:

// ###################### Start bbcodeparseimgcode #######################
function handle_bbcode_img($bbcode$dobbimagecode)
{
    global 
$vboptions$bbuserinfo;

    if(
$dobbimagecode AND ($bbuserinfo['userid'] == OR $bbuserinfo['showimages']))
    {
        
// do [img]https://vborg.vbsupport.ru/[/img]
        
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_img_match('\\1')"$bbcode);
    }
    
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_url('\\1', '', 'url')"$bbcode);

    return 
$bbcode;


Replace it with this (change the location to the image as needed):
PHP Code:

// ###################### Start bbcodeparseimgcode #######################
function handle_bbcode_img($bbcode$dobbimagecode)
{
    global 
$vboptions$bbuserinfo;

    if(
$dobbimagecode AND $bbuserinfo['userid'] == 0)
    {
        
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iU'"<a href=\"register.php\"><img src=\"/images/register.gif\" border=\"0\" alt=\"Please Register\" /></a>"$bbcode);
    }
    else if(
$dobbimagecode AND $bbuserinfo['showimages'])
    {
        
// do [img]https://vborg.vbsupport.ru/[/img]
        
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_img_match('\\1')"$bbcode);
    }
    
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_url('\\1', '', 'url')"$bbcode);

    return 
$bbcode;



Keep in mind though, this also affects sigs with the IMG tag....

atomic fireball 06-21-2004 06:20 AM

Awesome, Jason!!

I'm going to have to test this out on my forum, but thanks for the code help. I'm sure others will use this as well. Great bandwidth saver for non-members, etc.

atomic fireball 06-26-2004 11:43 AM

It worked perfecty, thanks!

For those of us that use a portal (like vBAdvanced) is there any way to allow for the IMG tag function on just the index page?

I'm guessing that the easiest way to do this would be to just include some code that EXCLUDES a forum ID number (or multiple forum IDs) from this new IMG rule for registered only. Then we could enter in the forum ID (or IDs) for the news forum used on the index page.

I know the "theory" of what should be done, but don't know the code. :)

Would it be possible to add this as well?

Thanks!!

atomic fireball 07-14-2004 10:04 PM

Jason was kind enough to tweak this hack to allow for a specific single forum to be EXCLUDED from this hack. In order words, you can choose a particular forum (by forum ID #) to allow even guests to view images from the IMG tag.

In case anyone needs this tweak as well, I'm posting this code from Jason, and any and all credit goes to him:

All you need to do is change the "$forumid != X" to whatever the forumid you want to exclude. If you want multiple forums you will need to defind them as an array and use the in_array function.

PHP Code:

// ###################### Start bbcodeparseimgcode ####################### 
function handle_bbcode_img($bbcode$dobbimagecode

++++global 
$vboptions$bbuserinfo$forumid

++++if(
$dobbimagecode AND $bbuserinfo['userid'] == AND $forumid != X
++++{ 
++++++++
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iU'"<a href=\"register.php\"><img src=\"/images/register.gif\" border=\"0\" alt=\"Please Register\" /></a>"$bbcode);
++++} 
++++else if(
$dobbimagecode AND $bbuserinfo['showimages']) 
++++{ 
++++++++
// do [img]xxx[/img] 
++++++++$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"' iif(!$vboptions['allowdynimg'], '?&') . ']+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_img_match('\\1')"$bbcode);
++++} 
++++
$bbcode preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe'"handle_bbcode_url('\\1', '', 'url')"$bbcode);

++++return 
$bbcode


Thanks, again Jason!

This is an excellent hack!

apfparadise 12-25-2005 05:16 AM

Hey just found this thread again. I used to have this in 3.0 but now with 3.5 how do you do this. I dont have functions_bbcodeparse.php, where is it done now?

apfparadise 01-05-2006 01:39 AM

Anyone? :(


All times are GMT. The time now is 11:28 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.01270 seconds
  • Memory Usage 1,767KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)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