1 |
aurelien |
1 |
<?
|
|
|
2 |
include("../modules/connect.php");
|
|
|
3 |
|
|
|
4 |
$contenu = "";
|
|
|
5 |
$entetes = array("sequence_id","mesure_id","mesure_annee","mesure_date","evenement_nom","code_bbch_numero",
|
|
|
6 |
"espece_nom_scientifique","plateforme_nom","pltaforme_longitude",
|
|
|
7 |
"plateforme_latitude","plateforme_altitude","plateforme_type_nom","personne_id");
|
|
|
8 |
$requete_utils = mysql_query("select distinct -MESURE.SEQUENCE_ID, -MESURE.MESURE_ID, ".
|
|
|
9 |
"EXTRACT(YEAR from MESURE_DATE), ".
|
|
|
10 |
"DATE_FORMAT(MESURE_DATE,'%d/%m/%Y'), EVENEMENT_NOM, NULL, ".
|
|
|
11 |
"ESPECE_NOM_SCIENTIFIQUE, STATION_NOM, STATION_LATITUDE, ".
|
|
|
12 |
"STATION_LONGITUDE, SEQUENCE_ALTITUDE, ENVIRONNEMENT_NOM, ".
|
|
|
13 |
"-SEQUENCE.PARTICIPANT_ID ".
|
|
|
14 |
"from MESURE, SEQUENCE, EVENEMENT, ESPECE, STATION, ENVIRONNEMENT ".
|
|
|
15 |
"where MESURE.SEQUENCE_ID=SEQUENCE.SEQUENCE_ID ".
|
|
|
16 |
"and SEQUENCE.ESPECE_ID=ESPECE.ESPECE_ID ".
|
|
|
17 |
"and MESURE.EVENEMENT_ID=EVENEMENT.EVENEMENT_ID ".
|
|
|
18 |
"and STATION.STATION_ID=SEQUENCE.STATION_ID ".
|
|
|
19 |
"and ENVIRONNEMENT.ENVIRONNEMENT_ID=SEQUENCE.ENVIRONNEMENT_ID ORDER BY MESURE_DATE");
|
|
|
20 |
|
|
|
21 |
$fichierc = implode(';',$entetes)."\n";
|
|
|
22 |
while ($util = mysql_fetch_row($requete_utils)) {
|
|
|
23 |
if (($icode = strpos($util[4],"stade"))>0) {
|
|
|
24 |
$code_bbch = substr($util[4],$icode+5);
|
|
|
25 |
$util[5] = $code_bbch;
|
|
|
26 |
$util[4] = substr($util[4],0,$icode-1);
|
|
|
27 |
}
|
|
|
28 |
$fichierc .= implode(';',$util)."\n";
|
|
|
29 |
}
|
|
|
30 |
$fichier = "observations_export.csv";
|
|
|
31 |
$handle = fopen($chemin.$fichier,'w');
|
|
|
32 |
fwrite($handle,$fichierc);
|
|
|
33 |
fclose($handle);
|
|
|
34 |
|
|
|
35 |
$contenue = file_get_contents($fichier);
|
|
|
36 |
$tailledufichier = filesize($fichier);
|
|
|
37 |
|
|
|
38 |
@ob_end_clean();
|
|
|
39 |
@ini_set('zlib.output_compression','Off');
|
|
|
40 |
|
|
|
41 |
header('Pragma: public');
|
|
|
42 |
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
|
|
43 |
header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0');
|
|
|
44 |
|
|
|
45 |
header('Content-Tranfer-Encoding: none');
|
|
|
46 |
|
|
|
47 |
header('Content-Type: application/octetstream; name="'.$fichier.'"');
|
|
|
48 |
header('Content-Disposition: attachement; filename="'.$fichier.'"');
|
|
|
49 |
|
|
|
50 |
header('Content-Length: '.$tailledufichier);
|
|
|
51 |
|
|
|
52 |
echo $contenue;
|
|
|
53 |
exit();
|
|
|
54 |
?>
|