", " ", $person); $person = stripslashes ($person); ?>

Welcome to the Club of Friendship

Please introduce your name:

And share your Message with your Friends in Borges:


$max_file_size) { /* reads file and stores each line $lines' array elements */ $lines = file($chat_file_ok); /*get number of lines */ $a = count($lines); $u = $a - $chat_lenght; for($i = $a; $i >= $u ;$i--){ $msg_old = $lines[$i] . $msg_old; } $deleted = unlink($chat_file_ok); $fp = fopen($chat_file_ok, "a+"); $fw = fwrite($fp, $msg_old); fclose($fp); } /* the following is because every message has to be */ /* placed into one single line in the msg.txt file. */ /* You can render \n (new lines) with "
" html tag anyway. */ $msg = str_replace ("\n"," ", $message); /* if the user writes something... */ /* the new message is appended to the msg.txt file */ /* REMEMBER: the message is appended, hence, if */ /* you want the last message to be displayed as the */ /* first one, you have to */ /* 1. store the lines (messages) into the array */ /* 2. read the array in reverse order */ /* 3. post the messages in the output file (the chat) */ /* I added these three lines in order to avoid buggy html code and slashes */ $msg = str_replace ("\n"," ", $message); $msg = str_replace ("<", " ", $msg); $msg = str_replace (">", " ", $msg); $msg = stripslashes ($msg); if ($msg != ""){ $fp = fopen($chat_file_ok, "a+"); $fw = fwrite($fp, "\n$person : $msg
"); fclose($fp); } $lines = file($chat_file_ok); $a = count($lines); $u = $a - $chat_lenght; /* reads the array in reverse order and outputs to chat */ for($i = $a; $i >= $u ;$i--){ echo $lines[$i] . "
"; } ?>