vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Restrict [code] and [php] to registered members only (https://vborg.vbsupport.ru/showthread.php?t=58380)

Dean C 11-03-2003 10:00 PM

Restrict [code] and [php] to registered members only
 
Hi,

Long time since I release a hack and this was only a little one I brushed up. Still useful nevertheless.

What does it do?
It allows you to restrict the content of the [ php] and [ code] tags to registered members only. If the user is not registered then they get a 'Sorry you must be registered to view this code.' displayed in the boxes :)

Instructions:

In admin/functions.php find:

PHP Code:

return "</normalfont><blockquote><code><smallfont>PHP:</smallfont><hr>$buffer<hr></code></blockquote><normalfont>"

Replace with:

PHP Code:

if($bbuserinfo['userid'] != 0)

{

    
$newbuffer $buffer;

}

else

{

    
$newbuffer 'Sorry you must be registered to view this code.';

}

return 
"</normalfont><blockquote><pre><smallfont>PHP:</smallfont><hr>$newbuffer<hr></pre></blockquote><normalfont>";


Find:

PHP Code:

return "</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>" str_replace("<br>"""str_replace("<br />"""$foundcode) ) . "<hr></pre></blockquote><normalfont>"

Replace with:

PHP Code:


if($bbuserinfo['userid'] != 0)

{

      
$newfoundcode $foundcode;

}

else

{

      
$newfoundcode 'Sorry you must be registered to view this code.';
}
  
return 
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>" str_replace("<br>"""str_replace("<br />"""$newfoundcode) ) . "<hr></pre></blockquote><normalfont>"

Find:

PHP Code:

function stripbrsfromcode($foundcode) { 

Below it add:
PHP Code:

global $bbuserinfo

Find:

PHP Code:

function phphighlite($code) { 

Below it add:

PHP Code:

global $bbuserinfo

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+

In search.php find:

PHP Code:

$searchresult[posttitle]=str_replace("<","&lt;",$searchresult[posttitle]); 

Below it add:

PHP Code:

if($bbuserinfo['userid'] == 0)
{
    
$searchresult['pagetext'] = preg_replace('#\[(php|code)](\r\n)*(.*)\[/\1]#''[$1]Sorry you must be registered to view this code[/$1]'$searchresult['pagetext']);


---------------------
Enjoy :D!
- Dean

Zachery 11-04-2003 05:40 PM

nice job ^^ now fix the bug

Dean C 11-04-2003 05:42 PM

Already did it ;) ^^

Rampag33 11-04-2003 05:55 PM

Mist does it again

gmarik 11-04-2003 06:49 PM

Mist - wow.
But have you done it working, so you we can use real workin php code in vB 2 templates? No hack worked for me. How is it with you?

cirisme 11-04-2003 07:15 PM

kind of like vb.org not displaying code boxes to unliscensed members? :)

ap0c 11-04-2003 09:27 PM

nice and useful mist, thanks

t c 11-04-2003 11:32 PM

Mist, about a hack extremely similar to this?

Making the php & code tags viewable in only certain forums and not viewable in the rest.

Is this possible?

Xenon 11-05-2003 12:15 AM

nice hack Dean ^^

no fix the bugs of showing codes in search as posts and quoting msgs :p

if you done so, i'll give you the vb2 code we used at vb.org ;)

t c 11-05-2003 06:33 AM

Weird issue, null, the owner of the board I am Admin of installed this and it removed the usernames from the postbit. We are using vb 2.3.2 :(


All times are GMT. The time now is 11:20 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.01125 seconds
  • Memory Usage 1,751KB
  • 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
  • (10)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