48,6 → 48,7 |
$network_pb = False; |
$cert_add = "http://$hostname/certs"; |
$direct_access = False; |
$display_button_user_not_auth_yet=False; |
$diagnostic = "can't contact the default router"; |
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
$tab = array();$user = array(); |
111,7 → 112,33 |
exec("sudo /usr/sbin/ipset list not_auth_yet | grep $remote_ip | wc -l 2>&1", $ipset_not_auth_yet); |
if(!$direct_access && $ipset_not_auth_yet[0] == '0') |
{ |
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") # if HTTPS, we redirect user to HTTP to flag him (ipset : not_auth_yet) |
{ |
header("Location: http://$_SERVER[HTTP_HOST]"); |
exit; |
} |
|
$display_button_user_not_auth_yet=True; # Display menu for user not_auth_yet, he need to click on 'open connection' to be flagged in the ipset "not_auth_yet" |
} |
if(isset($_GET['url'])) #When user clicked to open a connection ... |
{ |
exec("sudo /usr/sbin/ipset add not_auth_yet $remote_ip"); # Add user in the ipset "not_auth_yet" to not loop when redirected |
echo "<script>window.location.href='http://$_GET[url]'</script>"; #we redirect him to his HTTP website (to be intecepted by coova) |
exit; |
|
} |
if ((!$direct_access && !$display_button_user_not_auth_yet) || $ipset_not_auth_yet[0] == '1'){ #if user not_auth_yet still here (index.php), we force DNS resquest. |
echo "<script>window.location.reload(true)</script>"; #We force DNS request |
} |
|
|
/* ANCIEN FONCTIONNEMENT : l'utilisateur ne cliquait pas sur le boutton pour etre flaggué + pas d'access au menu index.php avec les boutons |
# the user isn't connected and he isn't in the ipset "not_auth_yet" yet |
exec("sudo /usr/sbin/ipset list not_auth_yet | grep $remote_ip | wc -l 2>&1", $ipset_not_auth_yet); |
if(!$direct_access && $ipset_not_auth_yet[0] == '0') |
{ |
exec("sudo /usr/sbin/ipset add not_auth_yet $remote_ip"); # Add in the ipset "not_auth_yet" to not loop when redirected |
|
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") |
{ |
header("Location: http://$_SERVER[HTTP_HOST]"); |
123,10 → 150,15 |
} |
exit; |
} |
if(!$direct_access) #If user is already in not_auth_yet |
{ |
echo "<script>window.location.reload(true)</script>"; #We force DNS request |
exit; |
}*/ |
|
|
|
} |
|
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
151,8 → 183,16 |
$l_category = "catégorie :"; |
if ((isset ($user[4])) && ($user[4] == "0")) { |
$l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre système."; |
$l_logout = "<a href=\"http://www.google.com\">Ouvrir une session Internet</a>"; |
|
if($display_button_user_not_auth_yet) |
{ |
$l_logout = "<a href=\"http://alcasar/index.php?url=$_SERVER[HTTP_HOST]\">Ouvrir une session Internet</a>"; |
} |
else |
{ |
$l_logout = "<a href=\"http://www.google.com\">Ouvrir une session Internet</a>"; |
} |
|
|
} |
else { |
194,8 → 234,16 |
$l_category = "categoria :"; |
if ((isset ($user[4])) && ($user[4] == "0")) { |
$l_logout_explain = "Não há conexão de Internet aberta em seu computador, deseja conectar?"; |
$l_logout = "<a href=\"http://www.google.com\">Abrir uma conexão de Internet</a>"; |
if($display_button_user_not_auth_yet) |
{ |
$l_logout = "<a href=\"http://alcasar/index.php?url=$_SERVER[HTTP_HOST]\">Abrir uma conexão de Internet</a>"; |
} |
else |
{ |
$l_logout = "<a href=\"http://www.google.com\">Abrir uma conexão de Internet</a>"; |
} |
|
|
|
} |
else { |
237,7 → 285,14 |
$l_category = "category :"; |
if ((isset ($user[4])) && ($user[4] == "0")) { |
$l_logout_explain = "No Internet consultation session is actualy open on your system"; |
$l_logout = "<a href=\"http://www.google.com\">Open an Internet session</a>"; |
if($display_button_user_not_auth_yet) |
{ |
$l_logout = "<a href=\"http://alcasar/index.php?url=$_SERVER[HTTP_HOST]\">Open an Internet session</a>"; |
} |
else |
{ |
$l_logout = "<a href=\"http://www.google.com\">Open an Internet session</a>"; |
} |
|
|
} |
266,7 → 321,7 |
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny)); |
|
# set the icons |
$img_rep = "images/"; |
$img_rep = "http://alcasar/images/"; |
$img_organisme = "organisme.png"; |
$img_access = "globe_acces_70.png"; |
$img_connect = "globe_70.png"; |
299,7 → 354,18 |
<title>ALCASAR - <?php echo $l_title; ?></title> |
<meta http-equiv="Cache-control" content="no-cache"> |
<meta http-equiv="Pragma" content="no-cache"> |
<link rel="stylesheet" type="text/css" href="css/style_intercept.css"> |
<?php |
if($display_button_user_not_auth_yet) #if user is intercepted (ipset:not_auth_yet), css style is not included properly |
{ |
echo "<style>"; |
include("css/style_intercept.css"); |
echo "</style>"; |
} |
else |
{ |
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style_intercept.css\">"; |
} |
?> |
<script type="text/javascript"> |
function valoriserDiv5(param){ |
document.getElementById("box_info").innerHTML = param.innerHTML; |
308,7 → 374,7 |
</head> |
<body onload="valoriserDiv5(text_conn);"> |
<?php |
if ($direct_access){ |
if ($direct_access || $display_button_user_not_auth_yet){ |
echo " |
<div id=\"cadre_titre\" class=\"titre_controle\"> |
<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>"; |
323,7 → 389,7 |
} |
?> |
<div id="boite_logo"> |
<img src="images/organisme.png"> |
<img src="<?php echo "$img_rep$img_organisme"; ?>"> |
</div> |
</div> |
<div id="contenu_acces"> |
358,7 → 424,7 |
} |
?> |
<?php |
if ($direct_access){ |
if ($direct_access || $display_button_user_not_auth_yet){ |
echo " <div id=\"box_bienvenue\"> |
$l_welcome |
</div> |
394,7 → 460,7 |
<div id=\"box_info\"> |
</div>"; |
} |
else { |
else { |
echo " |
<div id=\"box_refuse\"> |
<img src=\"$img_rep$img_false\"> |
416,3 → 482,5 |
</div> |
</body> |
</html> |
|
|