1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<?php
require_once 'http_authenticate.php';
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){
// this simply means that they have submitted the login form for this realm
$auth=http_authenticate($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
define('USER_AUTHENTICATED',$auth);
}
if(defined('USER_AUTHENTICATED') && USER_AUTHENTICATED){
// authentication successful - show the content
echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n";
include_once(dirname(__FILE__).'/includes/utils.inc.php');
$link_target="main";
?>
<html>
<head>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<title>Nagios</title>
</head>
<body>
/**** Contenu du menu ****/
<table width="100%" border="0">
<tr>
<td align="center"><span class="connected">Vous êtes connecté en tant que <b><?php echo $_SERVER['PHP_AUTH_USER'] ?></b>.</span></td>
</tr>
</table>
</div>
</body>
</html>
<?php
}else{
// the user has not been authenticated, present a login form.
header('WWW-Authenticate: Basic realm="Nagios Web Access"');
header('HTTP/1.0 401 Unauthorized');
// if cancel the login form, below is what they get
exit('Authentification requise pour visualiser cette page.');
}
?> |
Partager