vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Parsing html for certain members (https://vborg.vbsupport.ru/showthread.php?t=49709)

Boofo 03-06-2003 09:56 AM

Parsing html for certain members
 
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?

PHP Code:

    if ($post[usergroupid]==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

PHP Code:

    $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]

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:
PHP 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 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%== 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.

PHP 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]==or $bbuserinfo[usergroupid]==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%== 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]==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:
PHP Code:

post.pagetext,post.allowsmilie,post.userid FROM post 

into this:
PHP Code:

post.pagetext,post.allowsmilie,post.userid,user.usergroupid FROM post 


Xenon 03-06-2003 03:12 PM

and this code:
PHP Code:

          if ($ignore[$post[userid]]) {
                
$reviewmessage $ignoreduser;
            } else {
                
$reviewmessage bbcodeparse($post[pagetext],$threadinfo[forumid],$post[allowsmilie]);
            }

    if (
$post[usergroupid]==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:
PHP Code:

          if ($ignore[$post[userid]]) {
                
$reviewmessage $ignoreduser;
            } elseif (
$post[usergroupid]==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 [high]else if[/high] the same way as [high]elseif[/high]?

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 ;)


All times are GMT. The time now is 10:17 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.01587 seconds
  • Memory Usage 1,798KB
  • 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
  • (8)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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