| Line 13... |
Line 13... |
| 13 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
13 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
| 14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
| 15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
| 16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
| 17 |
*/
|
17 |
*/
|
| - |
|
18 |
/*
|
| - |
|
19 |
* Paramètres: date.debut et date.fin (unixtime en secondes), navigation.limite (10 par défaut), navigation.depart, ordre (DESC par défaut)
|
| - |
|
20 |
* Ne pas Oublier l'api key dans le header $_SERVER['HTTP_API_KEY']
|
| - |
|
21 |
*/
|
| 18 |
class PlantNet extends RestService {
|
22 |
class PlantNet extends RestService {
|
| Line 19... |
Line 23... |
| 19 |
|
23 |
|
| 20 |
private $parametres = array();
|
24 |
private $parametres = array();
|
| 21 |
private $ressources = array();
|
25 |
private $ressources = array();
|
| Line 60... |
Line 64... |
| 60 |
$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
|
64 |
$chemins[] = $this->cheminCourant.$this->projetNom.DS.$classe.'.php';
|
| 61 |
$retour = '';
|
65 |
$retour = '';
|
| 62 |
$service = null;
|
66 |
$service = null;
|
| 63 |
foreach ($chemins as $chemin) {
|
67 |
foreach ($chemins as $chemin) {
|
| 64 |
if (file_exists($chemin)) {
|
68 |
if (file_exists($chemin)) {
|
| - |
|
69 |
$authorized_key = $this->conteneur->getParametre('api.key');
|
| - |
|
70 |
// Vérification de la clé API (et oui je sais, c'est relou, mais il faut bien commencer à sécuriser nos webservices)
|
| - |
|
71 |
if ($_SERVER['HTTP_API_KEY'] == $authorized_key){
|
| 65 |
require_once $chemin;
|
72 |
require_once $chemin;
|
| 66 |
$service = new $classe($this->conteneur);
|
73 |
$service = new $classe($this->conteneur);
|
| 67 |
$retour = $service->consulter($this->ressources, $this->parametres);
|
74 |
$retour = $service->consulter($this->ressources, $this->parametres);
|
| - |
|
75 |
} else {
|
| - |
|
76 |
$message = "Accès au service '{$this->projetNom}' refusé, veuillez vérifier votre clé API.";
|
| - |
|
77 |
$code = RestServeur::HTTP_CODE_ERREUR;
|
| - |
|
78 |
throw new Exception($message, $code);
|
| - |
|
79 |
}
|
| - |
|
80 |
|
| 68 |
}
|
81 |
}
|
| 69 |
}
|
82 |
}
|
| Line 70... |
Line 83... |
| 70 |
|
83 |
|
| 71 |
if (is_null($service)) {
|
84 |
if (is_null($service)) {
|