Subversion Repositories ALCASAR

Rev

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