Im using a php/flash chat, I added some parsing in it, but now Im having one problem left to solve, after nickname plus the message (msg) its suppose to create a new line \n, but if I parse it, and type a link or a swear word that uses the bad word filtering, it doesnt create a new line after you press send. It just continues on after you type something in again.I'll add the script so you can look it over amd let me know if you know where I can add another \n to make sure it gives me a line break after the parsing. <? header("Expires: ".gmdate("D, d M Y H:i:s")."GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); ?> <?
/* Credits: */ /* Modified for Flashkit by swissLyons: http://www.flashbuilder.ch based on the http://www.peopleforfun.com version */ /* Original script by Nicola Delbono <[EMAIL PROTECTED]> */ /* Modified by Mario http://www.bludocks.com */ /* Modified by Deadsam at http://www.deadsam.com // added parsing for links and bad word filter */ ?> <? $nickname = str_replace ("\n"," ", $nickname); $nickname = str_replace ("<", " ", $nickname); $nickname = str_replace (">", " ", $nickname); $nickname = stripslashes ($nickname); ?> <? $chat_file2 = "chat.txt"; $lines2 = file($chat_file2); $count = count($lines2); echo "&count=$count"; ?> &output= <? $chat_file = "chat.txt"; $chat_lenght = 80; $max_single_msg_lenght = 100000; $max_file_size = $chat_lenght * $max_single_msg_lenght; $file_size= filesize($chat_file); if ($file_size > $max_file_size) { $lines = file($chat_file); $a = count($lines); $u = $a - $chat_lenght; for($i = $a; $i >= $u ;$i--){ $msg_old = $lines[$i] . $msg_old; } $deleted = unlink($chat_file); $fp = fopen($chat_file, "a+"); $fw = fwrite($fp, $msg_old); fclose($fp); } $msg = str_replace ("\\","", $message); // //IF THE FORGOT TO ADD HTTP:THIS WILL DO IT FOR THEM $webStart = Array ('WWW', 'www'); $changeWebstart = 'http://www'; $msg = str_replace ($webStart, $changeWebstart, $msg); //this will take away the double http part $webDouble = Array ('http://http://www'); $changeWebSingle = 'http://www'; $msg = str_replace ($webDouble, $changeWebSingle, $msg); // Swear Word Filtering Section $badwords = Array ("fuck", "shit", "bastard", "fucker", "fucking", "bitch", "cunt", "pussy", "dick",); $changeto = '<font color="#CCCCFF">******</font>'; $msg = str_replace ($badwords, $changeto, $msg); // EMAIL PARSER $msg = ereg_replace("[[:alpha:]]+@[^<>[:space:]]+[[:alnum:]]","<font color=\"#FFFF00\"><u><a href=\"mailto:\\0\">\\0</a></u></font>", $msg); // // URL PARSER FOR MESSAGE $msg = ereg_replace ("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]]", "<font color=\"#FFFF00\"><u><a href=\"\\0\"target=\"_blank\">\\0</a></u></font>", $msg); //$msg = ereg_replace("\[url\]([^\[]+)\[/url\]", "<font color=\"#FFFF00\"><u><a href=\"\\1\"target=\"_blank\">\\1</a></u></font>", $msg); // // BOLD, ITALICS, UNDERLINE AND PRE PARSER $searchFor = Array ('[b]', '[/b]', '[pre]', '[/pre]', '[i]', '[/i]', '[u]', '[/u]'); $replaceWith = Array ('<b>', '</b>', '<pre>', '</pre>', '<i>', '</i>', '<u>', '</u>'); $msg = str_replace ($searchFor, $replaceWith, $msg); // // END PARSING SECTION $msg = stripslashes($msg); if ($msg != ""){ $fp = fopen($chat_file, "a+"); $fw = fwrite($fp, "<font Color=\"$Color\"> $nickname : $msg\n</font>"); fclose($fp);} $lines = file($chat_file); $a = count($lines); $u = $a - $chat_lenght; for($i = $a; $i >= $u ;$i--){ echo $lines[$i]; } ?> Thanks in advance for anyone who can help me out Deadsam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php