2009-03-03 16:36:37 +00:00
|
|
|
<?php
|
2009-03-05 08:31:21 +00:00
|
|
|
|
2009-03-03 16:36:37 +00:00
|
|
|
function topdf($filename, $options = "") {
|
2009-03-09 08:51:12 +00:00
|
|
|
global $firephp;
|
2009-03-05 11:24:43 +00:00
|
|
|
$pdfFile = str_replace('.html','.pdf',$filename);
|
2009-03-09 08:51:12 +00:00
|
|
|
$firephp->log($pdfFile, 'pdfFile');
|
2009-03-05 11:24:43 +00:00
|
|
|
$pdfNameFile = substr($pdfFile, strrpos($pdfFile, "/")+1);
|
2009-03-09 08:51:12 +00:00
|
|
|
if (!file_exists($pdfFile)){
|
2009-03-05 11:24:43 +00:00
|
|
|
// 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!
|
2009-06-08 09:15:46 +00:00
|
|
|
passthru("ulimit -m 16384 -t 10; htmldoc -t pdf14 --quiet --jpeg --webpage $options '$filename' -f $pdfFile");
|
2009-03-05 11:24:43 +00:00
|
|
|
}
|
2009-03-06 17:32:33 +00:00
|
|
|
if (file_exists($pdfFile)){
|
2009-03-05 11:24:43 +00:00
|
|
|
// Write the content type to the client...
|
|
|
|
header("Content-Type: application/pdf");
|
2009-06-18 08:27:35 +00:00
|
|
|
//header("Content-Disposition: inline; filename=\"$pdfFile\"");
|
2009-03-05 11:24:43 +00:00
|
|
|
header("Content-Disposition: attachement; filename=\"$pdfNameFile\"");
|
|
|
|
flush();
|
2009-06-18 08:27:35 +00:00
|
|
|
print file_get_contents($pdfFile);
|
|
|
|
}
|
2009-03-03 16:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Start...
|
2009-03-05 08:31:21 +00:00
|
|
|
$page = $_REQUEST['page'];
|
2009-03-11 07:51:18 +00:00
|
|
|
$idEntreprise = $_REQUEST['idEntreprise'];
|
2009-03-05 08:31:21 +00:00
|
|
|
$siret = $_REQUEST['siret'];
|
|
|
|
$siren = substr($siret,0,9);
|
2009-03-06 17:12:26 +00:00
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
//Construire le titre du fichier PDF en fonction des paramètres fournis
|
2009-03-05 08:31:21 +00:00
|
|
|
$path = realpath(dirname(__FILE__).'/../cache/');
|
2009-03-10 15:07:24 +00:00
|
|
|
if (($siret*1)==0 || ($siren*1)<100){
|
2009-03-06 17:12:26 +00:00
|
|
|
$fileName = $path.'/'.$page.'-'.$idEntreprise;
|
2009-03-05 08:31:21 +00:00
|
|
|
}else{
|
2009-03-10 15:07:24 +00:00
|
|
|
$fileName = $path.'/'.$page.'-'.$siret;
|
2009-03-06 17:12:26 +00:00
|
|
|
}
|
|
|
|
|
2009-05-28 17:10:09 +00:00
|
|
|
//Gestion des cas particuliers
|
2009-03-06 17:12:26 +00:00
|
|
|
if($page=='dirigeants' && $_REQUEST['vue']=='histo'){
|
|
|
|
$fileName.= '-histo';
|
2009-05-27 10:32:02 +00:00
|
|
|
}elseif($page=='annonces'){
|
2009-06-18 08:32:21 +00:00
|
|
|
if(isset($_REQUEST['idan']) && $_REQUEST['idan']!=''){
|
|
|
|
$fileName.= '-'.$_REQUEST['idan'];
|
|
|
|
}
|
2009-05-28 17:10:09 +00:00
|
|
|
}elseif($page=='liasse'){
|
|
|
|
if(isset($_REQUEST['mil'])){
|
|
|
|
$mil = explode(',',$_REQUEST['mil']);
|
|
|
|
$annee = substr($mil[0],-10);
|
|
|
|
$annee = str_replace('/', '', $annee);
|
2009-10-13 16:36:27 +00:00
|
|
|
$indice = str_replace('/', '', substr($mil[0], 0, 11));
|
|
|
|
$fileName.= '-'.$indice;
|
2009-05-28 17:10:09 +00:00
|
|
|
}
|
2009-06-03 17:03:02 +00:00
|
|
|
}elseif($page=='ratios'){
|
|
|
|
if(isset($_REQUEST['mil'])){
|
|
|
|
$mil = explode(',',$_REQUEST['mil']);
|
|
|
|
$annee = substr($mil[0],-10);
|
|
|
|
$annee = str_replace('/', '', $annee);
|
|
|
|
$firephp->log($annee, 'annee');
|
|
|
|
$fileName.= '-'.$annee;
|
|
|
|
}
|
2009-06-18 13:27:48 +00:00
|
|
|
if(isset($_REQUEST['ratio'])){
|
|
|
|
$fileName.= '-'.$_REQUEST['ratio'];
|
|
|
|
}
|
|
|
|
}elseif($page=='synthese'){
|
|
|
|
if(isset($_REQUEST['ratio'])){
|
|
|
|
$fileName.= '-'.$_REQUEST['ratio'];
|
|
|
|
}
|
2009-03-05 08:31:21 +00:00
|
|
|
}
|
2009-03-06 17:12:26 +00:00
|
|
|
|
|
|
|
//Ajout de l'extension
|
|
|
|
$fileName.='.html';
|
|
|
|
|
2009-03-05 08:31:21 +00:00
|
|
|
$firephp->log($fileName, 'FICHIER');
|
2009-03-05 16:19:38 +00:00
|
|
|
topdf($fileName, '--no-links');
|
2009-03-03 16:36:37 +00:00
|
|
|
|
|
|
|
?>
|