PDA

View Full Version : Parsing html for certain members


Boofo
03-06-2003, 09:56 AM
When a member is replying to a message, the threadbitlist lists out below the replybox with all the posts from that thread. I want to be able to have it parse any html code that is in those message ONLY from the Admins and Supermods who the message belong to. If an Admin or Supermod wrote a message with html, I want to parse the html code so anyone reading it will see it like it should be. But not on anyone else's messages. Does this make any sense? ;)

Here is the code I am using so far and it doesn't quite work right, for some reason. Anyone have any idea what I am doing wrong?

if ($post[usergroupid]==6 OR $post[usergroupid]==5) {
$reviewmessage = bbcodeparse2($post[pagetext],1,1,1,1);
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

And it isn't a security risk doing this, is it? Only Admins and Mods are allowed to use html on the site. No one else.

Xenon
03-06-2003, 11:30 AM
it's ok and no security risk, but you have forgotten, that messages are preparsed also, so you have to edit newreply as well :)

Boofo
03-06-2003, 12:00 PM
Where would I out that in the newreply.php to parse the threadlisting below the replybox? And will that code work ok? I have been trying to find the place to put it but can't seem to get it to take. ;)

Xenon
03-06-2003, 12:07 PM
$title=censortext($title);
$message=censortext($message);

censortext calls bbcodepars at least it did last time ;)

Boofo
03-06-2003, 12:17 PM
It didn't work there. Any other ideas? :)

Kars10
03-06-2003, 01:03 PM
Hi Boofo!!
I have this goodie installed by Logician and it works like a charm. Its not the same that you want, but maybe it helps you... :)[Link (https://vborg.vbsupport.ru/showthread.php?postid=263707#post263707)]

Boofo
03-06-2003, 01:38 PM
I'm using the hack that only allows Admins and Supermods to use html and no one else. All I'm trying to do is get it to parse the html in the threadreview (the listing of messages below the newreply box when you are replying) for only those messages that belong to the Admins and Supermods. Everyone else's messages I want it to show the actual code and not parse it. And I'm close but not having very much luck. :(

Xenon
03-06-2003, 02:59 PM
oh sorry, i missread something ;)

you have to edit this part:
$posts=$DB_site->query("
SELECT IF(post.userid=0,post.username,user.username) AS username,
post.pagetext,post.allowsmilie,post.userid FROM post
LEFT JOIN user ON user.userid=post.userid
WHERE post.visible=1 AND post.threadid='$threadid'
ORDER BY dateline DESC LIMIT " . ($maxposts+1)); // return +1 so that check later will still work

$threadreviewbits = '';
while ($post=$DB_site->fetch_array($posts)) {
if ($postcounter++ < $maxposts) {
if ($postcounter%2 == 0) {
$backcolor = "{firstaltcolor}";
$post[bgclass] = "alt1";
} else {
$backcolor = "{secondaltcolor}";
$post[bgclass] = "alt2";
}
$username=$post[username];
if ($ignore[$post[userid]]) {
$reviewmessage = $ignoreduser;
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}
eval("\$threadreviewbits .= \"".gettemplate("threadreviewbit")."\";");
} else {
break;
}
}

andd the usergroupid to the query at first and then make your ifclause :)

Boofo
03-06-2003, 03:08 PM
Here's what I have for that piece of code.

$posts=$DB_site->query("
SELECT IF(post.userid=0,post.username,user.username) AS username,
post.pagetext,post.allowsmilie,post.userid FROM post
LEFT JOIN user ON user.userid=post.userid
WHERE ".iif($bbuserinfo[usergroupid]==5 or $bbuserinfo[usergroupid]==6 or $bbuserinfo[usergroupid]==7,"","post.visible=1 AND ")."post.threadid='$threadid'
ORDER BY dateline DESC LIMIT " . ($maxposts+1)); // return +1 so that check later will still work

$threadreviewbits = '';
while ($post=$DB_site->fetch_array($posts)) {
if ($postcounter++ < $maxposts) {
if ($postcounter%2 == 0) {
$backcolor = "{firstaltcolor}";
$post[bgclass] = "alt1";
} else {
$backcolor = "{secondaltcolor}";
$post[bgclass] = "alt2";
}
$username=$post[username];
if ($ignore[$post[userid]]) {
$reviewmessage = $ignoreduser;
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

if ($post[usergroupid]==6 OR $post[usergroupid]==5) {
$reviewmessage = bbcodeparse2($post[pagetext],1,1,1,1);
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

eval("\$threadreviewbits .= \"".gettemplate("threadreviewbit")."\";");
} else {
break;
}
}

How would I add it?

Xenon
03-06-2003, 03:10 PM
change this line:post.pagetext,post.allowsmilie,post.userid FROM post

into this:
post.pagetext,post.allowsmilie,post.userid,user.us ergroupid FROM post

Xenon
03-06-2003, 03:12 PM
and this code: if ($ignore[$post[userid]]) {
$reviewmessage = $ignoreduser;
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

if ($post[usergroupid]==6 OR $post[usergroupid]==5) {
$reviewmessage = bbcodeparse2($post[pagetext],1,1,1,1);
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

should be like this: if ($ignore[$post[userid]]) {
$reviewmessage = $ignoreduser;
} elseif ($post[usergroupid]==6 OR $post[usergroupid]==5) {
$reviewmessage = bbcodeparse2($post[pagetext],1,1,1,1);
} else {
$reviewmessage = bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
}

Boofo
03-06-2003, 03:25 PM
LOL I was close. I had already done the bottom code like you showed here. I just didn't have any idea about the posts query part of it. I'm not very good with queries yet. This is almost as bad as not including the $bbuserinfo in the global line for the navbar (the one you helped me with the other day). I don't feel as stupid about this one, though, but almost. :)

Thank you very much, sir. It works great now. ;)

Boofo
03-06-2003, 03:31 PM
Stefan, can you tell me why I add this to the query:

user.usergroupid

instead of this:

post.usergroupid

which is what I thought I needed. I'm just curious so maybe I can start to understand this. ;)

And, can you use else if the same way as elseif?

Xenon
03-06-2003, 03:58 PM
AFAIK there is no real difference between elseif and else if...

you have to use user.usergroupid, because the field usergroupid just exists in the user table, not in the post table :)

that's why there are these nice join queries ;)