Subversion Repositories ALCASAR

Rev

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