Witam
Może wy coś poradzicie bo ja się zaciełem i nic nie moge wymyśleć.
Przerobiłem sobie moda PHP Syntax Highlighter BBCode tak, zeby pokazywalo mi tekst a'la quote w tagach text. Oto cały kod z bbcode.php:
Kod:
$bbcode_tpl['text_open'] = str_replace('{L_TEXT}', $lang['Text'], $bbcode_tpl['text_open']); // PHP MOD
@@@@@@@@@@@@@@@@@@
$text = bbencode_second_pass_text($text, $uid, $bbcode_tpl);
@@@@@@@@@@@@@@@@@@
$text = bbencode_first_pass_pda($text, $uid, '[text]', '[/text]', '', true, '');
@@@@@@@@@@@@@@@@@@
function bbencode_second_pass_text($text, $uid, $bbcode_tpl)
{
global $lang;
$html_entities_match = array("#<#", "#>#");
$html_entities_replace = array("<", ">");
$code_start_html = $bbcode_tpl['text_open'];
$code_end_html = $bbcode_tpl['text_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("#\[text:1:$uid\](.*?)\[/text: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 = "[text:1:$uid]" . $before_replace . "[/text:1:$uid]";
$replacement = $code_start_html;
$after_replace = str_replace('<', '<', $after_replace);
$after_replace = str_replace('>', '>', $after_replace);
ob_start();
highlight_string($after_replace);
$after_replace = ob_get_contents();
ob_end_clean();
$replacement .= $after_replace;
$replacement .= $code_end_html;
if( !$userdata['session_logged_in'] )
{
$text = str_replace($str_to_match, $replacement, $text);
}
else
{
$text = str_replace($str_to_match, 'Musisz byc zalogowany', $text);
}
}
// Now, do all the non-first-level matches. These are simple.
$text = str_replace("[text:$uid]", $code_start_html, $text);
$text = str_replace("[/text:$uid]", $code_end_html, $text);
return $text;
}
i teraz chce zeby treść w text widzieli zarejestrowani userzy, a goście aby widzieli tekst: Tu był kod, ale go myszy zjadły. Jak chcesz go widzieć, to się zaloguj
Wie ktoś jak coś takiego zrobic ?
btw. wiem ze kod jest daleki od ideału, ale to dla własnego forum tylko
APF 2.0 - patch | phpBB2 r0x | BeerMod 1.0.0 RC3 | My MODs