Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
733 richard 1
<?php
2
#
3
# intercept.php for Alcasar captive portal
4
# Copyright (C) 2003, 2004 Mondru AB.
5
# Modify by REXY & steweb57
6
# UI & css style by stephane ERARD
7
# Help for language translation by B. AUBARD (thanks)
8
 
9
# The contents of this file may be used under the terms of the GNU
10
# General Public License Version 2, provided that the above copyright
11
# notice and this permission notice is included in all copies or
12
# substantial portions of the software.
13
 
843 richard 14
$organisme = "";
733 richard 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
# Shared secret used to encrypt challenge with radius.
843 richard 25
$uamsecret = "";
733 richard 26
 
27
# URL loaded after success authenticates (let blank for browser defaults)
28
$adminurl = "";
29
 
30
# Our own path
31
$loginpath	= $_SERVER['PHP_SELF'];
32
$alcasarpath = "http://alcasar";
33
$statuspath = $alcasarpath."/status.php";
34
$debug		= false;
35
 
36
# Choice of language
37
$Language = 'en';
38
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
39
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
40
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
41
if($Language == 'es'){
42
  $l_ChilliError	= "La autenticación debe ser un éxito a través del servicio de portal cautivo.";
43
  $l_login		= "El éxito de la autenticación.<HR>Cierre esta ventana interrumpte la sesion.";
44
  $l_logout		= "Conexión de cierre";
45
  $l_loginfailed	= "Error de autenticación";
46
  $l_loggingin		= "Identificación en el portal cautivo";
47
  $l_loggedcont		= "Red de Control de Acceso";
48
  $l_loggedout		= "Su sesión se cierra";
49
  $l_user		= "Usuario";
50
  $l_password		= "Contraseña";
51
  $l_wait		= "Por favor, espere un momento ...";
52
  $l_onlinetime		= "Tiempo de conexión:";
53
  $l_remainingtime	= "Desconexión en:";
843 richard 54
  $l_encrypted		= "La apertura debe usar conexión cifrada (https)";
733 richard 55
  $l_boutonO		= "Autenticación";
56
  $l_boutonF		= "Cerrar";
57
  $l_loggedin_stringl1 = "Information System Security";
58
  $l_loggedin_stringl2 = "El portal fue creado reglamentos para garantizar la trazabilidad, la rendición de cuentas y el no repudio de las conexiones.";
59
  $l_loggedin_stringl3 = "Su actividad en la red es registrada, de conformidad con la privacidad.";
60
  $l_loggedin_stringl4 = "Los datos registrados pueden ser capaces de ser operado por una autoridad judicial en el curso de una investigación.";
61
  $l_loggedin_stringl5 = "Estos datos se eliminan automáticamente después de un año.";
62
  $l_loggedin_stringl6 = "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
63
  $l_loggedout_string = "Cerrar sesión hizo portal cautivo!";
64
  $l_reply_1 = "Your daily connexion time has been reached";
65
  $l_reply_2 = "Your monthly connexion time has been reached";
66
  $l_reply_3 = "You try to connect outside of your allowed timespan";
67
  $l_reply_4 = "your account expired";
68
  $l_reply_5 = "You have reached the maximum number of simultaneous logins";
69
  $l_online_time = "Tiempo en linea";
70
  $l_remaining_time = "Tiempo restante";
71
}
72
else if($Language == 'de'){
73
  $l_ChilliError	= "Die Authentifizierung ist erfolgreich durch die Nutzung des Portals erfolgt.";
74
  $l_login		= "Erfolgreiche Authentifizierung.<HR>Schlißen dieses fensters unterbricht die sitzung";
75
  $l_logout		= "Beenden der Verbindung";
76
  $l_loginfailed	= "Authentifizierungsfehler Eigenverbrauch";
77
  $l_loggingin		= "Kennzeichnung auf dem Eigenverbrauch";
78
  $l_loggedcont		= "Network Access Control";
79
  $l_loggedout		= "Ihre Sitzung ist geschlossen";
80
  $l_user		= "Benutzer";
81
  $l_password		= "Passwort";
82
  $l_wait		= "Bitte warten Sie einen Moment ...";
83
  $l_onlinetime		= "Online-Zeit:";
84
  $l_remainingtime	= "Abmelden:";
843 richard 85
  $l_encrypted		= "Die Öffnung muß der Anschluß Zahlen (https)";
733 richard 86
  $l_boutonO		= "Authentifizierung";
87
  $l_boutonF		= "Schließen";
88
  $l_loggedin_stringl1 = "Information System Security";
89
  $l_loggedin_stringl2 = "Dieses Portal wurde eingerichtet, um ordnungsgemäß die Rückverfolgbarkeit, der Zurechenbarkeit und der Nicht-Anerkennung der Verbindungen.";
90
  $l_loggedin_stringl3 = "Ihre Tätigkeit im Netzwerk registriert ist nach Schutz der Privatsphäre.";
91
  $l_loggedin_stringl4 = "Die gespeicherten Daten nicht pouront genutzt werden, dass von einer Justizbehörde im Rahmen einer Untersuchung.";
92
  $l_loggedin_stringl5 = "Diese Daten werden automatisch gelöscht nach einem Jahr.";
93
  $l_loggedin_stringl6 = "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
94
  $l_loggedout_string = "Trennung des Portals erfolgt Gefangener!";
95
  $l_reply_1 = "Your daily connexion time has been reached";
96
  $l_reply_2 = "Your monthly connexion time has been reached";
97
  $l_reply_3 = "You try to connect outside of your allowed timespan";
98
  $l_reply_4 = "your account expired";
99
  $l_reply_5 = "You have reached the maximum number of simultaneous logins";
100
  $l_online_time = "Online-zeit";
101
  $l_remaining_time = "Restzeit";
102
}
103
else if($Language == 'nl'){
104
  $l_ChilliError	= "De authenticatie moet een succes worden via de captive portal dienst.";
105
  $l_login		= "Succesvolle authenticatie.<HR>Dit venster te sluiten onderbreekt uw sessie.";
106
  $l_logout		= "Slotkoers verbinding";
107
  $l_loginfailed	= "Authenticatie mislukt";
108
  $l_loggingin		= "Identificatie van de captive-portaal";
109
  $l_loggedcont		= "Network Access Control";
110
  $l_loggedout		= "Uw sessie is gesloten";
111
  $l_user		= "Gebruiker";
112
  $l_password		= "Wachtwoord";
113
  $l_wait		= "Wacht een moment ...";
114
  $l_onlinetime		= "Sluit tijd:";
115
  $l_remainingtime	= "Verbreking in:";
843 richard 116
  $l_encrypted		= "De opening moet gebruiken gecodeerde verbinding (https)";
733 richard 117
  $l_boutonO		= "Authenticatie";
118
  $l_boutonF		= "Sluiten";
119
  $l_loggedin_stringl1 = "Information System Security";
120
  $l_loggedin_stringl2 = "Het portaal werd opgericht verordeningen om de traceerbaarheid, verantwoordelijkheid en onloochenbaarheid van de verbindingen.";
121
  $l_loggedin_stringl3 = "Uw activiteit op het netwerk is geregistreerd in overeenstemming met de persoonlijke levenssfeer.";
122
  $l_loggedin_stringl4 = "De geregistreerde gegevens kunnen worden kunnen worden bediend door een rechterlijke instantie in de loop van een onderzoek.";
123
  $l_loggedin_stringl5 = "Deze gegevens worden automatisch verwijderd na een jaar.";
124
  $l_loggedin_stringl6 = "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
125
  $l_loggedout_string = "Logout gemaakt intern portaal!";
126
  $l_reply_1 = "Your daily connexion time has been reached";
127
  $l_reply_2 = "Your monthly connexion time has been reached";
128
  $l_reply_3 = "You try to connect outside of your allowed timespan";
129
  $l_reply_4 = "your account expired";
130
  $l_reply_5 = "You have reached the maximum number of simultaneous logins";
131
  $l_online_time = "Online tijd";
132
  $l_remaining_time = "Reterende tijd";
133
}
134
else if($Language == 'fr'){
135
  $l_ChilliError	= "L'authentification doit &ecirc;tre r&eacute;ussie au travers du service du portail captif.";
136
  $l_login		= "Authentification r&eacute;ussie.<HR>La fermeture de cette fenêtre interrompt votre session.";
137
  $l_logout		= "Fermeture de la session";
138
  $l_loginfailed	= "Echec d'authentification";
139
  $l_loggingin		= "Identification sur le portail captif";
140
  $l_loggedcont		= "Contr&ocirc;le d'acc&egrave;s au r&eacute;seau";
141
  $l_loggedout		= "Votre session est fermée";
142
  $l_user		= "Identifiant";
143
  $l_password		= "Mot de passe";
144
  $l_wait		= "Patientez un instant ...";
145
  $l_onlinetime		= "Temps de connexion:";
146
  $l_remainingtime	= "Deconnexion dans :";
843 richard 147
  $l_encrypted		= "La connexion avec le portail doit &ecirc;tre chiffr&eacute;e (https)";
733 richard 148
  $l_boutonO		= "Authentification";
149
  $l_boutonF		= "Fermer";
150
  $l_loggedin_stringl1 = "S&eacute;curit&eacute; des Syst&egrave;mes d'Information";
151
  $l_loggedin_stringl2 = "Ce contr&ocirc;le a &eacute;t&eacute; mis en place pour assurer r&eacute;glementairement la tra&ccedil;abilit&eacute;, l'imputabilit&eacute; et la non-r&eacute;pudiation des connexions.";
152
  $l_loggedin_stringl3 = "Votre activit&eacute; sur le r&eacute;seau est enregistr&eacute;e conform&eacute;ment au respect de la vie priv&eacute;e.";
153
  $l_loggedin_stringl4 = "Les donn&eacute;es enregistr&eacute;es ne pourront &ecirc;tre exploit&eacute;es que par une autorit&eacute judiciaire dans le cadre d'une enqu&ecirc;te.";
154
  $l_loggedin_stringl5 = "Ces donn&eacute;es seront automatiquement supprim&eacute;es au bout d'un an.";
155
  $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";
156
  $l_loggedout_string = "D&eacute;connexion du portail captif effectu&eacute;e !";
157
  $l_reply_1 = "Votre dur&eacute;e de connexion journali&egrave;re a &eacute;t&eacute; atteinte";
158
  $l_reply_2 = "Votre dur&eacute;e de connexion mensuelle a &eacute;t&eacute; atteinte";
159
  $l_reply_3 = "Vous tentez de vous connecter en dehors de votre p&eacute;riode autoris&eacute;e";
160
  $l_reply_4 = "Votre compte a expir&eacute";
161
  $l_reply_5 = "Vous avez atteint le nombre maximum de connexions simultan&eacute;es";
162
  $l_online_time = "Temps de connexion";
163
  $l_remaining_time = "Temps restant";
164
}
165
else{
166
  $l_ChilliError	= "The authentication must be successful through the captive portal service.";
167
  $l_login		= "Successful authentication.<HR>Closing this window interrupts your session";
168
  $l_logout		= "Closing connection";
169
  $l_loginfailed	= "Authentication Failed";
170
  $l_loggingin		= "Identification on the captive portal";
171
  $l_loggedcont		= "Network Access Control";
172
  $l_loggedout		= "Your session is closed";
173
  $l_user		= "User";
174
  $l_password		= "Password";
175
  $l_wait		= "Please wait a moment ...";
176
  $l_onlinetime		= "Connect time:";
177
  $l_remainingtime	= "Disconnection in:";
843 richard 178
  $l_encrypted		= "The connection with the portal must encrypted (https)";
733 richard 179
  $l_boutonO		= "Authentication";
180
  $l_boutonF		= "Close";
181
  $l_loggedin_stringl1 = "Information System Security";
182
  $l_loggedin_stringl2 = "That control was set up regulations to ensure traceability, accountability and non-repudiation of connections.";
183
  $l_loggedin_stringl3 = "Your activity on the network is registered in accordance with privacy.";
184
  $l_loggedin_stringl4 = "The recorded data can be able to be operated by a judicial authority in the course of an investigation.";
185
  $l_loggedin_stringl5 = "These data will be automatically deleted after one year.";
186
  $l_loggedin_stringl6 = "Click <a href='$alcasarpath'>here</a> to change your password or to integrate the security certificate in your browser";
187
  $l_loggedout_string = "Logout made captive portal!";
188
  $l_reply_1 = "Your daily connexion time has been reached";
189
  $l_reply_2 = "Your monthly connexion time has been reached";
190
  $l_reply_3 = "You try to connect outside of your allowed timespan";
191
  $l_reply_4 = "your account expired";
192
  $l_reply_5 = "You have reached the maximum number of simultaneous logins";
193
  $l_online_time = "Online time";
194
  $l_remaining_time = "Remaining time";
195
}
196
 
197
# If https not use, tell it's wrong
198
if (!(isset($_SERVER['HTTPS'])&&($_SERVER['HTTPS'] == 'on'))) {
199
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
200
<html>
201
<head>
202
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
203
  <title>$l_loggedcont</title>
204
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
205
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
206
</head>
207
<body bgColor = 'white'>
208
  <h1 style=\"text-align: center;\">$l_loginfailed</h1>
209
  <center>$l_encrypted</center>
210
</body>
211
</html>";
212
    exit(0);
213
}
214
 
215
# Read form parameters which we care about
216
if (isset($_POST['UserName'])){	$username	= $_POST['UserName'];} else {$username="";}
217
if (isset($_POST['Password'])){	$password	= $_POST['Password'];} else {$password="";}
218
if (isset($_POST['challenge'])){$challenge	= $_POST['challenge'];} else {$challenge="";}
219
if (isset($_POST['button'])){	$button		= $_POST['button'];} else { $button="";}
220
//if (isset($_POST['logout'])){	$logout		= $_POST['logout'];} else {$logout="";}
221
//if (isset($_POST['prelogin'])){	$prelogin	= $_POST['prelogin'];} else {$prelogin="";}
222
if (isset($_POST['res'])){		$res		= $_POST['res'];} else {$res="";}
223
if (isset($_POST['uamip'])){	$uamip		= $_POST['uamip'];} else {$uamip="";}
224
if (isset($_POST['uamport'])){	$uamport	= $_POST['uamport'];} else {$uamport="";}
225
if (isset($_POST['userurl'])){	$userurl	= $_POST['userurl'];} else {$userurl="";}
226
if (isset($_POST['timeleft'])){	$timeleft	= $_POST['timeleft'];} else {$timeleft="";}
227
if (isset($_POST['redirurl'])){	$redirurl	= $_POST['redirurl'];} else {$redirurl="";}
228
 
229
# Read query parameters which we care about
230
if (isset($_GET['res']))		$res		= $_GET['res'];
231
if (isset($_GET['challenge']))	$challenge	= $_GET['challenge'];
232
if (isset($_GET['uamip']))		$uamip		= $_GET['uamip'];
233
if (isset($_GET['uamport']))	$uamport	= $_GET['uamport'];
234
if (isset($_GET['reply'])){		$reply		= $_GET['reply'];} else {$reply="";}
235
if (isset($_GET['userurl']))	$userurl	= $_GET['userurl'];
236
if (isset($_GET['timeleft']))	$timeleft	= $_GET['timeleft'];
237
if (isset($_GET['redirurl']))	$redirurl	= $_GET['redirurl'];
238
 
239
# translation of radius replies
240
if (isset($reply)){
241
	switch(trim ($reply)) {
242
  case 'Your maximum daily usage time has been reached' : $reply = $l_reply_1 ; break;
243
  case 'Your maximum monthly usage time has been reached' : $reply = $l_reply_2 ; break;
244
  case 'You are calling outside your allowed timespan' : $reply = $l_reply_3 ; break;
245
  case 'Password Has Expired' : $reply =  $l_reply_4 ; break;
246
  case 'You are already logged in - access denied' : $reply = $l_reply_5 ; break;
247
  }}
248
 
249
# If attempt to login
250
if ("$button" == "$l_boutonO") {
251
  $hexchal = pack ("H32", $challenge);
252
  $newchal = pack ("H*", md5($hexchal . $uamsecret));
253
  $response = md5("\0" . $password . $newchal);
254
  $newpwd = pack("a32", $password);
255
  $pappassword = implode ("", unpack("H32", ($newpwd ^ $newchal)));
256
  echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
257
<html>
258
<head>
259
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
260
  <title>$l_loggingin</title>
261
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
262
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
263
  <meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/logon?username=$username&password=$pappassword&userurl=$userurl\">
264
  </head>
265
<body bgColor = 'white'>
266
<h1 style=\"text-align: center;\">$l_loggingin</h1>
267
  <center>
268
    $l_wait
269
  </center>
270
</body>
271
</html>";
272
exit(0);
273
}
274
 
275
switch($res) {
276
  case 'success':     $result =  1; break; // If login successful
277
  case 'failed':      $result =  2; break; // If login failed
278
  case 'logoff':      $result =  3; break; // If logout successful
279
  case 'already':     $result =  4; break; // If tried to login while already logged in
280
  case 'notyet':      $result =  5; break; // If not logged in yet
281
  default: $result = 0; // Default: It was not a form request -> client go to login form
282
}
283
 
284
# Otherwise it was not a form request
285
# Send out an error message
286
if ($result == 0) {	//erreur
287
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
288
<html>
289
<head>
290
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
291
  <title>$l_loggingin</title>
292
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
293
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
294
  <meta http-equiv=\"refresh\" content=\"0;url=http://$uamip:$uamport/prelogin\">
295
  </head>
296
<body bgColor = 'white'>
297
<h1 style=\"text-align: center;\">$l_loggingin</h1>
298
  <center>
299
    $l_wait
300
  </center>
301
</body>
302
</html>";
303
    exit(0);
304
}
305
# Generate the output
306
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
307
<html>
308
<head>
309
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
310
  <title>$l_loggingin</title>
311
  <meta http-equiv=\"Cache-control\" content=\"no-cache\">
312
  <meta http-equiv=\"Pragma\" content=\"no-cache\">
313
  <script type=\"text/javascript\" language=\"JavaScript\">
314
    var blur = 0; // not un use
315
	var mytimeleft = 0; // not un use
316
	alcasar_popup = null;
317
 
318
    function popUp(URL) {
319
      if (self.name != \"alcasar_popup\") {
737 franck 320
        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');
733 richard 321
      }
322
    }
323
 
324
    function doOnLoad(result, userurl, redirurl, adminurl, timeleft) {
325
	    if (timeleft) { // not in use
326
        mytimeleft = timeleft;
327
      }
328
      if ((result == 1)||(result == 4)) {	//success or already
329
	      //window.location = userurl;
330
		  if (alcasar_popup != null) alcasar_popup.focus();
331
 
332
		  if (adminurl != ''){
333
			  window.location = adminurl;
334
		  } else if (redirurl != '') {
335
			  window.location = redirurl;
336
		  } else if (userurl != '') {
337
			  window.location = userurl;
338
		  } else {
339
			  window.home();
340
		  }
341
      }
342
      if ((result == 2) || (result == 3) || result == 5) { //failed or logoff or notyet
343
		if (alcasar_popup != null) alcasar_popup.close();
344
			document.form1.UserName.focus();
345
      }
346
    }
347
  </script>
348
<link rel=\"stylesheet\" href=\"/css/style_intercept.css\" type=\"text/css\">
349
</head>
350
<body onLoad=\"javascript:doOnLoad($result,'$userurl','$redirurl','$adminurl','$timeleft')\">
351
  <center>";
352
if ($result == 2 || $result == 3 || $result == 5) { //failed or logoff or notyet
353
  echo "
354
	<div id=\"logon\">
355
	<h1>$organisme</h1>
356
	<h2>$l_loggedcont</h2>";
357
	if ($result == 2) { //failed
358
		echo "	
359
		<h3>$l_loginfailed</h3>";
360
		if ($reply) {
361
		#traitement du reply ...
362
		echo "<center> $reply <br /><br /></center>";
363
		}
364
	}
365
	echo "
366
	<img id=\"logo-alcasar\" src=\"/images/logo-alcasar.png\">
367
	<form name=\"form1\" method=\"post\" action=\"$loginpath\">
368
	<input type=\"hidden\" name=\"challenge\" value=\"$challenge\">
369
	<input type=\"hidden\" name=\"uamip\" value=\"$uamip\">
370
	<input type=\"hidden\" name=\"uamport\" value=\"$uamport\">
371
	<input type=\"hidden\" name=\"userurl\" value=\"$userurl\">
372
		<table id=\"boite-logon\">
373
			<tr>
374
				<td width=\"20%\" rowspan=\"3\"><img id=\"logo-organ\" src=\"/images/organisme.png\"></td>
375
				<td width=\"30%\" align=\"right\">$l_user</td>
376
				<td width=\"50%\" align=\"left\"><INPUT type=\"text\" maxLength=\"32\" name=\"UserName\"></td>
377
			</tr>
378
			<tr>
379
				<td align=\"right\">$l_password</td>
380
				<td align=\"left\"><INPUT maxLength=\"32\" type=\"password\" name=\"Password\"></td>
381
			</tr>
382
			<tr>
383
				<td height=\"23\" colSpan=\"2\" align=\"center\"><INPUT value=\"$l_boutonO\" type=\"submit\" name=\"button\" onclick=\"javascript:popUp('$statuspath')\"></td>
384
			</tr>
385
		</table>
386
		<table id=\"boite-info\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\">
387
			<tr>
388
				<td align=\"center\"><FONT color=\"red\"><B>$l_loggedin_stringl1</B></FONT></td>
389
			</tr>
390
			<tr>
391
				<td align=\"left\">
392
					<ul>
393
						<LI>$l_loggedin_stringl2</LI>
394
						<LI>$l_loggedin_stringl4</LI>
395
						<LI>$l_loggedin_stringl3</LI>
396
						<LI>$l_loggedin_stringl5</LI>
397
						<LI>$l_loggedin_stringl6</LI>
398
					</ul>
399
				</td>
400
			</tr>
401
		</table>
402
  </form>
403
  </div>
404
  </center>
405
</body>
406
</html>";
407
}
408
exit(0);
409
?>