| Line 133... |
Line 133... |
| 133 |
protected function getAuthMotDePasse() {
|
133 |
protected function getAuthMotDePasse() {
|
| 134 |
$mdp = (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW'] : null;
|
134 |
$mdp = (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW'] : null;
|
| 135 |
return $mdp;
|
135 |
return $mdp;
|
| 136 |
}
|
136 |
}
|
| Line 137... |
Line 137... |
| 137 |
|
137 |
|
| 138 |
public function authentifierAdmin() {
|
138 |
protected function authentifierAdmin() {
|
| 139 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
139 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
| 140 |
$message_echec = "Accès limité aux administrateurs du CEL.\n".
|
140 |
$message_echec = "Accès limité aux administrateurs du CEL.\n".
|
| 141 |
"Votre tentative d'identification a échoué.\n".
|
141 |
"Votre tentative d'identification a échoué.\n".
|
| 142 |
"Actualiser la page pour essayer à nouveau si vous êtes bien inscrit comme administrateur.";
|
142 |
"Actualiser la page pour essayer à nouveau si vous êtes bien inscrit comme administrateur.";
|
| 143 |
return $this->authentifier($message_accueil, $message_echec, 'Admin');
|
143 |
return $this->authentifier($message_accueil, $message_echec, 'Admin');
|
| Line 144... |
Line 144... |
| 144 |
}
|
144 |
}
|
| 145 |
|
145 |
|
| 146 |
public function authentifierUtilisateur() {
|
146 |
protected function authentifierUtilisateur() {
|
| 147 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
147 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
| 148 |
$message_echec = "Accès limité aux utilisateur du CEL.\n".
|
148 |
$message_echec = "Accès limité aux utilisateur du CEL.\n".
|
| 149 |
"Inscrivez vous http://www.tela-botanica.org/page:inscription pour le devenir.\n".
|
149 |
"Inscrivez vous http://www.tela-botanica.org/page:inscription pour le devenir.\n".
|
| Line 168... |
Line 168... |
| 168 |
}
|
168 |
}
|
| 169 |
}
|
169 |
}
|
| 170 |
return true;
|
170 |
return true;
|
| 171 |
}
|
171 |
}
|
| Line 172... |
Line 172... |
| 172 |
|
172 |
|
| 173 |
public function etreUtilisateurAutorise() {
|
173 |
protected function etreUtilisateurAutorise() {
|
| 174 |
$identifiant = $this->getAuthIdentifiant();
|
174 |
$identifiant = $this->getAuthIdentifiant();
|
| 175 |
$mdp = md5($this->getAuthMotDePasse());
|
175 |
$mdp = md5($this->getAuthMotDePasse());
|
| 176 |
$url = sprintf($this->config['authentification']['serviceUrlTpl'], $identifiant, $mdp);
|
176 |
$url = sprintf($this->config['authentification']['serviceUrlTpl'], $identifiant, $mdp);
|
| 177 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
177 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
| Line 178... |
Line 178... |
| 178 |
$existe = json_decode($json);
|
178 |
$existe = json_decode($json);
|
| 179 |
|
179 |
|
| 180 |
$autorisation = (isset($existe) && $existe) ? true :false;
|
180 |
$autorisation = (isset($existe) && $existe) ? true :false;
|
| Line 181... |
Line 181... |
| 181 |
return $autorisation;
|
181 |
return $autorisation;
|
| 182 |
}
|
182 |
}
|
| 183 |
|
183 |
|
| 184 |
public function etreAdminAutorise($identifiant) {
|
184 |
protected function etreAdminAutorise($identifiant) {
|
| 185 |
$identifiant = $this->getAuthIdentifiant();
|
185 |
$identifiant = $this->getAuthIdentifiant();
|
| Line 186... |
Line 186... |
| 186 |
$autorisation = ($this->etreUtilisateurAutorise() && $this->etreAdminCel($identifiant)) ? true : false;
|
186 |
$autorisation = ($this->etreUtilisateurAutorise() && $this->etreAdminCel($identifiant)) ? true : false;
|
| 187 |
return $autorisation;
|
187 |
return $autorisation;
|
| 188 |
}
|
188 |
}
|
| Line 189... |
Line 189... |
| 189 |
|
189 |
|
| 190 |
public function etreAdminCel($courriel) {
|
190 |
protected function etreAdminCel($courriel) {
|
| 191 |
$admins = $this->config['authentification']['administrateurs'];
|
191 |
$admins = $this->config['authentification']['administrateurs'];
|
| Line 192... |
Line 192... |
| 192 |
$courriels_autorises = explode(',', $admins);
|
192 |
$courriels_autorises = explode(',', $admins);
|
| 193 |
|
193 |
|
| Line -... |
Line 194... |
| - |
|
194 |
$autorisation = (in_array($courriel, $courriels_autorises)) ? true : false ;
|
| - |
|
195 |
return $autorisation;
|
| - |
|
196 |
}
|
| - |
|
197 |
|
| - |
|
198 |
//+----------------------------------------------------------------------------------------------------------------+
|
| 194 |
$autorisation = (in_array($courriel, $courriels_autorises)) ? true : false ;
|
199 |
// GESTION de l'ENVOIE au NAVIGATEUR
|
| 195 |
return $autorisation;
|
200 |
|
| 196 |
}
|
201 |
protected function envoyerJsonp($donnees = null, $encodage = 'utf-8') {
|
| 197 |
|
202 |
$contenu = $_GET['callback'].'('.json_encode($donnees).');';
|
| 198 |
//+----------------------------------------------------------------------------------------------------------------+
|
203 |
$this->envoyer($contenu, 'text/html', $encodage);
|
| Line 240... |
Line 245... |
| 240 |
} else if (!is_null($mime) && is_null($encodage)) {
|
245 |
} else if (!is_null($mime) && is_null($encodage)) {
|
| 241 |
header("Content-Type: $mime");
|
246 |
header("Content-Type: $mime");
|
| 242 |
}
|
247 |
}
|
| 243 |
print $contenu;
|
248 |
print $contenu;
|
| 244 |
}
|
249 |
}
|
| 245 |
|
250 |
|
| 246 |
private function envoyerAuth($message_accueil, $message_echec) {
|
251 |
private function envoyerAuth($message_accueil, $message_echec) {
|
| 247 |
header('HTTP/1.0 401 Unauthorized');
|
252 |
header('HTTP/1.0 401 Unauthorized');
|
| 248 |
header('WWW-Authenticate: Basic realm="'.mb_convert_encoding($message_accueil, 'ISO-8859-1', 'UTF-8').'"');
|
253 |
header('WWW-Authenticate: Basic realm="'.mb_convert_encoding($message_accueil, 'ISO-8859-1', 'UTF-8').'"');
|
| 249 |
header('Content-type: text/plain; charset=UTF-8');
|
254 |
header('Content-type: text/plain; charset=UTF-8');
|
| 250 |
print $message_echec;
|
255 |
print $message_echec;
|
| Line 261... |
Line 266... |
| 261 |
* @param String $fichier le chemin du fichier du squelette
|
266 |
* @param String $fichier le chemin du fichier du squelette
|
| 262 |
* @param Array $donnees un tableau associatif contenant les variables a injecter dans le squelette.
|
267 |
* @param Array $donnees un tableau associatif contenant les variables a injecter dans le squelette.
|
| 263 |
*
|
268 |
*
|
| 264 |
* @return boolean false si le squelette n'existe pas, sinon la chaine résultat.
|
269 |
* @return boolean false si le squelette n'existe pas, sinon la chaine résultat.
|
| 265 |
*/
|
270 |
*/
|
| 266 |
public static function traiterSquelettePhp($fichier, Array $donnees = array()) {
|
271 |
protected static function traiterSquelettePhp($fichier, Array $donnees = array()) {
|
| 267 |
$sortie = false;
|
272 |
$sortie = false;
|
| 268 |
if (file_exists($fichier)) {
|
273 |
if (file_exists($fichier)) {
|
| 269 |
// Extraction des variables du tableau de données
|
274 |
// Extraction des variables du tableau de données
|
| 270 |
extract($donnees);
|
275 |
extract($donnees);
|
| 271 |
// Démarage de la bufferisation de sortie
|
276 |
// Démarage de la bufferisation de sortie
|