Subversion Repositories ALCASAR

Rev

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