I have been working on a chat system for a while now and I am now down to the last part-removing people from the "users list" when they leave. The following code is called by a JS when the user leaves:
<?php
setcookie ("cookie_logged", "", time()+2592000);
$filepointer1 = fopen("middle_right.html", "r");
$Array = file ("middle_right.html");
fclose ($filepointer1);
$filepointer2 = fopen("middle_right.html", "w");
$x = count($Array);
for ($i=0; $i<=$x; $i++) {
if ($Array == "$uid<br>") {
//The file it is checking right now,
//middle_right.html is formatted
//with a user id (uid) and then a
//<br>
fwrite ($filepointer2, "");
} else {
fwrite ($filepointer2, $Array);
}
}
print "<font color='#FFFFFF'>";
print "<body bgcolor='#000000'>";
print "<b>YOU HAVE BEEN LOGGED OUT</b>";
print "</font>";
fclose ($filepointer2);
?>