Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 242 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 jpm 1
<?php
2
class Chorodep extends Script {
3
	protected $nbre_dep = 0;
4
	private $type_donnee = '';
5
	protected $aso_num_nomenc = array();
6
	protected $nbre_ligne = 0;
7
	protected $nbre_plte_presente = 0;
8
	protected $nbre_plte_a_confirmer = 0;
9
	protected $nbre_plte_douteux = 0;
10
	protected $nbre_plte_erreur = 0;
11
	protected $nbre_plte_disparue = 0;
12
	protected $nc_autres_valeur_champ = 0;
13
	protected $aso_totaux_dep = array();
14
 
15
 
16
	public function __construct($cmd, $parametres = array()) {
17
		parent::__construct($cmd, $parametres);
18
		$this->fichier_verif = './chorodep_verif.html';
19
	}
20
 
21
	public function executer() {
22
		$this->bdd = new Bdd();
23
		$cmd = $this->getParametre('a');
24
		switch ($cmd) {
25
 
26
			case 'verifier-donnees' :
27
				$this->initialiserTraitement();
28
				$this->verifierDonnees();
29
				break;
30
 
31
			default :
32
				echo 'Erreur : la commande "'.$cmd.'" n\'existe pas!'."\n";
33
		}
34
	}
35
 
36
	private function initialiserTableaux($dep) {
37
		//$departements = new ZgFrDepartements();
38
		//$dep = $departements->get();
39
		//$a = array();
40
		foreach ($dep as $code_dep) {
41
			if ( preg_match('/^\d{2}$/', $code_dep) ) {
42
				$this->aso_totaux_dep[$code_dep]['plte_presente'] = 0;
43
				$this->aso_totaux_dep[$code_dep]['plte_a_confirmer'] = 0;
44
				$this->aso_totaux_dep[$code_dep]['plte_douteux'] = 0;
45
				$this->aso_totaux_dep[$code_dep]['plte_erreur'] = 0;
46
				$this->aso_totaux_dep[$code_dep]['plte_disparue'] = 0;
47
				$this->aso_totaux_dep[$code_dep]['autres_valeur_champ'] = 0;
48
				$this->aso_totaux_dep[$code_dep]['nc_plte_presente'] = 0;
49
				$this->aso_totaux_dep[$code_dep]['nc_plte_a_confirmer'] = 0;
50
				$this->aso_totaux_dep[$code_dep]['nc_plte_douteux'] = 0;
51
				$this->aso_totaux_dep[$code_dep]['nc_plte_erreur'] = 0;
52
				$this->aso_totaux_dep[$code_dep]['nc_plte_disparue'] = 0;
53
				$this->aso_totaux_dep[$code_dep]['nc_autres_valeur_champ'] = 0;
54
			}
55
		}
56
	}
57
	private function initialiserTraitement() {
58
		//------------------------------------------------------------------------------------------------------------//
59
		// Récupération des informations à vérifier
60
		$requete = 	'SELECT * '.
61
					'FROM chorodep ';
62
		$taxons = $this->bdd->recupererTous($requete);
63
		$tax_col = $taxons[1];
64
		$col = array_keys($tax_col);
65
		$this->initialiserTableaux($col);
66
		//------------------------------------------------------------------------------------------------------------//
67
		// Analyse des données
68
		echo 'Traitement de la ligne n° :';
69
		$i = 0;
70
		$j = 0;
71
		$aso_departements_analyses = array();
72
		$this->nbre_ligne_avec_guillemet = 0;
73
		foreach ($taxons as $aso_champs) {
74
			$nom = $aso_champs['nom_sci'];
75
			$num_taxo = $aso_champs['num_tax'];
76
			$num_nomenc = $aso_champs['num_nom'];
77
			if ($num_nomenc == 'nc') {
78
				$this->nc_nbre_nom++;
79
			} else if ($num_nomenc != 'nc') {
80
				$this->nbre_nom++;
81
				// Vérification de la nom duplication des numéros nomenclaturaux
82
				if ( !array_key_exists($num_nomenc, (array) $this->aso_num_nomenc) ) {
83
					$this->aso_num_nomenc[$num_nomenc]['compteur'] = 1;
84
					$this->aso_num_nomenc[$num_nomenc]['ligne'] = ($this->nbre_ligne+1);
85
				} else {
86
					$this->aso_num_nomenc[$num_nomenc]['compteur']++;
87
					$this->aso_num_nomenc[$num_nomenc]['ligne'] .= ' - '.($this->nbre_ligne+1);
88
				}
89
			}
90
			foreach ($aso_champs as $cle => $val ) {# Pour chaque département du taxon, on regarde la valeur
91
				$this->nbre_ligne_avec_guillemet += preg_match('/"/', $val);
92
				if ( preg_match('/^\d{2}$/', $cle) ) {# Nous vérifions que le nom du champs comprend bien le numéro du département entre ()
93
					$nd = $cle;# Numéro du département
94
					// Nous comptons le nombre de département en base de données
95
					if (!isset($aso_departements_analyses[$nd])) {
96
						$this->nbre_dep_analyse++;
97
						$aso_departements_analyses[$nd] = $nd;
98
					}
99
					if ( $num_nomenc != 'nc' && isset($val) && $val != '') {# Si le taxon n'est pas abscent du département
100
						if ($val == '1') {# Présent
101
							// Calcul du nombre de plante ayant un statut "Présent"
102
							$this->nbre_plte_presente++;
103
							// Stockage par département du nombre de plante ayant un statut "Présent"
104
							$this->aso_totaux_dep[$nd]['plte_presente']++;
105
							// Stockage des informations
106
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 3, $this->id_donnee_choro++);
107
						} else if ($val == '1?') {# Présence à confirmer
108
							// Calcul du nombre de plante ayant un statut "Présence à confirmer"
109
							$this->nbre_plte_a_confirmer++;
110
							// Stockage par département du nombre de plante ayant un statut "Présence à confirmer"
111
							$this->aso_totaux_dep[$nd]['plte_a_confirmer']++;
112
							// Stockage des informations
113
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 4, $this->id_donnee_choro++);
114
						} else if (preg_match('/^\s*(?:\?)\s*$/', $val)) {# Douteux
115
							// Calcul du nombre de plante ayant un statut "Disparu ou douteux"
116
							$this->nbre_plte_douteux++;
117
							// Stockage par département du nombre de plante ayant un statut "Douteux"
118
							$this->aso_totaux_dep[$nd]['plte_douteux']++;
119
							// Stockage des informations
120
							$this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 5, $this->id_donnee_choro++);
121
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
122
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
123
								$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
124
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
125
							}
126
						} elseif (preg_match('/^\s*(?:#)\s*$/', $val)) {# Erreur
127
	                        # Calcul du nombre de plante ayant un statut "Erreur"
128
	                        $this->nbre_plte_erreur++;
129
	                        # Stockage par département du nombre de plante ayant un statut "Erreur"
130
	                        $this->aso_totaux_dep[$nd]['plte_erreur']++;
131
	                        # Stockage des informations
132
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
133
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
134
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
135
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
136
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
137
	                        }
138
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
139
	                        # Calcul du nombre de plante ayant un statut "Disparu"
140
	                        $this->nbre_plte_disparue++;
141
	                        # Stockage par département du nombre de plante ayant un statut "Disparu"
142
	                        $this->aso_totaux_dep[$nd]['plte_disparue']++;
143
	                        # Stockage des informations
144
	                        $this->tab_choro_dep[$j] = array(ZgFrDepartements::getIdChaine($nd), $num_taxo, $num_nomenc, 6, $this->id_donnee_choro++);
145
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
146
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
147
	                            $autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
148
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
149
	                        }
150
                    	} else {
151
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
152
							$this->autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
153
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
154
						}
155
						$j++;
156
					} else if (isset($val) && $val != '') {
157
						if ($val == '1') {# Présent
158
							// Calcul du nombre de plante 'nc' ayant un statut "Présent"
159
							$this->nc_nbre_plte_presente++;
160
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présent"
161
							$this->aso_totaux_dep[$nd]['nc_plte_presente']++;
162
						} elseif ($val == '1?') {# Présence à confirmer
163
							// Calcul du nombre de plante 'nc' ayant un statut "Présence à confirmer"
164
							$this->nc_nbre_plte_a_confirmer++;
165
							// Stockage par département du nombre de plante 'nc' ayant un statut "Présence à confirmer"
166
							$this->aso_totaux_dep[$nd]['nc_plte_a_confirmer']++;
167
						} elseif (preg_match('/^(?:\?| \?|\? | \?)$/', $val)) {# Douteux
168
							// Calcul du nombre de plante 'nc' ayant un statut "Douteux"
169
							$this->nc_nbre_plte_douteux++;
170
							// Stockage par département du nombre de plante 'nc' ayant un statut "Douteux"
171
							$this->aso_totaux_dep[$nd]['nc_plte_douteux']++;
172
							if (preg_match('/(?: \?|\? | \? )/', $val)) {# Douteux
173
								// Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "?".
174
								$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
175
														' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
176
							}
177
						} elseif (preg_match('/^(?:#| #|# | # )$/', $val)) {# Erreur
178
	                        # Calcul du nombre de plante 'nc' ayant un statut "Erreur"
179
	                        $this->nc_nbre_plte_erreur++;
180
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Erreur"
181
	                        $this->aso_totaux_dep[$nd]['nc_plte_erreur']++;
182
	                        if (preg_match('/(?: #|# | # )/', $val)) {# Erreur avec espace
183
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "#".
184
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
185
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
186
	                        }
187
                    	} elseif (preg_match('/^\s*(?:-\|-)\s*$/', $val)) {# Disparu
188
	                        # Calcul du nombre de plante 'nc' ayant un statut "Disparu"
189
	                        $this->nc_nbre_plte_disparue++;
190
	                        # Stockage par département du nombre de plante 'nc' ayant un statut "Disparu"
191
	                        $this->aso_totaux_dep[$nd]['nc_plte_disparue']++;
192
	                        if (preg_match('/(?: -\|-|-\|- | -\|- )/', $val)) {# Disparu avec espace
193
	                            # Ajout de la valeur dans une variable car elle n'est pas tout à fait conforme à "-|-".
194
	                            $nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
195
	                                                    ' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
196
	                        }
197
                    	} else {
198
							// Ajout de la valeur dans une variable car elle n'est pas conforme.
199
							$this->nc_autres_valeur_champ .= '<'.$val.'> '.'(Ligne n°: '.($this->nbre_ligne+2).
200
													' - N° nomenclatural: '.$num_nomenc.' - N° département: '.$nd.')<br />';
201
						}
202
					}
203
					// Affichage dans la console du numéro de l'enregistrement analysé.
204
					//echo str_repeat(chr(8), ( strlen( $i ) + 1 ))."\t".$i++;
205
				}
206
			}// fin du foreach
207
			// Affichage dans la console du numéro de l'enregistrement analysé.
208
			echo str_repeat(chr(8), ( strlen( $this->nbre_ligne ) + 1 ))."\t".$this->nbre_ligne++;
209
		}
210
		echo "\n";
211
	}
212
 
213
	private function verifierDonnees()
214
	{
215
		// Ouverture du fichier contenant les résultats (sortie)
216
		if (!$handle = fopen($this->fichier_verif, 'w')) {
217
			echo "Impossible d'ouvrir le fichier ($this->fichier_verif)";
218
			exit;
219
		}
220
 
221
		// Création de la page
222
		$page = '<html>'."\n";
223
		$page .= '<head>'."\n";
224
		$page .= '<title>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</title>'."\n";
225
		$page .= '</head>'."\n";
226
		$page .= '<body>'."\n";
227
		$page .= '<h1>RESULTAT DE LA VERIFICATION DU FICHIER TABULE DE LA CHOROLOGIE</h1>'."\n";
228
		$page .= '<hr/>'."\n";
229
		$page .= 	'<p>'.
230
						'Adresse fichier analysé : '.'<br />'."\n".
231
						'</p>'."\n";
232
		$page .= '<hr/>'."\n";
233
		$page .= '<h2>RESULTATS PROGRAMME DE VERIFICATION</h2>'."\n";
234
		$page .= 	'<p>'.
235
						'Nom du programme générant ce fichier : '.__FILE__.'<br />'."\n".
236
						'Nombre de lignes analysées : '.$this->nbre_ligne.'<br />'."\n".
237
						'Nbre de départements analysés : '.$this->nbre_dep_analyse.'<br />'."\n".
238
						'Date d\'exécution du programme : '.date('m.d.Y').'<br />'."\n".
239
						'</p>'."\n";
240
		$page .= '<hr/>'."\n";
241
		$page .= '<h2>RESULTATS ANALYSE CHOROLOGIE</h2>'."\n";
242
		$page .= 	'<p>'.
243
						'Nombre de nom "nc" : '.$this->nc_nbre_nom.'<br />'."\n".
244
						'Nombre de nom : '.$this->nbre_nom.'<br />'."\n".
245
						'Valeurs autres que 1, 1?, ?, # et -|- : '.$this->autres_valeur_champ.'<br />'."\n".
246
						'Valeurs autres que 1, 1?, ?, # et -|- pour les plantes nc : <br />'."\n".$this->nc_autres_valeur_champ.'</br>'."\n".
247
						'</p>'."\n";
248
		$page .= '<hr/>'."\n";
249
		$page .= '<h2>RESULTATS ANALYSE des CHAMPS</h2>'."\n";
250
		$page .= 	'<p>'.
251
						'Nombre de guillemets antislashés: '.$this->nbre_ligne_avec_guillemet.'<br />'."\n".
252
						'</p>'."\n";
253
		$page .= '<hr/>'."\n";
254
		$page .= '<h2>TABLEAUX</h2>'."\n";
255
 
256
		// Tableau des numéros nomenclaturaux dupliqués
257
		$table = '<table><thead><tr><th colspan="3">Tableau des numéros nomenclaturaux dupliqués </th></tr>';
258
		$table .= '<tr><th>Numéro nomenclatural</th><th>Nbre d\'itération</th><th>Lignes</th></tr></thead>';
259
		$afficher_tab_num_duplique = 0;
260
		ksort($this->aso_num_nomenc);
261
		$table .= '<tbody style="text-align: center;">';
262
		foreach ($this->aso_num_nomenc as $cle_nomenc => $val ) {
263
			$ligne = '<tr><td>'.$cle_nomenc.'</td><td>'.$val['compteur'].'</td><td>'.$val['ligne'].'</td></tr>';
264
			if ($val['compteur'] > 1) {
265
				$table .= $ligne;
266
				$afficher_tab_num_duplique = 1;
267
			}
268
		}
269
		if ( $afficher_tab_num_duplique == 1 ) {
270
			$page .= $table.'</tbody></table>';
271
		}
272
 
273
		// Tableau des résultats par départements
274
		$table = '<table><thead><tr><th colspan="12">Tableau des résulats par départements</th></tr>';
275
		$table .= '<tr><th>Département</th><th>Nbre pltes présentes</th><th>Nbre pltes à confirmer</th>'.
276
			'<th>Nbre pltes douteuses</th><th>Nbre pltes disparues</th><th>Nbre pltes erreur</th>'.
277
			'<th>Total</th><th>Nbre pltes nc présentes</th><th>Nbre pltes nc à confirmer</th>'.
278
			'<th>Nbre nc pltes douteuses</th><th>Nbre nc pltes disparues</th><th>Nbre nc pltes erreur</th></tr></thead>';
279
		$table .= '<tbody style="text-align: center;">';
280
		ksort($this->aso_totaux_dep);
281
		foreach ($this->aso_totaux_dep as $cle_dep => $val ) {
282
			$plt_total = $val{'plte_presente'} + $val{'plte_a_confirmer'} + $val{'plte_douteux'} + $val{'plte_disparue'} + $val{'plte_erreur'};
283
			$table .= '<tr><td>'.ZgFrDepartements::getNom($cle_dep).' ('.ZgFrDepartements::getIdChaine($cle_dep).') </td>'.
284
				'<td>'.$val{'plte_presente'}.'</td><td>'.$val{'plte_a_confirmer'}.'</td><td>'.$val{'plte_douteux'}.'</td>'.
285
				'<td>'.$val{'plte_disparue'}.'</td><td>'.$val{'plte_erreur'}.'</td><td>'.$plt_total.'</td>'.
286
				'<td>'.$val{'nc_plte_presente'}.'</td><td>'.$val{'nc_plte_a_confirmer'}.'</td><td>'.$val{'nc_plte_douteux'}.'</td>'.
287
				'<td>'.$val{'nc_plte_disparue'}.'</td><td>'.$val{'nc_plte_erreur'}.'</td></tr>';
288
		}
289
 
290
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
291
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
292
		$plt_total = $this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur;
293
		$table .= '<tr><td>Totaux : '.$this->nbre_dep_analyse.' départements</td><td>'.$this->nbre_plte_presente.'</td>'.
294
			'<td>'.$this->nbre_plte_a_confirmer.'</td><td>'.$this->nbre_plte_douteux.'</td><td>'.$this->nbre_plte_disparue.'</td>'.
295
			'<td>'.$this->nbre_plte_erreur.'</td><td>'.$plt_total.'</td>'.
296
			'<td>'.$this->nc_nbre_plte_presente.'</td>'.'<td>'.$this->nc_nbre_plte_a_confirmer.'</td>'.
297
			'<td>'.$this->nc_nbre_plte_douteux.'</td><td>'.$this->nc_nbre_plte_disparue.'</td><td>'.$this->nc_nbre_plte_erreur.'</td></tr>';
298
 
299
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
300
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
301
		$total_nbre_plte = ($this->nbre_plte_presente + $this->nbre_plte_a_confirmer + $this->nbre_plte_douteux + $this->nbre_plte_disparue + $this->nbre_plte_erreur);
302
		$total_nbre_plte_nc = ($this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nc_nbre_plte_douteux + $this->nc_nbre_plte_disparue + $this->nc_nbre_plte_erreur);
303
		$table .= '<tr><td>Totaux plante / plante nc</td><td colspan="6">'.$total_nbre_plte.'</td>'.
304
			'<td colspan="5">'.$total_nbre_plte_nc.'</td></tr>';
305
 
306
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
307
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
308
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente + $this->nc_nbre_plte_a_confirmer + $this->nbre_plte_a_confirmer;
309
		$table .= '<tr><td>Total plantes présentes et à confirmer</td><td colspan="11">'.$plt_total.'</td></tr>';
310
 
311
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
312
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
313
		$plt_total = $this->nbre_plte_presente + $this->nc_nbre_plte_presente;
314
		$table .= '<tr><td>Total plantes présentes</td><td colspan="11">'.$plt_total.'</td></tr>';
315
 
316
		$table .= '<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'.
317
				'<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
318
		$plt_total = $total_nbre_plte + $total_nbre_plte_nc;
319
		$table .= '<tr><td>Total données chorologiques</td><td colspan="11">'.$plt_total.'</td></tr>';
320
 
321
		$table .= '</tbody></table>';
322
		$page .= $table;
323
 
324
		$page .= '<hr/>'."\n";
325
		$page .= '<h2>NOTES</h2>'."\n";
326
		$page .= 	'<p>'.
327
						'1.- Chaque champ précédé par "ATTENTION" doit être vide.'."\n".
328
						'S\'il ne l\'est pas, il y a une erreur'."\n".
329
						'</p>'."\n";
330
		$page .= '</body>'."\n";
331
		$page .= '</html>'."\n";
332
		// Fermeture de la poignée sur le fichier de sortie
333
		if (fwrite($handle, $page) === FALSE) {
334
			echo "Impossible d'écrire dans le fichier ($this->fichier_verif)";
335
			exit;
336
		}
337
		echo 'Ecriture du fichier de vérification de la chorologie réalisée!'."\n";
338
		fclose($handle);
339
	}
340
 
341
}
342
 
343
class ZgFrDepartements {
344
	static private $departements =
345
        array(
346
        "01" => array("Ain", "01", 1),
347
        "02" => array("Aisne", "02", 2),
348
        "03" => array("Allier", "03", 3),
349
        "04" => array("Alpes-de-Haute-Provence", "04", 4),
350
        "05" => array("Hautes-Alpes", "05", 5),
351
        "06" => array("Alpes-Maritimes", "06", 6),
352
        "07" => array("Ardèche", "07", 7),
353
        "08" => array("Ardennes", "08", 8),
354
        "09" => array("Ariège", "09", 9),
355
        "10" => array("Aube", "10", 10),
356
        "11" => array("Aude", "11", 11),
357
        "12" => array("Aveyron", "12", 12),
358
        "13" => array("Bouches-du-Rhône", "13", 13),
359
        "14" => array("Calvados", "14", 14),
360
        "15" => array("Cantal", "15", 15),
361
        "16" => array("Charente", "16", 16),
362
        "17" => array("Charente-Maritime", "17", 17),
363
        "18" => array("Cher", "18", 18),
364
        "19" => array("Corrèze", "19", 19),
365
        "20" => array("Corse", "20", 20),
366
        "2A" => array("Haute-Corse", "2A", 20),
367
        "2B" => array("Corse-du-Sud", "2B", 20),
368
        "21" => array("Côte-d'Or", "21", 21),
369
        "22" => array("Côtes-d'Armor", "22", 22),
370
        "23" => array("Creuse", "23", 23),
371
        "24" => array("Dordogne", "24", 24),
372
        "25" => array("Doubs","25", 25),
373
        "26" => array("Drôme", "26", 26),
374
        "27" => array("Eure", "27", 27),
375
        "28" => array("Eure-et-Loir", "28", 28),
376
        "29" => array("Finistère", "29", 29),
377
        "30" => array("Gard", "30", 30),
378
        "31" => array("Haute-Garonne", "31", 31),
379
        "32" => array("Gers", "32", 32),
380
        "33" => array("Gironde", "33", 33),
381
        "34" => array("Hérault", "34", 34),
382
        "35" => array("Ille-et-Vilaine", "35", 35),
383
        "36" => array("Indre", "36", 36),
384
        "37" => array("Indre-et-Loire", "37", 37),
385
        "38" => array("Isère", "38", 38),
386
        "39" => array("Jura", "39", 39),
387
        "40" => array("Landes", "40", 40),
388
        "41" => array("Loir-et-Cher", "41", 41),
389
        "42" => array("Loire", "42", 42),
390
        "43" => array("Haute-Loire", "43", 43),
391
        "44" => array("Loire-Atlantique", "44", 44),
392
        "45" => array("Loiret", "45", 45),
393
        "46" => array("Lot", "46", 46),
394
        "47" => array("Lot-et-Garonne", "47", 47),
395
        "48" => array("Lozére ", "48", 48),
396
        "49" => array("Maine-et-Loire", "49", 49),
397
        "50" => array("Manche", "50", 50),
398
        "51" => array("Marne", "51", 51),
399
        "52" => array("Haute-Marne", "52", 52),
400
        "53" => array("Mayenne", "53", 53),
401
        "54" => array("Meurthe-et-Moselle", "54", 54),
402
        "55" => array("Meuse", "55", 55),
403
        "56" => array("Morbihan", "56", 56),
404
        "57" => array("Moselle", "57", 57),
405
        "58" => array("Nièvre", "58", 58),
406
        "59" => array("Nord", "59", 59),
407
        "60" => array("Oise", "60", 60),
408
        "61" => array("Orne", "61", 61),
409
        "62" => array("Pas-de-Calais", "62", 62),
410
        "63" => array("Puy-de-Dôme", "63", 63),
411
        "64" => array("Pyrénées-Atlantiques", "64", 64),
412
        "65" => array("Hautes-Pyrénées", "65", 65),
413
        "66" => array("Pyrénées-Orientales", "66", 66),
414
        "67" => array("Bas-Rhin", "67", 67),
415
        "68" => array("Haut-Rhin", "68", 68),
416
        "69" => array("Rhône", "69", 69),
417
        "70" => array("Haute-Saône", "70", 70),
418
        "71" => array("Saône-et-Loire", "71", 71),
419
        "72" => array("Sarthe", "72", 72),
420
        "73" => array("Savoie", "73", 73),
421
        "74" => array("Haute-Savoie", "74", 74),
422
        "75" => array("Paris", "75", 75),
423
        "76" => array("Seine-Maritime", "76", 76),
424
        "77" => array("Seine-et-Marne", "77", 77),
425
        "78" => array("Yvelines", "78", 78),
426
        "79" => array("Deux-Sèvres", "79", 79),
427
        "80" => array("Somme", "80", 80),
428
        "81" => array("Tarn", "81", 81),
429
        "82" => array("Tarn-et-Garonne", "82", 82),
430
        "83" => array("Var", "83", 83),
431
        "84" => array("Vaucluse", "84", 84),
432
        "85" => array("Vendée", "85", 85),
433
        "86" => array("Vienne", "86", 86),
434
        "87" => array("Haute-Vienne", "87", 87),
435
        "88" => array("Vosges", "88", 88),
436
        "89" => array("Yonne", "89", 89),
437
        "90" => array("Territoire-de-Belfort", "90", 90),
438
        "91" => array("Essonne", "91", 91),
439
        "92" => array("Hauts-de-Seine", "92", 92),
440
        "93" => array("Seine-Saint-Denis", "93", 93),
441
        "94" => array("Val-de-Marne", "94", 94),
442
        "95" => array("Val-d'Oise", "95", 95),
443
        "96" => array("aaa", "96", 96),
444
        "971" => array("Guadeloupe", "971", 971),
445
        "972" => array("Martinique", "972", 972),
446
        "973" => array("Guyane", "973", 973),
447
        "974" => array("Réunion", "974", 974),
448
        "99" => array("Etranger", "99", 99),
449
        );
450
 
451
	static public function get() {
452
		return self::$departements;
453
	}
454
 
455
    static public function getNom($n) {
456
		return self::$departements[$n][0];
457
	}
458
 
459
	static public function getIdChaine($n) {
460
		return self::$departements[$n][1];
461
	}
462
 
463
	static public function getIdNumerique($n) {
464
		return (int)self::$departements[$n][2];
465
	}
466
 
467
	static public function getIdEflore($n) {
468
		return (int)self::$departements[$n][3];
469
	}
470
}
471
?>