source: portal_2019/php/sign.php @ b8bdf51

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

Portal funcional

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