Zusammenfassung der format-Funktionen (wie formatpost etc.)

Begonnen von k00ni, 19. September 2007, 09:36:14

Vorheriges Thema - Nächstes Thema

k00ni

Hallo,
so wie es aussieht, machen alle formatXYZ-Funktionen das gleiche, bis auf eine paar kleine Unterschiede: da mal kein nl2br, dort mal ein AddSlashes. Ich habe mir mal die Mühe gemacht und alle Funktionen zusammenzufassen. Nachfolgend ein erster Entwurf und noch nicht getestet. Meines Erachtens wäre es sinnvoll, wenn man über die Parameterliste der Funktion sagen kann, was sie formatieren soll und was nicht. Als Gegenstück dazu, bräuchten wir nun noch ein Funktion, die von HTML in HRC zurückwandelt. Jedenfalls scheint  das so, wenn ich mir den Code so anschaue.
 

\', $S_string);
    $S_string = str_replace(\";-)\", \'\', $S_string);
    $S_string = str_replace(\":O\",  \'\', $S_string);
    $S_string = str_replace(\";-(\", \'\', $S_string);
    $S_string = str_replace(\":D\",  \'\', $S_string);
    $S_string = str_replace(\"8-)\", \'\', $S_string);
    $S_string = str_replace(\":-O\", \'\', $S_string);
    $S_string = str_replace(\":-(\", \'\', $S_string);
    $S_string = str_replace(\"(?)\", \'\', $S_string);
    $S_string = str_replace(\"(!)\", \'\', $S_string);
}
elseif ($S_convert_to_smilies == \'mini\')
{
$S_string = str_replace(\":-)\", \'\', $S_string);
    $S_string = str_replace(\";-)\", \'\', $S_string);
    $S_string = str_replace(\":O\",  \'\', $S_string);
    $S_string = str_replace(\";-(\", \'\', $S_string);
    $S_string = str_replace(\":D\",  \'\', $S_string);
    $S_string = str_replace(\"8-)\", \'\', $S_string);
    $S_string = str_replace(\":-O\", \'\', $S_string);
    $S_string = str_replace(\":-(\", \'\', $S_string);
    $S_string = str_replace(\"(?)\", \'\', $S_string);
    $S_string = str_replace(\"(!)\", \'\', $S_string);
}
// Maskiert Sonderzeichen. ##############################################################################
if ($B_use_addslashes === true AND get_magic_quotes_gpc() != 1)
{
$S_string = AddSlashes($S_string);
}
// Konvertiert Sonderzeichen in HTML-Code ###############################################################
if ($B_use_htmlspecialchars === true)
{
$S_string = htmlspecialchars($S_string);
}
// Konvertiert BBC Code in entsprechenden HTML-Code #####################################################
if ($B_convert_from_bbc_code === true)
{        
    // ######### HRC Codes:
    $S_string = str_replace(\"
\", \"\", $S_string);
    $S_string = str_replace(\"\", \"\", $S_string);
    $S_string = str_replace(\"
\", \"\", $S_string);
    $S_string = str_replace(\"\", \"\", $S_string);
    $S_string = str_replace(\"
\", \"\", $S_string);
    $S_string = str_replace(\"[img]\", \" \", $S_string);
    // [url], in HTML-Equivalent umwandeln
    $S_string = eregi_replace(\"\\\\[url\\\\]www.([^\\\\[]*)\\\\[/url\\\\]\", \"\\\\1\", $S_string);
    $S_string = eregi_replace(\"\\\\[url\\\\]([^\\\\[]*)\\\\[/url\\\\]\", \"\\\\1\", $S_string);
    $S_string = eregi_replace(\"\\\\[email\\\\]([^\\\\[]*)\\\\[/email\\\\]\", \"\\\\1\", $S_string);
    $S_string = eregi_replace(\"\\\\[url=\\\"([^\\\"]*)\\\"\\\\]([^\\\\[]*)\\\\[\\\\/url\\\\]\", \"\\\\2\", $S_string);
    $S_string = eregi_replace(\"\\\\[url=([^\\\"]*)\\\\]([^\\\\[]*)\\\\[\\\\/url\\\\]\", \"\\\\2\", $S_string);
$S_string = preg_replace(\"#\\[youtube\\]http://(www\\.)?youtube.com/watch\\?v=([A-Za-z0-9\\-\\_]+)\\[/youtube\\]#i\",
                    \"\",
                    $S_string);
 
// Irgendwas mit \"Security\" :ugly:
    $S_string = str_replace(\"javascript:\", \"java script:\", $S_string);
 
    //
[code]-Teil bearbeiten                   
    // siehe im QUOTE-Tag unten
}
// Ersetzt \"\\n\" durch \"\" ###########################################################################
if ($B_use_nl2br === true)
{
$S_string = nl2br ($S_string);
}
// Übergebene Suchbegriff aus der Suche farblich hervorheben. ###########################################
if ($B_use_highlighting === true AND !empty($_GET[\'highlight\']))
{
$S_string = search_highlight($S_string);
}
return $S_string;
}
?>

 
 
Hier noch der Quelltext für die [ code ] -Teil Bearbeitung, den hat er irgendwie hier nicht vertragen (zerkloppt die Formatierung). :ugly:
[edit]Den Codeteil hab ich rausgenommen, da er total verformatiert war. Ich hänge die Funktion als Datei an, für alle Interessenten.[/edit]
 
Grüße

all your base are belong to us