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 10-01-2003, 06:51 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hack for [IMG] tag in posts so that guests must register to view imbedded images

Hi all,

I have a hack that I'd like to see, and I'm hoping that it actually wouldn't been to difficult to implement. 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. Ideally, this would be a forum permission that could apply to certain forums only, at the Admin's choice.

Instead of guests seeing the images within a post (as you normally would) they could see either:

1. A Replacement graphic that says something along the lines of "In order to view this image, you need to register."

2. Or any custom text (via a template) that would say the same thing: ""In order to view this image, you need to register. Click here to register." etc.

This could be a way to save bandwidth and bump up the amount of registered users. Seems like it would be nice hack.

Is there already a similar hack out there, or does someone want to tackle this one?
Reply With Quote
  #2  
Old 10-06-2003, 01:11 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone want to take on this one?

Pretty please?
Reply With Quote
  #3  
Old 10-19-2003, 06:34 AM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone? Bueller??
Reply With Quote
  #4  
Old 10-19-2003, 07:29 AM
kuwaitsun kuwaitsun is offline
 
Join Date: Mar 2002
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great Idea

And also it will help to incarege the visitors to register in my forum

Any body can do it ???
Reply With Quote
  #5  
Old 11-08-2003, 10:26 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm still really interested in this hack, and it looks like there's other interest from at least kuwaitsun as well. Anyone want to take this one on?

Mist has created this nice hack which works with the PHP vb code tag in messages, but he's a bit busy to take this IMG hack on.

For admins who host a lot of images in posts, this seems like an excellent way to reduce bandwidth AND get new registered users. Ideally, I'd like to see it be able to have an ON/OFF toggle per certain forums, so it would be easy for Admins to decide which forums get the treatment of this hack, without having to alter more templates, etc.

I'll be happy to create the graphic(s) needed to show the "Sorry, you must register before you can view this image." graphic, etc.
Reply With Quote
  #6  
Old 11-09-2003, 08:04 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this:

Open admin/functions.php, look around line 884 for this line:

PHP Code:
      $bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode); 
Replace that line with:

PHP Code:
 if($bbuserinfo[userid]==0) {
      
$bbcode preg_replace("|\[img\](.*)\[/img\]|i""<img src=\"http://www.forumurl.com/youllneedtoregister.jpg\" border=\"0\" alt=\"\">"$bbcode);
      } else {    
      
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode);
      } 
Change 'http://www.forumurl.com/youllneedtoregister.jpg' into the correct url for the image to display for guests.

That should do the job.
Reply With Quote
  #7  
Old 11-10-2003, 03:35 AM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lesane, thanks for the reply.

I tried the suggested hack, but it didn't work. After applying your hack suggestion, any thread would view as a completely blank page. I don't just mean the contents of the post, but a total white page in the browser. (No header, no forum home, nada.) It would be a blank browser page for forum home, everything, not just individual threads.

I double-checked, and made sure I was applying this hack to admin/functions.php (and not admin/adminfunctions.php), double-checked my suggested link to the replacement image (customized for my forum) and again, a total blank page. I'm using 2.3.0 if that helps.

Lesane, were you able to get this working in a test? I'd really love to get this working, so please let me know if there's anything I'm missing. Thanks again for the help and suggestion.
Reply With Quote
  #8  
Old 11-10-2003, 02:50 PM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I did tested it on 2.3.2 but it should not give you a completely blank page even if it isn't working. But 2.3.0 does have a different line so try again:

(redo last one)

Open admin/functions.php and find:

PHP Code:
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode); 
Replace it with:

PHP Code:
if($bbuserinfo[userid]==0) { 
      
$bbcode preg_replace("|\[img\](.*)\[/img\]|i""<a href=\"http://www.url.com/forums/register.php?s=&action=signup\"><img src=\"http://www.url.com/forums/images/registerpic.jpg\" border=\"0\" alt=\"\"></a>"$bbcode);
      } else { 
      
$bbcode preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU""<img src=\"\\2\" border=\"0\" alt=\"\">"$bbcode);
    } 
If the code is not working then post your replacement code with the replacement image url.
Reply With Quote
  #9  
Old 11-10-2003, 06:21 PM
atomic fireball's Avatar
atomic fireball atomic fireball is offline
 
Join Date: Apr 2003
Location: California
Posts: 80
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lesane, it worked like a charm!!
Thank you so much!!!

But I did figure out what was causing the entire forum to be blank.

1. In the hack you suggested, at the end, there was an extra "}" character which caused the site to show up as blank. That one extra character was the issue for my board.

Removing the extra "}" at the end of the replacement code did the trick!!

Wow, thanks again for taking the time to generate this great little hack.
You may want to post this hack in the hacks forum, because I'm sure others will get some use out of it.

(Just to note, vB3 is odd with the Mac/Safari/IE for Mac. I had to copy/paste using a PC to get the true PHP code without any extra added characters.) So I'm going to save this as a separate TXT attachment just in case.

Lesane, thanks again for the help with this!
Awesome!
Reply With Quote
  #10  
Old 11-10-2003, 07:32 PM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're welcome, glad it's working now.

And to be honest.. i don't know what that extra } is doing there hehe, i cut-n-paste it. Aah well, it's working 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 02:14 AM.


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.04563 seconds
  • Memory Usage 2,289KB
  • Queries Executed 12 (?)
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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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
  • (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_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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete