source: portal_2019/php/sign.php @ e8c9209

devportal
Last change on this file since e8c9209 was b1a751e, checked in by Angelo Osorio <danielking.321@…>, 5 years ago

Cambios de frontend

  • Property mode set to 100644
File size: 4.0 KB
Line 
1<!DOCTYPE html>
2<html lang="es">
3<head>
4  <?php require_once "./url.php" ?>
5
6  <!-- Metadata & Essential styles and scripts -->
7  <?php require_once "./headEssential.php" ?>
8  <?php require_once "./gen_keys.php"; ?>
9
10</head>
11<body>
12
13  <!-- Header -->
14  <?php require_once "./header.php" ?>
15
16  <!-- Navbar -->
17  <?php require_once "./navbar.php" ?>
18
19  <!-- Main -->
20  <main class="container">
21    <div id="operation">
22      <ul id="tabs-operation" class="nav nav-tabs mt-6" data-tabs="tabs">
23        <li class="nav-item">
24          <a class="nav-link" href="<?php returnURL(); ?>">Firmar con token</a>
25        </li>
26        <li>
27          <a class="nav-link active" href="<?php returnURL(); ?>/php/sign.php">Firmar con .p12</a>
28        </li>
29        <li>
30          <a class="nav-link" href="<?php returnURL(); ?>/">Verificar</a>
31        </li>
32      </ul>
33
34      <div id="operation-tab-content" class="tab-content py-4">
35        <input id="pubkey" type="hidden" value=" <?php echo $_SESSION['public_key_pem'] ?>">
36        <section class="container-fluid">
37          <div class="row">
38            <div class="col-12 px-0">
39              <h2 class="text-center py-3 font-weight-bold text-dark">
40                Firmar Electrónicamente <span class="text-primary">PKCS12</span>
41              </h2>
42            </div>
43          </div>
44
45          <div class="row">
46            <div class="col-10 offset-1 col-md-8 offset-md-2 pt-4">
47              <form action="./run_script.php" method="POST" enctype="multipart/form-data">
48
49                <div class="input-group pb-3">
50                  <div class="custom-file">
51                    <input id="pdf" class="custom-file-input" type="file" name="pdf" accept=".pdf" required tabindex="1">
52                    <label class="custom-file-label" for="pdf">Seleccionar PDF</label>
53                  </div>
54                </div>
55
56                <div class="input-group pb-3">
57                  <div class="custom-file">
58                    <input id="pkcs12" class="custom-file-input" type="file" name="pkcs12" accept=".p12" required tabindex="2">
59                    <label class="custom-file-label" for="pkcs12">Seleccionar certificado PKCS12</label>
60                  </div>
61                </div>
62
63                <div class="form-group">
64                  <input id="phasepass" class="form-control" type="password" aria-describedby="passHelp"
65                         required tabindex="3" placeholder="Contraseña del certificado" />
66                  <small id="passHelp" class="form-text text-muted">Esta contraseña no será guardada en el servidor.</small>
67                  <input id="password" name="password" type="hidden" />
68                </div>
69
70                <div class="form-group text-center">
71                  <input class="btn btn-primary btn-block" name="submit" type="submit" value="Firmar" tabindex="4">
72                </div>
73
74              </form>
75            </div>
76          </div>
77
78        </section>
79      </div>
80    </div>
81  </main>
82
83  <!-- Footer -->
84  <?php require_once "./footer.php" ?>
85
86  <script src="../js/jsencrypt.min.js"></script>
87  <script>
88    (function() {
89      /**
90       * Función para imprimir los nombres en los label de los input[type=file]
91       */
92      var files = document.querySelectorAll('.custom-file-input');
93      var fileLabel = document.querySelectorAll('.custom-file-input ~ .custom-file-label');
94      for (var i = 0; i <= files.length -1; i++) {
95        files[i].addEventListener('change', function() {
96          let backslack = this.value.lastIndexOf("\\") + 1;
97          let namePDF = this.value.slice(backslack, this.value.length)
98          this.nextElementSibling.innerText = namePDF;
99        });
100      }
101    })();
102
103    (function() {
104    /**
105     * Función para encriptar la frase de paso
106     */
107      document.getElementById('phasepass').addEventListener('change', function() {
108        var encrypt = new JSEncrypt();
109        encrypt.setPublicKey(document.getElementById("pubkey").value);
110        document.getElementById("password").value = encrypt.encrypt(this.value);
111      });
112    })();
113
114  </script>
115</body>
116</html>
Note: See TracBrowser for help on using the repository browser.