• Zitat von ST-O Keule

    Ups ... sorry habe das wichtigste vergessen


    Code
    $text = str_replace("&","&",$text);


    tut mir leid

    ich wollt' schon sagen :lol:

    Mess with the best, die like the rest

    • Offizieller Beitrag

    Hier das Script

    for posting code (HTML, PHP, C etc etc) in your posts.
    $text = bbencode_second_pass_code($text, $uid, $bbcode_tpl);
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    // PHP MOD
    // [PHP] and [/PHP] for posting PHP code in your posts.
    $text = bbencode_second_pass_php($text, $uid, $bbcode_tpl);
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    //

    Code
    and

    for posting code (HTML, PHP, C etc etc) in your posts.
    $text = bbencode_first_pass_pda($text, $uid, '

    Code
    ', '

    ', '', true, '');
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    // PHP MOD
    // [PHP] and [/PHP] for posting PHP code in your posts.
    $text = bbencode_first_pass_pda($text, $uid, '[php]', '[/php]', '', true, '');
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    } // bbencode_second_pass_code()
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    /**
    * PHP MOD
    * Does second-pass bbencoding of the [php] tags. This includes
    * running htmlspecialchars() over the text contained between
    * any pair of [php] tags that are at the first level of
    * nesting. Tags at the first level of nesting are indicated
    * by this format: [php:1:$uid] ... [/php:1:$uid]
    * Other tags are in this format: [php:$uid] ... [/php:$uid]
    *
    * Original code/function by phpBB Group
    * Modified by JW Frazier / Fubonis < php@fubonis.com >
    */
    function bbencode_second_pass_php($text, $uid, $bbcode_tpl)
    {
    global $lang;

    $html_entities_match = array("#<#", "#>#");
    $html_entities_replace = array("&lt;", "&gt;");

    $code_start_html = $bbcode_tpl['php_open'];
    $code_end_html = $bbcode_tpl['php_close'];

    // First, do all the 1st-level matches. These need an htmlspecialchars() run,
    // so they have to be handled differently.
    $match_count = preg_match_all("#\[php:1:$uid\](.*?)\[/php:1:$uid\]#si", $text, $matches);

    for ($i = 0; $i < $match_count; $i++)
    {
    $before_replace = $matches[1][$i];
    $after_replace = $matches[1][$i];

    $after_replace = preg_replace($html_entities_match, $html_entities_replace, $after_replace);

    // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
    $after_replace = str_replace(" ", " ", $after_replace);
    // now Replace 2 spaces with " " to catch odd #s of spaces.
    $after_replace = str_replace(" ", " ", $after_replace);

    // Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
    $after_replace = str_replace("\t", " ", $after_replace);

    $str_to_match = "[php:1:$uid]" . $before_replace . "[/php:1:$uid]";

    $replacement = $code_start_html;
    $after_replace = str_replace('&lt;', '<', $after_replace);
    $after_replace = str_replace('&gt;', '>', $after_replace);
    ob_start();
    highlight_string($after_replace);
    $after_replace = ob_get_contents();
    ob_end_clean();
    $replacement .= $after_replace;
    $replacement .= $code_end_html;

    $text = str_replace($str_to_match, $replacement, $text);
    }

    // Now, do all the non-first-level matches. These are simple.
    $text = str_replace("[php:$uid]", $code_start_html, $text);
    $text = str_replace("[/php:$uid]", $code_end_html, $text);
    $text = str_replace('&amp;nbsp;', '', $text);
    $text = str_replace('&amp;</font><font color="#0000CC">nbsp</font><font color="#006600">;', '', $text);
    $text = str_replace('&amp;</font><font color="#0000BB">nbsp</font><font color="#007700">;', '', $text);

    return $text;

    } // bbencode_second_pass_php()
    #
    #-----[ ACTION: CLOSE /includes/bbcode.php]------------------------------------------
    #
    #
    #-----[ ACTION: OPEN /templates/YOUR_TEMPLATE_NAME/bbcode.tpl]------------------------------------------
    #
    #
    #-----[ ACTION: FIND]------------------------------------------
    #

    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #

    </span>
    <table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
    <tr>
    <td><span class="genmed">{L_PHP}:</span></td>
    </tr>
    <tr>
    <td class="code">


    </td>
    </tr>
    </table>
    <span class="postbody">

    #
    #-----[ ACTION: CLOSE /templates/YOUR_TEMPLATE_NAME/bbcode.tpl]------------------------------------------
    #
    #
    #-----[ ACTION: OPEN /templates/YOUR_TEMPLATE_NAME/posting_body.tpl]------------------------------------------
    #
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    f_help = "{L_BBCODE_F_HELP}";
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    h_help = "{L_BBCODE_H_HELP}";
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    bbtags = new Array('','','','','','','

    Zitat

    ','

    ','

    Code
    ','

    ','

      ','

    ','

      ','

    ','','http://,');
    #
    #-----[ ACTION: REPLACE WITH]------------------------------------------
    #
    bbtags = new Array('','','','','','','

    Zitat

    ','

    ','

    Code
    ','

    ','

      ','

    ','

      ','

    ','','http://,','[php]<?php\n','\n?>[/php]');
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    <td><span class="genmed">
    <input type="button" class="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
    </span></td>
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    <td><span class="genmed">
    <input type="button" class="button" accesskey="h" name="addbbcode18" value="PHP" style="width: 40px" onClick="bbstyle(18)" onMouseOver="helpline('h')" />
    </span></td>
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    <select name="addbbcode18" onChange="bbfontstyle('[color=' + this.form.addbbcode18.options[this.form.addbbcode18.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">
    #
    #-----[ ACTION: REPLACE WITH]------------------------------------------
    #
    <select name="addbbcode20" onChange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]')" onMouseOver="helpline('s')">
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    <select name="addbbcode20" onChange="bbfontstyle('[size=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">
    #
    #-----[ ACTION: REPLACE WITH]------------------------------------------
    #
    <select name="addbbcode22" onChange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onMouseOver="helpline('f')">
    #
    #-----[ ACTION: CLOSE /templates/YOUR_TEMPLATE/posting_body.tpl]------------------------------------------
    #
    #
    #-----[ ACTION: OPEN /language/lang_YOUR_LANGUAGE/lang_main.php]------------------------------------------
    #
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    $lang['Code'] = "Code"; // comes before bbcode code output.
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    $lang['PHPCode'] = "PHP"; // PHP MOD
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    $lang['bbcode_f_help'] = "Font size: [size=x-small]small text[/size]";
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    $lang['bbcode_h_help'] = "PHP syntax highlighter. [php]<?php code ?>[/php] (alt+h)"; // PHP MOD
    #
    #-----[ ACTION: CLOSE language/lang_YOUR_LANGUAGE/lang_main.php]------------------------------------------
    #
    #
    #-----[ ACTION: OPEN /posting.php]------------------------------------------
    #
    #
    #-----[ ACTION: FIND]------------------------------------------
    #
    "L_BBCODE_F_HELP" => $lang['bbcode_f_help'],
    #
    #-----[ ACTION: ADD BELOW]------------------------------------------
    #
    "L_BBCODE_H_HELP" => $lang['bbcode_h_help'], // PHP MOD
    #
    #-----[ ACTION: CLOSE /posting.php]------------------------------------------
    #
    #
    #-----[ ACTION: UPLOAD YOUR FILES]------------------------------------------
    #[/code]

  • vielleicht liegt es irgendwo im script an einem htmlspecialchars, htmlentities oder ähnlich.
    diese funktionen setzen sonderzeichen wie & automatisch in die dazugehörigen codes wie &amp; um.
    ist dann aber komisch, dass andere sonderzeichen wie < und > nicht umgesetzt werden...

    aber auf jeden fall drin lassen, man kann ja auch AND statt && schreiben und so viele & brauchts in php auch nicht :wink: