<?php
if (isset($_REQUEST['idan']) && $_REQUEST['idan']*1<>0 && $_REQUEST['vue']=='balo' && isset($_GET['mode']) && $_GET['mode']=='pdf' ) {
	$tmp=explode('.', $_REQUEST['idan']);
	$rcs=substr($_REQUEST['siret'],0,9);
	if (is_numeric($tmp[0]))						$num=$tmp[0];
	if (is_numeric($tmp[1]))						$par=$tmp[1];
	$conid = mysql_pconnect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS);
	if (!($conid === false)) {
		if (mysql_select_db(MYSQL_DB, $conid) === false)
			die('Base de données indisponible');
	}
	$tabTmp=mysql_select('balo', 'Url_Annonce_Pdf, YEAR(Date_Parution) as Annee',
					 "Societe_Rcs='$rcs' AND Num_Affaire='$num' AND Num_Parution='$par'");
	$ann=$tabTmp[0];
	$file = PATH_DATA.'/jo/balo/'.$ann['Annee'].'/'.basename($ann['Url_Annonce_Pdf']);
	if (file_exists($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: ".filesize($file));
		header("Content-disposition: inline; filename=$file");
		header("Accept-Ranges: ".filesize($file)); 
		readfile($file);
	} else
		afficheErreur('Erreur 11000 : Document inexistant !');
	die();
}
$title='Annonces l&eacute;gales - Siren '.substr($_REQUEST['siret'],0,3).' '.substr($_REQUEST['siret'],3,3).' '.
										 substr($_REQUEST['siret'],6,3);
//echo "<!--_page=annonces-->\n";
$page2='annonces.php';
include('./pages/main.php');
?>