Subversion Repositories Applications.annuaire

Rev

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

Rev 390 Rev 394
Line 169... Line 169...
169
		$methode = 'update';
169
		$methode = 'update';
170
		$methode .= str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($nom))));
170
		$methode .= str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($nom))));
171
		return $methode;
171
		return $methode;
172
	}
172
	}
Line -... Line 173...
-
 
173
 
-
 
174
	protected function traiterNomMethodePut($nom) {
-
 
175
		$methode = 'create';
-
 
176
		$methode .= str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($nom))));
-
 
177
		return $methode;
-
 
178
	}
173
 
179
 
174
	protected function traiterParametresUrl($params_attendu, $params, $pourBDD = true) {
180
	protected function traiterParametresUrl($params_attendu, $params, $pourBDD = true) {
175
		$sortie = array();
181
		$sortie = array();
176
		foreach ($params_attendu as $num => $nom) {
182
		foreach ($params_attendu as $num => $nom) {
177
			if (isset($params[$num]) && $params[$num] != '*') {
183
			if (isset($params[$num]) && $params[$num] != '*') {
Line 241... Line 247...
241
			header('HTTP/1.0 401 Unauthorized');
247
			header('HTTP/1.0 401 Unauthorized');
242
			header('Content-type: text/html; charset=UTF-8');
248
			header('Content-type: text/html; charset=UTF-8');
243
			echo 'Accès interdit';
249
			echo 'Accès interdit';
244
			exit;
250
			exit;
245
		} else {
251
		} else {
246
			if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
252
			if ($this->verifierAcces()) {
247
				return ;
253
				return ;
248
			} else {
254
			} else {
249
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
255
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
250
				header('HTTP/1.0 401 Unauthorized');
256
				header('HTTP/1.0 401 Unauthorized');
251
				header('Content-type: text/html; charset=UTF-8');
257
				header('Content-type: text/html; charset=UTF-8');
Line 253... Line 259...
253
				exit ;
259
				exit ;
254
			}
260
			}
255
		}
261
		}
256
	}
262
	}
Line 257... Line 263...
257
 
263
 
-
 
264
	protected function verifierAcces($id = null, $mdp = null) {
-
 
265
		$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
-
 
266
		$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
258
	protected function verifierAcces($id) {
267
 
259
		$query = 'SELECT '.$this->config['database_ident']['ann_id'].' AS name '.
268
		$requete = 'SELECT '.$this->config['database_ident']['ann_id'].' AS courriel '.
260
			'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
269
			'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
261
			'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
270
			'WHERE '.$this->config['database_ident']['ann_id'].' = '.$this->bdd->quote($id).' '.
262
			'	AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($_SERVER['PHP_AUTH_PW']).')' ;
271
			'	AND '.$this->config['database_ident']['ann_pwd'].' = '.$this->config['database_ident']['pass_crypt_funct'].'('.$this->bdd->quote($mdp).')' ;
Line 263... Line 272...
263
		$res = $this->bdd->query($query);
272
		$resultat = $this->bdd->query($requete)->fetch();
-
 
273
 
264
 
274
		$identifie = false;
265
		if ($res == '') {
275
		if (isset($resultat['courriel'])) {
-
 
276
			$identifie = true;
-
 
277
		}
Line -... Line 278...
-
 
278
		return $identifie;
266
			return false ;
279
	}
267
		}
280
 
268
 
-
 
Line -... Line 281...
-
 
281
	protected function creerCookiePersistant($id = null, $mdp = null) {
-
 
282
		$id = is_null($id) ? $_SERVER['PHP_AUTH_USER'] : $id;
-
 
283
		$mdp = is_null($mdp) ? $_SERVER['PHP_AUTH_PW'] : $mdp;
-
 
284
 
-
 
285
		$nomCookie = $this->config['database_ident']['nom_cookie_persistant'];
-
 
286
		$valeurCookie = md5($mdp).$id;
-
 
287
		$dureeCookie = (int) time()+3600*24*30;// 1 mois à partir de l'appel
-
 
288
		setcookie($nomCookie, $valeurCookie, $dureeCookie, '/');
-
 
289
	}
-
 
290
 
-
 
291
	protected function verifierIdentification() {
-
 
292
		$identifie = false;
269
		if (DB::isError($res)) {
293
		$nomCookie = $this->config['database_ident']['nom_cookie_persistant'];
270
			die($res->getMessage());
294
		if (isset($_COOKIE[$nomCookie])) {
Line 271... Line 295...
271
		}
295
			$identifie = true;
272
 
296
		}
273
		return true;
297
		return $identifie;
274
	}
298
	}
275
 
299
 
276
	protected function estAutoriseMessagerie($adresse) {
300
	protected function estAutoriseMessagerie($adresse) {
277
		$utilisateurs_messagerie = explode(',', $this->config['messagerie']['utilisateurs_autorises']);
301
		$utilisateurs_messagerie = explode(',', $this->config['messagerie']['utilisateurs_autorises']);
Line 278... Line 302...
278
		return in_array($adresse, $utilisateurs_messagerie);
302
		return in_array($adresse, $utilisateurs_messagerie);
279
	}
303
	}