Advertisement:

Author Topic: Hide the content of [code] tags from guests  (Read 45233 times)

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Hide the content of [code] tags from guests
« on: January 09, 2011, 12:29:47 PM »
I was personally having the problem on my forum that people were posting links in code tag which was visible to guests, so as to overcome this problem we can now hide the whole data in code tag from guests.

To do so, you just have to make following edits;

In Themes\Default\Languages\Modification.english.php

Find:
Code: [Select]
?>
Add Before:
Code: [Select]
$txt['something'] = 'Only registered users can see contents.';
$txt['blabla'] = 'Please click here to <a target="_blank" href="' . $scripturl . '?action=register"">Register</a> or <a target="_blank" href="' . $scripturl . '?action=login">Login</a>';


In Sources/Subs.php

Find:
Code: [Select]
'tag' => 'code',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',

Replace it with:
Code: [Select]
'tag' => 'code',
'type' => 'unparsed_content',
'content' => $user_info['is_guest'] ? '<div class="codeheader">' . $txt['code'] . ': </div><code class="bbc_code">' . $txt['something'] . ' ' . $txt['blabla'] . '</code>' :  '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',


You can change text strings as you like.


This trick is available as mod also, here.
« Last Edit: May 28, 2011, 01:19:03 PM by Joker™ »
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 48,087
Re: Hide the content of [code] tags from guests
« Reply #1 on: January 09, 2011, 12:45:33 PM »
this might be better on the tips board. it is a nice idea for some forums.

Offline tesser

  • Jr. Member
  • **
  • Posts: 262
Re: Hide the content of [code] tags from guests
« Reply #2 on: January 09, 2011, 01:07:43 PM »
arantor had a mod that works for RC3 but it also works on RC4  that did the  hide code  from guests  ;D lucky me i have it now his site is gone.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #3 on: January 09, 2011, 01:14:14 PM »
arantor had a mod that works for RC3 but it also works on RC4  that did the  hide code  from guests  ;D lucky me i have it now his site is gone.
I must have missed that mod.


For working demo of code above you can open any non-sticky post from this board.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 48,087
Re: Hide the content of [code] tags from guests
« Reply #4 on: January 09, 2011, 01:20:53 PM »
might be slightly more professional to add a space in the code replacement
Code: [Select]
Only registered users can see contents.Please click here to Register or Login and replace with
Code: [Select]
Only registered users can see this content. Please click here to Register or Login.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,061
    • Arantor on GitHub
Re: Hide the content of [code] tags from guests
« Reply #5 on: January 09, 2011, 01:30:55 PM »
Quote
I must have missed that mod.

I did a mega version of the 'registered links' mod that did code tags as well, also provided the option to only hide links that aren't internal ones.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #6 on: January 09, 2011, 01:31:56 PM »
might be slightly more professional to add a space in the code replacement
Code: [Select]
Only registered users can see contents.Please click here to Register or Login and replace with
Code: [Select]
Only registered users can see this content. Please click here to Register or Login.
Thanks for the suggestion. Made the changes in above code regarding the space you have mentioned.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #7 on: January 09, 2011, 01:34:30 PM »
Quote
I must have missed that mod.

I did a mega version of the 'registered links' mod that did code tags as well, also provided the option to only hide links that aren't internal ones.
Nice to see the biggest spammer back ;D.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,061
    • Arantor on GitHub
Re: Hide the content of [code] tags from guests
« Reply #8 on: January 09, 2011, 01:36:20 PM »
I wouldn't call it back, seeing how the support I'm doing is extremely limited, mostly to assess things that I think need to be fixed in SMF, and that none of the mods that were on arantormods.com are being published anywhere by me, in fact the only place to get them now is a paid site I gave them to, so they could sell the mods to folks.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #9 on: January 09, 2011, 01:43:40 PM »
I wouldn't call it back, seeing how the support I'm doing is extremely limited, mostly to assess things that I think need to be fixed in SMF, and that none of the mods that were on arantormods.com are being published anywhere by me, in fact the only place to get them now is a paid site I gave them to, so they could sell the mods to folks.
Lol, I myself was busy like hell in past month, even missed to celebrate new year :-X.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Cowley

  • Newbie
  • *
  • Posts: 1
Re: Hide the content of [code] tags from guests
« Reply #10 on: January 31, 2011, 07:13:34 PM »
Thank you so much for your advice. Exactly what I was looking for!  ;)

Offline Jeet Chowdhury

  • Jr. Member
  • **
  • Posts: 239
  • Gender: Male
  • Running SMF 2.0.2
    • MuSKiL AShaN
Re: Hide the content of [code] tags from guests
« Reply #11 on: February 01, 2011, 11:25:49 AM »
I was personally having the problem on my forum that people were posting links in code tag which was visible to guests, so as to overcome this problem we can now hide the whole data in code tag from guests.

To do so, you just have to make following edits;

In Themes\Default\Modification.english.php

Find:
Code: [Select]
?>
Add Before:
Code: [Select]
$txt['something'] = 'Only registered users can see contents.';
$txt['blabla'] = 'Please click here to <a target="_blank" href="' . $scripturl . '?action=register"">Register</a> or <a target="_blank" href="' . $scripturl . '?action=login">Login</a>';


In Sources/Subs.php

Find:
Code: [Select]
            'tag' => 'code',
            'type' => 'unparsed_content',
            'content' => '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',

Replace it with:
Code: [Select]
            'tag' => 'code',
            'type' => 'unparsed_content',
            'content' => $user_info['is_guest'] ? '<div class="codeheader">' . $txt['code'] . ': </div><code class="bbc_code">' . $txt['something'] . ' ' . $txt['blabla'] . '</code>' :  '<div class="codeheader">' . $txt['code'] . ': <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>',


You can change text strings as you like.

how to hide quote tag also?


also after login user backto forum index. how to log him back to where he is actually?
« Last Edit: February 01, 2011, 11:30:53 AM by Jeet Chowdhury »

Offline Matthew K.

  • SMF Super Hero
  • *******
  • Posts: 12,430
  • Gender: Male
    • matthew.kerle on Facebook
    • @matthew_kerle on Twitter
Re: Hide the content of [code] tags from guests
« Reply #12 on: February 01, 2011, 11:45:28 AM »
The same way you would with the code tags...only for the quote tags.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #13 on: February 01, 2011, 12:10:31 PM »
The same way you would with the code tags...only for the quote tags.
That depends that how the data of quotes is being handled. I may take a look at the file in a bit.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #14 on: February 02, 2011, 08:29:36 AM »
Lol hiding data in quotes seems to bit tricky as last night I was unable to find how that data is supplied in quotes tag, I will this thing a shot tonight for sure.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,061
    • Arantor on GitHub
Re: Hide the content of [code] tags from guests
« Reply #15 on: February 02, 2011, 08:32:23 AM »
You actually can't directly rewrite quote tags because the contents of the tag is never supplied to the parser (since it can contain other tags)

All you can do is what I used to do in my registered-links mod: rewrite the start and end tags in the validate function to something else, then strip them out in the obsess_rewrite buffer.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #16 on: February 02, 2011, 08:36:05 AM »
You actually can't directly rewrite quote tags because the contents of the tag is never supplied to the parser (since it can contain other tags)
That's what I thought after seeing "Remove images from quotes tag" mod.


Quote
All you can do is what I used to do in my registered-links mod: rewrite the start and end tags in the validate function to something else, then strip them out in the obsess_rewrite buffer.
Umm that seems to be a bit above my head.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Offline steeltape

  • Newbie
  • *
  • Posts: 8
Re: Hide the content of [code] tags from guests
« Reply #17 on: May 24, 2011, 09:47:12 AM »
hi this is very useful mod for me and i'm grateful that you share this with us the leechers
however, there is no Themes\Default\Modification.english.php file in my default theme nor my other sub themes.
so how?

smf 2.0 rc5

Offline mashby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,394
  • Gender: Male
  • badass beer hound
    • Choppix
Re: Hide the content of [code] tags from guests
« Reply #18 on: May 24, 2011, 09:55:26 AM »
Try one level down, so:
Themes/default/languages/Modifications.english.php
Always be a little kinder than necessary.
- James M. Barrie

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,914
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Hide the content of [code] tags from guests
« Reply #19 on: May 24, 2011, 10:24:20 AM »
Try one level down, so:
Themes/default/languages/Modifications.english.php
Thanks for pointing out the error ;).
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved