Subversion Repositories ALCASAR

Rev

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