Subversion Repositories eFlore/Applications.cel

Rev

Rev 2036 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2036 Rev 2071
Line 15... Line 15...
15
 * @copyright © 2012, 2013 Tela Botanica
15
 * @copyright © 2012, 2013 Tela Botanica
16
 */
16
 */
17
require_once('Bdd2.php');
17
require_once('Bdd2.php');
Line 18... Line 18...
18
 
18
 
-
 
19
abstract class Cel {
-
 
20
	const ARRET_SERVICE = false;
19
abstract class Cel {
21
 
20
	const TYPE_OBS = 'observation';
22
	const TYPE_OBS = 'observation';
Line 21... Line 23...
21
	const TYPE_IMG = 'image';
23
	const TYPE_IMG = 'image';
22
 
24
 
Line 234... Line 236...
234
		return $this->restClient;
236
		return $this->restClient;
235
	}
237
	}
Line 236... Line 238...
236
 
238
 
237
	//+----------------------------------------------------------------------------------------------------------------+
239
	//+----------------------------------------------------------------------------------------------------------------+
238
	// GESTION DE L'IDENTIFICATION
240
	// GESTION DE L'IDENTIFICATION
239
	
241
 
240
	static function getAuthIdentifiant() {
242
	static function getAuthIdentifiant() {
241
		return isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
243
		return isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
Line 242... Line 244...
242
	}
244
	}
Line 275... Line 277...
275
				print 'Accès interdit';
277
				print 'Accès interdit';
276
				exit();
278
				exit();
277
			}
279
			}
278
		}
280
		}
279
	}
281
	}
280
	
282
 
281
	public function controleAppelIpAutorisee() {
283
	public function controleAppelIpAutorisee() {
282
		$ips_autorisees = explode(',', @$this->config['jrest_admin']['ip_autorisees']);
284
		$ips_autorisees = explode(',', @$this->config['jrest_admin']['ip_autorisees']);
283
		if(!in_array($_SERVER['REMOTE_ADDR'], $ips_autorisees) && $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
285
		if(!in_array($_SERVER['REMOTE_ADDR'], $ips_autorisees) && $_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
284
			header('HTTP/1.0 401 Unauthorized');
286
			header('HTTP/1.0 401 Unauthorized');
285
			exit('Accès interdit');
287
			exit('Accès interdit');
Line 581... Line 583...
581
			}
583
			}
582
			$valeurs = implode($separateur_sortie, $valeurs_protegees);
584
			$valeurs = implode($separateur_sortie, $valeurs_protegees);
583
		}
585
		}
584
		return ($this->etreNull($valeurs)) ? null : $valeurs;
586
		return ($this->etreNull($valeurs)) ? null : $valeurs;
585
	}
587
	}
586
	
588
 
587
	protected function obtenirSousTaxonsPourNt($referentiel, $nt) {
589
	protected function obtenirSousTaxonsPourNt($referentiel, $nt) {
588
		return $this->obtenirSousTaxons($referentiel, 'nt:'.$nt);
590
		return $this->obtenirSousTaxons($referentiel, 'nt:'.$nt);
589
	}
591
	}
590
	
592
 
591
	protected function obtenirSousTaxonsPourNn($referentiel, $nn) {
593
	protected function obtenirSousTaxonsPourNn($referentiel, $nn) {
592
		return $this->obtenirSousTaxons($referentiel, $nn);
594
		return $this->obtenirSousTaxons($referentiel, $nn);
593
	}
595
	}
594
	
596
 
595
	private function obtenirSousTaxons($referentiel, $requete) {
597
	private function obtenirSousTaxons($referentiel, $requete) {
596
		$sous_taxons = array();
598
		$sous_taxons = array();
597
		$url_service_taxon = str_replace('{referentiel}', $referentiel, $this->config['eflore']['url_service_taxon']);
599
		$url_service_taxon = str_replace('{referentiel}', $referentiel, $this->config['eflore']['url_service_taxon']);
598
		$url = $url_service_taxon.'/'.$requete.'/relations/hierarchie';
600
		$url = $url_service_taxon.'/'.$requete.'/relations/hierarchie';
599
		$res = json_decode(file_get_contents($url),true);
601
		$res = json_decode(file_get_contents($url),true);
600
		if($res && !empty($res)) {
602
		if($res && !empty($res)) {
601
			$sous_taxons = array_pop($res);
603
			$sous_taxons = array_pop($res);
602
		}
604
		}
603
		return $sous_taxons;
605
		return $sous_taxons;
604
	}
606
	}
605
	
607
 
606
	protected function supprimerVersionDuReferentiel($referentiel) {
608
	protected function supprimerVersionDuReferentiel($referentiel) {
607
		$referentiel_parties = explode(':', $referentiel);
609
		$referentiel_parties = explode(':', $referentiel);
608
		$referentiel_parties = explode('_', $referentiel_parties[0]);
610
		$referentiel_parties = explode('_', $referentiel_parties[0]);
609
		return $referentiel_parties[0];
611
		return $referentiel_parties[0];
610
	}
612
	}
611
	
613
 
612
	protected function getUrlEflore($referentiel, $nn) {
614
	protected function getUrlEflore($referentiel, $nn) {
613
		$urlEflore = null;
615
		$urlEflore = null;
614
		if (! $this->etreNull($nn)) {
616
		if (! $this->etreNull($nn)) {
615
			$code_referentiel = $this->supprimerVersionDuReferentiel($referentiel);
617
			$code_referentiel = $this->supprimerVersionDuReferentiel($referentiel);
616
			if($code_referentiel == '') {
618
			if($code_referentiel == '') {