Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2004, 08:54 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Restrict [IMG] tag to registered members only

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.
Attached Images
File Type: gif register.GIF (14.2 KB, 0 views)
Reply With Quote
  #2  
Old 06-18-2004, 01:39 AM
eoc_Jason's Avatar
eoc_Jason eoc_Jason is offline
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Reply With Quote
  #3  
Old 06-18-2004, 07:00 AM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 06-18-2004, 08:24 PM
eoc_Jason's Avatar
eoc_Jason eoc_Jason is offline
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, I could probably whip something out in a few... lemme give it a test on my forum then I'll post some code.
Reply With Quote
  #5  
Old 06-18-2004, 10:25 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome, thanks Jason!
Reply With Quote
  #6  
Old 06-19-2004, 04:09 PM
eoc_Jason's Avatar
eoc_Jason eoc_Jason is offline
 
Join Date: Dec 2001
Location: Houston, TX
Posts: 493
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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....
Reply With Quote
  #7  
Old 06-21-2004, 06:20 AM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 06-26-2004, 11:43 AM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!!
Reply With Quote
  #9  
Old 07-14-2004, 10:04 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #10  
Old 12-25-2005, 05:16 AM
apfparadise apfparadise is offline
 
Join Date: Jan 2005
Location: Northridge CA
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04468 seconds
  • Memory Usage 2,308KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete