Rev 1 | Blame | Last modification | View Log | RSS feed
<?
include("../modules/connect.php");
$contenu = "";
$entetes = array("sequence_id","mesure_id","mesure_annee","mesure_date","evenement_nom","code_bbch_numero",
"espece_nom_scientifique","plateforme_nom","pltaforme_longitude",
"plateforme_latitude","plateforme_altitude","plateforme_type_nom","personne_id");
$requete_utils = mysql_query("select distinct -MESURE.SEQUENCE_ID, -MESURE.MESURE_ID, ".
"EXTRACT(YEAR from MESURE_DATE), ".
"DATE_FORMAT(MESURE_DATE,'%d/%m/%Y'), EVENEMENT_NOM, NULL, ".
"ESPECE_NOM_SCIENTIFIQUE, STATION_NOM, STATION_LATITUDE, ".
"STATION_LONGITUDE, SEQUENCE_ALTITUDE, ENVIRONNEMENT_NOM, ".
"-SEQUENCE.PARTICIPANT_ID ".
"from MESURE, SEQUENCE, EVENEMENT, ESPECE, STATION, ENVIRONNEMENT ".
"where MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID ".
"and SEQUENCE.ESPECE_ID=ESPECE.ESPECE_ID ".
"and MESURE.EVENEMENT_ID=EVENEMENT.EVENEMENT_ID ".
"and STATION.STATION_ID=SEQUENCE.STATION_ID ".
"and ENVIRONNEMENT.ENVIRONNEMENT_ID=SEQUENCE.ENVIRONNEMENT_ID ORDER BY MESURE_DATE");
$fichierc = implode(';',$entetes)."\n";
while ($util = mysql_fetch_row($requete_utils)) {
if (($icode = strpos($util[4],"stade"))>0) {
$code_bbch = substr($util[4],$icode+5);
$util[5] = $code_bbch;
$util[4] = substr($util[4],0,$icode-1);
}
$fichierc .= implode(';',$util)."\n";
}
$fichier = "observations_export.csv";
$handle = fopen($chemin.$fichier,'w');
fwrite($handle,$fichierc);
fclose($handle);
$contenue = file_get_contents($fichier);
$tailledufichier = filesize($fichier);
@ob_end_clean();
@ini_set('zlib.output_compression','Off');
header('Pragma: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0');
header('Content-Tranfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$fichier.'"');
header('Content-Disposition: attachement; filename="'.$fichier.'"');
header('Content-Length: '.$tailledufichier);
echo $contenue;
exit();
?>