1<?php
2
3/*
4 * LibreNMS
5 *
6 * Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.  Please see LICENSE.txt at the top level of
12 * the source code distribution for details.
13 */
14
15use LibreNMS\Config;
16use LibreNMS\Util\Debug;
17
18$init_modules = ['web', 'auth'];
19require realpath(__DIR__ . '/..') . '/includes/init.php';
20
21if (! Auth::check()) {
22    exit('Unauthorized');
23}
24
25Debug::set(strpos($_SERVER['PATH_INFO'], 'debug'));
26
27$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
28
29$project_name = Config::get('project_name');
30
31$pdf->SetCreator($project_name);
32$pdf->SetAuthor($project_name);
33$pdf->setFooterData([0, 64, 0], [0, 64, 128]);
34$pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);
35$pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]);
36$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
37$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
38$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
39$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
40$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
41$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
42$pdf->setFontSubsetting(true);
43$pdf->SetFont('dejavusans', '', 14, '', true);
44$pdf->setTextShadow(['enabled' => false, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => [196, 196, 196], 'opacity' => 1, 'blend_mode' => 'Normal']);
45
46if (! empty($_GET['report'])) {
47    $report = \LibreNMS\Util\Clean::fileName($_GET['report']);
48    $image = base_path('html/' . Config::get('title_image'));
49    $pdf->SetHeaderData($image, 40, ucfirst($report), $project_name, [0, 0, 0], [0, 64, 128]);
50    include_once "includes/html/reports/$report.pdf.inc.php";
51} else {
52    $report = 'report';
53}
54
55$pdf->Output("$report.pdf", 'I');
56