This repository was archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdisplayPDF.php
More file actions
83 lines (63 loc) · 2.69 KB
/
displayPDF.php
File metadata and controls
83 lines (63 loc) · 2.69 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/*
* displayPDF.php
* displays a PDF file stored in the database. Ensures that you are logged in first and that
* you have permission to view this PDF (either an admin or you did this person's expungement)
* Copyright 2011-2015 Community Legal Services
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once("config.php");
require_once("Attorney.php");
// if the user isn't logged in, then don't display this page. Tell them they need to log in.
if (!isLoggedIn())
include("displayNotLoggedIn.php");
else
{
$attorney = new Attorney($_SESSION["loginUserID"], $db);
if($GLOBALS['debug'])
$attorney->printAttorneyInfo();
// only certain users can see this page
// we're being overly restrictive right now - only letting CLS lawyers see it
if ($attorney->getProgramId() != 1)
print "You must have permission to view this page.";
else
{
$id = $_GET['id'];
$docketFile = $GLOBALS['docketSheetsDir'] . "$id";
$outputFilename = ".pdf";
// get the docket number from the arrest ID
$sql = "SELECT docketNumPrimary as docketNum FROM arrest WHERE arrest.arrestID='" . ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $id) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : "")) . "'";
$result = $db->query($sql);
if (!$result)
{
if ($GLOBALS['debug'])
die("Could not get the PDF from the databsae. Perhaps it doesn't exist?:" . $db->error);
else
die("Could not get the PDF from the databsae. Perhaps it doesn't exist?");
}
$row = $result->fetch_assoc();
$result->close();
// set the filename to the docket number. at some point we might want to change this
// so that we have a zip file with all of the docket numbers
$outputFilename = $row['docketNum'] . $outputFilename;
header('Content-type: application/pdf');
//header("Content-length: {$row['size']}");
header("Content-length: " . filesize($docketFile));
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: inline;filename='$outputFilename'");
// echo $row['data'];
readfile($docketFile);
}
}
?>