.###################################### function validated_tag (string tag) : string { var string[] tagsallowed = [ "br", "br/", "br /", "/a", "/span", "b", "s", "i", "code", "blockquote", "em", "strong", "p", "/b", "/s", "/i", "/code", "/blockquote", "/em", "/strong", "/p" ]; var string[] tagsskipped = [ "a ", "img ", "span class=", "lj user=" ]; var string[] tagsreplaced = [ "form ", "/form" ]; var string[] replaceto = [ "blockquote", "/blockquote" ]; var string tagl = $tag->lower(); var int i = -1; foreach var string t ($tagsreplaced) { $i = $i + 1; if ($tagl->substr(0, $t->length()) == $t) { return "<" + $replaceto[$i] + ">"; } } foreach var string t ($tagsskipped) { if ($tagl->substr(0, $t->length()) == $t) { return "<" + $tag + ">"; } } foreach var string t ($tagsallowed) { if ($tagl == $t) { return "<" + $t + ">"; } } # citus (neapstrādātos) tag-us vienkārši dzēšam return ""; } function striphtml2 (string s) : string { var string result = ""; var string curr_tag = ""; var bool outside = true; foreach var string ch ($s) { if ($outside) { if ($ch == "<") { $outside = false; } else { $result = $result + $ch; } } else { if ($ch == ">") { $outside = true; $result = $result + validated_tag($curr_tag); $curr_tag = ""; } else { $curr_tag = $curr_tag + $ch; } } } return $result; } ######################################
(Ņem vērā, ka parasti neviens neizvēlas atbildēt uz pilnīgi anonīmiem komentāriem!)