/usr/share/php/Icinga/File/Pdf.php is in php-icinga 2.1.0-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\File;
use DOMPDF;
use DOMDocument;
use DOMXPath;
use Font_Metrics;
use Icinga\Application\Icinga;
use Icinga\Web\StyleSheet;
use Icinga\Web\Url;
use Icinga\Exception\ProgrammingError;
require_once 'dompdf/dompdf_config.inc.php';
require_once 'dompdf/include/autoload.inc.php';
class Pdf extends DOMPDF
{
public $paginateTable = false;
public function __construct()
{
$this->set_paper('A4', 'portrait');
parent::__construct();
}
protected function assertNoHeadersSent()
{
if (headers_sent()) {
throw new ProgrammingError(
'Could not send pdf-response, content already written to output.'
);
}
}
public function renderControllerAction($controller)
{
$this->assertNoHeadersSent();
ini_set('memory_limit', '384M');
ini_set('max_execution_time', 300);
$viewRenderer = $controller->getHelper('viewRenderer');
$controller->render(
$viewRenderer->getScriptAction(),
$viewRenderer->getResponseSegment(),
$viewRenderer->getNoController()
);
$layout = $controller->getHelper('layout')->setLayout('pdf');
$layout->content = $controller->getResponse();
$html = $layout->render();
$imgDir = Url::fromPath('img');
$html = preg_replace('~src="' . $imgDir . '/~', 'src="' . Icinga::app()->getBootstrapDirectory() . '/img/', $html);
$this->load_html($html);
$this->render();
$request = $controller->getRequest();
$this->stream(
sprintf(
'%s-%s-%d.pdf',
$request->getControllerName(),
$request->getActionName(),
time()
)
);
}
}
|