1

Topic: Short URL (no domain) In BBCode?

I'm making an extension where I'm using [img]path/file.jpg[/img] for uploaded (local) files (base href="/" is in <head>).

It's making me use the domain in the path. eg: http://domain.com/forum/path/file.txt

What do I need to change in the parser to allow "img" and "url" bbcode to use just "path/file.txt"?

Re: Short URL (no domain) In BBCode?

Hook ps_do_bbcode_replace. Add code

    if (($is_signature && $forum_config['p_sig_img_tag'] == '1') || (!$is_signature && $forum_config['p_message_img_tag'] == '1'))
    {
        $pattern[] = '#\[img\]([^\s<"]*?)\[/img\]#e';
        $pattern[] = '#\[img=([^\[]*?)\]([^\s<"]*?)\[/img\]#e';
        if ($is_signature)
        {
            $replace[] = 'handle_img_tag(\'$1\', true)';
            $replace[] = 'handle_img_tag(\'$2\', true, \'$1\')';
        }
        else
        {
            $replace[] = 'handle_img_tag(\'$1\', false)';
            $replace[] = 'handle_img_tag(\'$2\', false, \'$1\')';
        }
    }

The code didn't test. Possibly links can incorrectly be created.

ForkBB
I speak only Russian  :P

3

Re: Short URL (no domain) In BBCode?

Thank you!

I didn't end up using it, but did find where I would need to change it!

To avoid adding to preg_replace(), I'm removing it at the end with strpos() / str_replace().

 <hook id="ps_parse_message_end"><![CDATA[
  if (strpos($text, 'http://img/')) $text = str_replace('http://img/', 'img/', $text);
 ]]></hook>

This way it only effects links having to do with my extension (in progress), and not any others.

Also, I didn't end up needing to add "base href".. smile

Re: Short URL (no domain) In BBCode?

scrutinize

sorry my BAD english T___T
Have a nice day >.<
(^____^)v

5

Re: Short URL (no domain) In BBCode?

pear wrote:

I'm making an extension where I'm using [img]path/file.jpg[/img] for uploaded (local) files (base href="/" is in <head>).

It's making me use the domain in the path. eg: http://domain.com/forum/path/file.txt

What do I need to change in the parser to allow "img" and "url" bbcode to use just "path/file.txt"?

Incorrect code incorrect connection