Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1989 → Rev 1988

/web/index.php
48,7 → 48,6
$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();
112,33 → 111,7
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]");
150,15 → 123,10
}
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'])){
183,16 → 151,8
$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&egrave;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 {
234,16 → 194,8
$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?";
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>";
}
$l_logout = "<a href=\"http://www.google.com\">Abrir uma conexão de Internet</a>";
 
}
else {
285,14 → 237,7
$l_category = "category :";
if ((isset ($user[4])) && ($user[4] == "0")) {
$l_logout_explain = "No Internet consultation session is actualy open on your system";
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>";
}
$l_logout = "<a href=\"http://www.google.com\">Open an Internet session</a>";
 
}
321,7 → 266,7
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
 
# set the icons
$img_rep = "http://alcasar/images/";
$img_rep = "images/";
$img_organisme = "organisme.png";
$img_access = "globe_acces_70.png";
$img_connect = "globe_70.png";
354,18 → 299,7
<title>ALCASAR - <?php echo $l_title; ?></title>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<?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\">";
}
?>
<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;
374,7 → 308,7
</head>
<body onload="valoriserDiv5(text_conn);">
<?php
if ($direct_access || $display_button_user_not_auth_yet){
if ($direct_access){
echo "
<div id=\"cadre_titre\" class=\"titre_controle\">
<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
389,7 → 323,7
}
?>
<div id="boite_logo">
<img src="<?php echo "$img_rep$img_organisme"; ?>">
<img src="images/organisme.png">
</div>
</div>
<div id="contenu_acces">
424,7 → 358,7
}
?>
<?php
if ($direct_access || $display_button_user_not_auth_yet){
if ($direct_access){
echo " <div id=\"box_bienvenue\">
$l_welcome
</div>
460,7 → 394,7
<div id=\"box_info\">
</div>";
}
else {
else {
echo "
<div id=\"box_refuse\">
<img src=\"$img_rep$img_false\">
482,5 → 416,3
</div>
</body>
</html>