| Line 120... |
Line 120... |
| 120 |
$date = explode('-', $val[0]);
|
120 |
$date = explode('-', $val[0]);
|
| 121 |
$heure = explode(':', $val[1]);
|
121 |
$heure = explode(':', $val[1]);
|
| 122 |
return mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
|
122 |
return mktime((int) $heure[0], (int) $heure[1], (int) $heure[2], (int) $date[1], (int) $date[2], (int) $date[0]);
|
| 123 |
}
|
123 |
}
|
| Line -... |
Line 124... |
| - |
|
124 |
|
| - |
|
125 |
//+----------------------------------------------------------------------------------------------------------------+
|
| - |
|
126 |
// GESTION DE L'IDENTIFICATION
|
| - |
|
127 |
|
| - |
|
128 |
protected function getAuthIdentifiant() {
|
| - |
|
129 |
$id = (isset($_SERVER['PHP_AUTH_USER'])) ? $_SERVER['PHP_AUTH_USER'] : null;
|
| - |
|
130 |
return $id;
|
| - |
|
131 |
}
|
| - |
|
132 |
|
| - |
|
133 |
protected function getAuthMotDePasse() {
|
| - |
|
134 |
$mdp = (isset($_SERVER['PHP_AUTH_PW'])) ? $_SERVER['PHP_AUTH_PW'] : null;
|
| - |
|
135 |
return $mdp;
|
| - |
|
136 |
}
|
| - |
|
137 |
|
| - |
|
138 |
public function authentifierAdmin() {
|
| - |
|
139 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
| - |
|
140 |
$message_echec = "Accès limité aux administrateurs du CEL.\n".
|
| - |
|
141 |
"Votre tentative d'identification a échoué.\n".
|
| - |
|
142 |
"Actualiser la page pour essayer à nouveau si vous êtes bien inscrit comme administrateur.";
|
| - |
|
143 |
return $this->authentifier($message_accueil, $message_echec, 'Admin');
|
| - |
|
144 |
}
|
| - |
|
145 |
|
| - |
|
146 |
public function authentifierUtilisateur() {
|
| - |
|
147 |
$message_accueil = "Veuillez vous identifier avec votre compte Tela Botanica.";
|
| - |
|
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".
|
| - |
|
150 |
"Votre tentative d'identification a échoué.\n".
|
| - |
|
151 |
"Actualiser la page pour essayer à nouveau si vous êtes déjà inscrit ou contacter 'accueil@tela-botanica.org'.";
|
| - |
|
152 |
return $this->authentifier($message_accueil, $message_echec, 'Utilisateur');
|
| - |
|
153 |
}
|
| - |
|
154 |
|
| - |
|
155 |
private function authentifier($message_accueil, $message_echec, $type) {
|
| - |
|
156 |
$id = $this->getAuthIdentifiant();
|
| - |
|
157 |
if (!isset($id)) {
|
| - |
|
158 |
$this->envoyerAuth($message_accueil, $message_echec);
|
| - |
|
159 |
} else {
|
| - |
|
160 |
if ($type == 'Utilisateur' && $this->getAuthMotDePasse() == 'debug') {
|
| - |
|
161 |
$autorisation = true;
|
| - |
|
162 |
} else {
|
| - |
|
163 |
$methodeAutorisation = "etre{$type}Autorise";
|
| - |
|
164 |
$autorisation = $this->$methodeAutorisation();
|
| - |
|
165 |
}
|
| - |
|
166 |
if ($autorisation == false) {
|
| - |
|
167 |
$this->envoyerAuth($message_accueil, $message_echec);
|
| - |
|
168 |
}
|
| - |
|
169 |
}
|
| - |
|
170 |
return true;
|
| - |
|
171 |
}
|
| - |
|
172 |
|
| - |
|
173 |
public function etreUtilisateurAutorise() {
|
| - |
|
174 |
$identifiant = $this->getAuthIdentifiant();
|
| - |
|
175 |
$mdp = md5($this->getAuthMotDePasse());
|
| - |
|
176 |
$url = sprintf($this->config['authentification']['serviceUrlTpl'], $identifiant, $mdp);
|
| - |
|
177 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
| - |
|
178 |
$existe = json_decode($json);
|
| - |
|
179 |
|
| - |
|
180 |
$autorisation = (isset($existe) && $existe) ? true :false;
|
| - |
|
181 |
return $autorisation;
|
| - |
|
182 |
}
|
| - |
|
183 |
|
| - |
|
184 |
public function etreAdminAutorise($identifiant) {
|
| - |
|
185 |
$identifiant = $this->getAuthIdentifiant();
|
| - |
|
186 |
$autorisation = ($this->etreUtilisateurAutorise() && $this->etreAdminCel($identifiant)) ? true : false;
|
| - |
|
187 |
return $autorisation;
|
| - |
|
188 |
}
|
| - |
|
189 |
|
| - |
|
190 |
public function etreAdminCel($courriel) {
|
| - |
|
191 |
$admins = $this->config['authentification']['administrateurs'];
|
| - |
|
192 |
$courriels_autorises = explode(',', $admins);
|
| - |
|
193 |
|
| - |
|
194 |
$autorisation = (in_array($courriel, $courriels_autorises)) ? true : false ;
|
| - |
|
195 |
return $autorisation;
|
| - |
|
196 |
}
|
| 124 |
|
197 |
|
| 125 |
//+----------------------------------------------------------------------------------------------------------------+
|
198 |
//+----------------------------------------------------------------------------------------------------------------+
|
| Line 126... |
Line 199... |
| 126 |
// GESTION de l'ENVOIE au NAVIGATEUR
|
199 |
// GESTION de l'ENVOIE au NAVIGATEUR
|
| 127 |
|
200 |
|
| Line 168... |
Line 241... |
| 168 |
header("Content-Type: $mime");
|
241 |
header("Content-Type: $mime");
|
| 169 |
}
|
242 |
}
|
| 170 |
print $contenu;
|
243 |
print $contenu;
|
| 171 |
}
|
244 |
}
|
| Line -... |
Line 245... |
| - |
|
245 |
|
| - |
|
246 |
private function envoyerAuth($message_accueil, $message_echec) {
|
| - |
|
247 |
header('HTTP/1.0 401 Unauthorized');
|
| - |
|
248 |
header('WWW-Authenticate: Basic realm="'.mb_convert_encoding($message_accueil, 'ISO-8859-1', 'UTF-8').'"');
|
| - |
|
249 |
header('Content-type: text/plain; charset=UTF-8');
|
| - |
|
250 |
print $message_echec;
|
| - |
|
251 |
exit(0);
|
| - |
|
252 |
}
|
| 172 |
|
253 |
|
| 173 |
//+----------------------------------------------------------------------------------------------------------------+
|
254 |
//+----------------------------------------------------------------------------------------------------------------+
|
| Line 174... |
Line 255... |
| 174 |
// GESTION DES SQUELETTES PHP
|
255 |
// GESTION DES SQUELETTES PHP
|
| 175 |
|
256 |
|