vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Parse BBCode (in 3.5) (https://vborg.vbsupport.ru/showthread.php?t=82693)

DrewM 03-15-2006 10:11 PM

bump

Andreas 03-17-2006 02:54 AM

1) This not the place to ask question
2) Where do you set any values to $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable
?

STGU_daNo 03-27-2006 01:42 PM

Here is a question that is relevant to the thread:

Does the bbcode parser remove unwanted text, like if someone were to try submitting sql code? If not, what function removes code such as that? Is it simply addslashes?

I have an app that gets user text and stores it in the database, and I would like to be cautious and remove any possible threats to the system. I had put it in this thread but I have not had a response yet ... any help would be appreciated.

Andreas 03-27-2006 02:02 PM

Class vB_Input_Cleaner is what you want to have a look at.

Dot50Cal 05-05-2006 01:34 PM

Hi, Andreas or someone else maybe? I just finished porting a plugin which was very vital to my site after 3 days. I didnt know any php or sql before doing this so thats what took me so long. It took a whole lot of trial and error.

Basically the plugin Im using is PluhNews. I've converted it to work with Vbulletin 3.5, as its been broken ever since 3.0 came out. Anyway, I've now run into a slight snag. I dont know jack squat about parsing VB code. The way this plugin works is, it rips posts from a specified forum and displays them on a non forum page. Essentially a news ripper.

So as you can see here - http://www.thehorrorisalive.com none of the VB code is being parsed, and rightfully so because I have NO idea how to impliment your code here. Right now Im using the following code to display the posts content

PHP Code:

while ($row mysql_fetch_array($sql_result2)) { 
   
$pagetext $row["pagetext"]; 

So wherever I want the post to be put, I put $pagetext.

Im assuming I need to somehow bind your command to run after pagetext, but being a newbie to php and sql I have no clue on how to do that and every attempt has ended in failure. This is probably a really simple request, and Id appreciate it if anyone who could answer it helps me out. As soon as its done Ill release the upgraded hack, since a lot of people still would like to use PluhNews.

Besides that I have a small infinite loop whenver I try to include global.php, which Im still hunting for. So any help is greatly appreciated.

Aesma Deva 05-05-2006 08:43 PM

Try changing this:
PHP Code:

while ($row mysql_fetch_array($sql_result2)) {  
   
$pagetext $row["pagetext"]; 

To this:
PHP Code:

require_once(DIR '/includes/class_bbcode.php'); 
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
while (
$row mysql_fetch_array($sql_result2)) {  
   
$pagetext $parser->do_parse($row["pagetext"], falsetruetruetruetruefalse); 

(you can change the do_parse()'s arguments depending on what you want to parse, if you use it as I posted it now, HTML wouldn't be parsed, and smilies, BB code and the img BB code would be parsed)
I didn't understand your problem including global.php, though since it's a plugin and not an entirely new .php file, global.php should have already been included/requested.

Dot50Cal 05-09-2006 09:34 PM

Aesma, thank you very much! That solves my problem with my QUOTE tags not being translated to html! However I still have a serious error somewhere. You can see the page here
EDIT: FIXED!! WOO HOO!!!!

aridha 05-17-2006 01:10 AM

I have used the same code and every thing is fine exept the QUOTE tags

linc_ 06-29-2006 10:39 PM

Is there any way to define the HTML the parser will output to something else than the forum is using? For instance, to remove the "target="_blank"" from [url]'s and change the HTML that [QUOTE] is producing?

rogersnm 08-13-2006 02:25 PM

After it goes through the bbcode parser it should be <a href="link" target="_blank">text</a> instead of text. So you should be able to do a str replace to remove it.

harmor19 08-14-2006 09:15 PM

I liked to turn off the bbcode and have any bbcode stripped from the text.
I know how to turn off bbcode but how do I strip it?

bigtime 09-17-2006 07:41 PM

Hi,

Using 3.6.1 and trying to parse bbcode on a non-vb page at the bottom of http://www.defend.net.

Could someone please let me know how to correct this code so that the bbcode will be parsed? I read this thread and tried some things but couldn't get it working.

PHP Code:

<?php
    $num_active 
5;
    
$num_topicchars  110;

     
$db=mysql_connect("localhost","user","pass");
    
mysql_select_db("dbname");

    
$querylatest="select * from thread where forumid='1' or forumid='2' or forumid='3' or forumid='4' or forumid='5' or forumid='6' or forumid='7' or forumid='10' or forumid='11' or forumid='12' or forumid='13' or forumid='14' or forumid='15' or forumid='16' or forumid='17' or forumid='18' or forumid='19' or forumid='20' or forumid='22' or forumid='23' or forumid='25' or forumid='26' or forumid='27' or forumid='28' or forumid='29' or forumid='30' or forumid='31' or forumid='32' or forumid='34' or forumid='35' or forumid='36' or forumid='37' or forumid='38' order by lastpost desc limit $num_active";

    
$resultlatest mysql_query($querylatest,$db);

?>

<table width="100%" align="center" cellpadding="2" cellspacing="0">
  <?
    while ($latest_array = mysql_fetch_array($resultlatest)) {

    // Get Forum Infomation
    $query_forum = "select * from forum where forumid='$latest_array[forumid]'";
    
    $result_forum = mysql_query($query_forum,$db);
    $forum_info_array = mysql_fetch_array($result_forum);

        // split the date up a bit
        $datestr1 = substr($latest_array["dateline"],0,10);
    $datetime = substr($latest_array["dateline"],11,8);


?>
  <tr>
    <td align="left"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#335980"><? echo $forum_info_array["title"]; ?></font>:<br>
            <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><? echo $latest_array["title"]; ?></font></b></td>
  </tr>
  <?



    $querythread="select * from post where threadid='$latest_array[threadid]' order by dateline desc limit 1";

    $result_thread_text= mysql_query($querythread,$db);

    $result_thread_array = mysql_fetch_array($result_thread_text);


    $pagetext = substr(strip_tags($result_thread_array[pagetext]),0,$num_topicchars);
    ?>
  <td width="100%"><p align="left"><img src="/deluxeforums/images/statusicon/forum_new.gif"> <span class="style2"><? echo "$pagetext"; ?>... <a href="/deluxeforums/showthread.php?threadid=<? echo "$latest_array[threadid]"; ?>">(more)</a></span></p>
          <p align="left"><span class="style2">Started By: <? echo "$latest_array[postusername]"; ?> <br>
        Last Post By: <? echo "$latest_array[lastposter]"; ?> </span></p><hr align="center" width="80%">
      </td></tr>
     <?
     
}

     
?>
</table>


TYorke 11-24-2006 05:28 PM

Hi,

I am trying hard as well to include custom BB tags I have created myself but no go. The do_parse function will not include it as hard as I try. Same with Quotes, they are not being parsed at all. Did I miss a command somewhere?

I have this initially:

PHP Code:

    $bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list(), true);

        while(
$News $db->fetch_array($NewestNews)){
        
$Data .= ParseTemplate($Template,
                            array(
                                
'threadid'     => $News['threadid'],
                                
'threadname'   => $News['title'],
                                
'postuserid'   => $News['postuserid'],
                                
'postusername' => $News['postusername'],
                                
'post'         => $bbcode_parser->do_parse($News['pagetext'], falsetruetruetruetruefalse),
                                
'comments'     => vb_number_format($News['replycount']),
                                
'date'         => vbdate($vbulletin->options['dateformat'], $News['dateline']),
                                
'time'         => vbdate($vbulletin->options['timeformat'], $News['dateline']),
                                
'views'        => vb_number_format($News['views']),
                            )
            );
        } 

IMG does get parsed but so far Quotes and any custom BB codes do not.

Thanks for any help in advance

peterska2 12-06-2006 03:17 PM

If you require assistance with some code that you are writing, please use the programming discussions forum.

Thank you.

keithsl 01-16-2007 03:52 AM

I'm using this same code and I'm having some problems with Japanese text. I made a separate thread about it: https://vborg.vbsupport.ru/showthread.php?t=136248

Ducain 03-09-2007 11:46 PM

You guys rock. Thanks so much for sharing this information.

Mythotical 03-13-2008 07:38 PM

Ok my turn for help:

This is my code:
PHP Code:

                require_once(DIR '/includes/class_bbcode.php');
                
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
                
$thread['threadtitle'] = $parser->do_parse($thread['threadtitle'], $do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable); 
                
$threadbit =& $threadbits_sticky

Trying to get bbcoder for stickied threads to parse but it won't parse. If I change it any other way than it is now, it will make the sticky threads vanish.

Thanks
Steve

Opserty 03-13-2008 09:32 PM

Quote:

Originally Posted by Steve M (Post 1464074)
Ok my turn for help:

This is my code:
PHP Code:

                require_once(DIR '/includes/class_bbcode.php');
                
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
                
$thread['threadtitle'] = $parser->do_parse($thread['threadtitle'], $do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable); 
                
$threadbit =& $threadbits_sticky

Trying to get bbcoder for stickied threads to parse but it won't parse. If I change it any other way than it is now, it will make the sticky threads vanish.

Thanks
Steve

You need to find where the threadbit template is evaluated for stickied threads, ensure this code is placed just before it, also remove the last line, I don' think you need it.

Shane 03-14-2008 05:43 PM

In 3.7.x, I got every phrased, except the smiles, even though I pass "true" through:
PHP Code:

    function parse_bbcode()
    {
        
$this->data['message'] = $this->bbcode_parser->parse($this->data['pagetext'], ''$this->data['allowsmilie']);
    } 

"allowsmilie" does equal 1.

Mythotical 03-15-2008 04:18 AM

Opserty, thanks, I'll give it a go later.

--------------- Added [DATE]1205610787[/DATE] at [TIME]1205610787[/TIME] ---------------

Opserty: Tried that, makes all the sticky's vanish. So I'm not too sure, gonna keep playing with it and hope I figure it out.

hellbringer80 09-05-2008 03:53 AM

Wow great man, thanks, very useful!

tuursw 09-26-2008 10:58 AM

i want to use a script outside of the folder where the forum is installed, but when i include the global.php with "require_once('forum/global.php');" the my script doesn't works anymore..?

Do i need to include anything else which has the reference to the folder or so?

(when i put my script in the forum folder is seems to work fine)

BlackxRam 10-12-2008 10:52 AM

in 3.6 how can I get BBcode and Line Breaks to work properly in the Profile Pages? Especially in Custom Fields?

MTGDarkness 02-28-2009 09:27 AM

Two questions.
1. Does this work with 3.7.x?
2. What's the right syntax to make $text the combination of three variables? I have this right now:
Code:

if ($post[field11] && $post[field12])
{
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($text, $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable); 

$text = $post[field11].$message.$post[field12];
}

And in the postbit template, I intend to use a conditional to replace $message with $parsed_text if both fields are filled in. However, the message comes up as blank. I checked the source code and came up with just the start of the post div. I'm guessing it's because my syntax is wrong; specifically
Code:

$post[field11].$message.$post[field12]

Fox Mc Cloud 11-21-2009 10:48 AM

Quote:

Originally Posted by Andreas (Post 663634)
If you want to parse BBCodes somewhere in your hacks/scripts (assuming that global.php is already required):

PHP Code:

require_once(DIR '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
$parsed_text $parser->do_parse($text$do_html$do_smilies$do_bbcode$do_imgcode$do_nl2br$cachable); 

The parameters for method do_parse() are:
  • $text = Text to be parsed
  • $do_html = Whether to allow HTML or not (Default = false)
  • $do_smilies = Whether to parse smilies or not (Default = true)
  • $do_bbcode = Whether to parse BB code (Default = true)
  • $do_imgcode = Whether to parse the [img] BB code or not, independant of $do_bbcode (Default = true)
  • $do_nl2br = Whether to automatically replace new lines with HTML line breaks or not (Default = true)
    This should be set to false if you allow HTML.
  • $cachable = Whether the post text is cachable or not (Default = false)

All parameters except $text can be omitted and will use the defaults then.

Thanks, that was what I needed :D


All times are GMT. The time now is 06:47 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.01432 seconds
  • Memory Usage 1,849KB
  • 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
  • (2)bbcode_code_printable
  • (9)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete