-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdf_visu.php
60 lines (57 loc) · 1.92 KB
/
pdf_visu.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_start();
if($_SESSION['acesso']==""){
header("Location:index.php");
die;
}
?>
<?php
include_once "ConAL.php";
$nome = $_GET['id'];
if($nome ==""){
echo "Nenhum registro selecionado";
}else{
$usuario = $_SESSION['usuarioname'];
$setor = $_SESSION['setor'];
$data = date('Y-m-d');
$result_usuarioa = "SELECT * FROM Ko WHERE id LIKE '".$nome."'";
$resultado_usuarioa = mysqli_query($conn, $result_usuarioa);
$row_usuarioa = mysqli_fetch_assoc($resultado_usuarioa);
$local = $row_usuarioa['can'];
if (isset($local)){
$pdf_name = $row_usuarioa['nome_pdf'];
$conf = fopen('conf.txt','r');
$conf = fgets($conf, 1024);
$local =$conf.$local;
$ln = $row_usuarioa['nome'];
if (file_exists($local)) {
$inser = "INSERT INTO acessos (id, id_doc, uso_ac, uso_set, dt_acesso)
VALUES (NULL, '$nome', '$usuario', '$setor', '$data')";
mysqli_query($conn, $inser);
$file = $local;
$filename = $pdf_name;
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' .$filename. '"');
header('Content-Transfer-Encoding; binary');
header('Accept-Ranges; bytes');
readfile($file);
}elseif (file_exists($conf."/In/pdf/".$row_usuarioa['can'])){
$inser = "INSERT INTO acessos (id, id_doc, uso_ac, uso_set, dt_acesso)
VALUES (NULL, '$nome', '$usuario', '$setor', '$data')";
mysqli_query($conn, $inser);
$file = $conf."/In/pdf/".$row_usuarioa['can'];
$filename = $pdf_name;
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' .$filename. '"');
header('Content-Transfer-Encoding; binary');
header('Accept-Ranges; bytes');
readfile($file);
}
else{
echo "<script>alert('Ocorreu um erro [document does not exist], reporte ao administrador')</script><script>javascript:window.close()</script>";
}
}else{
echo "<script>alert('Ocorreu um erro [does not exist], reporte ao administrador')</script><script>javascript:window.close()</script>";
}
}
?>