42,20 → 42,19 |
/**************************************************************** |
* Read CONF_FILE * |
*****************************************************************/ |
$ouvre=fopen(CONF_FILE,"r"); |
if ($ouvre){ |
while (!feof ($ouvre)) |
{ |
$tampon = fgets($ouvre, 4096); |
if (strpos($tampon,"=")!==false){ |
$tmp = explode("=",$tampon); |
$conf[$tmp[0]] = $tmp[1]; |
$file_conf = fopen(CONF_FILE, 'r'); |
if (!$file_conf) { |
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); |
$conf[$tmp[0]] = trim($tmp[1]); |
} |
}else{ |
exit("Erreur d'ouverture du fichier ".CONF_FILE); |
} |
fclose($ouvre); |
fclose($file_conf); |
|
$organisme = trim($conf["ORGANISM"]); |
|
# Shared secret used to encrypt password with coova. |
66,16 → 65,16 |
|
# Our own path |
$loginpath = htmlspecialchars($_SERVER['PHP_SELF']); |
$alcasarpath = "http://alcasar.".trim($conf["DOMAIN"]); |
$statuspath = $alcasarpath."/status.php"; |
$debug = false; |
$alcasarpath = 'http://'.trim($conf['HOSTNAME']).'.'.trim($conf['DOMAIN']); |
$statuspath = $alcasarpath.'/status.php'; |
|
# Choice of language |
$Language = 'en'; |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){ |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); |
$Language = strtolower(substr(chop($Langue[0]),0,2)); } |
if($Language == 'es'){ |
$Language = strtolower(substr(chop($Langue[0]),0,2)); |
} |
if ($Language === 'es') { |
$l_ChilliError = "La autenticación debe ser un éxito a través del servicio de portal cautivo."; |
$l_login = "El éxito de la autenticación.<HR>Cierre esta ventana interrumpte la sesion."; |
$l_logout = "Conexión de cierre"; |
107,8 → 106,8 |
$l_online_time = "Tiempo en linea"; |
$l_remaining_time = "Tiempo restante"; |
$l_uam_domain = "Sitios web autorizados : "; |
$l_autoregistration = "Registo automático";} |
else if ($Language == 'pt'){ |
$l_autoregistration = "Registo automático"; |
} else if ($Language === 'pt') { |
$l_ChilliError = "A autenticação precisa ser bem sucedida através do portal."; |
$l_login = "Sucesso na autenticação.<HR>Matenha esse pop-up apenas minimizado para não interromper a conexão"; |
$l_logout = "Encerrar conexão"; |
140,8 → 139,8 |
$l_online_time = "Tempo Online"; |
$l_remaining_time = "Tempo restante"; |
$l_uam_domain = "Sites autorizados : "; |
$l_autoregistration = "Registo automático";} |
else if ($Language == 'zh'){ |
$l_autoregistration = "Registo automático"; |
} else if ($Language === 'zh') { |
$l_ChilliError = "验证必须通过强制门户服务"; |
$l_login = "验证成功<HR>关闭此窗口中断连接"; |
$l_logout = "关闭连接"; |
173,8 → 172,8 |
$l_online_time = "在线时间"; |
$l_remaining_time = "剩余时间"; |
$l_uam_domain = "授权网站 : "; |
$l_autoregistration = "短信注册";} |
else if($Language == 'ar'){ |
$l_autoregistration = "短信注册"; |
} else if($Language === 'ar') { |
$l_ChilliError = "يجب نجاح المصادقة على البوابة الأسيرة"; |
$l_login = "إغلاق هذه النافذة يقطع دورة عملك"; |
$l_logout = "إغلاق الدورة"; |
206,8 → 205,8 |
$l_online_time = "مذة الإتصال"; |
$l_remaining_time = "الوقت المتبق"; |
$l_uam_domain = ":المواقع المسموحة "; |
$l_autoregistration = "تسجيل ذاتي (SMS)";} |
else if($Language == 'de'){ |
$l_autoregistration = "تسجيل ذاتي (SMS)"; |
} else if($Language === 'de') { |
$l_ChilliError = "Die Authentifizierung ist erfolgreich durch die Nutzung des Portals erfolgt."; |
$l_login = "Erfolgreiche Authentifizierung.<HR>Schlißen dieses fensters unterbricht die sitzung"; |
$l_logout = "Beenden der Verbindung"; |
239,8 → 238,8 |
$l_online_time = "Online-zeit"; |
$l_remaining_time = "Restzeit"; |
$l_uam_domain = "Autorisierten websites : "; |
$l_autoregistration = "Automatische registrierung";} |
else if($Language == 'nl'){ |
$l_autoregistration = "Automatische registrierung"; |
} else if($Language === 'nl') { |
$l_ChilliError = "De authenticatie moet een succes worden via de captive portal dienst."; |
$l_login = "Succesvolle authenticatie.<HR>Dit venster te sluiten onderbreekt uw sessie."; |
$l_logout = "Slotkoers verbinding"; |
272,8 → 271,8 |
$l_online_time = "Online tijd"; |
$l_remaining_time = "Reterende tijd"; |
$l_uam_domain = "Geautoriseerde website : "; |
$l_autoregistration = "Automatische registratie";} |
else if($Language == 'fr'){ |
$l_autoregistration = "Automatische registratie"; |
} else if($Language === 'fr') { |
$l_ChilliError = "L'authentification doit être réussie sur le portail captif."; |
$l_login = "Authentification réussie.<HR>La fermeture de cette fenêtre interrompt votre session."; |
$l_logout = "Fermeture de la session"; |
305,8 → 304,8 |
$l_online_time = "Temps de connexion"; |
$l_remaining_time = "Temps restant"; |
$l_uam_domain = "Sites autorisés : "; |
$l_autoregistration = "Auto enregistrement (sms)";} |
else{ |
$l_autoregistration = "Auto enregistrement (sms)"; |
} else { |
$l_ChilliError = "The authentication must be successful through the captive portal service."; |
$l_login = "Successful authentication.<HR>Closing this window interrupts your session"; |
$l_logout = "Closing connection"; |
342,26 → 341,28 |
} |
|
# If https not use, tell it's wrong |
if (!(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS'] == 'on'))) { |
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> |
if ((!isset($_SERVER['HTTPS'])) || (empty($_SERVER['HTTPS'])) || ($_SERVER['HTTPS'] === 'off')) { |
?> |
<!doctype html> |
<html> |
<head> |
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
<title>$l_loggedcont</title> |
<meta http-equiv=\"Cache-control\" content=\"no-cache\"> |
<meta http-equiv=\"Pragma\" content=\"no-cache\"> |
<meta charset="utf-8"> |
<title><?= $l_loggedcont ?></title> |
<meta http-equiv="Cache-control" content="no-cache"> |
<meta http-equiv="Pragma" content="no-cache"> |
</head> |
<body bgColor = 'white'> |
<h1 style=\"text-align: center;\">$l_loginfailed</h1> |
<center>$l_encrypted</center> |
<body style="background-color: white;"> |
<h1 style="text-align: center;"><?= $l_loginfailed ?></h1> |
<center><?= $l_encrypted ?></center> |
</body> |
</html>"; |
exit(0); |
</html> |
<?php |
exit(); |
} |
|
# Read form parameters which we care about |
# avoid the "user as a MAC address" attempts |
if ((isset($_POST['UserName'])) && (preg_match('/^([0-9A-F]{2}-){5}[0-9A-F]{2}$/',$_POST['UserName'])!=1)){ |
if ((isset($_POST['UserName'])) && (preg_match('/^([0-9A-F]{2}-){5}[0-9A-F]{2}$/', $_POST['UserName']) !== 1)) { |
$username = $_POST['UserName'];} else {$username="";} |
if (isset($_POST['Password'])){ $password = $_POST['Password'];} else {$password="";} |
if (isset($_POST['challenge'])){$challenge = $_POST['challenge'];} else {$challenge="";} |
394,41 → 395,41 |
case 'Password Has Expired' : $reply = $l_reply_4 ; break; |
case 'You are already logged in - access denied' : $reply = $l_reply_5 ; break; |
case 'Your maximum never usage time has been reached' : $reply = $l_reply_6 ; break; |
}} |
} |
} |
|
# If attempt to login |
if ("$button" == "$l_boutonO") { |
#correction password length in coova-chilli |
#thanks to http://www.stochasticgeometry.ie/2009/09/09/maximum-password-length-in-coova-chilli/ |
$hexchal = pack ("H*", $challenge); |
$newchal = pack ("H*", md5($hexchal . $uamsecret)); |
// If attempt to login |
if ($button === $l_boutonO) { |
//correction password length in coova-chilli |
//thanks to http://www.stochasticgeometry.ie/2009/09/09/maximum-password-length-in-coova-chilli/ |
$hexchal = pack('H*', $challenge); |
$newchal = pack('H*', md5($hexchal . $uamsecret)); |
|
# If challenge isn't long enough, repeat it until it is |
// If challenge isn't long enough, repeat it until it is |
while (strlen($newchal) < strlen($password)){ |
$newchal .= $newchal; |
} |
|
$response = md5("\0" . $password . $newchal); |
$newpwd = pack("a*", $password); |
# Encode plain text password with challenge |
$pappassword = implode ("", unpack("H*", ($newpwd ^ $newchal))); |
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> |
$newpwd = pack('a*', $password); |
// Encode plain text password with challenge |
$pappassword = implode('', unpack('H*', ($newpwd ^ $newchal))); |
?> |
<!doctype html> |
<html> |
<head> |
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
<title>$l_loggingin</title> |
<meta http-equiv=\"Cache-control\" content=\"no-cache\"> |
<meta http-equiv=\"Pragma\" content=\"no-cache\"> |
<meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/logon?username=$username&password=$pappassword&userurl=$userurl\"> |
<meta charset="utf-8"> |
<title><?= $l_loggingin ?></title> |
<meta http-equiv="Cache-control" content="no-cache"> |
<meta http-equiv="Pragma" content="no-cache"> |
<meta http-equiv="refresh" content="0;url=<?= "http://$uamip:$uamport/logon?username=$username&password=$pappassword&userurl=$userurl" ?>"> |
</head> |
<body bgColor = 'white'> |
<h1 style=\"text-align: center;\">$l_loggingin</h1> |
<center> |
$l_wait |
</center> |
<body style="background-color: white;"> |
<h1 style="text-align: center;"><?= $l_loggingin ?></h1> |
<center><?= $l_wait ?></center> |
</body> |
</html>"; |
exit(0); |
</html> |
<?php |
exit(); |
} |
|
switch($res) { |
441,183 → 442,167 |
} |
|
//check if we need to warn user about the imputability logs. |
if($result == 1) |
{ |
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"); |
include_once("./acc/manager/lib/sql/drivers/mysql/functions.php"); |
if($result === 1) { |
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'); |
include_once('./acc/manager/lib/sql/drivers/mysql/functions.php'); |
$link = @da_sql_pconnect($config); // on affiche pas les erreurs |
if ($link) { |
$user_uid=da_sql_escape_string($link, $_GET['uid']); |
$sql = "SELECT attribute, value FROM radreply WHERE username='$user_uid'"; |
if ($link){ |
$sql = "SELECT attribute, value FROM radreply WHERE username='$user_uid' AND attribute='Filter-Id'"; |
$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs |
if ($res){ |
while(($row = @da_sql_fetch_array($res,$config))){ |
if ($row['attribute'] == "Filter-Id") $filter_id = $row['value']; // on obtient le Filter-Id de l'utilisateur |
} |
if($filter_id[3] == '1') |
{ |
#set the fourth bit of filter-id to '0' |
$row = @da_sql_fetch_array($res, $config); |
$filter_id = $row['value']; // on obtient le Filter-Id de l'utilisateur |
if($filter_id[3] === '1') { |
//set the fourth bit of filter-id to '0' |
$sql = "set @CurrentFilter=(SELECT value from radreply where username='$user_uid');set @CurrentFilterLeft=(SELECT LEFT(@CurrentFilter,3));set @CurrentFilterRight=(SELECT RIGHT(@CurrentFilter,4));UPDATE radreply SET value = CONCAT((@CurrentFilterLeft),'0', (@CurrentFilterRight)) WHERE username='$user_uid'"; |
$res = mysqli_multi_query($link,$sql); |
$user_url = urlencode($_GET['userurl']); |
header("Location: http://alcasar/index.php?warn=1&url=$user_url"); //we present to user information about imputability logs |
exit; |
header('Location: https://'.trim($conf['HOSTNAME']).'.'.trim($conf['DOMAIN']).'/index.php?warn=1&url='.urlencode($_GET['userurl'])); //we present to user information about imputability logs |
exit(); |
} |
} |
} |
} |
|
} |
|
|
# Otherwise it was not a form request |
# Send out an error message |
if ($result == 0) { //erreur |
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> |
// Otherwise it was not a form request |
// Send out an error message |
if ($result === 0) { //erreur |
?> |
<!doctype html> |
<html> |
<head> |
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
<title>$l_loggingin</title> |
<meta http-equiv=\"Cache-control\" content=\"no-cache\"> |
<meta http-equiv=\"Pragma\" content=\"no-cache\"> |
<meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/prelogin\"> |
<meta charset="utf-8"> |
<title><?= $l_loggingin ?></title> |
<meta http-equiv="Cache-control" content="no-cache"> |
<meta http-equiv="Pragma" content="no-cache"> |
<meta http-equiv="refresh" content="0;url=<?= "http://$uamip:$uamport/prelogin" ?>"> |
</head> |
<body bgColor = 'white'> |
<h1 style=\"text-align: center;\">$l_loggingin</h1> |
<center> |
$l_wait |
</center> |
<body style="background-color: white;"> |
<h1 style="text-align: center;"><?= $l_loggingin ?></h1> |
<center><?= $l_wait ?></center> |
</body> |
</html>"; |
exit(0); |
</html> |
<?php |
exit(); |
} |
# Generate the output |
echo "<!DOCTYPE html> |
?> |
<!doctype html> |
<html> |
<head> |
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> |
<title>$l_loggingin</title> |
<meta http-equiv=\"Cache-control\" content=\"no-cache\"> |
<meta http-equiv=\"Pragma\" content=\"no-cache\"> |
<script type=\"text/javascript\" language=\"JavaScript\"> |
alcasar_popup = null; |
<meta charset="utf-8"> |
<title><?= $l_loggingin ?></title> |
<meta http-equiv="Cache-control" content="no-cache"> |
<meta http-equiv="Pragma" content="no-cache"> |
<script type="text/javascript"> |
var alcasar_popup = null; |
function popUp(URL) { |
if (self.name != \"alcasar_popup\") { |
if (self.name !== "alcasar_popup") { |
alcasar_popup = window.open(URL, 'alcasar_popup', 'width=500,height=460,directories=no,resizable=no,scrollbars=yes,location=no,toolbar=no,statusbar=no,menubar=no'); |
} |
} |
function doOnLoad(result, userurl, redirurl, adminurl, timeleft) { |
if ((result == 1)||(result == 4)) { //success or already |
if ((result === 1) || (result === 4)) { //success or already |
//window.location = userurl; |
if (alcasar_popup != null) alcasar_popup.focus(); |
if (adminurl != ''){ |
if (alcasar_popup !== null) alcasar_popup.focus(); |
if (adminurl !== '') { |
window.location = adminurl; |
} else if (redirurl != '') { |
} else if (redirurl !== '') { |
window.location = redirurl; |
} else if (userurl != '') { |
} else if (userurl !== '') { |
window.location = userurl; |
} else { |
window.home(); |
} |
} |
if ((result == 2) || (result == 3) || result == 5) { //failed or logoff or notyet |
if (alcasar_popup != null) alcasar_popup.close(); |
if ((result === 2) || (result === 3) || result === 5) { //failed or logoff or notyet |
if (alcasar_popup !== null) alcasar_popup.close(); |
document.form1.UserName.focus(); |
} |
} |
</script> |
<link rel=\"stylesheet\" href=\"/css/style_intercept.css\" type=\"text/css\"> |
<link rel="stylesheet" href="/css/style_intercept.css" type="text/css"> |
</head> |
<body onLoad=\"javascript:doOnLoad($result,'$userurl','$redirurl','$adminurl','$timeleft')\"> |
<center>"; |
if ($result == 2 || $result == 3 || $result == 5) { //failed or logoff or notyet |
echo " |
<div id=\"logon\"> |
<h1>$organisme</h1> |
<h2>$l_loggedcont</h2>"; |
if ($result == 2) { //failed |
echo " |
<h3>$l_loginfailed</h3>"; |
if ($reply) { |
#traitement du reply ... |
echo "<center> $reply <br /><br /></center>"; |
} |
} |
if ($userurl == "http://logout/") $userurl="http://www.google.com"; //avoid cyclic logout |
echo " |
<img id=\"logo-alcasar\" src=\"/images/logo-alcasar.png\"> |
<form name=\"form1\" method=\"post\" action=\"$loginpath\"> |
<input type=\"hidden\" name=\"challenge\" value=\"$challenge\"> |
<input type=\"hidden\" name=\"uamip\" value=\"$uamip\"> |
<input type=\"hidden\" name=\"uamport\" value=\"$uamport\"> |
<input type=\"hidden\" name=\"userurl\" value=\"$userurl\"> |
<table id=\"boite-logon\"> |
<body onLoad="javascript:doOnLoad(<?= $result ?>,'<?= $userurl ?>','<?= $redirurl ?>','<?= $adminurl ?>','<?= $timeleft ?>')"> |
<center> |
|
<?php if ($result === 2 || $result === 3 || $result === 5): //failed or logoff or notyet ?> |
<div id="logon"> |
<h1><?= $organisme ?></h1> |
<h2><?= $l_loggedcont ?></h2> |
<?php if ($result === 2): //failed ?> |
<h3><?= $l_loginfailed ?></h3> |
<?php if ($reply): //traitement du reply ... ?> |
<center><?= $reply ?><br><br></center> |
<?php endif; ?> |
<?php endif; |
if ($userurl === 'http://logout/') $userurl = 'http://www.google.com'; // Avoid cyclic logout |
?> |
<img id="logo-alcasar" src="/images/logo-alcasar.png"> |
<form name="form1" method="post" action="<?= $loginpath ?>"> |
<input type="hidden" name="challenge" value="<?= $challenge ?>"> |
<input type="hidden" name="uamip" value="<?= $uamip ?>"> |
<input type="hidden" name="uamport" value="<?= $uamport ?>"> |
<input type="hidden" name="userurl" value="<?= $userurl ?>"> |
<table id="boite-logon"> |
<tr> |
<td width=\"20%\" rowspan=\"4\"><img id=\"logo-organ\" src=\"/images/organisme.png\"></td> |
<td width=\"30%\" align=\"right\">$l_user</td> |
<td width=\"50%\" align=\"left\"><INPUT type=\"text\" maxLength=\"32\" name=\"UserName\" autocomplete=\"off\"></td> |
<td width="20%" rowspan="4"><img id="logo-organ" src="/images/organisme.png"></td> |
<td width="30%" align="right"><?= $l_user ?></td> |
<td width="50%" align="left"><input type="text" maxLength="32" name="UserName" autocomplete="off"></td> |
</tr> |
<tr> |
<td align=\"right\">$l_password</td> |
<td align=\"left\"><INPUT maxLength=\"32\" type=\"password\" name=\"Password\" autocomplete=\"off\"></td> |
<td align="right"><?= $l_password ?></td> |
<td align="left"><input maxLength="32" type="password" name="Password" autocomplete="off"></td> |
</tr> |
"; |
|
echo " </tr> |
<td height=\"23\" align=\"left\"><INPUT value=\"$l_boutonO\" type=\"submit\" name=\"button\" onclick=\"window.open('$statuspath', '_blank');\"></td> |
"; |
|
|
<tr> |
<td height="23" align="left"><input value="<?= $l_boutonO ?>" type="submit" name="button" onclick="window.open('<?= $statuspath ?>', '_blank');"></td> |
<?php |
$service_SMS_status=false; |
if($service_SMS_status){ |
echo " <td><a href=\"./autoregistrationinfo.php\">".$l_autoregistration."</a></td>"; |
} |
|
echo " </tr> |
if ($service_SMS_status): ?> |
<td><a href="./autoregistrationinfo.php"><?= $l_autoregistration ?></a></td> |
<?php endif; ?> |
</tr> |
</table> |
|
</form> |
<table id=\"boite-info\" cellSpacing=\"0\" cellPadding=\"0\" width=\"80%\"> |
<table id="boite-info" cellSpacing="0" cellPadding="0" width="80%"> |
<tr> |
<td align=\"center\"><FONT color=\"red\"><B>$l_loggedin_stringl1</B></FONT></td> |
<td align="center"><font color="red"><b><?= $l_loggedin_stringl1 ?></b></font></td> |
</tr> |
<tr> |
<td align=\"left\"> |
<td align="left"> |
<ul> |
<LI>$l_loggedin_stringl2</LI> |
<LI>$l_loggedin_stringl4</LI> |
<LI>$l_loggedin_stringl3</LI> |
<LI>$l_loggedin_stringl5</LI> |
<LI>$l_loggedin_stringl6</LI> |
<li><?= $l_loggedin_stringl2 ?></li> |
<li><?= $l_loggedin_stringl4 ?></li> |
<li><?= $l_loggedin_stringl3 ?></li> |
<li><?= $l_loggedin_stringl5 ?></li> |
<li><?= $l_loggedin_stringl6 ?></li> |
</ul> |
</td> |
</tr> |
</table>"; |
|
</table> |
<?php |
// Read the "Domain allowed" file |
$tab=file(DOMAIN_ALLOWED_LIST); |
if ($tab) # the file isn't empty |
{ |
echo "<div id=\"authorized_domain\">$l_uam_domain"; |
foreach ($tab as $line) |
{ |
if (trim($line) != '') # the line isn't empty |
{ |
if ($tab) { // the file isn't empty |
echo '<div id="authorized_domain">'.$l_uam_domain; |
foreach ($tab as $line) { |
if (trim($line) !== '') { // the line isn't empty |
$domain_allowed=explode("#", $line); |
if (trim($domain_allowed[1]) != ''){ |
$domain=explode("\"", $domain_allowed[0]); |
#remove every '.' from the beginning of domain |
if (trim($domain_allowed[1]) !== '') { |
$domain = explode('"', $domain_allowed[0]); |
// remove every '.' from the beginning of domain |
$domain[1] = ltrim($domain[1], '.'); |
echo "<a href=\"http://".trim($domain[1])."\">".trim($domain_allowed[1])."</a> ";} |
echo '<a href="http://'.trim($domain[1]).'">'.trim($domain_allowed[1]).'</a>'; |
} |
} |
} |
echo " |
} |
?> |
</div> |
<?php endif; ?> |
|
</center> |
</body> |
</html>"; |
} |
exit(0); |
?> |
</html> |