<?php
if($_SESSION['connected_info']==1) {
	$times_m_24mins = time()-(60*24);
	@mysqli_query($bdd,"DELETE FROM ".$prefix."_userconnect WHERE connected<'".$times_m_24mins."'");
	@$other_users = @mysqli_query($bdd,"SELECT * FROM ".$prefix."_userconnect uc INNER JOIN ".$prefix."_user user ON uc.user_id = user.id WHERE uc.user_id != '".$_SESSION['user_id']."'");
	if(@mysqli_num_rows($other_users)>0) {
		echo '<p class="connected">'.CONNECTED;
		if(mysqli_num_rows($other_users)>1) { echo PLURIEL; }
		echo DOTS.' ';
		foreach ($other_users as $other_user) {
            $chat_class = ($other_user['auth_chat'] == 1) ? "chat-user" : "no-chat-user";
            echo '<span class="' . $chat_class . '" data-user="' . $other_user['login'] . '"  
                   data-user-id="' . $other_user['user_id'] . '">' . $other_user['login'] . '</span>. ';
        }
		echo '</p><br><br>';
	}
	if ($_SESSION['auth_chat'] == 1) {
    ?>
        <!-- Fenêtre de chat flottante -->
        <div id="chat-box" class="chat-box" style="display:none;">
            <div class="chat-header">
                <span id="chat-user-name"></span>
                <button id="close-chat">×</button>
            </div>
            <div id="chat-messages" class="chat-messages"></div>
            <textarea id="chat-input" placeholder="<?php echo WRITEMESS; ?>"></textarea>
            <button id="chat-send"><?php echo SEND; ?></button>
        </div>        
    <?php
    }
}
?>