MyBB Community Forums

Full Version: Parse links within [CODE] tags
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
After much searching, I still cannot find a solution to my dilemma. I'd like to parse all links within code tags; for what I am doing, I'd like to use code tags instead of quote tags.

Here is the effect I'm trying to achieve:

[Image: mwsnap259.png]

Here is the code from class_parser.php:

* Parses code MyCode.
    *
    * @param string The message to be parsed
    * @param boolean Are we formatting as text?
    * @return string The parsed message.
    */
    function mycode_parse_code($code, $text_only=false)
    {
        global $lang;

        if($text_only == true)
        {
            return "\n{$lang->code}\n--\n{$code}\n--\n";
        }

        // Clean the string before parsing.
        $code = preg_replace('#^(\t*)(\n|\r|\0|\x0B| )*#', '\\1', $code);
        $code = rtrim($code);
        $original = preg_replace('#^\t*#', '', $code);

        if(empty($original))
        {
            return;
        }

        $code = str_replace('$', '$', $code);
        $code = preg_replace('#\$([0-9])#', '\\\$\\1', $code);
        $code = str_replace('\\', '\', $code);
        $code = str_replace("\t", '    ', $code);
        $code = str_replace("  ", '  ', $code);
                $lcurl = 'http://wgtools.com/link-checker/?url=' . urlencode($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
                $wglc = ' [<a href="' . $lcurl .'" target="_blank"><strong>Check Links</strong></a>]';


        return "<div class=\"codeblock\">\n<div class=\"title\">".$lang->code.$wglc."\n</div><div class=\"body\" dir=\"ltr\"><code>".$code."</code></div></div>\n";
    }

    /**

I'd really appreciate the help. Blush
Can you give us your link of forum?
(2011-02-03, 02:21 PM)JovanJ. Wrote: [ -> ]Can you give us your link of forum?

Is it really neccesary? I mean, I don't mind showing you but the code is all I really need. Undecided

This has been asked for multiple times, and no one has been willing to do it simply because there is no reason for it. Nothing wrong with using Quote Tags in most peoples' minds. Most forums that want this, use it for illegal file sharing links anyways, to make it have to be manually copied and pasted into the address bar to prevent the site being shown as a referrer.