Some bits of php code are converted to smilies

Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at ****/includes/bbcode.php:860) in ***/viewtopic.php on line 555
Warning: Cannot modify header information - headers already sent by (output started at ******/includes/bbcode.php:860) in ********/includes/page_header.php on line 474
Warning: Cannot modify header information - headers already sent by (output started at ********/includes/bbcode.php:860) in ********/includes/page_header.php on line 476
Warning: Cannot modify header information - headers already sent by (output started at ******/includes/bbcode.php:860) in *******/includes/page_header.php on line 477
_spin_ wrote: sander marechal,
do you mind describing how you managed to convert the mod for C/C++?
I'm afraid I don't have access to php.ini and I am not sure how (and where) to use ini_set.
Code: Select all
/**
* CPP MOD
* Original code/function by phpBB Group
* Modified by JW Frazier / Fubonis < php_fubonis@yahoo.com > for PHP highlighting
* Modified again by Sander Maréchal < s.marechal@jejik.com > for C/C++ highlighting
*/
function bbencode_second_pass_cpp($text, $uid, $bbcode_tpl)
{
//split the post up and grab the code blocks
$code_start_html = $bbcode_tpl['cpp_open'];
$code_end_html = $bbcode_tpl['cpp_close'];
$matches = array();
$match_count = preg_match_all("#\[cpp:1:$uid\](.*?)\[/cpp:1:$uid\]#si", $text, $matches);
//this array holds all the C++ keywords. They will be highlighted in blue
$cppcodearray = array ("__abstract", "__alignof", "__asm", "__assume",
"__based", "__box", "__cdecl", "__declspec",
"__delegate", "__event", "__except", "__fastcall",
"__finally", "__forceinline", "__gc", "__hook",
"__identifier", "__if_exists", "__if_not_exists", "__inline",
"__int8", "__int16", "__int32", "__int64",
"__interface", "__leave", "__m64", "__m128",
"__m128d", "__m128i", "__multiple_inheritance", "__nogc",
"__noop", "__pin", "__property", "__raise",
"__sealed", "__single_inheritance", "__stdcall", "__super",
"__try_cast", "__try/__except", "__try/__finally", "__unhook", "__uuid_of",
"__value", "__virtual_inheritance", "__w64", "asm", "bool",
"break", "case", "catch", "char",
"class", "const", "const_cast", "continue",
"default", "delete", "deprecated", "dllexport",
"dllimport", "do", "double", "dynamic_cast",
"else", "enum", "explicit", "extern",
"false", "float", "for", "friend",
"goto", "if", "inline", "int",
"long", "mutable", "naked", "namespace",
"new", "noinline", "noreturn", "nothrow",
"novtable", "operator", "private", "property",
"protected", "public", "register", "reinterpret_cast",
"return", "selectany", "short", "signed",
"sizeof", "static", "static_cast", "struct",
"switch", "template", "this", "thread",
"throw", "true", "try", "typedef",
"typeid", "typename", "union", "unsigned",
"using", "uuid", "virtual", "void",
"volatile", "__wchar_t", "while",
"#define", "#error", "#import", "#undef",
"#elif", "#if", "#include", "#using",
"#else", "#ifdef", "#line", "#endif",
"#ifndef", "#pragma");
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = trim($matches[1][$i]);
$str_to_match = "[cpp:1:$uid]" . $before_replace . "[/cpp:1:$uid]";
$replacement = $code_start_html;
//replace the anti-HTML code with the real symbols
$after_replace = str_replace('<', '<', $after_replace);
$after_replace = str_replace('>', '>', $after_replace);
$after_replace = str_replace('&', '&', $after_replace);
//loop though all the keywords in the array and see if it is in the code text. If so,
//add <span style='color: #0000FF;'></span> to it. This function will match about
//99.9% of the keywords.
foreach ($cppcodearray as $cppcodetag)
{
$after_replace = ereg_replace("([^a-zA-Z0-9<>])(".$cppcodetag.")([^a-zA-Z0-9<>])", "\\1<span style='color: #0000FF;'>\\2</span>\\3", $after_replace);
}
//start of a block of cpp comments (comment will becode green)
$after_replace = ereg_replace("/\\*", "<span style='color: #007700;'>\\0", $after_replace);
//end of a comment block
$after_replace = ereg_replace("\\*/", "\\0</span>", $after_replace);
//a single line comment (green)
$after_replace = ereg_replace("(//[^\\\n]*)(\\\n)", "<span style='color: #007700;'>\\1</span>\\2", $after_replace);
//anything between square brackets (for arrays) will be red
$after_replace = ereg_replace("(\\[)([^]]*)(\\])", "\\1<span style='color: #770000;'>\\2</span>\\3", $after_replace);
//highlights text-strings
$after_replace = ereg_replace("\"[^\"]*\"", "<span style='color: #007777'>\\0</span>", $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);
// now Replace space occurring at the beginning of a line
$after_replace = preg_replace("/^ {1}/m", ' ', $after_replace);
//piece the post back together
$replacement .= $after_replace;
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
$text = str_replace("[cpp:$uid]", $code_start_html, $text);
$text = str_replace("[/cpp:$uid]", $code_end_html, $text);
return $text;
}
Code: Select all
Parse error: parse error in /home3/corrupte/public_html/forum/includes/bbcode.php on line 203
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/includes/sessions.php on line 293
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/includes/sessions.php on line 294
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/viewtopic.php on line 563
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/includes/page_header.php on line 474
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/includes/page_header.php on line 476
Warning: Cannot modify header information - headers already sent by (output started at /home3/corrupte/public_html/forum/includes/bbcode.php:203) in /home3/corrupte/public_html/forum/includes/page_header.php on line 477
Code: Select all
Fatal error: Call to undefined function: bbencode_second_pass() in /home3/corrupte/public_html/forum/viewtopic.php on line 1119
Code: Select all
syntax color mod, would this make a difference? I don't see how this would affect this version of this mod.
However, would using the same string value of [0] for both the [code] and [php] buttons affect how the $lang would be affected?
[color=red]EDITED[/color]: I made some changes that work for this mod. Although they work, they are a temp fix for the underlying coding fix that might need to be made to EM Mod.
Code: Select all
#
#-----[ FIND ]------------------------------------------------
#
'HELP' => sprintf($lang['bbcode_help'][(strtolower($EMBB_values[$i]))], $hotkeys[$i]),
#
#-----[ REPLACE WITH ]----------------------------------------
#
'HELP' => sprintf($lang['bbcode_help'][$EMBB_values[$i]], $hotkeys[$i]),