TransWar File Browser

Path: C:\

<?php
if (isset($_GET['arquivo'])) 
{ $arqxlsx=$_GET['arquivo'];
  echo "<!DOCTYPE html>
  <html lang='pt-br'>
  <head>
  <meta http-equiv='Refresh' CONTENT='1;URL=http://192.168.0.211:80/Viagens/".$arqxlsx."'>
  ";
}
else
{ echo"<!DOCTYPE html>
  <html lang='pt-br'>
  <head>";
}
ini_set('max_execution_time',259200); 
ini_set ('memory_limit','-1');
error_reporting(E_ALL);
ini_set('display_errors', 'On');
date_default_timezone_set('America/Sao_Paulo');
$hoje = date("d-m-Y H:i"); 
require_once 'includes/connect.inc.php';
$p=0;
$tsql =  "SELECT *  FROM trilha ORDER BY dia ASC";
$row2= $db->query($tsql);
while ($row = $row2->fetch(PDO::FETCH_BOTH)) 
{ 
  $dia[$p]  = $row ["dia" ];
  $nome[$p] = $row['usuario'];
  $mov[$p] = $row['movimento'];
  $just[$p] = $row['motivo'];
  $p++;
}
?>
<!DOCTYPE html>
<html lang='pt-br'>
<head>
<meta charset='utf-8'/>
<meta http-equiv="pragma" content="no-cache">
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
<title>TRILHA DE MUDANÇAS</title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<script src='../js/jquery-3.2.1.min.js'></script>
<script src='../js/tabelas.js'></script>
<link href="../css/tabelas3.css" rel="stylesheet">		
</head>
<table class="blue">
  <col width="3%" />
  <col width="10%" />
  <col width="15%" />
  <col width="30%" />
  <col width="42%" />
  <h1><?php echo "TRILHA DE MUDANÇAS";?></h1>
  <thead>
    <tr>
      <th style='border: 2px solid white;'>Nº</th>
      <th style='border: 2px solid white;'>Data</th>
      <th style='border: 2px solid white;'>Usuário</th>
      <th style='border: 2px solid white;'>Mudança</th>
      <th style='border: 2px solid white;'>Justificativa</th>
    </tr>
  </thead>
  <tbody>
<?php
$r=0;
$fptemp = fopen('trilha.csv', 'w+');
$cabecalho1='TRILHA DE MUDANÇAS NA ESCALA DE VIAGENS';
$cabecalho2='Nº;Data;Usuário;Mudança;Justificativa';
fwrite($fptemp,$cabecalho1.PHP_EOL);  
fwrite($fptemp,$cabecalho2.PHP_EOL);  
$lin=2;
for($y=0;$y<$p;$y++)
{ $dat=date("d-m-Y H:i:s",intval($dia[$y]));
  $r++;
  echo "
      <tr>
        <td>".$r."</td>
        <td style='text-align: center;'>".$dat."</td>
        <td style='text-align: left;'>&nbsp;".$nome[$y]."</td>
        <td style='text-align: left;'>&nbsp;".$mov[$y]."</td>
        <td style='text-align: left;'>&nbsp;".$just[$y]."</td>
      </tr>";
      $linha=$r.';'.$dat.';'.$nome[$y].';'.$mov[$y].';'.$just[$y].PHP_EOL;
      fwrite($fptemp,$linha);$lin++;
}
fclose($fptemp);
echo "
    </tbody>
  </table>
  <table align='center'>
    <tr>
      <td>
        <form method='GET' action='viagem03.php'>
          <button type='submit' class='btn btn-primary'>Voltar</button>
        </form>
      </td>
      <td>
        <form method='GET' action='viagem06.php'>
          <input id='lin' name='lin' type='hidden' value='".$lin."' />
          <button type='submit' class='btn btn-primary'>Baixar EXCEL</button>
        </form>
      </td>
    </tr>
  </table>
";
?>