<!DOCTYPE html>
<html>
<head>
  <title>NOTFLIX IPTV</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link rel="stylesheet" href="style.css">
</head>
<body>
  <div id="header">NOTFLIX IPTV</div>
  <div id="iframe-container">
    <iframe src="//iptv-libre.pages.dev" frameborder="0" width="100%" height="100%" allow="encrypted-media *" allowFullScreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe>
  </div>
  <div id="chatbox">
    <h2>Live Chat</h2>
    <div id="chat-messages"></div>
    <input type="text" id="chat-input" placeholder="Type a message..." maxlength="200">
    <button id="send-btn">Send</button>
  </div>

  <script>
    const chatInput = document.getElementById('chat-input');
    const chatMessages = document.getElementById('chat-messages');
    const sendBtn = document.getElementById('send-btn');

    function sanitizeMessage(message) {
      return DOMPurify.sanitize(message);
    }

    sendBtn.addEventListener('click', () => {
      const message = chatInput.value.trim();
      const sanitizedMessage = sanitizeMessage(message);

      if (sanitizedMessage.length > 0 && sanitizedMessage.length <= 200) {
        fetch('/save_message.php', {
          method: 'POST',
          headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
          body: `message=${sanitizedMessage}`,
        })
        .then(() => loadChatLogs())
        .catch((error) => console.error('Error:', error));
        chatInput.value = '';
      }
    });

    function loadChatLogs() {
      fetch('/chat.txt')
      .then((response) => response.text())
      .then((data) => {
        const messages = data.split('\n').map((line) => `<p>${line}</p>`);
        chatMessages.innerHTML = messages.join('');
        chatMessages.scrollTop = chatMessages.scrollHeight;
      })
      .catch((error) => console.error('Error:', error));
    }

    loadChatLogs();
    setInterval(loadChatLogs, 1000);
  </script>
  <script src="//cdn.jsdelivr.net/npm/disable-devtool@latest"></script>
  <script src="//cdn.jsdelivr.net/npm/dompurify@2.3.6/dist/purify.min.js"></script>
</body>
</html>