vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Hack for [IMG] tag in posts so that guests must register to view imbedded images (https://vborg.vbsupport.ru/showthread.php?t=57536)

atomic fireball 10-01-2003 06:51 PM

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?

atomic fireball 10-06-2003 01:11 PM

Anyone want to take on this one?

Pretty please? :)

atomic fireball 10-19-2003 06:34 AM

Anyone? Bueller??

kuwaitsun 10-19-2003 07:29 AM

Great Idea

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

Any body can do it ???

atomic fireball 11-08-2003 10:26 PM

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.

Lesane 11-09-2003 08:04 AM

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.

atomic fireball 11-10-2003 03:35 AM

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.

Lesane 11-10-2003 02:50 PM

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.

atomic fireball 11-10-2003 06:21 PM

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!

Lesane 11-10-2003 07:32 PM

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. :)


All times are GMT. The time now is 08:22 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.01145 seconds
  • Memory Usage 1,758KB
  • 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
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete