Subversion Repositories Applications.annuaire

Rev

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

Rev 291 Rev 292
Line 232... Line 232...
232
		$contenu = str_replace('<?=', '<?php echo ',  $contenu);
232
		$contenu = str_replace('<?=', '<?php echo ',  $contenu);
233
		// Ajout systématique d'un point virgule avant la fermeture php
233
		// Ajout systématique d'un point virgule avant la fermeture php
234
		$contenu = preg_replace("/;*\s*\?>/", "; ?>", $contenu);
234
		$contenu = preg_replace("/;*\s*\?>/", "; ?>", $contenu);
235
		return $contenu;
235
		return $contenu;
236
	}
236
	}
-
 
237
	
-
 
238
	protected function authentifier() {
-
 
239
		if (!isset($_SERVER['PHP_AUTH_USER'])) {
-
 
240
			header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
-
 
241
			header('HTTP/1.0 401 Unauthorized');
-
 
242
			header('Content-type: text/html; charset=UTF-8');
-
 
243
			echo 'Accès interdit';
-
 
244
			exit;
-
 
245
		} else {
-
 
246
			if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
-
 
247
				return ;
-
 
248
			} else {
-
 
249
				header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
-
 
250
				header('HTTP/1.0 401 Unauthorized');
-
 
251
				header('Content-type: text/html; charset=UTF-8');
-
 
252
				echo 'Accès interdit';
-
 
253
				exit ;
-
 
254
			}
-
 
255
		}
-
 
256
	}
-
 
257
 
-
 
258
	protected function verifierAcces($id) {
-
 
259
		$query = 'SELECT '.$this->config['database_ident']['ann_id'].' AS name '.
-
 
260
			'FROM '.$this->config['database_ident']['database'].'.'.$this->config['database_ident']['annuaire'].' '.
-
 
261
			'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']).')' ;
-
 
263
		$res = $this->bdd->query($query);
-
 
264
		
-
 
265
		if ($res == '') {
-
 
266
			return false ;
-
 
267
		}
-
 
268
 
-
 
269
		if (DB::isError($res)) {
-
 
270
			die($res->getMessage());
-
 
271
		}
-
 
272
 
-
 
273
		return true;
-
 
274
	}
237
}
275
}
238
?>
276
?>
239
277