Php code written into (.txt)
/* Check whether the user nickname is repeated * parameter $ user is the login user's nickname * When the returned value is true, when the nickname is available * When the returned value is false, nickname unavailable */function chklogin ($ file, $ user) {$ boo = false; if (file_exists ($ file) {$ userarr = file ($ file ); /* determine whether the nickname is repeated */foreach ($ userarr as $ value) {$ tmparr = explode ('#', $ value ); if ($ user = $ tmparr [0]) {$ boo = true; break ;}} return $ boo ;} /* write the nickname of the logged-on user to the file * save format: nickname # ip # logon time * $ file: save file address * $ user: nickname * $ ip: logon IP address * $ sex: Gender */function addlogin ($ file, $ User, $ ip, $ sex) {$ tmp = $ user. '#'. $ ip. '#'. $ sex. chr (13 ). chr (10); $ fp = fopen ($ file, 'A'); $ boo = fwrite ($ fp, $ tmp); fclose ($ fp ); return $ boo;}/* convert the user list to an array * $ file: User list file */function storeuser ($ file) {$ tmparr = file ($ file ); $ userarr = array (); foreach ($ tmparr as $ value) {$ tmparr = explode ('#', $ value); $ userarr [] = $ tmparr [0]. ','. $ tmparr [2];} return $ userarr;}/* write the speech content to the file * $ file: Save the file address * $ mess: save the content */function ad Dmess ($ file, $ mess) {$ fp = fopen ($ file, 'A'); $ boo = fwrite ($ fp, $ mess. chr (13 ). chr (10); fclose ($ fp); return boo;}/* delete the user in the file * $ file: Save the file address * $ user: user to be deleted */function deluser ($ file, $ user) {$ tmparr = file ($ file); $ rearr = array (); foreach ($ tmparr as $ value) {$ tmp = explode ('#', $ value); if ($ tmp [0]! = $ User) {$ rearr [] = $ value ;}}$ fp = fopen ($ file, 'W + '); foreach ($ rearr as $ value) {fwrite ($ fp, $ value) ;}fclose ($ fp );}