Subversion Repositories ALCASAR

Rev

Rev 1708 | Rev 2008 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
528 stephane 1
<?php
958 franck 2
# $Id: status.php 1878 2016-05-09 13:09:13Z raphael.pion $
528 stephane 3
#
4
# status.php for Alcasar captive portal
847 richard 5
# by steweb57 & Rexy
528 stephane 6
# 
847 richard 7
/****************************************************************
8
*			GLOBAL FILE PATHS			*
9
*****************************************************************/
10
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
11
 
12
/****************************************************************
13
*				FILE TEST			*
14
*****************************************************************/
15
//Test de présence et des droits en lecture des fichiers de configuration.
16
if (!file_exists(CONF_FILE)){
17
	exit("Fichier de configuration ".CONF_FILE." non présent");
18
}
19
if (!is_readable(CONF_FILE)){
20
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
21
}
22
 
23
/****************************************************************
24
*			Read CONF_FILE				*
25
*****************************************************************/
26
$ouvre=fopen(CONF_FILE,"r");
27
if ($ouvre){
28
	while (!feof ($ouvre))
29
	{
30
		$tampon = fgets($ouvre, 4096);
31
		if (strpos($tampon,"=")!==false){
32
			$tmp = explode("=",$tampon);
33
			$conf[$tmp[0]] = $tmp[1];
34
		}
35
	}
36
}else{
1030 stephane 37
	exit("Erreur d'ouverture du fichier ".CONF_FILE);
847 richard 38
}
39
fclose($ouvre);
40
 
41
$organisme = $conf["ORGANISM"];
42
 
725 stephane 43
$remote_ip = ($_SERVER['REMOTE_ADDR']);
44
$connection_history =  "";
45
$nb_connection_history = 3;
528 stephane 46
 
1026 richard 47
//On récupère le nom de connexion de la session active. on attend que chilli ait mis à jour ses tables
48
sleep (1);
49
exec ("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
1878 raphael.pi 50
if(isset($tab[0]))
725 stephane 51
$user = explode (" ", $tab[0]);
52
 
53
#### Affichage des 3 dernières connexions de $user[5]
54
function secondsToDuration($seconds = null){
55
	if ($seconds == null) return "";
56
 
57
	$temp = $seconds % 3600;
58
	$time[0] = ( $seconds - $temp ) / 3600 ;	// hours
732 richard 59
	$time[2] = $temp % 60 ;				// seconds
725 stephane 60
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
61
 
732 richard 62
	return $time[0]." h ".$time[1]." m ".$time[2]." s";
725 stephane 63
}
64
 
65
 
66
 
528 stephane 67
# Choice of language
68
//reste quelques traductions à faire
69
$Language = 'en';
70
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
71
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
72
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
73
if($Language == 'es'){
734 richard 74
	$l_login1			= "El éxito de la autenticación";
528 stephane 75
	$l_logout			= "Conexión de cierre";
955 richard 76
	$l_logout_question		= "Are you sure you want to disconnect now?";	//à traduire
77
	$l_loggedout			= "Su sesión se cierra";
528 stephane 78
	$l_wait				= "Por favor, espere un momento ...";
955 richard 79
	$l_state_label			= "State";		//à traduire
80
	$l_session_id_label		= "Session ID";	//à traduire
528 stephane 81
	$l_max_session_time_label	= "Max Session Time";	//à traduire
82
	$l_max_idle_time_label		= "Max Idle Time";		//à traduire
955 richard 83
	$l_start_time_label		= "Start Time";	//à traduire
528 stephane 84
	$l_session_time_label		= "Tiempo de conexión";
955 richard 85
	$l_idle_time_label		= "Idle Time";	//à traduire
86
	$l_downloaded_label		= "Downloaded";	//à traduire
87
	$l_uploaded_label		= "Uploaded";	//à traduire
528 stephane 88
	$l_original_url_label		= "Original URL";	//à traduire
955 richard 89
	$l_not_available		= "Not available";	//à traduire
90
	$l_na				= "N/A";		//à traduire
91
	$l_error			= "error";		//à traduire
92
	$l_welcome			= "Welcome";	//à traduire
93
	$l_conn_history			= "Your last $nb_connection_history connections";	//à traduire
737 franck 94
	$l_connected 			= "logged"; //à traduire
1708 richard 95
	$l_a_connection			= "You have"; //à traduire
96
	$l_a_connection_time		= "active connections on the network"; //à traduire
528 stephane 97
}
912 richard 98
else if ($Language == 'pt'){
99
	$l_login1			= "Autenticação bem sucedida.";
100
	$l_logout			= "Fechando a conexão";
955 richard 101
	$l_logout_question		= "Tem certeza de que deseja desconectar agora?";
971 richard 102
	$l_loggedout			= "Sua conexão será fechada";
912 richard 103
	$l_wait				= "Por favor, aguarde um momento ...";
971 richard 104
	$l_state_label			= "Estado da conexão";
955 richard 105
	$l_session_id_label		= "Sessão ID";
971 richard 106
	$l_max_session_time_label	= "Restante em horas da conexão";
107
	$l_max_idle_time_label		= "Restante máximo liberado por dia";
108
	$l_start_time_label		= "Dia, mês, ano e hora da conexão";
955 richard 109
	$l_session_time_label		= "Duração da conexão";
110
	$l_idle_time_label		= "Tempo de Espera";
971 richard 111
	$l_downloaded_label		= "Recebidos";
112
	$l_uploaded_label		= "Enviados";
912 richard 113
	$l_original_url_label		= "URL Original";
955 richard 114
	$l_not_available		= "Não disponível";
115
	$l_na				= "N/A";
116
	$l_error			= "Erro";
971 richard 117
	$l_welcome			= "Bem-vindo(a)";
118
	$l_conn_history			= "Suas últimos conexões : $nb_connection_history";
955 richard 119
	$l_connected 			= "Conectado"; 
971 richard 120
	$l_a_connection			= "Conexão ativa já detectada para essa LAN";
912 richard 121
	$l_a_connection_time		= "Tempo (s)";
122
}
528 stephane 123
else if($Language == 'de'){
734 richard 124
	$l_login1			= "Erfolgreiche Authentifizierung";
528 stephane 125
	$l_logout			= "Beenden der Verbindung";
126
	$l_logout_question	= "Are you sure you want to disconnect now?";	//à traduire
127
	$l_loggedout		= "Ihre Sitzung ist geschlossen";
128
	$l_wait				= "Bitte warten Sie einen Moment ...";
129
	$l_state_label				= "State";		//à traduire
130
	$l_session_id_label			= "Session ID";	//à traduire
131
	$l_max_session_time_label	= "Max Session Time";	//à traduire
132
	$l_max_idle_time_label		= "Max Idle Time";		//à traduire
133
	$l_start_time_label			= "Start Time";	//à traduire
134
	$l_session_time_label		= "Online-zeit";
135
	$l_idle_time_label			= "Idle Time";	//à traduire
136
	$l_downloaded_label			= "Downloaded";	//à traduire
137
	$l_uploaded_label			= "Uploaded";	//à traduire
138
	$l_original_url_label		= "Original URL";	//à traduire
139
	$l_not_available			= "Not available";	//à traduire
140
	$l_na						= "N/A";		//à traduire
141
	$l_error					= "error";		//à traduire
142
	$l_welcome					= "Welcome"; 	//à traduire
734 richard 143
	$l_conn_history				= "Your last $nb_connection_history connections";	//à traduire
144
	$l_connected 			= "logged"; //à traduire 
1708 richard 145
	$l_a_connection			= "You have"; //à traduire
146
	$l_a_connection_time		= "active connections on the network"; //à traduire
528 stephane 147
}
148
else if($Language == 'nl'){
734 richard 149
	$l_login1			= "Succesvolle authenticatie";
528 stephane 150
	$l_logout			= "Slotkoers verbinding";
151
	$l_logout_question	= "Are you sure you want to disconnect now?";	//à traduire
152
	$l_loggedout		= "Uw sessie is gesloten";
153
	$l_wait				= "Wacht een moment ...";
154
	$l_state_label				= "State";		//à traduire
155
	$l_session_id_label			= "Session ID";	//à traduire
156
	$l_max_session_time_label	= "Max Session Time";	//à traduire
157
	$l_max_idle_time_label		= "Max Idle Time";		//à traduire
158
	$l_start_time_label			= "Start Time";	//à traduire
159
	$l_session_time_label		= "Online tijd";
160
	$l_idle_time_label			= "Idle Time";	//à traduire
161
	$l_downloaded_label			= "Downloaded";	//à traduire
162
	$l_uploaded_label			= "Uploaded";	//à traduire
163
	$l_original_url_label		= "Original URL";	//à traduire
164
	$l_not_available			= "Not available";	//à traduire
165
	$l_na						= "N/A";		//à traduire
166
	$l_error					= "error";		//à traduire
167
	$l_welcome					= "Welcome";	//à traduire
734 richard 168
	$l_conn_history				= "Your last $nb_connection_history connections";	//à traduire
169
	$l_connected 			= "logged"; //à traduire 
1708 richard 170
	$l_a_connection			= "You have"; //à traduire
171
	$l_a_connection_time		= "active connections on the network"; //à traduire
528 stephane 172
}
173
else if($Language == 'fr'){
734 richard 174
	$l_login1			= "Authentification r&eacute;ussie";
528 stephane 175
	$l_logout			= "Fermeture de la session";
536 franck 176
	$l_logout_question	= "Etes vous sûr de vouloir vous déconnecter?";
528 stephane 177
	$l_loggedout		= "Votre session est fermée";
178
	$l_wait				= "Patientez un instant ....";
179
	$l_state_label				= "Etat";
180
	$l_session_id_label			= "Session ID";
181
	$l_max_session_time_label	= "Temps de connexion autoris&eacute";
182
	$l_max_idle_time_label		= "Inactivit&eacute; max. autoris&eacute;e";
183
	$l_start_time_label			= "D&eacute;but de connexion";
184
	$l_session_time_label		= "Dur&eacute;e de connexion";
185
	$l_idle_time_label			= "Inactivit&eacute;";
186
	$l_downloaded_label			= "Donn&eacute;es t&eacute;l&eacute;charg&eacute;es";
187
	$l_uploaded_label			= "Donn&eacute;es envoy&eacute;es";
536 franck 188
	$l_original_url_label		= "URL demand&eacute;e";
528 stephane 189
	$l_not_available			= "Non disponible";
190
	$l_na						= "N/D";	//à traduire
191
	$l_error					= "erreur";
192
	$l_welcome					= "Bienvenue";
734 richard 193
	$l_conn_history				= "Vos $nb_connection_history derni&egrave;res connexions";
737 franck 194
	$l_connected 			= "session active";  
1708 richard 195
	$l_a_connection			= "Vous avez";
196
	$l_a_connection_time		= "connexions actives sur le réseau";
528 stephane 197
}
198
else {
199
	$l_login1			= "Successful authentication.";
200
	$l_logout			= "Closing connection";
201
	$l_logout_question	= "Are you sure you want to disconnect now?";
202
	$l_loggedout		= "Your session is closed";
203
	$l_wait				= "Please wait a moment ...";
204
	$l_state_label				= "State";
205
	$l_session_id_label			= "Session ID";
206
	$l_max_session_time_label	= "Max Session Time";
207
	$l_max_idle_time_label		= "Max Idle Time";
208
	$l_start_time_label			= "Start Time";
209
	$l_session_time_label		= "Session Time";
210
	$l_idle_time_label			= "Idle Time";
211
	$l_downloaded_label			= "Downloaded";
212
	$l_uploaded_label			= "Uploaded";
213
	$l_original_url_label		= "Original URL";
214
	$l_not_available			= "Not available";
215
	$l_na						= "N/A";
216
	$l_error					= "error";
217
	$l_welcome					= "Welcome";
734 richard 218
	$l_conn_history				= "Your last $nb_connection_history connections";
219
	$l_connected 			= "logged"; 
1708 richard 220
	$l_a_connection			= "You have"; //à traduire
221
	$l_a_connection_time		= "active connections on the network"; //à traduire
528 stephane 222
}
734 richard 223
 
224
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
225
if (isset($user[5])){
226
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
227
		include_once("/etc/freeradius-web/config.php");
228
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
229
 
230
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
231
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
232
 
233
		if ($link){
234
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
235
 
236
			if ($res){
1026 richard 237
				$a_connection = ""; $a_connected=0; $connection_history.= "<ul>";
734 richard 238
				while(($row = @da_sql_fetch_array($res,$config))){
239
					$connected = "";
872 richard 240
					$start_conn = date_create($row['acctstarttime']);
737 franck 241
					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (";
872 richard 242
					if ($row['acctstoptime'] == "") {
737 franck 243
						$connected = $l_connected;
1026 richard 244
						$a_connected = $a_connected +1;
737 franck 245
					}else{
872 richard 246
						$connected = secondsToDuration($row['acctsessiontime']);
737 franck 247
					}
248
					$connection_history.= "$connected)</li>";
734 richard 249
				}
250
				$connection_history.="</ul>";
737 franck 251
				if ($a_connected > 1){
1026 richard 252
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time; }
737 franck 253
			}
254
		}
734 richard 255
	}
256
}
528 stephane 257
?>
258
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
259
<html lang="fr">
260
<!-- written by steweb57 -->
734 richard 261
	<head>
262
		<title>Alcasar - <?php echo $organisme; ?></title>
263
		<meta http-equiv="Cache-control" content="no-cache">
264
		<meta http-equiv="Pragma" content="no-cache">
265
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
266
		<script type="text/javascript" src="./js/ChilliLibrary.js"></script>
267
		<script type="text/javascript" src="./js/statusControler.js"></script>
268
		<link type="text/css" href="./css/status.css" rel="stylesheet">
269
	</head>
270
	<body>
271
		<div id="Chilli">
272
		<div id="locationName"></div>
273
		<div id="chilliPage">
274
		<div id="loggedOutPage" class="c1">
275
			<table id="disconnectTable">
276
				<tr>
277
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
278
					<td><p class="text_auth"><?php echo $l_loggedout; ?></p></td>
279
				</tr>
280
			</table>
281
		</div>
282
		<div id="statusPage" class="c1">
283
			<table border="0" id="statusTable">
284
				<tr>
737 franck 285
					<td colspan="2">
286
						<table border="0" cellpadding="0" cellspacing="0" width="100%">
287
							<tr>
288
								<td valign="top" rowspan="4">
289
									<img height="150" src="./images/logo-alcasar.png" alt="logo">
290
								</td>
291
								<td class="text_auth_welcom">
292
									<?php echo $l_login1; ?>
293
								</td>
294
							</tr>
295
							<tr>
296
								<td class="text_auth">
297
									<?php echo $l_welcome; ?>
298
									<br><span id="userName"></span>
299
								</td>
300
							</tr>
301
							<tr>
302
								<td class="alert">
1878 raphael.pi 303
									<?php if(isset($a_connection))echo $a_connection; ?>
737 franck 304
								</td>
305
							</tr>
306
							<tr>
307
								<td colspan="2" align="center" class="link_logout">
308
									<a href="#" onclick="return logoutWithConfirmation('<?php echo $l_logout_question;?>');" class="lien_deco"><?php echo $l_logout; ?></a>
309
								</td>
310
							</tr>
311
						</table>
734 richard 312
					</td>
313
				</tr>
528 stephane 314
<!--tr id="connectRow">
315
<td id="statusMessageLabel" class="chilliLabel"><strong><?php echo $l_state_label; ?></strong></td>
316
<td id="statusMessage" class="chilliValue">Connected</td>
317
</tr-->
318
<!--tr id="sessionIdRow">
319
<td id="sessionIdLabel" class="chilliLabel"><strong><?php echo $l_session_id_label; ?></strong></td>
320
<td id="sessionId" class="chilliValue"><?php echo $l_not_available; ?></td>
321
</tr-->
734 richard 322
				<tr id="sessionTimeoutRow">
323
					<td id="sessionTimeoutLabel" class="chilliLabel"><?php echo $l_max_session_time_label; ?></td>
324
					<td id="sessionTimeout" class="chilliValue"><?php echo $l_not_available; ?></td>
325
				</tr>
326
				<tr id="idleTimeoutRow">
327
					<td id="idleTimeoutLabel" class="chilliLabel"><?php echo $l_max_idle_time_label; ?></td>
328
					<td id="idleTimeout" class="chilliValue"><?php echo $l_not_available; ?></td>
329
				</tr>
330
				<tr id="startTimeRow">
331
					<td id="startTimeLabel" class="chilliLabel"><?php echo $l_start_time_label; ?></td>
332
					<td id="startTime" class="chilliValue"><?php echo $l_not_available; ?></td>
333
				</tr>
334
				<tr id="sessionTimeRow">
335
					<td id="sessionTimeLabel" class="chilliLabel"><?php echo $l_session_time_label; ?></td>
336
					<td id="sessionTime" class="chilliValue"><?php echo $l_not_available; ?></td>
337
				</tr>
338
				<tr id="idleTimeRow">
339
					<td id="idleTimeLabel" class="chilliLabel"><?php echo $l_idle_time_label; ?></td>
340
					<td id="idleTime" class="chilliValue"><?php echo $l_not_available; ?></td>
341
				</tr>
342
				<tr id="inputOctetsRow">
343
					<td id="inputOctetsLabel" class="chilliLabel"><?php echo $l_downloaded_label; ?></td>
344
					<td id="inputOctets" class="chilliValue"><?php echo $l_na; ?></td>
345
				</tr>
346
				<tr id="outputOctetsRow">
347
					<td id="outputOctetsLabel" class="chilliLabel"><?php echo $l_uploaded_label; ?></td>
348
					<td id="outputOctets" class="chilliValue"><?php echo $l_na; ?></td>
349
				</tr>
725 stephane 350
<!--tr id="originalURLRow">
734 richard 351
<td id="originalURLLabel" class="chilliLabel"><?php echo $l_original_url_label; ?></td>
528 stephane 352
<td id="originalURL" class="chilliValue"><?php echo $l_na; ?></td>
725 stephane 353
</tr-->
734 richard 354
				<tr>
355
					<td colspan=2 id="conHistoryLabel" class="chilliLabel"><?php echo $l_conn_history; ?></td>
356
				</tr>
357
				<tr id="conHistoryRow">
358
					<td colspan=2 id="conHistory" class="chilliValue"><?php echo $connection_history; ?></td>
359
				</tr>
360
			</table>
361
		</div>
362
		<div id="waitPage">
363
			<table id="waitTable">
364
				<tr>
365
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
366
					<td><p class="text_auth"><img src="./images/wait.gif" width="16" height="16" class="wait" alt="<?php echo $l_wait; ?>"><?php echo $l_wait; ?></p></td>
367
				</tr>
368
			</table>
369
		</div>
370
		<div id="errorPage">
371
			<table id="errorTable">
372
				<tr>
373
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
374
					<td><span id="errorMessage"><?php echo $l_error; ?></span></td>
375
				</tr>
376
			</table>
377
		</div>
378
		</div>
528 stephane 379
<!--div id="debugPage" style="display:inline;">
380
<textarea id="debugarea" rows="20" cols="60">
381
</textarea>
734 richard 382
</div-->
383
		</div>
384
	</body>
528 stephane 385
</html>