Subversion Repositories ALCASAR

Rev

Rev 912 | Rev 958 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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