extranet/www/exportpdf.php
Michael RICOIS 5e2a861076 Export PDF
2009-03-05 08:31:21 +00:00

50 lines
1.4 KiB
PHP

<?php
function topdf($filename, $options = "") {
// Write the content type to the client...
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=\"$filename.pdf\"");
//header("Content-Disposition: attachement; filename=\"$filename.pdf\"");
flush();
// Run HTMLDOC to provide the PDF file to the user...
// Use the --no-localfiles option for enhanced security!
// Use ulimit to limit the maximum amount of memory used by each instance!
passthru("ulimit -m 16384 -t 5; htmldoc --no-localfiles -t pdf14 --quiet --jpeg --webpage $options '$filename'");
}
function bad_url($url) {
// See if the URL starts with http: or https:...
if (strncmp($url, "http://", 7) != 0 &&
strncmp($url, "https://", 8) != 0)
{ return 1; }
// Check for bad characters in the URL...
$len = strlen($url);
for ($i = 0; $i < $len; $i ++) {
if (!strchr("~_*()/:%?+-&@;=,$.", $url[$i]) &&
!ctype_alnum($url[$i]))
{ return 1; }
}
return 0;
}
//Start...
$page = $_REQUEST['page'];
$idEntreprise = $_REQUEST['iden'];
$siret = $_REQUEST['siret'];
$siren = substr($siret,0,9);
//Construire le titre du fichier PDF en fonction des paramètres fournis
$path = realpath(dirname(__FILE__).'/../cache/');
if ($siren==0){
$fileName = $path.'/'.$page.'-'.$idEntreprise.'.html';
}else{
$fileName = $path.'/'.$page.'-'.$siren.'.html';
}
$firephp->log($fileName, 'FICHIER');
exit;
topdf($fileName);
?>