<?php
  global $g_lang;
  global $g_res;
  global $g_params;
?>
<html lang="<?php global $g_lang;
echo $g_lang; ?>">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="author" content="Copyright P.Kassel, M.Seliger, G.Trietsch, all Rights Reserved">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title><?php echo($g_res['page_title']); ?></title>
    <link rel="stylesheet" type="text/css" href="auth/login.css?version=1">
    <link rel="stylesheet" type="text/css" href="auth/login-user.css?version=1">
    <script>
    function unmask() {
      const x = document.getElementById('idPassword')
      x.type = x.type === "password" ? "text" : "password";
    }
    </script>
  </head>
  <body>
  <div class="auth-header" role="banner">
    <div class="clearfix auth-header-image">
      <a tabindex=0 target="_blank" href="<?php echo $g_res['site_url']; ?>">
        <img src="<?php echo ($g_res['site_logo']); ?>" alt="<?php echo $g_res['site_url']; ?>">
      </a>
    </div>
  </div>
  <div>
    <main>
      <div class="auth-form" id="login">
        <form action="login" method="POST">
          <input type="hidden" name="response_type" value="<?php echo(trim($g_params['response_type'])); ?>">
          <input type="hidden" name="redirect_uri" value="<?php echo(trim($g_params['redirect_uri'])); ?>">
          <input type="hidden" name="client_id" value="<?php echo(trim($g_params['client_id'])); ?>">
          <input type="hidden" name="state" value="<?php echo(trim($g_params['state'])); ?>">
          <input type="hidden" name="scope" value="<?php echo(trim($g_params['scope'])); ?>">
          <input type="hidden" name="authMode" value="<?php echo(trim($g_params['authMode'])); ?>">
          <div class="auth-form-header">
            <h1><?php echo $g_res['title']; ?></h1>
          </div>
          <div class="auth-form-body">
            <?php if (!empty($g_params['infotext'])) {
              echo '<div class="infotext">'.$g_params['infotext'].'</div>';
            } ?>
            <label class="bold" for="idUsername"><?php echo $g_res['user_name']; ?></label>
            <input type="text" name="username" id="idUsername" tabindex="1"
                   autocapitalize="off" autofocus="autofocus" value="<?php if (isset($g_params['username'])) {
              echo $g_params['username'];
              } ?>">
            <label class="bold" for="idPassword"><?php echo $g_res['password']; ?></label>
            <input type="password" name="password" id="idPassword" tabindex="2">
            <div class="auth checkbox">
              <input type="checkbox" id="idUnMask" tabindex="3" onclick="unmask()">
              <label for="idUnMask"><?php echo $g_res['show_password']; ?></label>
            </div>
            <button type="submit" tabindex="4"><?php echo $g_res['button_text']; ?></button>
             <?php if (!empty($g_res['htmlinfo'])) {
              echo ('<div class="text-center htmlinfo">');
              include $g_res["htmlinfo"];
              echo ('</div>');
              } ?>
          </div>
        </form>
      </div>
    </main>
  </div>

  </body>
</html>
