include("./config.inc.php");
// ตรวจสอบว่ามีไฟล์เก็บข้อมูลหรือไม่.. ถ้าไม่มีให้สร้างขึ้นใหม่
if (!file_exists($file_data)) {
$fp=fopen($file_data,"w");
flock($fp,2);
fputs($fp,""); // create empty file
flock($fp,3);
fclose($fp);
}
// ตรวจสอบว่ามีไฟล์รายการผู้ใช้หรือไม่.. ถ้าไม่มีให้สร้างขึ้นใหม่
if (!file_exists($file_user)) {
$fp=fopen($file_user,"w");
flock($fp,2);
fputs($fp,""); // create empty file
flock($fp,3);
fclose($fp);
}
// ตรวจสอบว่า ถ้าไม่มีคนอยู่ในห้องแชทนานเกิน 10 นาที ให้ลบข้อมูลออกทั้งหมด
// (10 นาที หรือคือ 600 วินาที กำหนดไว้ในไฟล์ config.inc.php ชื่อตัวแปร $clear_data_time)
if (file_exists($file_user)) {
$chk_user = file($file_user);
if (sizeof($chk_user) <= 0) {
if (file_exists($file_chk)) {
$chk_data = file($file_chk);
$chk = $Logtime - $chk_data[0];
if ($chk > $clear_data_time) {
$fp=fopen($file_data,"w");
flock($fp,2);
fputs($fp,"ไม่มีใครอยู่ในห้อง!!
\n");
flock($fp,3);
fclose($fp);
}
} // จบ if (file_exists($file_chk))
} // จบ if (sizeof($chk_user) <= 0)
} // จบ if (file_exists($file_user))
// ตรวจสอบชื่อ (ดูได้จากไฟล์ config.inc.php)
$nick = CheckData($nick);
if(isset($login)) {
echo "