View Single Post
  #43  
Old 04-13-2005, 11:43 AM
smju smju is offline
 
Join Date: Nov 2004
Location: Kent, U.K.
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'];
    } 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01510 seconds
  • Memory Usage 1,989KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete