Log in

View Full Version : Admin/Mod BBcodes


VaaKo
01-13-2006, 10:00 PM
this is an easy hack for admins and mods who edit their users' posts and always wanna leave a msg at the bottom of it!

check the screenshots!
download the zip file for installation instructions!

For those who are looking to restrict the use of these bbcodes for normal users, please use this hack:
Advanced BBcode Permissions (https://vborg.vbsupport.ru/showthread.php?t=103747&highlight=bbcode)

http://www.oneforum.org

Brent H
01-13-2006, 10:39 PM
Awesome! Thanks for this :)

Julie
01-13-2006, 11:44 PM
Say a regular user knows, or finds out about this certain tag, what will stop he/she from using it?

Because if it's somehow restricted to admins/mods, I'd like to use it! :)

COBRAws
01-14-2006, 01:11 AM
Say a regular user knows, or finds out about this certain tag, what will stop he/she from using it?

Because if it's somehow restricted to admins/mods, I'd like to use it! :)

I believe its only for staff, cuz the title says "Admin/Mod BBcodes"

I want to know that too, so ill wait.

Yorixz
01-14-2006, 07:05 AM
I believe its only for staff, cuz the title says "Admin/Mod BBcodes"

I want to know that too, so ill wait.
The title says so but theres not a single line or whatsoever that would stop members from using it; they'll actually see the bbcode if they quote a post.

Very nice hack, but imho a bit unusable without restriction.

VaaKo
01-14-2006, 08:00 AM
you could use the "permission bbcode" hack release somewhere in here!
you're right about what you said, my suggestion is to use the hack I mentioned along with this one, you will restrict normal users from using certain bbcodes along with this one!

PersianImmortal
01-14-2006, 08:21 AM
Great mod. Very handy for mods and admins, and makes it harder for members to pretend they never saw an admin/mod edit.

I'd say it would be pretty ballsy for a user to use these tags in their own posts. Obviously imitating a mod or admin would be grounds for punishment.

Snake
01-14-2006, 10:37 AM
Nice addition!

bang
01-14-2006, 01:45 PM
have been looking for this! is it possible to make the text be alligned to the center of the [!] sign? right now it's on top and it looks rather odd.

Jaynesh
01-14-2006, 01:55 PM
Looks very nice, i will be giving this a try :)

VaaKo
01-14-2006, 04:02 PM
have been looking for this! is it possible to make the text be alligned to the center of the [!] sign? right now it's on top and it looks rather odd.

tweak the php code, maybe use this

<valign="center">{param}

Darat
01-14-2006, 09:03 PM
you could use the "permission bbcode" hack release somewhere in here!
you're right about what you said, my suggestion is to use the hack I mentioned along with this one, you will restrict normal users from using certain bbcodes along with this one!

I'd like to install this but I want to restrict it's use to only mods and admins - I've looked for the hack you mention "permission bbcode" but can't find it anywhere?

VaaKo
01-14-2006, 10:14 PM
This is it:

Advanced BBCode Permissions (https://vborg.vbsupport.ru/showthread.php?t=103747&highlight=bbcode)

Yorixz
01-15-2006, 07:49 AM
Any news on custom bbcodes?
Doesn't look like it's possable unless VB loads the custom bbcode admin PHP with hooks.
In the topic https://vborg.vbsupport.ru/showthread.php?t=103747

So I'm afraid you can't restrict these two custom bbcodes :(

Wild-Wing
02-07-2006, 08:53 PM
its a pain in the ass to restrict them you have to hard code them. damn.
heres the code
go to class_bbcode
add theses some where
/**
* Handles a [admin] tag. Displays a preformatted string.
*
* @param string The code to display
*
* @return string HTML representation of the tag.
*/
function handle_bbcode_admin($code)
{
global $vbulletin, $vbphrase, $stylevar, $show;

// remove unnecessary line breaks and escaped quotes
$code = str_replace(array('<br>', '<br />', '\\"'), array('', '', '"'), $code);

$code = $this->strip_front_back_whitespace($code, 1);
if ($this->printthread)
{
$code = $this->emulate_pre_tag($code);
$template = 'bbcode_admin_printthread';
}
else
{
$blockheight = $this->fetch_block_height($code);
$template = 'bbcode_admin';
}

eval('$html = "' . fetch_template($template) . '";');
return $html;
}
/**
* Handles a [mod] tag. Displays a preformatted string.
*
* @param string The code to display
*
* @return string HTML representation of the tag.
*/
function handle_bbcode_mod($code)
{
global $vbulletin, $vbphrase, $stylevar, $show;

// remove unnecessary line breaks and escaped quotes
$code = str_replace(array('<br>', '<br />', '\\"'), array('', '', '"'), $code);

$code = $this->strip_front_back_whitespace($code, 1);
if ($this->printthread)
{
$code = $this->emulate_pre_tag($code);
$template = 'bbcode_mod_printthread';
}
else
{
$blockheight = $this->fetch_block_height($code);
$template = 'bbcode_mod';
}

eval('$html = "' . fetch_template($template) . '";');
return $html;
}
find if ($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_CODE)
{
//[CODE]
$tag_list['no_option']['code'] = array(
'callback' => 'handle_bbcode_code',
'strip_empty' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1
);
}

after add:
if ($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ADMINWARN)
{
//[CODE]
$tag_list['no_option']['admin'] = array(
'callback' => 'handle_bbcode_admin',
'strip_empty' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1
);
}
if ($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_MODWARN)
{
//[CODE]
$tag_list['no_option']['mod'] = array(
'callback' => 'handle_bbcode_mod',
'strip_empty' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1
);
}
find this at the top of the file
define('ALLOW_BBCODE_HTML', 512);
after add :
define('ALLOW_BBCODE_MODWARN', 1024);
define('ALLOW_BBCODE_ADMINWARN', 2048);

save that file

open class_bbcode_alt.php
find:
function handle_bbcode_code($code)
{
$current_tag =& $this->current_tag;

$code = str_replace(' ', ' &nbsp;', $code);
$code = preg_replace('#(\r\n|\n|\r|<p>)( )(?!([\r\n]}|<p>))#i', '$1&nbsp;', $code);

return "[$current_tag[name]]" . $code . "[/$current_tag[name]]";
}
after add:
function handle_bbcode_admin($code)
{
$current_tag =& $this->current_tag;

$code = str_replace(' ', ' &nbsp;', $code);
$code = preg_replace('#(\r\n|\n|\r|<p>)( )(?!([\r\n]}|<p>))#i', '$1&nbsp;', $code);

return "[$current_tag[name]]" . $code . "[/$current_tag[name]]";
}
function handle_bbcode_mod($code)
{
$current_tag =& $this->current_tag;

$code = str_replace(' ', ' &nbsp;', $code);
$code = preg_replace('#(\r\n|\n|\r|<p>)( )(?!([\r\n]}|<p>))#i', '$1&nbsp;', $code);

return "[$current_tag[name]]" . $code . "[/$current_tag[name]]";
}

then make templates.

Wild-Wing
02-08-2006, 12:21 AM
i figured it out

Darat
02-08-2006, 10:04 AM
Wild-Wing - thanks.... I think!

I understand the file edits but after editing the files how do you create a tag that can only be used by an admin or mod?

Darat
02-08-2006, 02:34 PM
Wild-Wing - I realise what you meant - create templates called bbcode_admin and bbcode_mod for the code to display a "moderator box".

However I see that you add this:

define('ALLOW_BBCODE_MODWARN', 1024);
define('ALLOW_BBCODE_ADMINWARN', 2048);

So I presume somehow once I've made the modifications I would need to give permission to the admin and mod groups so they could use the tags?

Wild-Wing
02-08-2006, 02:40 PM
oh i forgot to add that part damn.

you have to be in developer mode to to the next step
go to the bbcode settings
where the Enabled Built-in BB Codes area is you should see a edit and delete links (note: you will only see this if you are in developer mode.)
add this to the bottom of the option code box above the span tag
<label for=\"bb1024\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"bb1024\" value=\"1024\" tabindex=\"1\" " . iif(bitwise($setting['value'],1024), 'checked="checked"') . " />[MOD]</label><br />
<label for=\"bb2048\"><input type=\"checkbox\" name=\"setting[$setting[varname]][]\" id=\"bb2048\" value=\"2048\" tabindex=\"1\" " . iif(bitwise($setting['value'],2048), 'checked="checked"') . " />[ADMIN]</label><br />

now you can enable it through out the board. now to restrict it to the usergroups admin and mod and what ever you have to use the Advanced BBcode Permissions hack. edit that approately and there you go

Darat
02-08-2006, 03:37 PM
Thanks.

I've now done that however now if I try to display a post that uses one the tags the page just doesn't display (I just get a completely blank page and the browser indicates it is busy).

If I switch off the mod and admin bbcodes in the vBulletin options page then the page displays but of course the tag is just shown as text.

(For testing purposes all my template is a single <div> with the words TEST ADMIN TAG in it.)

Any ideas?

Wild-Wing
02-08-2006, 04:20 PM
did u turn on debug mode in the config.php file? that turns on developer mode. when i get home ill post the templates i used.
i used this for the admin template and the admin_printthread
make sure you name them bbcode_admin and bbcode_admin_printthread
<style>
.code{font-family: Courier, Courier New, Verdana, Arial;
color: #465584;
background-color: #FAFCFE;
border: 1px dotted #000;
padding: 2px;
width:98%;
margin: 0px auto 0px auto;
/*overflow: auto;
height: 200px;*/}
</style>
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="smallfont"><strong>Administrator's Warning:</strong></span></td>
</tr>
<tr>
<td class="code"><img align="left" src="images/mod.gif">$code</td>
<tr>
</table>

Darat
02-09-2006, 09:31 AM
Just tried with your templates and the same problem, switch the tags on and a blank page, switch them off and the page displays fine.

I've double checked the edits of the files you've listed and my edits are correct - could it be you've missed an edit instruction?

Wild-Wing
02-09-2006, 02:30 PM
damn thats something i dont know whats wrong. i am not at home right now so i cant double check all my steps i might have forgoten something i dont know maybe i posted all the steps.

Smiry Kin's
02-09-2006, 03:02 PM
Wow quiet simple really!

Darat
02-10-2006, 03:43 PM
damn thats something i dont know whats wrong. i am not at home right now so i cant double check all my steps i might have forgoten something i dont know maybe i posted all the steps.

I reverted back to all orginal files and tried again and I get the same problem.

Lineman28645
02-10-2006, 06:33 PM
Installed and working! Very nice!

OndaReal
02-10-2006, 07:02 PM
worked like a dream, thanks =)

Darat
02-11-2006, 09:51 AM
Damn! Why isn't it working for me? I've even disabled every other plugin and product just to be on the safe side! Frustrating to say the least!

Luggruff
02-11-2006, 10:27 AM
uhm.. anyone can just go check these out and use them. In the BB code FAQ.
Solution please?? (pretty worthless if not)

without doing what some other members wrote above, I have no clue in that area of modding.

Delphiprogrammi
02-11-2006, 10:59 AM
well,

nice addition BUT it has a serious security hole.*anybody* with a username can go to www.yourboard.com/forum/misc.php?do=bbcode this generates a list of bbcode tags your board uses.The "advanced bbcode permissions hack" only handles permissions for bbcode build into vbulletin not custom bbcode tags so without some way to restrict this it is pretty useless

also ......

DO NOT TURN ON DEBUG MODE ON LIVE SITES

danger Will Robinson danger .....

Smiry Kin's
02-11-2006, 10:59 AM
Damn! Why isn't it working for me? I've even disabled every other plugin and product just to be on the safe side! Frustrating to say the least!
this isnt a plugin :S its just custom bb codes, plugins shouldnt really effect it.. i have this working :s its pretty simple really..

Smiry Kin's
02-11-2006, 11:02 AM
well,

nice addition BUT it has a serious security hole.*anybody* with a username can go to www.yourboard.com/forum/misc.php?do=bbcode this generates a list of bbcode tags your board uses.The "advanced bbcode permissions hack" only handles permissions for bbcode build into vbulletin not custom bbcode tags so without some way to restrict this it is pretty useless

also ......

DO NOT TURN ON DEBUG MODE ON LIVE SITES

danger Will Robinson danger .....yeh your right dude..

* Smiry Kin's going to uninstall, unless a fix is made soon

Luggruff
02-11-2006, 11:35 AM
yeh your right dude..

* Smiry Kin's going to uninstall, unless a fix is made soon

*So is Luggruff*

Delphiprogrammi
02-11-2006, 03:20 PM
well,

you could add a plugin on hook location bbcodeparse_start which checks the individual permissions using the bitfields from the advanced bbcode permissions hack.But you need to modify this hack a bit.

i'll have a look later no time for it now :D

Darat
02-11-2006, 05:19 PM
Although I can't get it to work you can alter the Advanced bbcode permissions (https://vborg.vbsupport.ru/showthread.php?t=103747) mod to control the usergroups that can use the new tags.

Download the Advanced permission add-on and edit the bitfield_advancedbbcodepermissions.xml file to add these two lines to the group options:

<bitfield name="allow_bbcode_admin" group="advanced_bbcode_permissions" phrase="allow_bbcode_admin">1024</bitfield>

<bitfield name="allow_bbcode_mod" group="advanced_bbcode_permissions" phrase="allow_bbcode_mod">2048</bitfield>

Save that. Then open the product-advancedbbcodepermissions.xml file and add these two lines:

<phrase name="allow_bbcode_admin"><![CDATA[[ADMIN]]]></phrase>
<phrase name="allow_bbcode_mod"><![CDATA[[MOD]]]></phrase>

Save that file.

Then install the Advanced permissions product as per the instructions and you can then use that to control permissions to the new "admin" and "mod".

(Word of warning - I can't at the moment test this but it should work!)

Darat
02-12-2006, 10:50 AM
I've got this working now - rather embarrassing I'd been mucking around class_bbcode a little while ago on my test forum to see if I could implement this and forgot about them, once I started from original files it all worked first time!

I've modified the advanced bbcode permissions to handle the new tags and that works – so the codes can only be used by a mod or admin however if I use more then one mod box in the thread only the first one is parsed correctly – the subsequent ones are ignored as if I didn’t have permission to use the tag,

Delphiprogrammi
02-12-2006, 05:23 PM
well,

if u use that hack called "advanced bbcode permissions" then something like this should work


if(!$vbulletin->userinfo['permissions']['advanced_bbcode_usergroup_permissions'] & !$vbulletin->bf_ugp_advanced_bbcode_usergroup_permissions['allow_bbcode_modwarn'])//this is set in the bitfield XML
{
//no permission
}

Darat
02-12-2006, 05:29 PM
I've got the advanced bbcode hack installed and working but if I post more then one tag in a thread only the first one is correctly parsed, the subsequent tags are ignored as if I had no permission.

Luggruff
02-15-2006, 11:20 AM
<bitfield name="allow_bbcode_admin" group="advanced_bbcode_permissions" phrase="allow_bbcode_admin">1024</bitfield>

<bitfield name="allow_bbcode_mod" group="advanced_bbcode_permissions" phrase="allow_bbcode_mod">2048</bitfield>


What is 1024 and 2048?

well,

if u use that hack called "advanced bbcode permissions" then something like this should work


if(!$vbulletin->userinfo['permissions']['advanced_bbcode_usergroup_permissions'] & !$vbulletin->bf_ugp_advanced_bbcode_usergroup_permissions['allow_bbcode_modwarn'])//this is set in the bitfield XML
{
//no permission
}


would work? instead of Darat's solution? And where to put it?

Details please !

Delphiprogrammi
02-15-2006, 08:22 PM
What is 1024 and 2048?


those are the bitfield values vbulletin uses to identify each bitfield you can read this (https://vborg.vbsupport.ru/showthread.php?t=82844) if you want to better understand it


would work? instead of Darat's solution? And where to put it?

Details please !

that code would check the value of a bitfield.I didn't check if it *does* work correctly.These two tags are a nice thing but it needs some way to reserve it for mods,supermods, or administrators.We need to figure out what hook location can be used to get that effect

Abe1
02-16-2006, 12:39 PM
Although I can't get it to work you can alter the Advanced bbcode permissions (https://vborg.vbsupport.ru/showthread.php?t=103747) mod to control the usergroups that can use the new tags.

Download the Advanced permission add-on and edit the bitfield_advancedbbcodepermissions.xml file to add these two lines to the group options:

<bitfield name="allow_bbcode_admin" group="advanced_bbcode_permissions" phrase="allow_bbcode_admin">1024</bitfield>

<bitfield name="allow_bbcode_mod" group="advanced_bbcode_permissions" phrase="allow_bbcode_mod">2048</bitfield>

Save that. Then open the product-advancedbbcodepermissions.xml file and add these two lines:

<phrase name="allow_bbcode_admin"><![CDATA[[ADMIN]]]></phrase>
<phrase name="allow_bbcode_mod"><![CDATA[[MOD]]]></phrase>

Save that file.

Then install the Advanced permissions product as per the instructions and you can then use that to control permissions to the new "admin" and "mod".

(Word of warning - I can't at the moment test this but it should work!)

Can you tell me why this should work? There is more then just adding bitfields to allow or not allow BBCODES. The bitfield numbers I use are vbulletin's numbers and I over ride them in my hack. Custom BBcodes dont get a bitfield. There is no reason why these insructions should work.

I am trying to work on a way to get permissions for custom bbcodes.

Darat
02-16-2006, 12:54 PM
Can you tell me why this should work? There is more then just adding bitfields to allow or not allow BBCODES. The bitfield numbers I use are vbulletin's numbers and I over ride them in my hack. Custom BBcodes dont get a bitfield. There is no reason why these insructions should work.

I am trying to work on a way to get permissions for custom bbcodes.

In the code to add to "class_bbcode" (that Wild-Wing posted) there is the code:

if ($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ADMINWARN)

Isn't that then using going to use the new bitcodes that we defined to control these new tags. And my extension to your hack then lets you switch them on and off in the admincp (and that seems to does work).

Abe1
02-16-2006, 12:58 PM
In the code to add to "class_bbcode" (that Wild-Wing posted) there is the code:

if ($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_ADMINWARN)

Isn't that then using going to use the new bitcodes that we defined to control these new tags. And my extension to your hack then lets you switch them on and off in the admincp (and that seems to does work).

I still dont understand. I think you are missing a word some where in your post.

Darat
02-16-2006, 01:01 PM
Wild Wing code adds the [admin] and [mod] tag into class_bbcode and like the standard bbcodes he does a check if a bit is set or not to see if someone has permission to use them. What I was trying to do was add setting those bits to your script so that they can be toggled in the admincp in your hack.

Abe1
02-16-2006, 01:03 PM
Wild Wing code adds the [admin] and [mod] tag into class_bbcode and like the standard bbcodes he does a check if a bit is set or not to see if someone has permission to use them. What I was trying to do was add setting those bits to your script so that they can be toggled in the admincp in your hack.

Got it.

I would not recommend adding to vb bitfields for 2 reasons.
1) What if vb added to it?
2) What if another coder addes to it? Best no coders add to it.

Darat
02-22-2006, 09:00 AM
Got it.

I would not recommend adding to vb bitfields for 2 reasons.
1) What if vb added to it?
2) What if another coder addes to it? Best no coders add to it.

All good points but if it worked reliably as I've tweaked it I'd take the chance on using it and deal with any future conflicts as they came up.. :)

Are you making progress in getting this to work without this type of hack?

Abe1
02-22-2006, 11:50 AM
All good points but if it worked reliably as I've tweaked it I'd take the chance on using it and deal with any future conflicts as they came up.. :)

Are you making progress in getting this to work without this type of hack?

100% yes.

I've been working on the hack for the past week. Hours and hours. Last night I finaly finished how to save custom BBcodes permissions. I have the usergroup settings page listing all custom bbcodes already. I have to get that page though to show the current settings now and then work on removing the custom bbcodes if you dont have permissions to use it. I have found the place to do it already.

Darat
02-22-2006, 12:05 PM
I suspect you are going to become even more popular when you release this!

Abe1
02-22-2006, 12:54 PM
I suspect you are going to become even more popular when you release this!

I think so also.

BTW, I just totaly completed the usergroup permissions. It works perfectly. The usergroup permissions page pulls all custom codes and gives you an option for them.

I will now be working to actualy remove the bbcodes not allowed to be used because of a setting.

Yorixz
02-22-2006, 01:12 PM
I can't wait till you release it Abe1, will it be an "upgrade" of your "Advanced BbCode Permissions"-hack or stand-alone?

Abe1
02-22-2006, 01:21 PM
I can't wait till you release it Abe1, will it be an "upgrade" of your "Advanced BbCode Permissions"-hack or stand-alone?

It will be a "MAJOR" upgrade.

Luggruff
02-23-2006, 05:19 AM
100% yes.

I've been working on the hack for the past week. Hours and hours. Last night I finaly finished how to save custom BBcodes permissions. I have the usergroup settings page listing all custom bbcodes already. I have to get that page though to show the current settings now and then work on removing the custom bbcodes if you dont have permissions to use it. I have found the place to do it already.

Man am I glad I asked for this ! :D ♥
(rofl? is there only green as fontcolor on this forum?? It's supposed to be Dark Red)

Yorixz
02-23-2006, 09:02 AM
Luggruff, yeah, they messed with the css ;)

Abe1
02-24-2006, 05:25 PM
Man am I glad I asked for this ! :D ♥
(rofl? is there only green as fontcolor on this forum?? It's supposed to be Dark Red)

All finished :) enjoy!

Yorixz
02-24-2006, 06:01 PM
I hope you don't mind, but I changed the code a little to make it some neater; <style> tags outside the <header> isn't too nice imho ;)

<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="smallfont"><strong>Administrator's Warning:</strong></span></td>
</tr>
<tr>
<td style="font-family: Verdana, Arial, Courier, Courier New; color: #465584; background-color: #FAFCFE; border: 1px dotted #000; padding: 2px; width:98%; margin: 0px auto 0px auto; overflow: auto; color: red; font-weight: bold"><img align="left" src="../images/mod.gif">{param}</td>
<tr>
</table>

Barakat
02-25-2006, 09:38 AM
love it very nice idea .

Nathan2006
03-11-2006, 01:46 PM
Great idea

Thank you :D

Install

Mecho
01-23-2007, 08:50 PM
thanks . great mod .

i installed Advanced BBcode Permissions , but that's not work at all with this mod . any idea ?

thanks

Chicago_VLNU_4s
01-26-2007, 06:40 AM
nice, very professional

AcidX
03-20-2007, 03:25 PM
Great hack, installed.
I installed Advanced BBCode Permissions too. Everyone should install it, unless you want users playing with the admin/mod codes.

VaaKo
04-20-2007, 08:00 AM
Long time I haven't checked this thread!

princeedward
05-07-2007, 11:15 PM
great hack...thanks ;)

sgrisole
11-25-2007, 11:55 PM
I installed this hack and Advanced BBCode Permissions to restrict the use of the [mod] tag to moderators but there's a problem: if a moderator edits a post written by another user, he can't use the [mod] tag inside that post. It seems that that the post inherits the BBCode permissions of the original author and even if you are a moderator you can't use [mod] within the user's post. Is there any way to fix this?

Attitude5ire
11-29-2007, 04:18 PM
Yes i second this bug.. Infact if a person does have permissions to use this bbcode, then they can even see this code used at all.. they jus see simple bbcode tags.. Hopefully there is a fix for this.

fariborz
05-21-2008, 03:39 PM
Please fix this problem :(