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 05: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 12:11 PM

Anyone want to take on this one?

Pretty please? :)

atomic fireball 10-19-2003 05:34 AM

Anyone? Bueller??

kuwaitsun 10-19-2003 06: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. :)

corsacrazy 11-10-2003 08:06 PM

this also effects users signature images if a user has an [img[ code in there sig..........

corsacrazy 11-10-2003 08:28 PM

i modded it a bit to make the image a link to teh register page if u r interested ?

$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);

atomic fireball 11-11-2003 12:31 AM

Awesome! Let me apply this new little tweak. Very good idea.

Lesane and corsacrazy, thanks again for your assistance with this!

corsacrazy 11-11-2003 12:34 PM

all credit goes to the L man ;) and ofcourse atomic for the idea ;)

atomic fireball 11-11-2003 06:37 PM

1 Attachment(s)
If anyone is intersted, I created a simple quick and dirty "You'll need to register" graphic and have attached it to this post. (I just used the generic vBulletin colors/fonts, so it's not flashy, but it'll do the job. It includes the corsacrazy mod, telling users they can click the image to register.)

Lesane, would it be a LOT more work to get this hack selectable per forum? Or perhaps a line of code that would exclude a certain forum(s) from this IMG hack? (Perhaps the admin could hard code the forum IDs they want to include for this into the hack, etc? Or vice-versa, one could exclude a particular forum from this IMG tag behavior?)

Its not crucial, but if it's not too difficult, it would be a nice addition.

Thanks again to Lesane for the PHP work and corsacrazy for the mod!

corsacrazy 11-11-2003 07:19 PM

1 Attachment(s)
here tis my graffic

atomic fireball 11-11-2003 07:25 PM

Hey, no fair!! Your graphic is way better than mine! :D

corsacrazy 11-11-2003 09:07 PM

lol i also hav a swf flah move telin people to register i may incorportae that into it ;)

atomic fireball 11-12-2003 12:57 AM

Just so this question doesn't get lost from the first page: Lesane, would it be a LOT more work to get this hack selectable per forum? Or perhaps a line of code that would exclude a certain forum(s) from this IMG hack? (Perhaps the admin could hard code the forum IDs they want to include for this into the hack, etc? Or vice-versa, one could exclude a particular forum from this IMG tag behavior?)

Lesane 11-12-2003 10:40 AM

Quote:

Originally Posted by atomic fireball
If anyone is intersted, I created a simple quick and dirty "You'll need to register" graphic and have attached it to this post. (I just used the generic vBulletin colors/fonts, so it's not flashy, but it'll do the job. It includes the corsacrazy mod, telling users they can click the image to register.)

Lesane, would it be a LOT more work to get this hack selectable per forum? Or perhaps a line of code that would exclude a certain forum(s) from this IMG hack? (Perhaps the admin could hard code the forum IDs they want to include for this into the hack, etc? Or vice-versa, one could exclude a particular forum from this IMG tag behavior?)

Its not crucial, but if it's not too difficult, it would be a nice addition.

Thanks again to Lesane for the PHP work and corsacrazy for the mod!

Nice image, will use it once i install it.

It's not really that hard, open admin/functions.php and find:

Code:

return bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode);
Change that line into:

Code:

return bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode,$forumid);
Then find:

Code:

function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode)
Change that line into:

Code:

function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode,$forumid)
Last one, find:

Code:

if($bbuserinfo[userid]==0) {
Change that line into:

Code:

if($bbuserinfo[userid]==0 AND $forumid != X) {
Where X is the forumid wich you want to exclude. It will display the register now image on signatures.

atomic fireball 11-13-2003 07:35 PM

Lesane, you da man!!

Thanks so much for this help. I'll test this out on my test forum tonite. In the spirit of your avatar, I'm sure everything will be "Kool Mo' D"! :D

atomic fireball 06-03-2004 09:03 PM

Lesane, this is an excellent hack.

I just wanted to know if it would be possible to update this for vB3?
I sure hope so, thanks!

RonH. 06-04-2004 07:01 AM

Has anyone ported over the code to/for vB 3.0.1 for this useful bit of a hack? This is assuming that the code above is for 2.3.2.

Sylvus 06-04-2004 02:55 PM

If you can find it under the 3.x hack section, the answer to your question is yes. :)

Syl...

atomic fireball 06-04-2004 03:11 PM

Not everyone who ports over the code for their own personal board releases it here at vb.org.

So again, has anyone used this hack and customized it for vB3?
Unfortunately, it looks as if Lesane is no longer here to offer his excellent help. :(

andyLA 06-09-2004 10:25 PM

According to a personal email from Lesane, he has been banned from this site, vb.org and will not be able to post here ever. I will remain in contact and possibly post his responses as I get them. I hope this helps you understand his delay in responding. Best wishes.

-Andy

bigmonay2k 06-10-2004 10:59 AM

Quote:

Originally Posted by andyLA
According to a personal email from Lesane, he has been banned from this site, vb.org and will not be able to post here ever. I will remain in contact and possibly post his responses as I get them. I hope this helps you understand his delay in responding. Best wishes.

-Andy

WHAT HAPPENED???

BabesAndStuff 06-17-2004 06:14 PM

nice work guys this is a very good hack and ill be using it on babesandstuff .. that way the forums can be spidered and images wont show to non registered users .

atomic fireball 06-17-2004 07:01 PM

Quote:

Originally Posted by BabesAndStuff
nice work guys this is a very good hack and ill be using it on babesandstuff .. that way the forums can be spidered and images wont show to non registered users .

Actually, you can easily block spiders from your entire images folder (or any other folder for that matter) by properly editing your Robots.txt file at the root of your directory.

But this hack is great for sites that have many many guest viewers.

WE NEED THIS HACK FOR VB3!!! :D

Anyone??

wolfyman 08-17-2005 12:53 AM

I'd love to see this for 3.0.8 (OR 3.5, Ill be scooting on over soon) - I have a similar hack working, but it does not affect thumbnails. Which kind of defeats the purpose, since I have all images thumbnailed. When a guest clicks the (viewable) thubnail, they get the full size image. The only thing that gets blocked is sigs!


All times are GMT. The time now is 05:51 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.02797 seconds
  • Memory Usage 1,819KB
  • 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
  • (6)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (30)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