Subversion Repositories ALCASAR

Rev

Rev 1314 | Rev 1320 | 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 1319 2014-03-20 21:44:23Z stephane $
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
*****************************************************************/
27
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
913 richard 28
define ("DOMAIN_ALLOWED_LIST", "/usr/local/etc/alcasar-uamdomain");
895 richard 29
 
30
/****************************************************************
930 richard 31
*			FILE reading test			*
895 richard 32
*****************************************************************/
930 richard 33
$conf_files=array(CONF_FILE,DOMAIN_ALLOWED_LIST);
913 richard 34
foreach ($conf_files as $file){
35
	if (!file_exists($file)){
36
		exit("Fichier ".$file." non présent");
37
	}
38
	if (!is_readable($file)){
39
		exit("Vous n'avez pas les droits de lecture sur le fichier ".$file);
40
	}
41
}
895 richard 42
/****************************************************************
43
*			Read CONF_FILE				*
44
*****************************************************************/
45
$ouvre=fopen(CONF_FILE,"r");
46
if ($ouvre){
47
	while (!feof ($ouvre))
48
	{
49
		$tampon = fgets($ouvre, 4096);
50
		if (strpos($tampon,"=")!==false){
51
			$tmp = explode("=",$tampon);
52
			$conf[$tmp[0]] = $tmp[1];
53
		}
54
	}
55
}else{
1249 richard 56
	exit("Erreur d'ouverture du fichier ".CONF_FILE);
895 richard 57
}
58
fclose($ouvre);
1269 richard 59
$organisme = trim($conf["ORGANISM"]);
895 richard 60
 
61
# Shared secret used to encrypt challenge with radius.
930 richard 62
$uamsecret = "";
895 richard 63
 
64
# URL loaded after success authenticates (let blank for browser defaults)
65
$adminurl = "";
66
 
67
# Our own path
68
$loginpath	= $_SERVER['PHP_SELF'];
1269 richard 69
$alcasarpath = "http://alcasar.".trim($conf["DOMAIN"]);
895 richard 70
$statuspath = $alcasarpath."/status.php";
71
$debug		= false;
72
 
73
# Choice of language
74
$Language = 'en';
75
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
76
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
77
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
78
if($Language == 'es'){
79
  $l_ChilliError	= "La autenticación debe ser un éxito a través del servicio de portal cautivo.";
80
  $l_login		= "El éxito de la autenticación.<HR>Cierre esta ventana interrumpte la sesion.";
81
  $l_logout		= "Conexión de cierre";
82
  $l_loginfailed	= "Error de autenticación";
83
  $l_loggingin		= "Identificación en el portal cautivo";
84
  $l_loggedcont		= "Control de Acceso";
85
  $l_loggedout		= "Su sesión se cierra";
86
  $l_user		= "Usuario";
87
  $l_password		= "Contraseña";
88
  $l_wait		= "Por favor, espere un momento ...";
89
  $l_onlinetime		= "Tiempo de conexión:";
90
  $l_remainingtime	= "Desconexión en:";
91
  $l_encrypted		= "La apertura debe usar conexión cifrada";
92
  $l_boutonO		= "Autenticación";
93
  $l_boutonF		= "Cerrar";
930 richard 94
  $l_loggedin_stringl1	= "Information System Security";
95
  $l_loggedin_stringl2	= "El portal fue creado reglamentos para garantizar la trazabilidad, la rendición de cuentas y el no repudio de las conexiones.";
96
  $l_loggedin_stringl3	= "Su actividad en la red es registrada, de conformidad con la privacidad.";
97
  $l_loggedin_stringl4	= "Los datos registrados pueden ser capaces de ser operado por una autoridad judicial en el curso de una investigación.";
98
  $l_loggedin_stringl5	= "Estos datos se eliminan automáticamente después de un año.";
99
  $l_loggedin_stringl6	= "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
100
  $l_loggedout_string	= "Cerrar sesión hizo portal cautivo!";
101
  $l_reply_1		= "Your daily connexion time has been reached";
102
  $l_reply_2		= "Your monthly connexion time has been reached";
103
  $l_reply_3		= "You try to connect outside of your allowed timespan";
104
  $l_reply_4		= "your account expired";
105
  $l_reply_5		= "You have reached the maximum number of simultaneous logins";
106
  $l_reply_6		= "Your authorized connexion time has been reached";
107
  $l_online_time	= "Tiempo en linea";
108
  $l_remaining_time	= "Tiempo restante";
109
  $l_uam_domain		= "Sitios web autorizados : ";}
913 richard 110
else if ($Language == 'pt'){
955 richard 111
  $l_ChilliError	= "A autenticação precisa ser bem sucedida através do portal.";
112
  $l_login		= "Sucesso na autenticação.<HR>Matenha esse pop-up apenas minimizado para não interromper a conexão";
113
  $l_logout		= "Encerrar conexão";
913 richard 114
  $l_loginfailed	= "Falha na autenticação";
115
  $l_loggingin		= "Identificação do portal cativo";
922 richard 116
  $l_loggedcont		= "Controle de acesso";
955 richard 117
  $l_loggedout		= "Sua sessão foi fechada";
913 richard 118
  $l_user		= "Usuário";
119
  $l_password		= "Senha";
120
  $l_wait		= "Por favor, aguarde um momento ...";
121
  $l_onlinetime		= "Tempo de conexão:";
122
  $l_remainingtime	= "Desconectado em:";
123
  $l_encrypted		= "A conexão com o portal deve ser criptografada";
124
  $l_boutonO		= "Autenticação";
125
  $l_boutonF		= "Fechar";
955 richard 126
  $l_loggedin_stringl1	= "Sistema de Informação e segurança";
127
  $l_loggedin_stringl2	= "Este controle foi criado para garantir acesso seguro.";
128
  $l_loggedin_stringl3	= "A autenticação será criptografada em 256 bits, impedindo captura por escâner de rede.";
129
  $l_loggedin_stringl4	= "Sua atividade na Internet será resguardada de acordo com os regulamentos da lei.";
971 richard 130
  $l_loggedin_stringl5	= "Mantenha o popup da conexão minimizado para não interromper a cessão.";
955 richard 131
  $l_loggedin_stringl6	= "Clique <a href='$alcasarpath'>aqui</a> para alterar sua senha, instalar certificado ou sair do portal.";
132
  $l_loggedout_string	= "desconexão do portal cativo";
133
  $l_reply_1		= "Seu tempo de conexão diária foi finalizado";
921 richard 134
  $l_reply_2		= "Seu tempo de conexão mensal foi finalizado";
135
  $l_reply_3		= "Você tenta conectar-se fora do seu período de tempo permitido";
136
  $l_reply_4		= "Sua conta expirou";
137
  $l_reply_5		= "Você atingiu o número máximo de logins simultâneos";
138
  $l_reply_6		= "Seu tempo de conexão autorizada finalizou";
139
  $l_online_time	= "Tempo Online";
140
  $l_remaining_time	= "Tempo restante";
925 richard 141
  $l_uam_domain		= "Sites autorizados : ";}
895 richard 142
else if($Language == 'de'){
143
  $l_ChilliError	= "Die Authentifizierung ist erfolgreich durch die Nutzung des Portals erfolgt.";
144
  $l_login		= "Erfolgreiche Authentifizierung.<HR>Schlißen dieses fensters unterbricht die sitzung";
1319 stephane 145
  $l_login		= "Anmeldung erfolgreich.<HR>Das Schließen dieses Fensters trennt die Verbindung";
895 richard 146
  $l_logout		= "Beenden der Verbindung";
1319 stephane 147
  $l_logout		= "Verbindung beenden";
895 richard 148
  $l_loginfailed	= "Authentifizierungsfehler Eigenverbrauch";
1319 stephane 149
  $l_loginfailed	= "Anmeldung fehlgeschlagen";
895 richard 150
  $l_loggingin		= "Kennzeichnung auf dem Eigenverbrauch";
1319 stephane 151
  $l_loggingin		= "Sie sind Angemeldet";
895 richard 152
  $l_loggedcont		= "Zutrittskontrolle";
153
  $l_loggedout		= "Ihre Sitzung ist geschlossen";
1319 stephane 154
  $l_loggedout		= "Ihre Sitzung wurde beendet";
895 richard 155
  $l_user		= "Benutzer";
156
  $l_password		= "Passwort";
157
  $l_wait		= "Bitte warten Sie einen Moment ...";
158
  $l_onlinetime		= "Online-Zeit:";
159
  $l_remainingtime	= "Abmelden:";
1319 stephane 160
  $l_remainingtime	= "Restzeit:"; #Verbleibende Zeit
895 richard 161
  $l_encrypted		= "Die Öffnung muß der Anschluß Zahlen";
1319 stephane 162
  $l_encrypted		= "Die Verbindung muss verschl&uuml;sselt sein";
895 richard 163
  $l_boutonO		= "Authentifizierung";
1319 stephane 164
  $l_boutonO		= "Authentisieren";
895 richard 165
  $l_boutonF		= "Schließen";
930 richard 166
  $l_loggedin_stringl1	= "Information System Security";
1319 stephane 167
  //$l_loggedin_stringl2	= "Dieses Portal wurde eingerichtet, um ordnungsgemäß die Rückverfolgbarkeit, der Zurechenbarkeit und der Nicht-Anerkennung der Verbindungen.";
168
  $l_loggedin_stringl2	= "Dieses Portal wurde eingerichtet, um jeglichen Missbrauch durch den, eindeutig identifizierbaren, Benutzer zurückverfolgen zu können.";
169
  $l_loggedin_stringl3	= "Ihre Aktivität wird unter Beachtung der Privatsphäre aufgezeichnet."; #statt "Aktivitaet" kann auch "Sitzung" benutzt werden
170
  $l_loggedin_stringl4	= "Die gespeicherten Daten können nur im Falle einer Ermittlung von der Justiz genutzt werden.";
171
  //$l_loggedin_stringl4	= "Die gespeicherten Daten werden im Falle einer Ermittlung an die Justiz weitergegeben.";
172
  $l_loggedin_stringl5	= "Diese Daten werden nach einem Jahr automatisch geloescht.";
173
  $l_loggedin_stringl6	= "Klicken Sie <a href='$alcasarpath'>hier</a> um ihre Passwort zu ändern, oder um das Sicherheitszertifikat in ihren Browser zu integrieren";
174
  //$l_loggedout_string	= "Trennung des Portals erfolgt Gefangener!";
175
  $l_loggedout_string	= "Trennung des Portals erfolgt !"; // à modifier
176
  $l_reply_1		= "Ihr Tages Limit ist aufgebraucht";
177
  $l_reply_2		= "Ihr Monats Limit ist aufgebraucht";
178
  $l_reply_3		= "Sie versuchen sich ausserhalb des erlaubten Zeitraumes anzumelden";
179
  $l_reply_4		= "Ihr Benutzerkonto ist abgelaufen";
180
  $l_reply_5		= "Sie haben die maximale Anzahl an gleichzeitigen Anmeldungen erreicht";
181
  $l_reply_6		= "Ihr Zeit-Guthaben ist aufgebraucht";
930 richard 182
  $l_online_time	= "Online-zeit";
183
  $l_remaining_time	= "Restzeit";
184
  $l_uam_domain		= "Autorisierten websites : ";}
895 richard 185
else if($Language == 'nl'){
186
  $l_ChilliError	= "De authenticatie moet een succes worden via de captive portal dienst.";
187
  $l_login		= "Succesvolle authenticatie.<HR>Dit venster te sluiten onderbreekt uw sessie.";
188
  $l_logout		= "Slotkoers verbinding";
189
  $l_loginfailed	= "Authenticatie mislukt";
190
  $l_loggingin		= "Identificatie van de captive-portaal";
191
  $l_loggedcont		= "toegangscontrole";
192
  $l_loggedout		= "Uw sessie is gesloten";
193
  $l_user		= "Gebruiker";
194
  $l_password		= "Wachtwoord";
195
  $l_wait		= "Wacht een moment ...";
196
  $l_onlinetime		= "Sluit tijd:";
197
  $l_remainingtime	= "Verbreking in:";
198
  $l_encrypted		= "De opening moet gebruiken gecodeerde verbinding";
199
  $l_boutonO		= "Authenticatie";
200
  $l_boutonF		= "Sluiten";
930 richard 201
  $l_loggedin_stringl1	= "Information System Security";
202
  $l_loggedin_stringl2	= "Het portaal werd opgericht verordeningen om de traceerbaarheid, verantwoordelijkheid en onloochenbaarheid van de verbindingen.";
203
  $l_loggedin_stringl3	= "Uw activiteit op het netwerk is geregistreerd in overeenstemming met de persoonlijke levenssfeer.";
204
  $l_loggedin_stringl4	= "De geregistreerde gegevens kunnen worden kunnen worden bediend door een rechterlijke instantie in de loop van een onderzoek.";
205
  $l_loggedin_stringl5	= "Deze gegevens worden automatisch verwijderd na een jaar.";
206
  $l_loggedin_stringl6	= "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
207
  $l_loggedout_string	= "Logout gemaakt intern portaal!";
208
  $l_reply_1 		= "Your daily connexion time has been reached";
209
  $l_reply_2		= "Your monthly connexion time has been reached";
210
  $l_reply_3		= "You try to connect outside of your allowed timespan";
211
  $l_reply_4		= "your account expired";
212
  $l_reply_5		= "You have reached the maximum number of simultaneous logins";
213
  $l_reply_6		= "Your authorized connexion time has been reached";
214
  $l_online_time	= "Online tijd";
215
  $l_remaining_time	= "Reterende tijd";
216
  $l_uam_domain		= "Geautoriseerde website : ";}
895 richard 217
else if($Language == 'fr'){
925 richard 218
  $l_ChilliError	= "L'authentification doit être réussie sur le portail captif.";
219
  $l_login		= "Authentification réussie.<HR>La fermeture de cette fenêtre interrompt votre session.";
895 richard 220
  $l_logout		= "Fermeture de la session";
221
  $l_loginfailed	= "Echec d'authentification";
222
  $l_loggingin		= "Identification sur le portail captif";
925 richard 223
  $l_loggedcont		= "Contrôle d'accès";
895 richard 224
  $l_loggedout		= "Votre session est fermée";
225
  $l_user		= "Identifiant";
226
  $l_password		= "Mot de passe";
227
  $l_wait		= "Patientez un instant ...";
228
  $l_onlinetime		= "Temps de connexion:";
229
  $l_remainingtime	= "Deconnexion dans :";
925 richard 230
  $l_encrypted		= "La connexion avec le portail doit être chiffrée";
895 richard 231
  $l_boutonO		= "Authentification";
232
  $l_boutonF		= "Fermer";
930 richard 233
  $l_loggedin_stringl1	= "Sécurité des Systèmes d'Information";
234
  $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.";
235
  $l_loggedin_stringl3	= "Votre activité sur le réseau est enregistrée conformément au respect de la vie privée.";
236
  $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.";
237
  $l_loggedin_stringl5	= "Ces données seront automatiquement supprimées au bout d'un an.";
238
  $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";
239
  $l_loggedout_string	= "Déconnexion du portail captif effectuée !";
240
  $l_reply_1		= "Votre durée de connexion journaliè a été atteinte";
241
  $l_reply_2		= "Votre durée de connexion mensuelle a été atteinte";
242
  $l_reply_3		= "Vous tentez de vous connecter en dehors de votre période autorisée";
243
  $l_reply_4		= "Votre compte a expiré";
244
  $l_reply_5		= "Vous avez atteint le nombre maximum de connexions simultanées";
245
  $l_reply_6		= "Votre durée de connexion autorisée a été atteinte";
246
  $l_online_time	= "Temps de connexion";
247
  $l_remaining_time	= "Temps restant";
248
  $l_uam_domain		= "Sites autorisés : ";}
895 richard 249
else{
250
  $l_ChilliError	= "The authentication must be successful through the captive portal service.";
251
  $l_login		= "Successful authentication.<HR>Closing this window interrupts your session";
252
  $l_logout		= "Closing connection";
253
  $l_loginfailed	= "Authentication Failed";
254
  $l_loggingin		= "Identification on the captive portal";
255
  $l_loggedcont		= "Access Control";
256
  $l_loggedout		= "Your session is closed";
257
  $l_user		= "User";
258
  $l_password		= "Password";
259
  $l_wait		= "Please wait a moment ...";
260
  $l_onlinetime		= "Connect time:";
261
  $l_remainingtime	= "Disconnection in:";
262
  $l_encrypted		= "The connection with the portal must be encrypted";
263
  $l_boutonO		= "Authentication";
264
  $l_boutonF		= "Close";
930 richard 265
  $l_loggedin_stringl1	= "Information System Security";
266
  $l_loggedin_stringl2	= "That control was set up regulations to ensure traceability, accountability and non-repudiation of connections.";
267
  $l_loggedin_stringl3	= "Your activity on the network is registered in accordance with privacy.";
268
  $l_loggedin_stringl4	= "The recorded data can be able to be operated by a judicial authority in the course of an investigation.";
269
  $l_loggedin_stringl5	= "These data will be automatically deleted after one year.";
270
  $l_loggedin_stringl6	= "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
271
  $l_loggedout_string	= "Disconnection of the captive portal made";
272
  $l_reply_1		= "Your daily connexion time has been reached";
273
  $l_reply_2		= "Your monthly connexion time has been reached";
274
  $l_reply_3		= "You try to connect outside of your allowed timespan";
275
  $l_reply_4		= "your account expired";
276
  $l_reply_5		= "You have reached the maximum number of simultaneous logins";
277
  $l_reply_6		= "Your authorized connexion time has been reached";
278
  $l_online_time	= "Online time";
279
  $l_remaining_time	= "Remaining time";
280
  $l_uam_domain		= "Authorized websites : ";}
895 richard 281
 
282
# If https not use, tell it's wrong
283
if (!(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS'] == 'on'))) {
925 richard 284
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
895 richard 285
<html>
286
<head>
287
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
288
  <title>$l_loggedcont</title>
289
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
290
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
291
</head>
292
<body bgColor = 'white'>
293
  <h1 style=\"text-align: center;\">$l_loginfailed</h1>
294
  <center>$l_encrypted</center>
295
</body>
296
</html>";
297
    exit(0);
298
}
299
 
300
# Read form parameters which we care about
1314 richard 301
# avoid the "user as a MAC address" attempts
302
if ((isset($_POST['UserName'])) && (preg_match('/^([0-9A-F]{2}-){5}[0-9A-F]{2}$/',$_POST['UserName'])!=1)){
303
				$username	= $_POST['UserName'];} else {$username="";}
895 richard 304
if (isset($_POST['Password'])){	$password	= $_POST['Password'];} else {$password="";}
305
if (isset($_POST['challenge'])){$challenge	= $_POST['challenge'];} else {$challenge="";}
306
if (isset($_POST['button'])){	$button		= $_POST['button'];} else { $button="";}
307
//if (isset($_POST['logout'])){	$logout		= $_POST['logout'];} else {$logout="";}
308
//if (isset($_POST['prelogin'])){	$prelogin	= $_POST['prelogin'];} else {$prelogin="";}
309
if (isset($_POST['res'])){		$res		= $_POST['res'];} else {$res="";}
310
if (isset($_POST['uamip'])){	$uamip		= $_POST['uamip'];} else {$uamip="";}
311
if (isset($_POST['uamport'])){	$uamport	= $_POST['uamport'];} else {$uamport="";}
312
if (isset($_POST['userurl'])){	$userurl	= $_POST['userurl'];} else {$userurl="";}
313
if (isset($_POST['timeleft'])){	$timeleft	= $_POST['timeleft'];} else {$timeleft="";}
314
if (isset($_POST['redirurl'])){	$redirurl	= $_POST['redirurl'];} else {$redirurl="";}
315
 
316
# Read query parameters which we care about
317
if (isset($_GET['res']))		$res		= $_GET['res'];
318
if (isset($_GET['challenge']))	$challenge	= $_GET['challenge'];
319
if (isset($_GET['uamip']))		$uamip		= $_GET['uamip'];
320
if (isset($_GET['uamport']))	$uamport	= $_GET['uamport'];
321
if (isset($_GET['reply'])){		$reply		= $_GET['reply'];} else {$reply="";}
322
if (isset($_GET['userurl']))	$userurl	= $_GET['userurl'];
323
if (isset($_GET['timeleft']))	$timeleft	= $_GET['timeleft'];
324
if (isset($_GET['redirurl']))	$redirurl	= $_GET['redirurl'];
325
 
326
# translation of radius replies
327
if (isset($reply)){
328
	switch(trim ($reply)) {
329
  case 'Your maximum daily usage time has been reached' : $reply = $l_reply_1 ; break;
330
  case 'Your maximum monthly usage time has been reached' : $reply = $l_reply_2 ; break;
331
  case 'You are calling outside your allowed timespan' : $reply = $l_reply_3 ; break;
332
  case 'Password Has Expired' : $reply =  $l_reply_4 ; break;
333
  case 'You are already logged in - access denied' : $reply = $l_reply_5 ; break;
334
  case 'Your maximum never usage time has been reached' : $reply = $l_reply_6 ; break;
335
  }}
336
 
337
# If attempt to login
338
if ("$button" == "$l_boutonO") {
339
  $hexchal = pack ("H32", $challenge);
340
  $newchal = pack ("H*", md5($hexchal . $uamsecret));
341
  $response = md5("\0" . $password . $newchal);
342
  $newpwd = pack("a32", $password);
343
  $pappassword = implode ("", unpack("H32", ($newpwd ^ $newchal)));
925 richard 344
  echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
895 richard 345
<html>
346
<head>
347
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
348
  <title>$l_loggingin</title>
349
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
350
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
351
  <meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/logon?username=$username&password=$pappassword&userurl=$userurl\">
352
  </head>
353
<body bgColor = 'white'>
354
<h1 style=\"text-align: center;\">$l_loggingin</h1>
355
  <center>
356
    $l_wait
357
  </center>
358
</body>
359
</html>";
360
exit(0);
361
}
362
 
363
switch($res) {
364
  case 'success':     $result =  1; break; // If login successful
365
  case 'failed':      $result =  2; break; // If login failed
366
  case 'logoff':      $result =  3; break; // If logout successful
367
  case 'already':     $result =  4; break; // If tried to login while already logged in
368
  case 'notyet':      $result =  5; break; // If not logged in yet
369
  default: $result = 0; // Default: It was not a form request -> client go to login form
370
}
371
 
372
# Otherwise it was not a form request
373
# Send out an error message
374
if ($result == 0) {	//erreur
925 richard 375
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
895 richard 376
<html>
377
<head>
378
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
379
  <title>$l_loggingin</title>
380
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
381
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
382
  <meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/prelogin\">
383
  </head>
384
<body bgColor = 'white'>
385
<h1 style=\"text-align: center;\">$l_loggingin</h1>
386
  <center>
387
    $l_wait
388
  </center>
389
</body>
390
</html>";
391
    exit(0);
392
}
393
# Generate the output
925 richard 394
echo "<!DOCTYPE html>
895 richard 395
<html>
396
<head>
397
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
398
  <title>$l_loggingin</title>
399
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
400
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
401
  <script type=\"text/javascript\" language=\"JavaScript\">
402
    var blur = 0; // not un use
403
	var mytimeleft = 0; // not un use
404
	alcasar_popup = null;
405
 
406
    function popUp(URL) {
407
      if (self.name != \"alcasar_popup\") {
408
        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');
409
      }
410
    }
411
 
412
    function doOnLoad(result, userurl, redirurl, adminurl, timeleft) {
413
	    if (timeleft) { // not in use
414
        mytimeleft = timeleft;
415
      }
416
      if ((result == 1)||(result == 4)) {	//success or already
417
	      //window.location = userurl;
418
		  if (alcasar_popup != null) alcasar_popup.focus();
419
 
420
		  if (adminurl != ''){
421
			  window.location = adminurl;
422
		  } else if (redirurl != '') {
423
			  window.location = redirurl;
424
		  } else if (userurl != '') {
425
			  window.location = userurl;
426
		  } else {
427
			  window.home();
428
		  }
429
      }
430
      if ((result == 2) || (result == 3) || result == 5) { //failed or logoff or notyet
431
		if (alcasar_popup != null) alcasar_popup.close();
432
			document.form1.UserName.focus();
433
      }
434
    }
435
  </script>
436
<link rel=\"stylesheet\" href=\"/css/style_intercept.css\" type=\"text/css\">
437
</head>
438
<body onLoad=\"javascript:doOnLoad($result,'$userurl','$redirurl','$adminurl','$timeleft')\">
439
  <center>";
440
if ($result == 2 || $result == 3 || $result == 5) { //failed or logoff or notyet
441
  echo "
442
	<div id=\"logon\">
443
	<h1>$organisme</h1>
444
	<h2>$l_loggedcont</h2>";
445
	if ($result == 2) { //failed
446
		echo "	
447
		<h3>$l_loginfailed</h3>";
448
		if ($reply) {
449
		#traitement du reply ...
450
		echo "<center> $reply <br /><br /></center>";
451
		}
452
	}
453
	echo "
454
	<img id=\"logo-alcasar\" src=\"/images/logo-alcasar.png\">
455
	<form name=\"form1\" method=\"post\" action=\"$loginpath\">
456
	<input type=\"hidden\" name=\"challenge\" value=\"$challenge\">
457
	<input type=\"hidden\" name=\"uamip\" value=\"$uamip\">
458
	<input type=\"hidden\" name=\"uamport\" value=\"$uamport\">
459
	<input type=\"hidden\" name=\"userurl\" value=\"$userurl\">
925 richard 460
	<table id=\"boite-logon\">
461
		<tr>
462
			<td width=\"20%\" rowspan=\"3\"><img id=\"logo-organ\" src=\"/images/organisme.png\"></td>
463
			<td width=\"30%\" align=\"right\">$l_user</td>
464
			<td width=\"50%\" align=\"left\"><INPUT type=\"text\" maxLength=\"32\" name=\"UserName\" autocomplete=\"off\"></td>
465
		</tr>
466
		<tr>
467
			<td align=\"right\">$l_password</td>
468
			<td align=\"left\"><INPUT maxLength=\"32\" type=\"password\" name=\"Password\" autocomplete=\"off\"></td>
469
		</tr>
470
		<tr>
471
			<td height=\"23\" colSpan=\"2\" align=\"center\"><INPUT value=\"$l_boutonO\" type=\"submit\" name=\"button\" onclick=\"javascript:popUp('$statuspath')\"></td>
472
		</tr>
473
	</table>
474
	</form>
475
	<table id=\"boite-info\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">
476
		<tr>
477
			<td align=\"center\"><FONT color=\"red\"><B>$l_loggedin_stringl1</B></FONT></td>
478
		</tr>
479
		<tr>
480
			<td align=\"left\">
481
				<ul>
482
					<LI>$l_loggedin_stringl2</LI>
483
					<LI>$l_loggedin_stringl4</LI>
484
					<LI>$l_loggedin_stringl3</LI>
485
					<LI>$l_loggedin_stringl5</LI>
486
					<LI>$l_loggedin_stringl6</LI>
487
				</ul>
488
			</td>
489
		</tr>
490
	</table>";
913 richard 491
 
930 richard 492
// Read the "Domain allowed" file
913 richard 493
$tab=file(DOMAIN_ALLOWED_LIST);
494
if ($tab)  # the file isn't empty
495
	{
925 richard 496
	echo "<div id=\"authorized_domain\">$l_uam_domain";
913 richard 497
	foreach ($tab as $line)
498
		{
499
		if (trim($line) != '') # the line isn't empty
925 richard 500
			{
913 richard 501
			$domain_allowed=explode("#", $line);
925 richard 502
			if (trim($domain_allowed[1]) != ''){
503
				$domain=explode("\"", $domain_allowed[0]);
504
				echo "<a href=\"http://".trim($domain[1])."\">".trim($domain_allowed[1])."</a> ";}
505
			}	
913 richard 506
		}
507
	}
925 richard 508
echo "	
509
</div>
510
</center>
895 richard 511
</body>
512
</html>";
513
}
514
exit(0);
515
?>