33,21 → 33,20 |
exit('Error opening the file '.CONF_FILE); |
} |
while (!feof($file_conf)) { |
$tampon = fgets($file_conf, 4096); |
if ((strpos($tampon, '=') !== false) && (substr($tampon, 0, 1) !== '#')) { |
$tmp = explode('=', $tampon); |
$buffer = fgets($file_conf, 4096); |
if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) { |
$tmp = explode('=', $buffer); |
$conf[$tmp[0]] = trim($tmp[1]); |
} |
} |
fclose($file_conf); |
|
$organisme = trim($conf["ORGANISM"]); |
$hostname = trim($conf["HOSTNAME"]).'.'.trim($conf["DOMAIN"]); |
$organisme = $conf["ORGANISM"]; |
$hostname = $conf["HOSTNAME"].'.'.$conf["DOMAIN"]; |
$network_pb = False; # "alcasar-watchdog.sh" changes this value if a network issue is detected |
$diagnostic = "can't contact the default router"; # "alcasar-watchdog.sh" changes this value if a network issue is detected |
$cert_add = "http://$hostname/certs"; |
$direct_access = False; |
$display_menu=False; |
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
$tab = array();$user = array(); |
$connection_history = ""; |
66,7 → 65,6 |
# Test if it's a direct connexion to ALCASAR |
if (isset($_SERVER['HTTP_HOST']) && (($_SERVER['HTTP_HOST'] === $_SERVER['SERVER_ADDR']) || ($_SERVER['HTTP_HOST'] === 'alcasar') || ($_SERVER['HTTP_HOST'] === $hostname) || ($_SERVER['HTTP_HOST'] === $organisme))) { |
$direct_access = true; |
exec("sudo /usr/sbin/ipset del not_auth_yet $remote_ip"); # del user of the ipset "not_auth_yet" to not loop |
} |
|
# Function to adapt time connexion in seconds to H,M,S |
80,17 → 78,16 |
} |
|
# if user need to be warned |
if(isset($_GET['warn']) && isset($_GET['url'])) |
{ |
$direct_access = False; |
if (isset($_GET['warn']) && isset($_GET['url'])) { |
$direct_access = false; |
} |
|
if ((isset ($user[4])) && ($user[4] != "0")){ # the user is authenticated |
if(isset($_GET['redirect'])) # if user has been warned, we redirect him to his website |
{ |
if ((isset($user[4])) && ($user[4] != "0")) { # the user is authenticated |
if (isset($_GET['redirect'])) { # if user has been warned, we redirect him to his website |
header('Location: '.$_GET['url'], true, 307); |
exit; |
exit(); |
} |
|
# we retrieve his three last connections |
if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){ |
include_once("/etc/freeradius-web/config.php"); |
111,24 → 108,12 |
} |
} |
} |
else # the user isn't authenticated |
{ |
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'){ # it's the first stage of the interception |
$display_menu = True; # Display menu for user not_auth_yet |
if (!isset($_SERVER['HTTPS'])){ # In HTTP, the user is redirected on it's home page. In HTTPS, it's on the default page (see $redirect_link) |
$redirect_link = $_SERVER['HTTP_HOST']; |
} |
else { # the user isn't authenticated |
if (isset($_GET['url'])) { # it's the second stage (when user has clicked on the button "open a connection") |
$redir = 'http://'.$_GET['url']; |
header("Location: $redir", true, 307); |
exit(); |
} |
if(isset($_GET['url'])){ # it's the second stage (when user has clicked on the button "open a connection") |
exec("sudo /usr/sbin/ipset add not_auth_yet $remote_ip"); # Add user in the ipset "not_auth_yet" (DNS requests not intercepted) |
$redir = "http://".$_GET['url']; |
header("Location: $redir",TRUE,307); |
exit; |
} |
if ($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>"; # force DNS request |
} |
} |
# Choice of language |
if($Language == 'fr'){ |
409,8 → 394,8 |
$l_uam_domain = "Authorized websites : "; |
} |
|
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied)); |
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny)); |
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied)); |
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny)); |
|
# set the icons |
$img_rep = "/images/"; |
445,12 → 430,6 |
header("Cache-Control: post-check=0, pre-check=0", false); |
header("Pragma: no-cache"); |
|
exec("sudo /usr/sbin/ipset list not_filtered | grep $remote_ip | wc -l 2>&1", $ipset_not_filtered); |
# if user is in "ipset_not_filtered" then he must refresh its dns cache (we are in the interception process) |
if (!$direct_access && !$display_menu && ($ipset_not_filtered[0] == '1') && (!$network_pb) && (!isset($_GET['warn']))) { |
echo '<!doctype html><html><head><script>window.location.reload(true)</script></head><body></body></html>'; # force DNS request |
} |
|
?> |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
<html> |
468,7 → 447,7 |
</head> |
<body onload="valoriserDiv5(text_conn);"> |
<?php |
if ($direct_access || $display_menu){ |
if ($direct_access){ |
echo " |
<div id=\"cadre_titre\" class=\"titre_controle\"> |
<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>"; |
499,7 → 478,7 |
<div id="box_url"> |
<?php |
// Search blacklist categories |
if ((!$direct_access) && (!$display_menu) && (!$network_pb) && (!isset($_GET['warn']))) { |
if ((!$direct_access) && (!$network_pb) && (!isset($_GET['warn']))) { |
$pattern = str_replace('www.', '', $_SERVER['HTTP_HOST']); |
exec('grep -Re ' . escapeshellarg('^'.$pattern.'$') . " /etc/dansguardian/lists/blacklists/*/domains | cut -d'/' -f6", $output); |
$lists = []; |
538,9 → 517,9 |
$sms_div=''; |
$sms_div_over=''; |
} |
if ($direct_access || $display_menu){ |
if (!$network_pb){ |
echo " |
if ($direct_access) { |
if (!$network_pb) { |
echo " |
<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\"> |
<span>$l_logout</span> |
<img src=\"$img_rep$img_internet\"> |
554,7 → 533,7 |
$domainAllowedHtml .= '<p>'.$l_uam_domain.'<br><ul>'; |
foreach ($tab as $line) { |
if (trim($line) !== '') { // the line isn't empty |
$domain_allowed = explode("#", $line); |
$domain_allowed = explode('#', $line); |
if (trim($domain_allowed[1]) !== '') { |
$domain = explode('"', $domain_allowed[0]); |
// remove every '.' from the beginning of domain |