rendered paste body<?php# Copyright by Thomas Bowe [Funjoy]# Modul nur fr die bbcode.php Klasse. # Support webmaster@phpline.de# link www.k4d-clan.com//> Html farblich darstellen. function highlight_html($string,$CodeColor) { //> HTML Tags definieren und farben zuweisen. $parse_tags = array("script" => "#990000", "a" => "#009900", "*img" => "#990099", "style" => "#990099", "form" => "#ff9900", "textarea" => "#ff9900", "select" => "#ff9900", "option" => "#ff9900", "input" => "#ff9900", "table" => "#009999", "th" => "#009999", "td" => "#009999", "tr" => "#009999", "tbody" => "#009999", "tfoot" => "#009999"); //> Restliche Htmlelemente frben $parse_elements = array(//> Fr Format: &xxxx; "#000000", //> Fr Format: 'xxxx' und "xxxx" "#0000ff", //> Tags die keine definition haben. "#000099", //> Farbe fr Kommentare. "#999999", //> Farbe in style tags fr den Anfhrungszeichen "#006600", //> Farbe in script Tags fr die Anfhrungszeichen "#000000", //> Default farbe fr nicht definierten Code. $CodeColor); //> Tags farblich hervorheben! while(list($tag,$color) = each($parse_tags)) { if(substr($tag,0,1) == "*" && $tag != "#") { //> Offene Tags frben(fr die Tags die keine end- Tags besitzen!) $pattern[] = "%<".substr($tag,1)."(.+)>%Uis"; $replace[] = "<font color=\"".$color."\"><".substr($tag,1)."$1></font>"; } else { //> Offene Tags frben! $pattern[] = "%<".$tag."(.+)>%Uis"; $replace[] = "<font color=\"".$color."\"><".$tag."$1></font>"; //> Geschlossene Tags frben! $pattern[] = "%</".$tag.">%Uis"; $replace[] = "<font color=\"".$color."\"></".$tag."></font>"; } } //> Formatierung farblich hervorheben Beispiel: &xxxx; $pattern[] = "%&([a-zA-Z0-9#]+);%Uis"; $replace[] = "<font color=\"".$parse_elements[0]."\"><b><i>&$1;</i></b></font>"; //> Formatierung farblich hervorheben Beispiel: 'xxxx' $pattern[] = "%'(.*)'%esiU"; $replace[] = "_html_quotes('\$1','\'','".$parse_elements[1]."')"; //> Formatierung farblich hervorheben Beispiel: "xxxx" $pattern[] = "%"(.*)"%esiU"; $replace[] = "_html_quotes('\$1','"','".$parse_elements[1]."')"; //> Kommentar farblich hervorheben Beispiel: <!-- xxxx -->; $pattern[] = "%<!--(.*)-->%esiU"; $replace[] = "_html_comments('\$1','".$parse_elements[3]."')"; //> Ausfhrungszeichen in style- Tags farblich hervorheben. $pattern[] = "%<style(.*)>%esiU"; $replace[] = "_html_styletag('\$1','".$parse_elements[4]."')"; //> Ausfhrungszeichen in script- Tags farblich hervorheben. $pattern[] = "%<script(.*)>%esiU"; $replace[] = "_html_scripttag('\$1','".$parse_elements[5]."')"; //> CSS Code inerhalb eines Tags entsprechend hervorheben. $pattern[] = "%style( =| = |= |=)(.+)</font>%esiU"; $replace[] = "_html_style('\$2')"; //> CSS Code farblich hervorheben. (ggf. an Modul weiterleiten.) if(function_exists("highlight_css")) { $pattern[] = "%(<style)(.*)(></font>)(.*)(<font color=\"".$parse_tags['style']."\"><\/style>)%esiU"; $replace[] = "highlight_css('\$4','\$1\$2\$3','\$5')"; } else { $pattern[] = "%(<style)(.*)(></font>)(.*)(<font color=\"".$parse_tags['style']."\"><\/style>)%esiU"; $replace[] = "_html_defaultcode('\$4','\$1\$2\$3','\$5','".$parse_elements[6]."')"; } //> JavaScript Code farblich hervorheben. (ggf. an Modul weiterleiten. Dazu bitte selber if bedingung basteln!!!) $pattern[] = "%(<script)(.*)(></font>)(.*)(<font color=\"".$parse_tags['script']."\"><\/script>)%esiU"; $replace[] = "_html_defaultcode('\$4','\$1\$2\$3','\$5','".$parse_elements[6]."')"; $string = str_replace("<","<font color=\"".$parse_elements[2]."\"><",$string); $string = str_replace(">","></font>",$string); $string = preg_replace($pattern,$replace,$string); return stripslashes($string); } //> Sub funktion fr die Funktion "xxxx" und 'xxxx' function _html_quotes($string,$type,$color) { //> Farb- Tags (<font>) und Formatierungs- Tags (<b><i>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU", "%<(i|b)>%siU", "%</(i|b)>%siU"); $string = preg_replace($pattern,"",$string); return "<font color=\"".$color."\">".$type.$string.$type."</font>"; } //> Sub Funktion um CSS Code inerhalb eines Tags entsprechend hervorheben. function _html_style($string) { //> Farb- Tags (<font>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU"); $string = preg_replace($pattern,"",$string); unset($pattern); $pattern[] = "%("|')%siU"; $replace[] = "<font color=\"#0000ff\">$1</font>"; $pattern[] = "%:(.+);%siU"; $replace[] = "<font color=\"#FF00FF\">:</font><font color=\"#0000ff\">$1</font><font color=\"#FF00FF\">;</font>"; $string = preg_replace($pattern,$replace,$string); return "style=<font color=\"#000099\">".$string."</font>"; }//> Sub Funktion um in <style...> die Anfhrungszeichen anders farblich hervorzuheben. function _html_styletag($string,$color) { //> Farb- Tags (<font>) und Formatierungs- Tags (<b><i>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU"); $string = preg_replace($pattern,"",$string); unset($pattern); $pattern[] = "%"(.+)"%siU"; $replace[] = "<font color=\"".$color."\">"$1"</font>"; $pattern[] = "%'(.+)'%siU"; $replace[] = "<font color=\"".$color."\">'$1'</font>"; $string = preg_replace($pattern,$replace,$string); return "<style".$string.">"; } //> Sub Funktion um in <script...> die Anfhrungszeichen anders farblich hervorzuheben. function _html_scripttag($string,$color) { //> Farb- Tags (<font>) und Formatierungs- Tags (<b><i>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU"); $string = preg_replace($pattern,"",$string); unset($pattern); $pattern[] = "%"(.+)"%siU"; $replace[] = "<font color=\"".$color."\">"$1"</font>"; $pattern[] = "%'(.+)'%siU"; $replace[] = "<font color=\"".$color."\">'$1'</font>"; $string = preg_replace($pattern,$replace,$string); return "<script".$string.">"; } //> Sub Funktion um Kommentare Farblich hervorzuheben. function _html_comments($string,$color) { //> Farb- Tags (<font>) und Formatierungs- Tags (<b><i>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU", "%<(i|b)>%siU", "%</(i|b)>%siU"); $string = preg_replace($pattern,"",$string); return "<font color=\"".$color."\"><!--".$string."--></font>"; }//> Sub Funktion um Farben zu lschen und text in anderer Farbe darzustellen. function _html_defaultcode($string,$stag,$etag,$color) { //> Farb- Tags (<font>) und Formatierungs- Tags (<b><i>) Lschen. $pattern = array("%<font(.*)>%siU", "%</font>%siU", "%<(i|b)>%siU", "%</(i|b)>%siU"); $string = preg_replace($pattern,"",$string); return $stag."<font color=\"".$color."\">".$string."</font>".$etag; }?>