function securify($text, $cap = 0, $trim = 1, $paranoid = 1, $news = 0) { global $DBc; if ($news == 1) { // We need some html tags for the news $text = strip_tags($text, "

"); } else { if ($paranoid == 1) { // Get rid of tags and quotes $text = htmlentities($text, ENT_QUOTES, 'UTF-8'); } elseif ($paranoid == 2) { // just strip all tags for saving to db $text = strip_tags($text); } else { // Leave quotes alone $text = htmlentities($text, ENT_NOQUOTES, 'UTF-8'); } } if ($cap == 1) { // Capitalise the first word of every string $text = ucwords($text); } // replace the lf & cr tags to the
tag $text = nl2br($text); if (get_magic_quotes_gpc()) { // Stripslashes if magic quotes are on (really shouldn't be though) $text = stripslashes($text); } // Escape mysql special chars $text = mysqli_real_escape_string($DBc, $text); if ($trim == 1) { //Cut off empty spaces at the beginning and end $text = trim($text); //remove double spaces $text = str_replace(' ', ' ', $text); $text = str_replace(' ', ' ', $text); } if ($news == 1) { //replace nicknames with the right case $text = str_replace("SL", "sL", $text); } return $text; }