vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   BB Code Functions (https://vborg.vbsupport.ru/showthread.php?t=63113)

Marco van Herwaarden 04-13-2005 03:49 AM

Just copy & paste the edited lines (with a few lines above and under).

smju 04-13-2005 11:43 AM

OK, just to reiterate. The error received was a Parse error "Unexpected $ at line ... in functions_bbcodeparse.php" (where the line number corresponded to the last line of the php program = "?>".

Here be the areas of code I changed / inserted. As previously described I put comments in "// SMJU001 ..." to indicate what I had done.


Hack Steps 27/28
PHP Code:

    $bbcodes['custom']['recurse']['highlight'][0] = array('replace_html' => "<span class=\"highlight\">\\7</span>");

    return 
$bbcodes;
}

// ###################### Start bbcodeparse #######################
// SMJU001 {Step 27/28}
//     this line replaced by the following one - function parse_bbcode($bbcode, $forumid = 0, $allowsmilie = 1, $isimgcheck = 0, $parsedtext = '', $parsedhasimages = 0, $iswysiwyg = 0)
function parse_bbcode($bbcode$forumid 0$allowsmilie 1$isimgcheck 0$parsedtext ''$parsedhasimages 0$iswysiwyg 0$postid '')
{
    
// $parsedtext contains text that has already been turned into HTML and just needs images checking
    // $parsedhasimages specifies if the text has images in that need parsing

    
global $vboptions$parsed_postcache

Hack Steps 29/30
PHP Code:

    else
    {
        if (
$isimgcheck)
        { 
// do this since we're only checking for smilies and IMG code
            
$dobbcode 0;
        }
// SMJU001 {step 29/30}
//    this line replaced with the following one        return parse_bbcode2($bbcode, $dohtml, $dobbimagecode, $dosmilies, $dobbcode, $iswysiwyg, $donl2br);
        
return parse_bbcode2($bbcode$dohtml$dobbimagecode$dosmilies$dobbcode$iswysiwyg$donl2br$postid);
    }
}

// ###################### Start checkparam ####################### 

Hack Steps 31/32
PHP Code:

    $return preg_replace('#%(?!\d+\$s)#''%%'$return);
    return 
sprintf($return$param$option);
}

// ###################### Start bbcodeparse2 #######################
// SMJU001 {steps 31/32}
//    this line replaced with the following one function parse_bbcode2($bbcode, $dohtml, $dobbimagecode, $dosmilies, $dobbcode, $iswysiwyg = 0, $donl2br = 1)
function parse_bbcode2($bbcode$dohtml$dobbimagecode$dosmilies$dobbcode$iswysiwyg 0$donl2br 1$postid '')
{
// parses text for vB code, smilies and censoring

    
global $DB_site$vboptions$bbuserinfo$templatecache$smiliecache

Hack Steps 33/34
PHP Code:

            default:
                
$parsefunc 'parse_bbcode_regexrecurse';
        }
// SMJU001 {steps 33/34}
//                  this line replaced with the following one        $bbcode = $parsefunc($bbcode, $iswysiwyg);
      
$bbcode $parsefunc($bbcode$iswysiwyg$postid);

        if (
$wysiwygtype == 'ie'

Hack Steps 35/36/37/38
PHP Code:

    $replace = array("\n""\n""\n");
    
$innertext str_replace($find$replace$innertext);

    return 
'</p>' $prepend $innertext '[/list]<p style="margin:0px">';
// SMJU001 {step 35/36} This code inserted

// ###################### Start handle_bbcode_function #######################

function handle_bbcode_function($BBCODES$bbcode$post_bbcode$singleRegex$doubleRegex)
{
    if (
$bbcode['twoparams'])
    {
        
$regex sprintf($doubleRegex$bbcode['bbcodetag'], $bbcode['bbcodetag']);
        
$tagname "[$bbcode[bbcodetag]=";
        
        
$checkparam 5;
        
$option_param ",'\\7'";
    }
    else
    {
        
$regex sprintf($singleRegex$bbcode['bbcodetag'], $bbcode['bbcodetag']);
                    
        
$tagname "[$bbcode[bbcodetag]]";
        
$checkparam 4;
    }
    
    
$BBCODES['custom']['find']["$tagname"] = $regex;
    
    if (
$bbcode['bbcode_functionid'])
    {
        if (
$bbcode['include_file'])
        {
            
$BBCODES['custom']['include_file']["$tagname"] = $bbcode['include_file'];
        }
                
        
$BBCODES['custom']['replace']["$tagname"] = "@$bbcode[handle]('\\$checkparam'$option_param)";
                
        if (!
$bbcode['refresh'] && $post_bbcode)
        {
            if (
$bbcode['include_file'])
            {
                @include_once(
$bbcode['include_file']);
            }
                    
            if (
stristr($post_bbcode$tagname) !== false)
            {
                
$post_bbcode preg_replace($BBCODES['custom']['find']["$tagname"], $BBCODES['custom']['replace']["$tagname"], $post_bbcode);
                
$BBCODES['do_postupdate'] = 1;
            }
        }
    }
    else
    {
        
$BBCODES['custom']['replace']["$tagname"] = "handle_bbcode_parameter('\\$checkparam','" str_replace("'""\'"$bbcode['bbcodereplacement']) . "')";
    }
    
    unset(
$option_param);
    
    
    if (
$post_bbcode)
    {
        return 
$BBCODES;
    }
    else
    {
        
$BBCODE['replacement'] = $BBCODES['custom']['replace']["$tagname"];
        
$BBCODE['regex'] = $BBCODES['custom']['find']["$tagname"];
        
$BBCODE['include_file'] = $BBCODES['custom']['include_file']["$tagname"];
        
        return 
$BBCODE;
    }
}
// SMJU001 {step 36} End of inserted code


// ###################### Start bbcodeparse2_regexrecurse #######################
//SMJU001 {steps 37/38}
//                this line replaced by the following one - function parse_bbcode_regexrecurse($bbcode, $iswysiwyg)
function parse_bbcode_regexrecurse($bbcode$iswysiwyg$postid '')
{
    global 
$DB_site$vboptions$bbuserinfo$templatecache$datastore$wysiwygparse$session;
    static 
$BBCODES

Hack Steps 39/40/41/42/43/44
Note that I found the search text in step 43 twice in the file, therefore I inserted the code in step 44 twice. The duplicate area is further down the post.
PHP Code:

    $wysiwygparse $iswysiwyg;

    if (empty(
$BBCODES['standard']))
    {
        
$BBCODES fetch_bbcode_definitions();

        
$doubleRegex '/(\[)(%s)(=)(&quot;|"|\'|)([^"]*)(\\4)\](.*)(\[\/%s\])/esiU';
        
$singleRegex '/(\[)(%s)(\])(.*)(\[\/%s\])/esiU';
/* SMJU001 {step 39 / 41} This section of code replaced
        if (isset($datastore['bbcodecache'])) // get bbcodes from the datastore
        {
            $bbcodecache = unserialize($datastore['bbcodecache']);

            foreach ($bbcodecache AS $bbregex)
            {
                if ($bbregex['twoparams'])
                {
                    $regex = sprintf($doubleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    $bbregex['bbcodereplacement'] = str_replace(array('\\7', '\\5'), array('%1$s', '%2$s'), $bbregex['bbcodereplacement']);
                    $tagname = "[$bbregex[bbcodetag]=";
                    $checkparam = '\\7';
                    $checkoption = '\\5';
                }
                else
                {
                    $regex = sprintf($singleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    $bbregex['bbcodereplacement'] = str_replace('\\4', '%1$s', $bbregex['bbcodereplacement']);
                    $tagname = "[$bbregex[bbcodetag]]";
                    $checkparam = '\\4';
                    $checkoption = '';
                }
                $BBCODES['custom']['find']["$tagname"] = $regex;
                $BBCODES['custom']['replace']["$tagname"] = "handle_custom_bbcode('$checkparam', '$checkoption', '" . str_replace("'", "\'", $bbregex['bbcodereplacement']) . "')";
            }
        }
        else // query bbcodes out of the database
        {
            $bbcodes = $DB_site->query("
                SELECT bbcodetag, bbcodereplacement, twoparams
                FROM " . TABLE_PREFIX . "bbcode
            ");
            while ($bbregex = $DB_site->fetch_array($bbcodes))
            {
                if ($bbregex['twoparams'])
                {
                    $regex = sprintf($doubleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    $bbregex['bbcodereplacement'] = str_replace(array('\\7', '\\5'), array('%1$s', '%2$s'), $bbregex['bbcodereplacement']);
                    $tagname = "[$bbregex[bbcodetag]=";
                    $checkparam = '\\7';
                    $checkoption = '\\5';
                }
                else
                {
                    $regex = sprintf($singleRegex, $bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    $bbregex['bbcodereplacement'] = str_replace('\\4', '%1$s', $bbregex['bbcodereplacement']);
                    $tagname = "[$bbregex[bbcodetag]]";
                    $checkparam = '\\4';
                    $checkoption = '';
                }
                $BBCODES['custom']['find']["$tagname"] = $regex;
                $BBCODES['custom']['replace']["$tagname"] = "handle_custom_bbcode('$checkparam', '$checkoption', '" . str_replace("'", "\'", $bbregex['bbcodereplacement']) . "')";
            }
        }
// SMJU001 {step 39 / 41} end of code section to be replaced */
// SMJU001 {step 40 / 42} Replacement code - start
        
if (isset($datastore['bbcodecache'])) // get bbcodes from the datastore
        
{
            
$bbcodecache unserialize($datastore['bbcodecache']);
            
            foreach(
$bbcodecache AS $bbregex)
            {
                
$BBCODES handle_bbcode_function($BBCODES$bbregex, &$bbcode$singleRegex$doubleRegex);
            }
        }
        else 
// query bbcodes out of the database
        
{
            
$bbcodes $DB_site->query("
                SELECT bbcode.bbcodetag, bbcode.bbcodereplacement, bbcode.twoparams, 
                bbcode_function.handle, bbcode_function.include_file
                FROM " 
TABLE_PREFIX "bbcode
                LEFT JOIN " 
TABLE_PREFIX "bbcode_function 
                USING (bbcode_functionid)
            "
);
            
            while (
$bbregex $DB_site->fetch_array($bbcodes))
            {
                
$BBCODES handle_bbcode_function($BBCODES$bbregex$bbcode$singleRegex$doubleRegex);
            }
        }
// SMJU001 {step 40 / 42} Replacement code - end
    
}

// SMJU001 {step 43 / 44} Inserted Code - start
    
if ($BBCODES['do_postupdate'] && $postid// Hard code the retuned function value
    
{
        
$DB_site->query("
            UPDATE post 
            SET pagetext='"
.addslashes(str_replace('<br />'''html_entity_decode($bbcode)))."' 
            WHERE postid=
$postid");
    }
    
// SMJU001 {step 43 / 44} Inserted Code - End    
    
    
if ($iswysiwyg// text to show in the WYSIWYG editor box
    
{
        
$bbcode_find $BBCODES['standard']['find'];
        
$bbcode_replace $BBCODES['standard']['replace'];
    } 

Hack Steps 45/46
PHP Code:

    else // text to show everywhere else
    
{
        
//$bbcode_find = array_merge($BBCODES['standard']['find'], $BBCODES['custom']['find']);
        //$bbcode_replace = array_merge($BBCODES['standard']['replace'], $BBCODES['custom']['replace']);

        
$bbcode_find array_merge($BBCODES['custom']['find'], $BBCODES['standard']['find']);
        
$bbcode_replace array_merge($BBCODES['custom']['replace'], $BBCODES['standard']['replace']);

// SMJU001 {steps 45 / 46} Inserted code - start
        
if ($BBCODES['custom']['include_file'])
        {
            
$include_file $BBCODES['custom']['include_file'];
        }
// SMJU001 {steps 45 / 46} Inserted code - end
    
}

    foreach(
$bbcode_find AS $tag => $findregex)
    {
        
// if using option, $tag will be '[xxx='
        // if not using option, $tag will be '[xxx]'

        
while (stristr($bbcode$tag) !== false

Hack Steps 47/48
PHP Code:

        while (stristr($bbcode$tag) !== false)
        {
// SMJU001 {steps 47 / 48} Inserted code - start
            
if ($include_file["$tag"])
            {
                @include_once(
$include_file["$tag"]);
            }
// SMJU001 {steps 47 / 48} Inserted text - end
            // make a copy of the text pre-replacement for later comparison
            
$origtext $bbcode;

            
$bbcode preg_replace($findregex$bbcode_replace["$tag"], $bbcode); 

Hack Steps 43/44: In the hack instructions step 43 gave a search string. I therefore inserted the code twice, in both places.
PHP Code:

            while($bbregex $DB_site->fetch_array($bbcodes))
            {
                if (
$bbregex['twoparams'])
                {
                    
$regex sprintf($doubleRegex$bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    
$checkparam 7;
                }
                else
                {
                    
$regex sprintf($singleRegex$bbregex['bbcodetag'], $bbregex['bbcodetag']);
                    
$checkparam 4;
                }
                for (
$i 0$i 3$i++)
                {
                    
$BBCODES['custom']['find'][] = $regex;
                    
$BBCODES['custom']['replace'][] = "handle_bbcode_parameter('\\$checkparam','" str_replace("'","\'",$bbregex['bbcodereplacement']) . "')";
                }
            }
        }
    }
    
// SMJU001 Step 43/44 Inserted Code - start
//     I found the search string twice, so I sinserted it twice.

    
if ($BBCODES['do_postupdate'] && $postid// Hard code the retuned function value
    
{
        
$DB_site->query("
            UPDATE post 
            SET pagetext='"
.addslashes(str_replace('<br />'''html_entity_decode($bbcode)))."' 
            WHERE postid=
$postid
        "
);
    }
// SMJU001 Inserted Code - End    

    
if ($iswysiwyg// text to show in the WYSIWYG editor box
    
{
        
$bbcode_find $BBCODES['standard']['find'];
        
$bbcode_replace $BBCODES['standard']['replace'];
    } 


smju 04-16-2005 08:07 AM

One bit of info I forgot to add, was that I got the error after selecting the "Custom BB Code" option off the "Admin CP" menu.

smju 04-25-2005 03:52 PM

Hmmm.

I wonder if the lack of a response is due to me actually applying the changes correctly.

Hmmm.

Marco van Herwaarden 04-25-2005 08:52 PM

Well i don't see anything wrong when quickly browsing through it.

What editor did you use?

smju 04-28-2005 08:45 AM

HTML-Kit.

I am wondering if the problem was in step 43 where the instructions only indicate 1 occurance of the search string and I found 2. Should I only have inserted the code once? and if so at which point.

It gratifies me someone else has looked and can't spot a problem, I was pulling my hair out looking for a accidentally erased / misplaced semi-colon.

smju 07-05-2005 11:53 AM

bump

smju 11-27-2005 02:52 PM

I never did get this implemented, however we are now on 3.5.1 sooooooooo

Any chance that this mod is going to get ported to 3.5?


All times are GMT. The time now is 08:10 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.01513 seconds
  • Memory Usage 1,886KB
  • 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
  • (9)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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