Subversion Repositories ALCASAR

Rev

Rev 2823 | Rev 2850 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
895 richard 1
<?php
958 franck 2
# $Id: intercept.php 2837 2020-06-16 22:24:15Z rexy $
895 richard 3
#
1249 richard 4
# intercept.php for ALCASAR captive portal
895 richard 5
# Copyright (C) 2003, 2004 Mondru AB.
6
# Modify by REXY & steweb57
7
# UI & css style by stephane ERARD
8
# Help for language translation by B. AUBARD (thanks)
9
 
10
# The contents of this file may be used under the terms of the GNU
11
# General Public License Version 2, provided that the above copyright
12
# notice and this permission notice is included in all copies or
13
# substantial portions of the software.
14
 
15
# Redirects from CoovaChilli (chilli daemon) :
16
# Response to login:
17
  # success :	if login successful
18
  # failed :	if login failed
19
  # logoff :	if logout successful
20
  # already :	if tried to login while already logged in
21
  # notyet :	if not logged in yet
22
  # Default :	it was not a form request -> client go to login form
23
 
24
/****************************************************************
25
*			GLOBAL FILE PATHS			*
26
*****************************************************************/
2238 tom.houday 27
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
28
define('DOMAIN_ALLOWED_LIST', '/usr/local/etc/alcasar-uamdomain');
895 richard 29
 
30
/****************************************************************
930 richard 31
*			FILE reading test			*
895 richard 32
*****************************************************************/
2238 tom.houday 33
$conf_files = array(CONF_FILE, DOMAIN_ALLOWED_LIST);
2182 tom.houday 34
foreach ($conf_files as $file) {
35
	if (!file_exists($file)) {
2238 tom.houday 36
		exit("Fichier $file non présent");
913 richard 37
	}
2182 tom.houday 38
	if (!is_readable($file)) {
2238 tom.houday 39
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
913 richard 40
	}
41
}
895 richard 42
/****************************************************************
43
*			Read CONF_FILE				*
44
*****************************************************************/
2182 tom.houday 45
$file_conf = fopen(CONF_FILE, 'r');
46
if (!$file_conf) {
47
	exit('Error opening the file '.CONF_FILE);
48
}
49
while (!feof($file_conf)) {
2238 tom.houday 50
	$buffer = fgets($file_conf, 4096);
51
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 52
		$tmp = explode('=', $buffer, 2);
2370 tom.houday 53
		$conf[trim($tmp[0])] = trim($tmp[1]);
895 richard 54
	}
55
}
2182 tom.houday 56
fclose($file_conf);
57
 
2238 tom.houday 58
$organisme = $conf["ORGANISM"];
895 richard 59
 
2250 tom.houday 60
// Shared secret used to encrypt password with coova.
930 richard 61
$uamsecret = "";
895 richard 62
 
2250 tom.houday 63
// URL loaded after success authenticates (let blank for browser defaults)
895 richard 64
$adminurl = "";
65
 
2250 tom.houday 66
// Check if the SMS service is enable
2600 tom.houday 67
$service_SMS_status = ($conf['SMS'] === 'on');
2250 tom.houday 68
 
69
// Our own path
2409 tom.houday 70
$loginpath = htmlspecialchars($_SERVER['PHP_SELF']);
2378 tom.houday 71
$useHTTPS = ((isset($_SERVER['HTTPS'])) && (!empty($_SERVER['HTTPS'])) && ($_SERVER['HTTPS'] !== 'off'));
2409 tom.houday 72
$alcasarpath = (($useHTTPS) ? 'https' : 'http' ).'://'.$conf['HOSTNAME'].'.'.$conf['DOMAIN'];
73
$statuspath = (($conf['HTTPS_CHILLI'] === 'on') ? 'https' : 'http' ).'://'.$conf['HOSTNAME'].'.'.$conf['DOMAIN'].'/status.php';
895 richard 74
 
2250 tom.houday 75
// Choice of language
895 richard 76
$Language = 'en';
2250 tom.houday 77
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
2182 tom.houday 78
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
2370 tom.houday 79
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
1452 richard 80
}
2238 tom.houday 81
if ($Language === 'es') {		// Spanish
82
	$l_ChilliError			= "La autenticación debe ser un éxito a través del servicio de portal cautivo.";
83
	$l_login			= "El éxito de la autenticación.<HR>Cierre esta ventana interrumpte la sesion.";
84
	$l_logout			= "Conexión de cierre";
85
	$l_loginfailed			= "Error de autenticación";
86
	$l_loggingin			= "Identificación en el portal cautivo";
87
	$l_loggedcont			= "Control de Acceso";
88
	$l_loggedout			= "Su sesión se cierra";
89
	$l_user				= "Usuario";
90
	$l_password			= "Contraseña";
91
	$l_wait				= "Por favor, espere un momento ...";
92
	$l_onlinetime			= "Tiempo de conexión:";
93
	$l_remainingtime		= "Desconexión en:";
94
	$l_encrypted			= "La apertura debe usar conexión cifrada";
95
	$l_boutonO			= "Autenticación";
96
	$l_boutonF			= "Cerrar";
97
	$l_loggedin_stringl1		= "Information System Security";
98
	$l_loggedin_stringl2		= "El portal fue creado reglamentos para garantizar la trazabilidad, la rendición de cuentas y el no repudio de las conexiones.";
99
	$l_loggedin_stringl3		= "Su actividad en la red es registrada, de conformidad con la privacidad.";
100
	$l_loggedin_stringl4		= "Los datos registrados pueden ser capaces de ser operado por una autoridad judicial en el curso de una investigación.";
101
	$l_loggedin_stringl5		= "Estos datos se eliminan automáticamente después de un año.";
2370 tom.houday 102
	$l_loggedin_stringl6		= "Click <a href=\"$alcasarpath\">here</a> to change your password or to integrate the security certificate in your browser";
2238 tom.houday 103
	$l_loggedout_string		= "Cerrar sesión hizo portal cautivo!";
2702 tom.houday 104
	$l_reply_0			= "Nombre de usuario o contraseña incorrectos";
2591 rexy 105
	$l_reply_1			= "Su cuota diaria ha sido alcanzada (duración o volumen)";
106
	$l_reply_2			= "Su cuota mensual ha sido alcanzada (duración o volumen)";
2238 tom.houday 107
	$l_reply_3			= "You try to connect outside of your allowed timespan";
108
	$l_reply_4			= "your account expired";
109
	$l_reply_5			= "You have reached the maximum number of simultaneous logins";
110
	$l_reply_6			= "Your authorized connexion time has been reached";
111
	$l_online_time			= "Tiempo en linea";
112
	$l_remaining_time		= "Tiempo restante";
113
	$l_uam_domain			= "Sitios web autorizados : ";
114
	$l_autoregistration 		= "Registo autom&aacute;tico";
115
} else if ($Language === 'pt') {	// Portuguese
116
	$l_ChilliError			= "A autenticação precisa ser bem sucedida através do portal.";
117
	$l_login			= "Sucesso na autenticação.<HR>Matenha esse pop-up apenas minimizado para não interromper a conexão";
118
	$l_logout			= "Encerrar conexão";
119
	$l_loginfailed			= "Falha na autenticação";
120
	$l_loggingin			= "Identificação do portal cativo";
121
	$l_loggedcont			= "Controle de acesso";
122
	$l_loggedout			= "Sua sessão foi fechada";
123
	$l_user				= "Usuário";
124
	$l_password			= "Senha";
125
	$l_wait				= "Por favor, aguarde um momento ...";
126
	$l_onlinetime			= "Tempo de conexão:";
127
	$l_remainingtime		= "Desconectado em:";
128
	$l_encrypted			= "A conexão com o portal deve ser criptografada";
129
	$l_boutonO			= "Autenticação";
130
	$l_boutonF			= "Fechar";
131
	$l_loggedin_stringl1		= "Sistema de Informação e segurança";
132
	$l_loggedin_stringl2		= "Este controle foi criado para garantir acesso seguro.";
133
	$l_loggedin_stringl3		= "A autenticação será criptografada em 256 bits, impedindo captura por escâner de rede.";
134
	$l_loggedin_stringl4		= "Sua atividade na Internet será resguardada de acordo com os regulamentos da lei.";
135
	$l_loggedin_stringl5		= "Mantenha o popup da conexão minimizado para não interromper a cessão.";
2370 tom.houday 136
	$l_loggedin_stringl6		= "Clique <a href=\"$alcasarpath\">aqui</a> para alterar sua senha, instalar certificado ou sair do portal.";
2238 tom.houday 137
	$l_loggedout_string		= "desconexão do portal cativo";
2702 tom.houday 138
	$l_reply_0			= "Nome de usuário ou senha incorretos";
2591 rexy 139
	$l_reply_1			= "Sua cota diária foi alcançada (duração ou volume)";
140
	$l_reply_2			= "Sua cota mensal foi atingida (duração ou volume)";
2238 tom.houday 141
	$l_reply_3			= "Você tenta conectar-se fora do seu período de tempo permitido";
142
	$l_reply_4			= "Sua conta expirou";
143
	$l_reply_5			= "Você atingiu o número máximo de logins simultâneos";
144
	$l_reply_6			= "Seu tempo de conexão autorizada finalizou";
145
	$l_online_time			= "Tempo Online";
146
	$l_remaining_time		= "Tempo restante";
147
	$l_uam_domain			= "Sites autorizados : ";
148
	$l_autoregistration 		= "Registo autom&aacute;tico";
149
} else if ($Language === 'zh') {	// Chinese
150
	$l_ChilliError			= "验证必须通过强制门户服务";
151
	$l_login			= "验证成功<HR>关闭此窗口中断连接";
152
	$l_logout			= "关闭连接";
153
	$l_loginfailed			= "验证失败";
154
	$l_loggingin			= "强制门户身份识别";
155
	$l_loggedcont			= "访问控制";
156
	$l_loggedout			= "您的连接已关闭";
157
	$l_user				= "用户名";
158
	$l_password			= "密码";
159
	$l_wait				= "请等待 ...";
160
	$l_onlinetime			= "连接时间";
161
	$l_remainingtime		= "断开连接于";
162
	$l_encrypted			= "与门户的连接必须加密";
163
	$l_boutonO			= "验证";
164
	$l_boutonF			= "关闭";
165
	$l_loggedin_stringl1		= "信息系统安全";
166
	$l_loggedin_stringl2		= "这种控制实施以法定保证可追溯性,可归罪性和连接的不否认性.";
167
	$l_loggedin_stringl3		= "您的网络活动是私密登记的.";
168
	$l_loggedin_stringl4		= "记录的数据能被司法机关在调查中操作使用.";
169
	$l_loggedin_stringl5		= "这些数据将在一年后自动删除.";
2370 tom.houday 170
	$l_loggedin_stringl6		= "点击 <a href=\"$alcasarpath\"> 这里 </a> 修改密码或安装浏览器安全证书";
2238 tom.houday 171
	$l_loggedout_string		= "强制网络门户连接已断开";
2702 tom.houday 172
	$l_reply_0			= "用户名或密码无效";
2591 rexy 173
	$l_reply_1			= "您的每日配额已达到(持续时间或数量) ";
174
	$l_reply_2			= "已达到每月配额(持续时间或数量)";
2238 tom.houday 175
	$l_reply_3			= "您尝试在授权时间以外连接";
176
	$l_reply_4			= "您的账号已过期";
177
	$l_reply_5			= "您已经达到同时连接的最大数量";
178
	$l_reply_6			= "已经到达您的允许连接时间";
179
	$l_online_time			= "在线时间";
180
	$l_remaining_time		= "剩余时间";
181
	$l_uam_domain			= "授权网站 : ";
182
	$l_autoregistration		= "短信注册";
2250 tom.houday 183
} else if ($Language === 'ar') {	// Arabic
2238 tom.houday 184
	$l_ChilliError			= "يجب نجاح المصادقة على البوابة الأسيرة";
185
	$l_login			= "إغلاق هذه النافذة يقطع دورة عملك";
186
	$l_logout			= "إغلاق الدورة";
187
	$l_loginfailed			= "فشل المصادقة";
188
	$l_loggingin			= "التعريف على البوابة الأسيرة";
189
	$l_loggedcont			= "مراقبة الدخول";
190
	$l_loggedout			= "دورتكَ مغلقة";
191
	$l_user				= "التعريف";
192
	$l_password			= "كلمة السر";
193
	$l_wait				= "...إنتظر بعض اللحظات";
194
	$l_onlinetime			= ":مدة الإتصال";
195
	$l_remainingtime		= ":انقطاع الإتصال في";
196
	$l_encrypted			= "يجب تشفير الإتصال بالبوابة";
197
	$l_boutonO			= "مصادقة";
198
	$l_boutonF			= "أغلق";
199
	$l_loggedin_stringl1		= "سلامة نظم المعلومات";
200
	$l_loggedin_stringl2		= "وُضعت هذه المراقبة للضمان القانوني لتتبع ومساءلة وعدم تنصل الإتصالات";
201
	$l_loggedin_stringl3		= "نشاطك على الشبكة مسجل وفقاً لاحترام الحريات الشخصية";
202
	$l_loggedin_stringl4		= "لا يمكن استغلال البيانات المسجلة إلاّ من قِبل سلطات التحقيق القضائ";
203
	$l_loggedin_stringl5		= "سيتم حدف هذه البيانات تلقائياً بعد سنة من الْيَوْمَ";
2370 tom.houday 204
	$l_loggedin_stringl6		= "لتغيير كلمة السر أو شهادة الأمان <a href=\"$alcasarpath\">هنا</a> اضغط ";
2238 tom.houday 205
	$l_loggedout_string		= "تَمّ قطع الإتصال بالبوابة الأسيرة";
2702 tom.houday 206
	$l_reply_0			= "اسم المستخدم أو كلمة المرور غير صالحة";
2591 rexy 207
	$l_reply_1			= "تم الوصول إلى حصتك اليومية (المدة أو الحجم)";
208
	$l_reply_2			= "تم الوصول إلى حصتك الشهرية (المدة أو الحجم)";
2238 tom.houday 209
	$l_reply_3			= "محاولة اتصال خارج فترتك المأذونة";
210
	$l_reply_4			= "انتهت مدة صلاحية حسابك";
211
	$l_reply_5			= "لقد استكملت العدد الأقصى للإتصالات المتزامنة";
212
	$l_reply_6			= "استكملت مذة الإتصال المسموحة";
213
	$l_online_time			= "مذة الإتصال";
214
	$l_remaining_time		= "الوقت المتبق";
215
	$l_uam_domain			= ":المواقع المسموحة ";
216
	$l_autoregistration		= "تسجيل ذاتي (SMS)";
2250 tom.houday 217
} else if ($Language === 'de') {	// German
2766 rexy 218
	$l_ChilliError			= "Sie wurden erfolgreich durch das Portal authentifiziert.";
219
	$l_login			= "Erfolgreiche Authentifizierung.<HR>Schlißen dieses fensters unterbricht die Sitzung";
2238 tom.houday 220
	$l_logout			= "Beenden der Verbindung";
2766 rexy 221
	$l_loginfailed			= "Authentifizierungsfehler";
222
	$l_loggingin			= "Authentifizierung auf dem Portal";
223
	$l_loggedcont			= "Zugangskontrolle";
224
	$l_loggedout			= "Ihre Sitzung wurde geschlossen";
2238 tom.houday 225
	$l_user				= "Benutzer";
226
	$l_password			= "Passwort";
227
	$l_wait				= "Bitte warten Sie einen Moment ...";
228
	$l_onlinetime			= "Online-Zeit:";
229
	$l_remainingtime		= "Abmelden:";
2766 rexy 230
	$l_encrypted			= "Die Verbindung muss verschlüsselt sein";
2238 tom.houday 231
	$l_boutonO			= "Authentifizierung";
232
	$l_boutonF			= "Schließen";
233
	$l_loggedin_stringl1		= "Information System Security";
2766 rexy 234
	$l_loggedin_stringl2		= "Dieses Portal wurde eingerichtet, um ordnungsgemäß die Rückverfolgbarkeit, die Zurechenbarkeit und die Nicht-Abstreitbarkeit der Verbindungen zu sichern.";
235
	$l_loggedin_stringl3		= "Ihre Tätigkeiten im Netzwerk werden im Hinblick auf den Schutz Ihrer Privatsphäre gespeichert.";
236
	$l_loggedin_stringl4		= "Die gespeicherten Daten können von einer Justizbehörde im Falle einer Untersuchung genutzt werden.";
237
	$l_loggedin_stringl5		= "Diese Daten werden nach einem Jahr automatisch gelöscht.";
238
	$l_loggedin_stringl6		= "Klicken Sie <a href=\"$alcasarpath\">hier</a> um Ihr Password zu ändern oder das Sicherheitszertifikat für Ihren Browser herunterzuladen";
239
	$l_loggedout_string		= "Sie wurden vom Portal getrennt!";
2702 tom.houday 240
	$l_reply_0			= "Falscher Benutzername oder falsches Passwort";
2591 rexy 241
	$l_reply_1			= "Ihr Tageskontingent wurde erreicht (Dauer oder Volumen)";
242
	$l_reply_2			= "Ihr monatliches Kontingent wurde erreicht (Dauer oder Volumen)";
2766 rexy 243
	$l_reply_3			= "Sie haben versucht sich außerhalb der erlaubten Zeiten zu verbinden";
244
	$l_reply_4			= "Ihr Account ist abgelaufen";
245
	$l_reply_5			= "Sie haben die maximale Anzahl an simultanen Verbindungen erreicht";
246
	$l_reply_6			= "Ihre maximale Verbindungszeit wurde erreicht";
247
	$l_online_time			= "Online-Zeit";
248
	$l_remaining_time		= "Verbleibende Zeit";
249
	$l_uam_domain			= "Authorisierte Webseiten : ";
250
	$l_autoregistration		= "Automatische Registrierung";
2250 tom.houday 251
} else if ($Language === 'nl') {	// Dutch
2238 tom.houday 252
	$l_ChilliError			= "De authenticatie moet een succes worden via de captive portal dienst.";
253
	$l_login			= "Succesvolle authenticatie.<HR>Dit venster te sluiten onderbreekt uw sessie.";
254
	$l_logout			= "Slotkoers verbinding";
255
	$l_loginfailed			= "Authenticatie mislukt";
256
	$l_loggingin			= "Identificatie van de captive-portaal";
257
	$l_loggedcont			= "toegangscontrole";
258
	$l_loggedout			= "Uw sessie is gesloten";
259
	$l_user				= "Gebruiker";
260
	$l_password			= "Wachtwoord";
261
	$l_wait				= "Wacht een moment ...";
262
	$l_onlinetime			= "Sluit tijd:";
263
	$l_remainingtime		= "Verbreking in:";
264
	$l_encrypted			= "De opening moet gebruiken gecodeerde verbinding";
265
	$l_boutonO			= "Authenticatie";
266
	$l_boutonF			= "Sluiten";
267
	$l_loggedin_stringl1		= "Information System Security";
268
	$l_loggedin_stringl2		= "Het portaal werd opgericht verordeningen om de traceerbaarheid, verantwoordelijkheid en onloochenbaarheid van de verbindingen.";
269
	$l_loggedin_stringl3		= "Uw activiteit op het netwerk is geregistreerd in overeenstemming met de persoonlijke levenssfeer.";
270
	$l_loggedin_stringl4		= "De geregistreerde gegevens kunnen worden kunnen worden bediend door een rechterlijke instantie in de loop van een onderzoek.";
271
	$l_loggedin_stringl5		= "Deze gegevens worden automatisch verwijderd na een jaar.";
2370 tom.houday 272
	$l_loggedin_stringl6		= "Click <a href=\"$alcasarpath\">here</a> to change your password or to integrate the security certificate in your browser";
2238 tom.houday 273
	$l_loggedout_string		= "Logout gemaakt intern portaal!";
2702 tom.houday 274
	$l_reply_0			= "Ongeldige gebruikersnaam of wachtwoord";
2591 rexy 275
	$l_reply_1 			= "Uw dagelijkse quotum is bereikt (duur of volume)";
276
	$l_reply_2			= "Je maandelijkse quotum is bereikt (duur of volume)";
2238 tom.houday 277
	$l_reply_3			= "You try to connect outside of your allowed timespan";
278
	$l_reply_4			= "your account expired";
279
	$l_reply_5			= "You have reached the maximum number of simultaneous logins";
280
	$l_reply_6			= "Your authorized connexion time has been reached";
281
	$l_online_time			= "Online tijd";
282
	$l_remaining_time		= "Reterende tijd";
283
	$l_uam_domain			= "Geautoriseerde website : ";
284
	$l_autoregistration		= "Automatische registratie";
2250 tom.houday 285
} else if ($Language === 'fr') {	// French
2238 tom.houday 286
	$l_ChilliError			= "L'authentification doit être réussie sur le portail captif.";
287
	$l_login			= "Authentification réussie.<HR>La fermeture de cette fenêtre interrompt votre session.";
288
	$l_logout			= "Fermeture de la session";
289
	$l_loginfailed			= "Echec d'authentification";
290
	$l_loggingin			= "Identification sur le portail captif";
291
	$l_loggedcont			= "Contrôle d'accès";
292
	$l_loggedout			= "Votre session est fermée";
293
	$l_user				= "Identifiant";
294
	$l_password			= "Mot de passe";
295
	$l_wait				= "Patientez un instant ...";
296
	$l_onlinetime			= "Temps de connexion:";
297
	$l_remainingtime		= "Deconnexion dans :";
298
	$l_encrypted			= "La connexion avec le portail doit être chiffrée";
299
	$l_boutonO			= "Authentification";
300
	$l_boutonF			= "Fermer";
301
	$l_loggedin_stringl1		= "Sécurité des Systèmes d'Information";
302
	$l_loggedin_stringl2		= "Ce contrôle a été mis en place pour assurer réglementairement la traçabilité, l'imputabilité et la non-répudiation des connexions.";
303
	$l_loggedin_stringl3		= "Votre activité sur le réseau est enregistrée conformément au respect de la vie privée.";
304
	$l_loggedin_stringl4		= "Les données enregistrées ne pourront être exploitées que par une autorité judiciaire dans le cadre d'une enquête.";
305
	$l_loggedin_stringl5		= "Ces données seront automatiquement supprimées au bout d'un an.";
2370 tom.houday 306
	$l_loggedin_stringl6		= "Cliquez <a href=\"$alcasarpath\">ici</a> pour changer votre mot de passe ou pour intégrer le certificat de sécurité à votre navigateur";
2238 tom.houday 307
	$l_loggedout_string		= "Déconnexion du portail captif effectuée !";
2702 tom.houday 308
	$l_reply_0			= "Nom d'utilisateur ou mot de passe incorrect";
2591 rexy 309
	$l_reply_1			= "Votre quota journalier a été atteint (durée ou volume)";
310
	$l_reply_2			= "Votre quota mensuel a été atteint (durée ou volume)";
2238 tom.houday 311
	$l_reply_3			= "Vous tentez de vous connecter en dehors de votre période autorisée";
312
	$l_reply_4			= "Votre compte a expiré";
313
	$l_reply_5			= "Vous avez atteint le nombre maximum de connexions simultanées";
314
	$l_reply_6			= "Votre durée de connexion autorisée a été atteinte";
315
	$l_online_time			= "Temps de connexion";
316
	$l_remaining_time		= "Temps restant";
317
	$l_uam_domain			= "Sites autorisés : ";
318
	$l_autoregistration		= "Auto enregistrement (sms)";
319
} else {				// English
320
	$l_ChilliError			= "The authentication must be successful through the captive portal service.";
321
	$l_login			= "Successful authentication.<HR>Closing this window interrupts your session";
322
	$l_logout			= "Closing connection";
323
	$l_loginfailed			= "Authentication Failed";
324
	$l_loggingin			= "Identification on the captive portal";
325
	$l_loggedcont			= "Access Control";
326
	$l_loggedout			= "Your session is closed";
327
	$l_user				= "User";
328
	$l_password			= "Password";
329
	$l_wait				= "Please wait a moment ...";
330
	$l_onlinetime			= "Connect time:";
331
	$l_remainingtime		= "Disconnection in:";
332
	$l_encrypted			= "The connection with the portal must be encrypted";
333
	$l_boutonO			= "Authentication";
334
	$l_boutonF			= "Close";
335
	$l_loggedin_stringl1		= "Information System Security";
336
	$l_loggedin_stringl2		= "That control was set up regulations to ensure traceability, accountability and non-repudiation of connections.";
337
	$l_loggedin_stringl3		= "Your activity on the network is registered in accordance with privacy.";
338
	$l_loggedin_stringl4		= "The recorded data can be able to be operated by a judicial authority in the course of an investigation.";
339
	$l_loggedin_stringl5		= "These data will be automatically deleted after one year.";
2370 tom.houday 340
	$l_loggedin_stringl6		= "Click <a href=\"$alcasarpath\">here</a> to change your password or to integrate the security certificate in your browser";
2238 tom.houday 341
	$l_loggedout_string		= "Disconnection of the captive portal made";
2702 tom.houday 342
	$l_reply_0			= "Incorrect username or password";
2591 rexy 343
	$l_reply_1			= "Your daily quota has been reached (duration or volume)";
344
	$l_reply_2			= "Your monthly quota has been reached (duration or volume)";
2238 tom.houday 345
	$l_reply_3			= "You try to connect outside of your allowed timespan";
346
	$l_reply_4			= "your account expired";
347
	$l_reply_5			= "You have reached the maximum number of simultaneous logins";
348
	$l_reply_6			= "Your authorized connexion time has been reached";
349
	$l_online_time			= "Online time";
350
	$l_remaining_time		= "Remaining time";
351
	$l_uam_domain			= "Authorized websites : ";
352
	$l_autoregistration		= "Auto registration (sms)";
2182 tom.houday 353
}
895 richard 354
 
2324 tom.houday 355
# If HTTPS not use, tell it's wrong
356
if (($conf['HTTPS_LOGIN'] === 'on') && ((!isset($_SERVER['HTTPS'])) || (empty($_SERVER['HTTPS'])) || ($_SERVER['HTTPS'] === 'off'))) {
2238 tom.houday 357
	// Cleaning the cache
358
	header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
359
	header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
360
	header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
361
	header('Cache-Control: post-check=0, pre-check=0', false);
362
	header('Pragma: no-cache');
2182 tom.houday 363
	?>
2238 tom.houday 364
	<!DOCTYPE html>
2182 tom.houday 365
	<html>
366
	<head>
367
		<meta charset="utf-8">
368
		<title><?= $l_loggedcont ?></title>
369
	</head>
370
	<body style="background-color: white;">
371
		<h1 style="text-align: center;"><?= $l_loginfailed ?></h1>
372
		<center><?= $l_encrypted ?></center> 
373
	</body>
374
	</html>
375
	<?php
376
	exit();
895 richard 377
}
378
 
379
# Read form parameters which we care about
1314 richard 380
# avoid the "user as a MAC address" attempts
2378 tom.houday 381
if ((isset($_POST['username'])) && (preg_match('/^([0-9A-F]{2}-){5}[0-9A-F]{2}$/', $_POST['username']) !== 1))
2407 tom.houday 382
				$username	= htmlspecialchars(trim($_POST['username']));	else $username = '';
2378 tom.houday 383
if (isset($_POST['password']))	$password	= htmlspecialchars($_POST['password']);		else $password = '';
2370 tom.houday 384
if (isset($_POST['challenge']))	$challenge	= htmlspecialchars($_POST['challenge']);	else $challenge = '';
2205 tom.houday 385
if (isset($_POST['button']))	$button		= htmlspecialchars($_POST['button']);		else $button = '';
386
// if (isset($_POST['logout']))	$logout		= htmlspecialchars($_POST['logout']);		else $logout = '';
387
// if (isset($_POST['prelogin']))	$prelogin	= htmlspecialchars($_POST['prelogin']);		else $prelogin = '';
2378 tom.houday 388
// if (isset($_POST['res']))	$res		= htmlspecialchars($_POST['res']);		else $res = '';
389
// if (isset($_POST['uamip']))	$uamip		= htmlspecialchars($_POST['uamip']);		else $uamip = '';
390
// if (isset($_POST['uamport']))	$uamport	= htmlspecialchars($_POST['uamport']);		else $uamport = '';
2205 tom.houday 391
if (isset($_POST['userurl']))	$userurl	= htmlspecialchars($_POST['userurl']);		else $userurl = '';
2378 tom.houday 392
// if (isset($_POST['timeleft']))	$timeleft	= htmlspecialchars($_POST['timeleft']);		else $timeleft = '';
393
// if (isset($_POST['redirurl']))	$redirurl	= htmlspecialchars($_POST['redirurl']);		else $redirurl = '';
895 richard 394
 
395
# Read query parameters which we care about
2378 tom.houday 396
if (isset($_GET['res']))	$res		= htmlspecialchars($_GET['res']);		else $res = '';
397
// if (isset($_GET['reason']))	$reason		= htmlspecialchars($_GET['reason']);		else $reason = '';
2205 tom.houday 398
if (isset($_GET['challenge']))	$challenge	= htmlspecialchars($_GET['challenge']);
2378 tom.houday 399
// if (isset($_GET['uamip']))	$uamip		= htmlspecialchars($_GET['uamip']);
400
// if (isset($_GET['uamport']))	$uamport	= htmlspecialchars($_GET['uamport']);
401
if (isset($_GET['timeleft']))	$timeleft	= htmlspecialchars($_GET['timeleft']);		else $timeleft = '';
402
if (isset($_GET['reply']))	$reply		= htmlspecialchars(trim($_GET['reply']));	else $reply = '';
403
if (isset($_GET['redirurl']))	$redirurl	= htmlspecialchars($_GET['redirurl']);		else $redirurl = '';
2205 tom.houday 404
if (isset($_GET['userurl']))	$userurl	= htmlspecialchars($_GET['userurl']);
895 richard 405
 
2378 tom.houday 406
// TODO: clean unused query params
407
 
408
$uamip = $conf['HOSTNAME'].'.'.$conf['DOMAIN'];
2409 tom.houday 409
if (($conf['HTTPS_CHILLI'] === 'on') && $useHTTPS) {
2378 tom.houday 410
	$uamproto = 'https';
411
	$uamport  = 3991;
412
} else {
413
	$uamproto = 'http';
414
	$uamport  = 3990;
2239 tom.houday 415
}
416
 
895 richard 417
# translation of radius replies
2378 tom.houday 418
if (!empty($reply)) {
419
	switch ($reply) {
2591 rexy 420
		case 'Username not found'				: $reply = $l_reply_0; break;
2702 tom.houday 421
		case 'Login failed'					: $reply = $l_reply_0; break;
2205 tom.houday 422
		case 'Your maximum daily usage time has been reached'	: $reply = $l_reply_1; break;
423
		case 'Your maximum monthly usage time has been reached'	: $reply = $l_reply_2; break;
2837 rexy 424
		case 'You are out your allowed time period'		: $reply = $l_reply_3; break;
425
		case 'Your expiration date has been reached'	: $reply = $l_reply_4; break;
2205 tom.houday 426
		case 'You are already logged in - access denied'	: $reply = $l_reply_5; break;
2837 rexy 427
		case 'Your usage time has been reached'	: 			$reply = $l_reply_6; break;
2182 tom.houday 428
	}
429
}
895 richard 430
 
2182 tom.houday 431
// If attempt to login
432
if ($button === $l_boutonO) {
433
	//correction password length in coova-chilli
434
	//thanks to http://www.stochasticgeometry.ie/2009/09/09/maximum-password-length-in-coova-chilli/
435
	$hexchal = pack('H*', $challenge);
436
	$newchal = pack('H*', md5($hexchal . $uamsecret));
1947 raphael.pi 437
 
2182 tom.houday 438
	// If challenge isn't long enough, repeat it until it is
2238 tom.houday 439
	while (strlen($newchal) < strlen($password)) {
2182 tom.houday 440
		$newchal .= $newchal;
441
	}
1947 raphael.pi 442
 
2182 tom.houday 443
	$newpwd   = pack('a*', $password);
444
	// Encode plain text password with challenge
445
	$pappassword = implode('', unpack('H*', ($newpwd ^ $newchal)));
2238 tom.houday 446
 
2378 tom.houday 447
	header("Location: $uamproto://$uamip:$uamport/logon?username=$username&password=$pappassword&userurl=$userurl");
2182 tom.houday 448
	exit();
895 richard 449
}
450
 
451
switch($res) {
2182 tom.houday 452
	case 'success':	$result = 1; break; // If login successful
453
	case 'failed':	$result = 2; break; // If login failed
454
	case 'logoff':	$result = 3; break; // If logout successful
455
	case 'already':	$result = 4; break; // If tried to login while already logged in
456
	case 'notyet':	$result = 5; break; // If not logged in yet
457
	default:	$result = 0; // Default: It was not a form request -> client go to login form
895 richard 458
}
459
 
2010 raphael.pi 460
//check if we need to warn user about the imputability logs.
2378 tom.houday 461
if ($result === 1) {
2182 tom.houday 462
	if ((is_file('./acc/manager/lib/sql/drivers/mysql/functions.php')) && (is_file('/etc/freeradius-web/config.php'))) {
463
		include_once('/etc/freeradius-web/config.php');
464
		include_once('./acc/manager/lib/sql/drivers/mysql/functions.php');
465
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
466
		if ($link) {
467
			$user_uid = da_sql_escape_string($link, $_GET['uid']);
2501 tom.houday 468
			$sql = "SELECT value FROM radreply WHERE username='$user_uid' AND attribute='Alcasar-Imputability-Warning'";
2182 tom.houday 469
			$res = @da_sql_query($link, $config, $sql); // on affiche pas les erreurs
470
			if ($res) {
471
				$row = @da_sql_fetch_array($res, $config);
2501 tom.houday 472
				if ($row['value'] === '1') {
473
					$sql = "DELETE FROM radreply WHERE username='$user_uid' AND attribute='Alcasar-Imputability-Warning'";
474
					@da_sql_query($link, $config, $sql);
2370 tom.houday 475
					header('Location: '.(($conf['HTTPS_LOGIN'] === 'on') ? 'https' : 'http').'://'.$conf['HOSTNAME'].'.'.$conf['DOMAIN'].'/index.php?warn=1&url='.urlencode($_GET['userurl']));   //we present to user information about imputability logs 
2182 tom.houday 476
					exit();
477
				}
478
			}
479
		}
480
	}
2010 raphael.pi 481
}
482
 
2378 tom.houday 483
// By default, redirect to prelogin in order to generate a challenge
484
if ($result === 0) {
485
	header("Location: $uamproto://$uamip:$uamport/prelogin");
2182 tom.houday 486
	exit();
895 richard 487
}
2238 tom.houday 488
 
2766 rexy 489
//////////////////////////////////////////////
490
///////////// TEST VARIABLES /////////////////
491
//////////////////////////////////////////////////////////////////
492
//$result = 5;     // = 1/2/3/4/5 
493
// reply is a displayed sentence
494
//$reply = 'dsfsdfsdfdsf';    //  = ''/'Incorrect user/password'
495
//$service_SMS_status = true;    // = true/false
496
// test of domain Allowed
497
//////////////////////////////////////////////////////////////////
498
 
2238 tom.houday 499
// Cleaning the cache
500
header('Expires: Tue, 01 Jan 2000 00:00:00 GMT');
501
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
502
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
503
header('Cache-Control: post-check=0, pre-check=0', false);
504
header('Pragma: no-cache');
2182 tom.houday 505
?>
2238 tom.houday 506
<!DOCTYPE html>
895 richard 507
<html>
508
<head>
2182 tom.houday 509
	<meta charset="utf-8">
510
	<title><?= $l_loggingin ?></title>
511
	<script type="text/javascript">
1346 richard 512
	function doOnLoad(result, userurl, redirurl, adminurl, timeleft) {
2283 tom.houday 513
		if ((result === 1) || (result === 4)) {	// success or already
2201 tom.houday 514
			var url;
2182 tom.houday 515
			if (adminurl !== '') {
2201 tom.houday 516
				url = adminurl;
2182 tom.houday 517
			} else if (redirurl !== '') {
2201 tom.houday 518
				url = redirurl;
519
			} else if (userurl !== '') {
520
				url = userurl;
1346 richard 521
			}
2201 tom.houday 522
 
523
			if (typeof url !== 'undefined') {
2283 tom.houday 524
				var win = window.open('<?= $statuspath ?>', '_blank');
525
 
2406 tom.houday 526
				if ((win === null) || (typeof win === 'undefined')) { // Pop-up blocked
2283 tom.houday 527
					window.location = '<?= $statuspath ?>';
528
				} else {
529
					window.location = url;
2201 tom.houday 530
				}
2283 tom.houday 531
			} else {
532
				window.location = '<?= $statuspath ?>';
2201 tom.houday 533
			}
1346 richard 534
		}
2283 tom.houday 535
		if ((result === 2) || (result === 3) || result === 5) { // failed or logoff or notyet
2378 tom.houday 536
			document.form1.username.focus();
1346 richard 537
		}
538
	}
2182 tom.houday 539
	</script>
2766 rexy 540
	<link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css">
2809 rexy 541
	<link rel="stylesheet" href="/css/intercept.css" type="text/css">
2823 rexy 542
	<link rel="icon" href="/images/favicon-48.ico" type="image/ico">
895 richard 543
</head>
2182 tom.houday 544
<body onLoad="javascript:doOnLoad(<?= $result ?>,'<?= $userurl ?>','<?= $redirurl ?>','<?= $adminurl ?>','<?= $timeleft ?>')">
2766 rexy 545
	<div class="col-xs-12">	
546
	<?php if ($result === 2 || $result === 3 || $result === 5): // failed or logoff or notyet ?>
547
		<div class ="row">
548
			<div class="col-xs-12 col-sm-10 col-sm-offset-1">
549
				<div class="row banner">
550
					<div class="col-xs-8 col-xs-offset-2 col-sm-12 col-sm-offset-0">
551
							<h1 class="organisme"><?= $organisme ?></h1>
552
					</div>
553
				</div>
554
				<div class="row">
555
					<form name="form1" class="form-horizontal col-xs-12 col-sm-12 col-md-10 col-md-offset-1 background-form" method="post" action="<?= $loginpath ?>">
556
						<div class="row">
557
							<div class="col-xs-12 col-sm-12 col-md-6 col-md-offset-3">
558
								<h2 class="titre-controle-acces"><?= $l_loggedcont ?></h2>
559
							</div>
560
							<div class="hidden-xs hidden-sm col-md-3">
561
							<?php
562
							// Read the "Domain allowed" file
563
							$tab = file(DOMAIN_ALLOWED_LIST);
564
							if ($tab) { // the file isn't empty
565
								echo '<div id="authorized_domain">'.$l_uam_domain.'</div>';
566
								echo '<ul>';
567
								foreach ($tab as $line) {
568
									if (trim($line) !== '') { // the line isn't empty
569
										$domain_allowed = explode('#', $line);
570
										if (trim($domain_allowed[1]) !== '') {
571
											$domain = explode('"', $domain_allowed[0]);
572
											// remove every '.' from the beginning of domain
573
											$domain[1] = ltrim($domain[1], '.');
574
											echo '<li><a href="http://'.trim($domain[1]).'">'.trim($domain_allowed[1]).'</a></li>';
575
										}
576
									}
577
								}
578
								echo '</ul>';
579
							}
580
							?>
2182 tom.houday 581
 
2766 rexy 582
							</div>
583
						</div>
584
						<div>
585
						<?php if ($result === 2): // failed ?>
586
							<h3 class="titre-erreur"><?= $l_loginfailed ?>
587
							<?php if ($reply): // traitement du reply ... ?>
588
								: <?= $reply ?>
589
							<?php endif; ?>
590
							</h3>
591
						<?php endif;
592
						if ($userurl === 'http://logout/') $userurl = 'http://www.google.com'; // Avoid cyclic logout
593
						?>
594
 
595
						</div>
596
 
597
						<div class="row inputs">
598
							<div class="hidden-xs col-sm-2">
599
								 <img id="logo-organ" class="img-responsive" src="/images/organisme.png">
600
							</div>
601
							<div class="col-xs-12 col-sm-8">
602
								<input type="hidden" name="challenge" value="<?= $challenge ?>">
603
								<input type="hidden" name="userurl" value="<?= $userurl ?>">
604
								<div class="form-group row">
605
									<div class="col-xs-2 col-sm-2 control-label">
606
										<p class="boite-info-text"><?= $l_user ?></p>
607
									</div>
608
									<div class="col-xs-8 col-sm-8" id="input_username">
609
										<input type="text" class="form-control boite-info-text" name="username" autocomplete="off" placeholder="<?= $l_user ?>">
610
									</div>
611
								</div>
612
								<div class="form-group row">
613
									<div class="col-xs-2 col-sm-2 control-label">
614
										<p class="boite-info-text"><?= $l_password ?></p>
615
									</div>
616
									<div class="col-xs-8 col-sm-8" id="input_password">
617
										<input type="password" class="form-control boite-info-text" name="password" autocomplete="off" placeholder="<?= $l_password ?>">
618
									</div>
619
								</div>
620
							</div>
621
							<div class="hidden-xs col-sm-2">
622
 
623
							</div>
624
						</div>
625
						<div class="row row_button">
626
							<div class="col-xs-12 text-center">
627
								<input value="<?= $l_boutonO ?>" class="btn btn-primary button" type="submit" name="button">
628
							</div>	
629
						</div>
630
						<?php if ($service_SMS_status): ?>
631
							<div class= "row autoregistration_sms">
632
								<a href="autoregistrationinfo.php"><?= $l_autoregistration ?></a>
633
							</div>
2743 rexy 634
						<?php endif; ?>
2766 rexy 635
					</form>
636
				</div>
637
			</div>
638
		</div>
639
			<div class="row boite-info-spacing">
640
				<div class="col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 boite-info-spacing">
641
					<table id="boite-info" cellSpacing="0" cellPadding="0">
642
						<tr class="boite-info-titre">
643
							<td align="center"><font color="red"><b><?= $l_loggedin_stringl1 ?></b></font></td>
644
						</tr>
645
						<tr class="boite-info-text">
646
							<td align="left">
647
								<ul>
648
									<li><?= $l_loggedin_stringl2 ?></li>
649
									<li><?= $l_loggedin_stringl4 ?></li>
650
									<li><?= $l_loggedin_stringl3 ?></li>
651
									<li><?= $l_loggedin_stringl5 ?></li>
652
									<li><?= $l_loggedin_stringl6 ?></li>
653
								</ul>
654
							</td>
655
						</tr>
656
					</table>
657
				</div>
658
				<div class="hidden-xs hidden-sm col-md-2">
659
					<img id="logo-alcasar" class="img-responsive" src="/images/logo-alcasar.png">
660
				</div>
661
			</div>
662
			<div class="row">
663
				<div class="col-xs-6 col-sm-12 hidden-md hidden-lg">
664
						<img id="logo-alcasar" class="img-responsive img-xs-bottom" src="/images/logo-alcasar.png">
665
					</div>
2743 rexy 666
 
2766 rexy 667
				<div class="col-xs-6 hidden-sm hidden-md hidden-lg">
668
					<img id="logo-organ" class="img-responsive img-xs-bottom" src="/images/organisme.png">
2743 rexy 669
 
2766 rexy 670
				</div>
671
			</div>
672
		<div class="row" style="text-align: center">
673
			<div class="col-xs-8 col-xs-offset-2 col-sm-6 col-sm-offset-3 hidden-md hidden-lg">
674
			<?php
675
			// Read the "Domain allowed" file
676
			$tab = file(DOMAIN_ALLOWED_LIST);
677
			if ($tab) { // the file isn't empty
678
				echo '<div id="authorized_domain">'.$l_uam_domain.'</div>';
679
				echo '<ul>';
680
				foreach ($tab as $line) {
681
					if (trim($line) !== '') { // the line isn't empty
682
						$domain_allowed = explode('#', $line);
683
						if (trim($domain_allowed[1]) !== '') {
684
							$domain = explode('"', $domain_allowed[0]);
685
							// remove every '.' from the beginning of domain
686
							$domain[1] = ltrim($domain[1], '.');
687
							echo '<li><a href="http://'.trim($domain[1]).'">'.trim($domain_allowed[1]).'</a></li>';
688
						}
2182 tom.houday 689
					}
690
				}
2766 rexy 691
				echo '</ul>';
2182 tom.houday 692
			}
2766 rexy 693
			?>
694
			</div>
695
		</div>
2182 tom.houday 696
	</div>
697
	<?php endif; ?>
895 richard 698
</body>
2182 tom.houday 699
</html>