1

Topic: problem with parser.php since last upagrade

I'm using the modification of parser.php suggested by code xp in here

This mod worked without any problem

Since the last upgrade of punbb (1.2.7) I now got this error:
"Parse error: parse error, unexpected $ in /home/ju37853/forum/include/parser.php on line 511"

Any suggestion?

Ludo,

Re: problem with parser.php since last upagrade

Show us the lines around 511 please

3 (edited by Ludo 2005-09-07 21:02)

Re: problem with parser.php since last upagrade

511 is the last line of parser.php. There is anything. 511 is after the }.

You can see my parser.php here

Ludo,

Re: problem with parser.php since last upagrade

I'll look into it tomorrow, and if needed, fix the code smile

5

Re: problem with parser.php since last upagrade

thanks code xp wink

Ludo,

Re: problem with parser.php since last upagrade

Ok, here's the new code:

Open ./include/parser.php

Find, line 282:

//
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
//
function handle_img_tag($url, $is_signature = false)
{
    global $lang_common, $pun_config, $pun_user;

    $img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';

    if ($is_signature && $pun_user['show_img_sig'] != '0')
        $img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
    else if (!$is_signature && $pun_user['show_img'] != '0')
        $img_tag = '<img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

    return $img_tag;
}

Add after:

function handle_img_tag_left($url, $is_signature = false)
{
    global $lang_common, $pun_config, $pun_user;

    $img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';

    if ($is_signature && $pun_user['show_img_sig'] != '0')
        $img_tag = '<img class="sigimage_left" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
    else if (!$is_signature && $pun_user['show_img'] != '0')
        $img_tag = '<img class="postimg_left" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

    return $img_tag;
}
function handle_img_tag_right($url, $is_signature = false)
{
    global $lang_common, $pun_config, $pun_user;

    $img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';

    if ($is_signature && $pun_user['show_img_sig'] != '0')
        $img_tag = '<img class="sigimage_right" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
    else if (!$is_signature && $pun_user['show_img'] != '0')
        $img_tag = '<img class="postimg_right" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';

    return $img_tag;
}

Find, line 406:

            $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\')', $text);

Add after:

            $text = preg_replace('#\[img=left\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_left(\'$1$3\')', $text);
            $text = preg_replace('#\[img=right\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_right(\'$1$3\')', $text);

Find, line 467:

            $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\', true)', $text);

Add after:

            $text = preg_replace('#\[img=left\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_left(\'$1$3\', true)', $text);
            $text = preg_replace('#\[img=right\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag_left(\'$1$3\', true)', $text);

Save & upload.

7

Re: problem with parser.php since last upagrade

it works good now smile

Just because I'm curious, what was the problem with the new parser.php ?

Ludo,

Re: problem with parser.php since last upagrade

Ludo wrote:

it works good now smile

Just because I'm curious, what was the problem with the new parser.php ?

Ludo,

To be honest... I have no idea wink I didn't notice anything particular about the mod that could be causing this, but there was a few missing } in your parser.php file.

Anyway, seeing as it's such a simple tweak to add, I just re-wrote it to be sure smile