大编辑:
好的,所以这是一个简单的方法(使用无聊的文本文件):
创建另一个名为bad_people.txt的文本文件
创建一个脚本以将顽皮的用户IP地址插入到文本文件中。像这样的东西:
$myFile = "../bad_people.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$ip_splitter="-::-"; //This is a splitter...Will be used to split each IP address in the text file to make it readable in future.
$bad_address = "22.22.22.22".$ip_splitter;
fwrite($fh, $bad_address);
fClose($fh);所以,当你想让某人离开聊天时你运行上面的代码...
注意:请参阅我如何使用拆分器($ip_splitter)来拆分文本文件中的每个IP地址。这样可以更轻松地读取文件并将所有地址插入到数组中。
然后,在AJAX调用中(我假设在无限循环中运行):
$myFile = "../bad_people.txt";
$fh = fopen($myFile, 'r') or die("can't open file");
$ip_splitter="-::-";
$bad_people_array=explode($ip_splitter,$fh);
$user_ip=$_SERVER['REMOTE_ADDR'];
foreach ($bad_people_array as $BAD_IP){
if($BAD_IP==$user_ip){
//do whatever here......
}//end of if the user is bad
}//end of for loop所以你在你的ajax调用上运行该脚本,以及你的脚本来检查新消息....
你有它。