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 :(

Dean C 11-05-2003 09:10 AM

Very odd t c - i tested this on my localboard and it worked fine :)

@Stefan - i'll have a crack at fixing that tonight ;)

Dean C 11-05-2003 02:58 PM

ewww i made the fix for searching but look at the bottom php code box - ignore it for now until the bug on vb.org is fixed :)

MindTrix 11-05-2003 07:00 PM

Lmao @ the code box error up there. Nice mod anyway Mist, Thank!

Could that error be there because vB.org is not a vB2 board? Or wouldnt this matter.

Dean C 11-06-2003 01:52 PM

It's a vb3 bug MindTrix :) I've reported it at vb.com

MindTrix 11-06-2003 03:20 PM

Oh ok sorry, Cheers for clearing it up for me

Mr. HillBilly 11-08-2003 04:19 AM

Mist, could you maybe make a hack to restrict 'ALL' vB code to registered members only?

atomic fireball 11-08-2003 05:31 AM

I was hoping for a similar thing.

I'd like to make it so that guests would see a replacement image instead of the actual imbedded image that would do the same thing. Then Admins could create any image they wanted that also said words to the effect of "Sorry, you must register in order to view this image."

Would it be difficult/possible to convert this hack to the IMG tag instead?

Dean C 11-08-2003 10:39 AM

It's possible - my time is too limited right now though sorry - make a request in the 'Requests' forum :)

atomic fireball 11-08-2003 09:51 PM

No problem Mist, thanks for the reply.
I posted it a week or so ago on the requests forum, but no one was interested. :(

Dan 11-08-2003 10:36 PM

nice hack dean

Dean C 11-09-2003 10:05 AM

Chen helped me rewrite the code to compensate for the vb3 "bogus" bug as they're calling it and also this is a lot cleaner. So this hack is fully functional now :)!

ap0c 11-10-2003 12:35 AM

any change of getting a text file? I'd like to install this. All I see right now is Codedisplayerror: (Update license status) You cannot view codes as long as you haven't proven your license status!

which is not the case

Dean C 11-10-2003 05:29 PM

Well you'll need to contact the administrators privately about that issue if there are problems with your licensing status. Seems as you posted here you are licensed alright :)

nawialkair 11-20-2003 10:48 PM

Hi All

I tried to install the hack on my 2.3.2 forum and the result was:

Parse error: parse error in /home/safwaci1/public_html/testforum/admin/functions.php on line 967

Fatal error: Call to undefined function: vbdate() in /home/safwaci1/public_html/testforum/admin/sessions.php on line 400

Can you please tell me what the problem is??

Thanks

Dean C 11-21-2003 04:10 PM

You applied the hack incorrectly ;) ^^ reapply the changes.


All times are GMT. The time now is 06:25 AM.

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.01236 seconds
  • Memory Usage 1,775KB
  • 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)post_thanks_navbar_search
  • (1)printthread
  • (25)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