Subversion Repositories ALCASAR

Rev

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