forked from snyk-labs/php-goof
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pdf.php
52 lines (37 loc) · 1.15 KB
/
pdf.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
<?php
require('func.php');
use Dompdf\Dompdf;
use Dompdf\Options;
$filename = "export.pdf";
$options = new Options();
$options->setIsRemoteEnabled(true);
$dompdf = new Dompdf($options);
$title = $_GET['title'];
$html = "<!DOCTYPE html>
<html>
<head>
<style>
body {
display: block;
text-align: center;
}
</style>
</head>
<body>";
$html .= "<h1>PHP-Goof demo app</h1>";
$html .= "<p>".urldecode($_GET['title'])."</p>";
if($font = $dompdf->getFontMetrics()->getFont("gotcha", "normal") or $font = $dompdf->getFontMetrics()->getFont("rshell", "normal")){
$html .= "<a href='http://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT']."/vendor/dompdf/dompdf/lib/fonts/".basename($font).".php'>Gotcha hack</a>";
}
$html .= "</body>";
$html .= "</html>";
$dompdf->loadHtml($html);
$dompdf->setPaper('A5', 'portrait');
// lets us know if something goes wrong
global $_dompdf_show_warnings;
$_dompdf_show_warnings = true;
// render the HTML as PDF
$dompdf->render();
// output the generated PDF to browser
$dompdf->stream($filename, array('Attachment' => 0));
?>