1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | | PHP-Quelltext function code_check($text) {
$pattern="/\[PHP](.*)\[\/PHP\]/esiU";
while(preg_match($pattern,$text)) {
$text=preg_replace($pattern,"highlight_phpcode('\\1')",$text); }
$pattern="/\[CODE](.*)\[\/CODE\]/esiU";
while(preg_match($pattern,$text)) {
$text=preg_replace($pattern,"highlight_code('\\1')",$text); }
return $text; }
function highlight_code($code){
$trans = get_html_translation_table(HTML_ENTITIES);
$code = stripslashes(strtr(strip_tags(str_replace('</P>',"\n",str_replace('<BR>',"\n",str_replace('\\',"\\\\",$code)))), array_flip($trans)));
ob_start();
highlight_string("<?\n".$code." ");
$code = ob_get_contents();
ob_end_clean();
$code = explode('<br />', $code);
$textwidth = "500";
$textsmallheight = "22";
$text = '<table class="standard" border="0" width="'.$textwidth.'" cellpadding="4" cellspacing="1" >';
$text .= '<tr><br><td class="quote">';
$text .= '<table class="quote" border="0" width="'.$textwidth.'" cellpadding="0" cellspacing="0" >';
$text .= '<tr><td class="quote"><b>Code:</b></td></tr>';
$text .= '<tr><td class="quote">';
$text .= '<table border="0" width="100%" cellpadding="0" cellspacing="0" >';
$text .= '<tr>';
for ($x=1; $x < sizeof($code); $x++)
if ($code[$x] != '') $x+0;
$textheight = $x*$textsmallheight;
$text .= '<td style="background-color: #FFFFFF;" width="100%" valign="top">';
$text .= '<div style="overflow: auto; width: '.$textwidth.'px; height: '.$textheight.'px">';
$text .= '<table class="quote" border="0" cellpadding="2" cellspacing="0" width="100%">';
for ($x=1; $x < sizeof($code); $x++)
if ($code[$x]!='')
$text .= '<tr><td style="background-color: #FFFFFF;" width="100%" height="'.$textsmallheight.'" nowrap>'.$code[$x].'</td></tr>';
$text .= '</table></div></td></tr></table></td></tr></table></td></tr></table>';
$pattern = "/COLOR\=\"\#(.*)\"/esiU";
while (preg_match($pattern,$text)) {
$text=preg_replace($pattern,"color2style('\\1')",$text); }
return $text; }
function highlight_phpcode($code){
$trans = get_html_translation_table(HTML_ENTITIES);
$code = stripslashes(strtr(strip_tags(str_replace('</P>',"\n",str_replace('<BR>',"\n",str_replace('\\',"\\\\",$code)))), array_flip($trans)));
ob_start();
highlight_string("<?\n".$code." ");
$code = ob_get_contents();
ob_end_clean();
$code = explode('<br />', $code);
$textwidth = "500";
$textsmallwidth = "40";
$textsmallheight = "22";
$text = '<table class="standard" border="0" width="'.$textwidth.'" cellpadding="4" cellspacing="1" >';
$text .= '<tr><br><td class="quote">';
$text .= '<table class="quote" border="0" width="'.$textwidth.'" cellpadding="0" cellspacing="0" >';
$text .= '<tr><td class="quote" width="'.$textsmallwidth.'" ></td><td class="quote"><b>Quell-Code:</b></td></tr>';
$text .= '<tr><td class="quote" colspan="2">';
$text .= '<table border="0" width="100%" cellpadding="0" cellspacing="0" align="left">';
$text .= '<tr><td valign="top" width="'.$textsmallwidth.'">';
$text .= '<table class="quote" border="0" cellpadding="2" cellspacing="0" width="'.$textsmallwidth.'" >';
for ($x=1; $x < sizeof($code); $x++)
if ($code[$x] != '')
$text .= '<tr><td class="quote" height="'.$textsmallheight.'" align="right" nowrap>'.($x+0).' </td></tr>';
$text .= '</table></td>';
$textheight = $x*$textsmallheight;
$textwidth = $textwidth-($textsmallwidth);
$text .= '<td style="background-color: #FFFFFF;" width="100%" valign="top">';
$text .= '<div style="overflow: auto; width: '.$textwidth.'px; height: '.$textheight.'px">';
$text .= '<table class="quote" border="0" cellpadding="2" cellspacing="0" width="100%">';
for ($x=1; $x < sizeof($code); $x++)
if ($code[$x]!='')
$text .= '<tr><td style="background-color: #FFFFFF;" width="100%" height="'.$textsmallheight.'" nowrap>'.$code[$x].'</td></tr>';
$text .= '</table></div></td></tr></table></td></tr></table></td></tr></table>';
$pattern = "/COLOR\=\"\#(.*)\"/esiU";
while (preg_match($pattern,$text)) {
$text=preg_replace($pattern,"color2style('\\1')",$text); }
return $text; }
function color2style($font_code) {
return "style=\"color: $font_code\""; } |