extranet/www/pages/actes.php
2009-07-21 07:17:54 +00:00

49 lines
1.4 KiB
PHP

<?php
require_once 'common/curl.php';
if (!$_SESSION['connected'])
echo ('Vous devez être connecté afin de pouvoir utiliser cette fonctionnalité');
else
{
$eol="\n";
$siret=$_REQUEST['siret'];
$siren=substr($siret,0,9);
if (substr($_REQUEST['ref'],0,6)=='bilan-') {
$ref=substr($_REQUEST['ref'],6,strlen($_REQUEST['ref'])-6);
$file = PATH_DATA.'/pdf/bilan-'.$siren.'-'.$ref.'.pdf';
} elseif (substr($_REQUEST['ref'],0,4)=='kbis') {
$file= PATH_DATA.'/pdf/kbis-'.$siren.'.pdf';
if (!file_exists($file) ||
date('Ymd', filemtime($file))<>date('Ymd') ||
filesize($file)<=500 ) {
$page=getUrl(WEBSERVICE_URI.'pdf/kbis-'.$siren.'.pdf', '', '', '', false);
$body=$page['body'];
$fp=@fopen($file, 'w');
@fwrite($fp, $body);
@fclose($fp);
}
} elseif (substr($_REQUEST['ref'],0,4)=='rncs') {
$ref=substr($_REQUEST['ref'],5,strlen($_REQUEST['ref'])-5);
$file= PATH_DATA.'/pdf/rncs-'.$siren.'-'.$ref.'.pdf';
} else {
$ref=$_REQUEST['ref'];
$file= PATH_DATA.'/pdf/acte-'.$siren.'-'.$ref.'.pdf';
}
$filename=basename($file);
$body=file_get_contents($file);
header("Pragma: public");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate");
header("Content-type: application/pdf");
header("Content-Length: ".strlen($body));
header('Content-disposition: inline; filename="'.$filename.'"');// attachement or inline
header("Accept-Ranges: ".strlen($body));
echo $body;
}
?>