query("SELECT status,room FROM ".C_USR_TBL." WHERE username = '$U' LIMIT 1"); if($DbLink->num_rows() != 0) { // There is a row for the user in the users table list($status,$room) = $DbLink->next_record(); $DbLink->clean_results(); $kicked = 0; if ($room != stripslashes($R)) // Same nick in another room { $DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ($T, '$R', 'SYS exit', '', ".time().", '', 'sprintf(L_EXIT_ROM, \"".special_char($U,$Latin1,1)."\")')"); $kicked = 3; } elseif ($status == "k") // Kicked by a moderator or the admin. { $DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ($T, '$R', 'SYS exit', '', ".time().", '', 'sprintf(L_KICKED, \"".special_char($U,$Latin1,1)."\")')"); $kicked = 1; } elseif ($status == "d") // The admin just deleted the room { $kicked = 2; } elseif ($status == "b") // Banished by a moderator or the admin. { $DbLink->query("INSERT INTO ".C_MSG_TBL." VALUES ($T, '$R', 'SYS exit', '', ".time().", '', 'sprintf(L_BANISHED, \"".special_char($U,$Latin1,1)."\")')"); $kicked = 4; }; if ($kicked > 0) { // Kick the user from the current room ?> close(); exit; } // Updates the time to ensure the user won't be cleaned from the users table $DbLink->query("UPDATE ".C_USR_TBL." SET u_time = ".time()." WHERE room = '$R' AND username = '$U'"); } else { // User hasn't been found in the users table -> add a row $DbLink->clean_results(); $DbLink->query("SELECT perms,rooms FROM ".C_REG_TBL." WHERE username='$U' LIMIT 1"); $reguser = ($DbLink->num_rows() != 0); if ($reguser) list($perms, $rooms) = $DbLink->next_record(); $DbLink->clean_results(); // Get user status $status = "u"; if ($reguser) { switch ($perms) { case 'admin': $status = "a"; break; case 'moderator': $roomsTab = explode(",",$rooms); for (reset($roomsTab); $room_name=current($roomsTab); next($roomsTab)) { if (strcasecmp(stripslashes($R), $room_name) == 0) { $status = "m"; break; }; }; default: $status = "r"; }; }; // Get IP address include("./lib/get_IP.lib.php3"); // Set the $IP var $DbLink->query("INSERT INTO ".C_USR_TBL." VALUES ('$R', '$U', '$Latin1', ".time().", '$status', '$IP')"); }; // ** Check for updates in users list ** if ($First) $LastCheck = 0; if ($CleanUsrTbl) { $Users_Refresh = "1"; } else { $QueryRoom = " AND (type = 1".($T == "0" ? " OR (type = 0 AND room = '$R')" : "").") "; $DbLink->query("SELECT DISTINCT m_time FROM ".C_MSG_TBL." WHERE m_time > '$LastCheck' AND username IN ('SYS enter','SYS exit','SYS promote','SYS delreg')".$QueryRoom."ORDER BY m_time DESC LIMIT 1"); $Users_Refresh = ($DbLink->num_rows() > 0); if ($Users_Refresh) list($LastCheck) = $DbLink->next_record(); $DbLink->clean_results(); }; // ** Check for updates in messages list and get new messages ** if ($First) $LastLoad = 0; // Define the SQL query (depends on values for ignored users list and on whether to display // notification messages or not $CondForQuery = ""; $IgnoreList = ""; if (isset($Ign)) $IgnoreList = "'".str_replace(",","','",addslashes(urldecode($Ign)))."'"; if ($NT == "0") $IgnoreList .= ($IgnoreList != "" ? ",":"")."'SYS enter','SYS exit'"; if ($IgnoreList != "") $CondForQuery = "username NOT IN (${IgnoreList}) AND "; $CondForQuery .= "(address = ' *' OR (address = '$U' AND (room = '$R' OR username = 'SYS inviteTo')) OR (room = '$R' AND (address = '' OR username = '$U')))"; $LimitForQuery = ($First ? " LIMIT $N" : ""); $DbLink->query("SELECT m_time, username, latin1, address, message FROM ".C_MSG_TBL." WHERE m_time > '$LastLoad' AND ".$CondForQuery." ORDER BY m_time DESC".$LimitForQuery); // Format and store new messages $Messages = Array(); if($DbLink->num_rows() > 0) { $i = "1"; $today = date('j', time() + C_TMZ_OFFSET*60*60); while(list($Time, $User, $Latin1, $Dest, $Message) = $DbLink->next_record()) { // Skip the oldest message if the day seperator has been added if (isset($day_separator) && $First && $i == $N) continue; // Separator between messages sent before today and other ones if (!isset($day_separator) && date("j", $Time + C_TMZ_OFFSET*60*60) != $today) { $Messages[] = "
--------- ".L_TODAY_DWN." ---------<\/SPAN><\/P>"; $day_separator = "1"; }; $NewMsg = "