(nie mogę użyć BBCODE {php} bo przy wyrażeniach regularnych sie zaczyna krzaczyć)
Kod
Function pokazhtml($str){
//$str = str_replace ( '&', '&', $str);
//$str = str_replace ( ''', "'", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("<br />", "", $str);
$str = str_replace ('"', '"', $str);
return $str;}
function phpHighlight($text){
$text = str_replace('[php]', "[php]<?php\n", $text);
$text = str_replace('[/php]', "\n?>[/php]", $text);
$temp = '';
$st = 0;
$c = preg_match_all('#\[php](.+?)\[/php]#is', $text, $m, PREG_PATTERN_ORDER|PREG_OFFSET_CAPTURE);
for($x = 0; $x < $c; $x++) {
$temp .= substr($text, $st, $m[0][$x][1] - $st).tloNumeracja(highlight_string(pokazhtml(str_replace('<br />', '', $m[1][$x][0])), true));
$st = $m[0][$x][1] + strlen($m[0][$x][0]);}
return ($st > 0) ? $temp . substr($text, $st) : $text;}
Function tloNumeracja($input){
$scheiden = explode("<br />", $input);
$regels = count($scheiden);
$return = "<table cellpadding=2 cellspacing=0 width='100%' style='table-layout:fixed;'>";
$return .= "<tr><td bgcolor=#D3D3D3 align=right width='25'><font color=\"#000000\">";
$return .= "";
for($i=1; $i <= $regels; $i++){$return .= $i."<br>";}
$return .= "</font></td><td bgcolor=#FBFBFB>";
$return .= $input;
$return .= "</td></tr></table>";
return $return;}
Function bbcode($str){
$str=nl2br(stripslashes(htmlspecialchars(trim($str))));
$str = preg_replace("#\[b\](.*?)\[/b\]#si", "<b>\\1</b>", $str);
$str=phpHighlight($str);
return $str;}
//$str = str_replace ( '&', '&', $str);
//$str = str_replace ( ''', "'", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("<br />", "", $str);
$str = str_replace ('"', '"', $str);
return $str;}
function phpHighlight($text){
$text = str_replace('[php]', "[php]<?php\n", $text);
$text = str_replace('[/php]', "\n?>[/php]", $text);
$temp = '';
$st = 0;
$c = preg_match_all('#\[php](.+?)\[/php]#is', $text, $m, PREG_PATTERN_ORDER|PREG_OFFSET_CAPTURE);
for($x = 0; $x < $c; $x++) {
$temp .= substr($text, $st, $m[0][$x][1] - $st).tloNumeracja(highlight_string(pokazhtml(str_replace('<br />', '', $m[1][$x][0])), true));
$st = $m[0][$x][1] + strlen($m[0][$x][0]);}
return ($st > 0) ? $temp . substr($text, $st) : $text;}
Function tloNumeracja($input){
$scheiden = explode("<br />", $input);
$regels = count($scheiden);
$return = "<table cellpadding=2 cellspacing=0 width='100%' style='table-layout:fixed;'>";
$return .= "<tr><td bgcolor=#D3D3D3 align=right width='25'><font color=\"#000000\">";
$return .= "";
for($i=1; $i <= $regels; $i++){$return .= $i."<br>";}
$return .= "</font></td><td bgcolor=#FBFBFB>";
$return .= $input;
$return .= "</td></tr></table>";
return $return;}
Function bbcode($str){
$str=nl2br(stripslashes(htmlspecialchars(trim($str))));
$str = preg_replace("#\[b\](.*?)\[/b\]#si", "<b>\\1</b>", $str);
$str=phpHighlight($str);
return $str;}
która ma fajnie formatować kod php.
Zarzucam prościuchny pliczek
<?php include(\"bbcode.php\"); $str=\"byle co nie pisze znaczników bbcode bo skrypt forumowy się krzaczy\"; ?>
i otrzymuję błąd:
Cytat
Warning: Wrong parameter count for highlight_string() in c:\apache\htdocs\phpstart\extensions\bbcode.php on line 18
Problem w tym, że błąd wyskakuje na moim kompiem podczas gdy na serwecie już działa. ERROR_REPORTING mam ustawiony domyślnie.
Nie proszę o gotowe rozwiązanie tylko podpowiedź w którą stronę muszę pójść.