TransWar File Browser

Path: C:\

<?php
function LoadData($file)
{
  $lines = file($file);
  $data = array();
  foreach ($lines as $line)
    $data[] = explode('|', trim($line));
  return $data;
}
$data = LoadData('\\\\tw-nas\\06-RH\\AFD\\Projeto\\Funcionarios_corel_final_lote.txt');
$ii = count($data);

// Mesma geometria do gerador individual: o cartao na tela guarda a proporcao do
// template e a captura sai direto no tamanho de impressao (6 cm a 300 DPI).
$imgSize = getimagesize(__DIR__ . '/QRHTML.png');
$displayW = 240;
$displayH = round($displayW * $imgSize[1] / $imgSize[0]);
$printW = 709;
$captureScale = $printW / $displayW;

include 'vendor/autoload.php';
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
for ($x = 0; $x < $ii; $x++) {
  $renderer = new ImageRenderer(
    new RendererStyle(160),
    new SvgImageBackEnd()
  );
  $writer = new Writer($renderer);

  $url = $data[$x][1];
  $nome_arq = $data[$x][0];

  $name = $nome_arq;

  if (!mb_check_encoding($nome_arq, 'UTF-8')) {
    $nome_arq = mb_convert_encoding($nome_arq, 'UTF-8', 'ISO-8859-1');
  }
  if (!mb_check_encoding($url, 'UTF-8')) {
    $url = mb_convert_encoding($url, 'UTF-8', 'ISO-8859-1');
  }

  $name = $nome_arq;
  $split_name = explode(" ", $name);
  if (count($split_name) > 2) {
    for ($i = 1; (count($split_name) - 1) > $i; $i++) {
      if (mb_strlen($split_name[$i], 'UTF-8') > 3) {
        $split_name[$i] = mb_substr($split_name[$i], 0, 1, 'UTF-8') . ".";
      }
    }
  }
  $final = implode(" ", $split_name);

  $qrcode = $writer->writeString($url);

  echo '
  <script src="./js/html2canvas.js"></script>
    <style>
      #botao {
        display: none;
      }
      .hero-image {
        height: ' . $displayH . 'px;
        width: ' . $displayW . 'px;
        position: relative;
        overflow: hidden;
      }

      .hero-qrcode {
        text-align: center;
        position: absolute;
        width: 160px;
        top: 84px;
        left: 40px;
        z-index: 2;
      }    
      .hero-qrtxt {
        text-align: center;
        position: absolute;
        line-height: 95%;
        top: 260px;
        width: 216px;
        left: 12px;
        z-index: 2;
      }    
    </style>
    <body>
      <div class="container">
        <!-- Modal -->
        <div id="aqui">
          <button type="button" id="botao" data-bs-toggle="modal" data-bs-target="#myModal"></button>
          <div class="modal fade" id="myModal" role="dialog" data-bs-theme="light">
            <div class="modal-dialog modal-sm modal-dialog-centered">
              <div class="modal-content border-0 shadow-lg" style="border-radius:12px;">
                <div class="modal-body" align="center" style="background:#f8fafc; border-radius:12px;">
                  <div id="' . $final . '-wrapper" style="padding: 10px; background: transparent; width: 260px; height: 370px; box-sizing: border-box; position: relative;">
                    <div class="hero-image" id="' . $final . '">
                      <img src="QRHTML.png" style="position: absolute; top:0; left:0; width: 100%; height: 100%; z-index: 1;" crossorigin="anonymous" />
                      <div class="hero-qrcode">' . $qrcode . '</div>
                      <div class="hero-qrtxt" style="color:#000;">
                        <strong style="font-size: 18px; display:block; margin-bottom:5px; line-height: 1.1;">' . $final . '</strong>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </body>
    <script type="text/javascript">
          window.scrollTo(0, 0);
          setTimeout(function() {
              html2canvas(document.getElementById("' . $final . '"), {
                  scale: ' . $captureScale . ',
                  useCORS: true,
                  backgroundColor: null,
                  logging: false,
                  scrollX: 0,
                  scrollY: 0
              }).then(function (canvas) {
       
              // Create an AJAX object
              var ajax = new XMLHttpRequest();
       
              // Setting method, server file name, and asynchronous
              ajax.open("POST", "save-capture2.php?arq=' . rawurlencode($final) . '", true);
       
              // Setting headers for POST method
              ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
       
              // Sending image data to server
              ajax.send("image=" + encodeURIComponent(canvas.toDataURL("image/png")));
       
              // Receiving response from server
              // This function will be called multiple times
              ajax.onreadystatechange = function () {
       
                  // Check when the requested is completed
                  if (this.readyState == 4 && this.status == 200) {
       
                      // Displaying response from server
                      console.log(this.responseText);
                  }
              };
          });
          }, 150);
    </script>
	';
}
?>