Subversion Repositories ALCASAR

Rev

Rev 790 | Rev 872 | 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";
73
	$l_logout_question	= "Are you sure you want to disconnect now?";	//à traduire
74
	$l_loggedout		= "Su sesión se cierra";
75
	$l_wait				= "Por favor, espere un momento ...";
76
	$l_state_label				= "State";		//à traduire
77
	$l_session_id_label			= "Session ID";	//à traduire
78
	$l_max_session_time_label	= "Max Session Time";	//à traduire
79
	$l_max_idle_time_label		= "Max Idle Time";		//à traduire
80
	$l_start_time_label			= "Start Time";	//à traduire
81
	$l_session_time_label		= "Tiempo de conexión";
82
	$l_idle_time_label			= "Idle Time";	//à traduire
83
	$l_downloaded_label			= "Downloaded";	//à traduire
84
	$l_uploaded_label			= "Uploaded";	//à traduire
85
	$l_original_url_label		= "Original URL";	//à traduire
86
	$l_not_available			= "Not available";	//à traduire
87
	$l_na						= "N/A";		//à traduire
88
	$l_error					= "error";		//à traduire
89
	$l_welcome					= "Welcome";	//à traduire
734 richard 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
}
95
else if($Language == 'de'){
734 richard 96
	$l_login1			= "Erfolgreiche Authentifizierung";
528 stephane 97
	$l_logout			= "Beenden der Verbindung";
98
	$l_logout_question	= "Are you sure you want to disconnect now?";	//à traduire
99
	$l_loggedout		= "Ihre Sitzung ist geschlossen";
100
	$l_wait				= "Bitte warten Sie einen Moment ...";
101
	$l_state_label				= "State";		//à traduire
102
	$l_session_id_label			= "Session ID";	//à traduire
103
	$l_max_session_time_label	= "Max Session Time";	//à traduire
104
	$l_max_idle_time_label		= "Max Idle Time";		//à traduire
105
	$l_start_time_label			= "Start Time";	//à traduire
106
	$l_session_time_label		= "Online-zeit";
107
	$l_idle_time_label			= "Idle Time";	//à traduire
108
	$l_downloaded_label			= "Downloaded";	//à traduire
109
	$l_uploaded_label			= "Uploaded";	//à traduire
110
	$l_original_url_label		= "Original URL";	//à traduire
111
	$l_not_available			= "Not available";	//à traduire
112
	$l_na						= "N/A";		//à traduire
113
	$l_error					= "error";		//à traduire
114
	$l_welcome					= "Welcome"; 	//à traduire
734 richard 115
	$l_conn_history				= "Your last $nb_connection_history connections";	//à traduire
116
	$l_connected 			= "logged"; //à traduire 
737 franck 117
	$l_a_connection			= "Active connection detected on LAN"; //à traduire
118
	$l_a_connection_time		= "time(s)"; //à traduire
528 stephane 119
}
120
else if($Language == 'nl'){
734 richard 121
	$l_login1			= "Succesvolle authenticatie";
528 stephane 122
	$l_logout			= "Slotkoers verbinding";
123
	$l_logout_question	= "Are you sure you want to disconnect now?";	//à traduire
124
	$l_loggedout		= "Uw sessie is gesloten";
125
	$l_wait				= "Wacht een 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 tijd";
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 == 'fr'){
734 richard 146
	$l_login1			= "Authentification r&eacute;ussie";
528 stephane 147
	$l_logout			= "Fermeture de la session";
536 franck 148
	$l_logout_question	= "Etes vous sûr de vouloir vous déconnecter?";
528 stephane 149
	$l_loggedout		= "Votre session est fermée";
150
	$l_wait				= "Patientez un instant ....";
151
	$l_state_label				= "Etat";
152
	$l_session_id_label			= "Session ID";
153
	$l_max_session_time_label	= "Temps de connexion autoris&eacute";
154
	$l_max_idle_time_label		= "Inactivit&eacute; max. autoris&eacute;e";
155
	$l_start_time_label			= "D&eacute;but de connexion";
156
	$l_session_time_label		= "Dur&eacute;e de connexion";
157
	$l_idle_time_label			= "Inactivit&eacute;";
158
	$l_downloaded_label			= "Donn&eacute;es t&eacute;l&eacute;charg&eacute;es";
159
	$l_uploaded_label			= "Donn&eacute;es envoy&eacute;es";
536 franck 160
	$l_original_url_label		= "URL demand&eacute;e";
528 stephane 161
	$l_not_available			= "Non disponible";
162
	$l_na						= "N/D";	//à traduire
163
	$l_error					= "erreur";
164
	$l_welcome					= "Bienvenue";
734 richard 165
	$l_conn_history				= "Vos $nb_connection_history derni&egrave;res connexions";
737 franck 166
	$l_connected 			= "session active";  
167
	$l_a_connection			= "Vous &ecirc;tes d&eacute;j&agrave; connect&eacute; sur le r&eacute;seau";
168
	$l_a_connection_time		= "fois";
528 stephane 169
}
170
else {
171
	$l_login1			= "Successful authentication.";
172
	$l_logout			= "Closing connection";
173
	$l_logout_question	= "Are you sure you want to disconnect now?";
174
	$l_loggedout		= "Your session is closed";
175
	$l_wait				= "Please wait a moment ...";
176
	$l_state_label				= "State";
177
	$l_session_id_label			= "Session ID";
178
	$l_max_session_time_label	= "Max Session Time";
179
	$l_max_idle_time_label		= "Max Idle Time";
180
	$l_start_time_label			= "Start Time";
181
	$l_session_time_label		= "Session Time";
182
	$l_idle_time_label			= "Idle Time";
183
	$l_downloaded_label			= "Downloaded";
184
	$l_uploaded_label			= "Uploaded";
185
	$l_original_url_label		= "Original URL";
186
	$l_not_available			= "Not available";
187
	$l_na						= "N/A";
188
	$l_error					= "error";
189
	$l_welcome					= "Welcome";
734 richard 190
	$l_conn_history				= "Your last $nb_connection_history connections";
191
	$l_connected 			= "logged"; 
737 franck 192
	$l_a_connection			= "Active connection detected on LAN";
193
	$l_a_connection_time		= "time(s)";
528 stephane 194
}
734 richard 195
 
196
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
197
if (isset($user[5])){
198
	if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
199
		include_once("/etc/freeradius-web/config.php");
200
		include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
201
 
202
		$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
203
		$link = @da_sql_pconnect($config); // on affiche pas les erreurs
204
 
205
		if ($link){
206
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
207
 
208
			if ($res){
209
				$connection_history.= "<ul>";
210
				while(($row = @da_sql_fetch_array($res,$config))){
211
					$connected = "";
212
					$start_conn = date_create($row[acctstarttime]);
737 franck 213
					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (";
214
					if ($row[acctstoptime] == "") {
215
						$connected = $l_connected;
216
					}else{
217
						$connected = secondsToDuration($row[acctsessiontime]);
218
					}
219
					$connection_history.= "$connected)</li>";
220
//					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
734 richard 221
				}
222
				$connection_history.="</ul>";
223
			}
224
		}
737 franck 225
		$sql_2 = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' AND AcctStopTime IS NULL ORDER BY AcctStartTime DESC";
226
		$link_2 = @da_sql_pconnect($config); // on affiche pas les erreurs
227
 
228
		if ($link_2){
229
			$res_2 = @da_sql_query($link_2,$config,$sql_2); // on affiche pas les erreurs
230
			$a_connection = "";
231
			if ($res_2){
232
				while(($row_2 = @da_sql_fetch_array($res_2,$config))){
233
					$a_connected = 1;
234
					if ($row_2[acctstoptime] == "") $a_connected = $a_connected + 1;
235
				}
236
				if ($a_connected > 1){
237
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time;
238
				}
239
			}
240
		}
734 richard 241
	}
242
}
528 stephane 243
?>
244
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
245
<html lang="fr">
246
<!-- written by steweb57 -->
734 richard 247
	<head>
248
		<title>Alcasar - <?php echo $organisme; ?></title>
249
		<meta http-equiv="Cache-control" content="no-cache">
250
		<meta http-equiv="Pragma" content="no-cache">
251
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
252
		<script type="text/javascript" src="./js/ChilliLibrary.js"></script>
253
		<script type="text/javascript" src="./js/statusControler.js"></script>
254
		<link type="text/css" href="./css/status.css" rel="stylesheet">
255
	</head>
256
	<body>
257
		<div id="Chilli">
258
		<div id="locationName"></div>
259
		<div id="chilliPage">
260
		<div id="loggedOutPage" class="c1">
261
			<table id="disconnectTable">
262
				<tr>
263
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
264
					<td><p class="text_auth"><?php echo $l_loggedout; ?></p></td>
265
				</tr>
266
			</table>
267
		</div>
268
		<div id="statusPage" class="c1">
269
			<table border="0" id="statusTable">
270
				<tr>
737 franck 271
					<td colspan="2">
272
						<table border="0" cellpadding="0" cellspacing="0" width="100%">
273
							<tr>
274
								<td valign="top" rowspan="4">
275
									<img height="150" src="./images/logo-alcasar.png" alt="logo">
276
								</td>
277
								<td class="text_auth_welcom">
278
									<?php echo $l_login1; ?>
279
								</td>
280
							</tr>
281
							<tr>
282
								<td class="text_auth">
283
									<?php echo $l_welcome; ?>
284
									<br><span id="userName"></span>
285
								</td>
286
							</tr>
287
							<tr>
288
								<td class="alert">
289
									<?php echo $a_connection; ?>
290
								</td>
291
							</tr>
292
							<tr>
293
								<td colspan="2" align="center" class="link_logout">
294
									<a href="#" onclick="return logoutWithConfirmation('<?php echo $l_logout_question;?>');" class="lien_deco"><?php echo $l_logout; ?></a>
295
								</td>
296
							</tr>
297
						</table>
734 richard 298
					</td>
299
				</tr>
528 stephane 300
<!--tr id="connectRow">
301
<td id="statusMessageLabel" class="chilliLabel"><strong><?php echo $l_state_label; ?></strong></td>
302
<td id="statusMessage" class="chilliValue">Connected</td>
303
</tr-->
304
<!--tr id="sessionIdRow">
305
<td id="sessionIdLabel" class="chilliLabel"><strong><?php echo $l_session_id_label; ?></strong></td>
306
<td id="sessionId" class="chilliValue"><?php echo $l_not_available; ?></td>
307
</tr-->
734 richard 308
				<tr id="sessionTimeoutRow">
309
					<td id="sessionTimeoutLabel" class="chilliLabel"><?php echo $l_max_session_time_label; ?></td>
310
					<td id="sessionTimeout" class="chilliValue"><?php echo $l_not_available; ?></td>
311
				</tr>
312
				<tr id="idleTimeoutRow">
313
					<td id="idleTimeoutLabel" class="chilliLabel"><?php echo $l_max_idle_time_label; ?></td>
314
					<td id="idleTimeout" class="chilliValue"><?php echo $l_not_available; ?></td>
315
				</tr>
316
				<tr id="startTimeRow">
317
					<td id="startTimeLabel" class="chilliLabel"><?php echo $l_start_time_label; ?></td>
318
					<td id="startTime" class="chilliValue"><?php echo $l_not_available; ?></td>
319
				</tr>
320
				<tr id="sessionTimeRow">
321
					<td id="sessionTimeLabel" class="chilliLabel"><?php echo $l_session_time_label; ?></td>
322
					<td id="sessionTime" class="chilliValue"><?php echo $l_not_available; ?></td>
323
				</tr>
324
				<tr id="idleTimeRow">
325
					<td id="idleTimeLabel" class="chilliLabel"><?php echo $l_idle_time_label; ?></td>
326
					<td id="idleTime" class="chilliValue"><?php echo $l_not_available; ?></td>
327
				</tr>
328
				<tr id="inputOctetsRow">
329
					<td id="inputOctetsLabel" class="chilliLabel"><?php echo $l_downloaded_label; ?></td>
330
					<td id="inputOctets" class="chilliValue"><?php echo $l_na; ?></td>
331
				</tr>
332
				<tr id="outputOctetsRow">
333
					<td id="outputOctetsLabel" class="chilliLabel"><?php echo $l_uploaded_label; ?></td>
334
					<td id="outputOctets" class="chilliValue"><?php echo $l_na; ?></td>
335
				</tr>
725 stephane 336
<!--tr id="originalURLRow">
734 richard 337
<td id="originalURLLabel" class="chilliLabel"><?php echo $l_original_url_label; ?></td>
528 stephane 338
<td id="originalURL" class="chilliValue"><?php echo $l_na; ?></td>
725 stephane 339
</tr-->
734 richard 340
				<tr>
341
					<td colspan=2 id="conHistoryLabel" class="chilliLabel"><?php echo $l_conn_history; ?></td>
342
				</tr>
343
				<tr id="conHistoryRow">
344
					<td colspan=2 id="conHistory" class="chilliValue"><?php echo $connection_history; ?></td>
345
				</tr>
346
			</table>
347
		</div>
348
		<div id="waitPage">
349
			<table id="waitTable">
350
				<tr>
351
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
352
					<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>
353
				</tr>
354
			</table>
355
		</div>
356
		<div id="errorPage">
357
			<table id="errorTable">
358
				<tr>
359
					<td><img height="150" src="./images/logo-alcasar.png" alt="logo"></td>
360
					<td><span id="errorMessage"><?php echo $l_error; ?></span></td>
361
				</tr>
362
			</table>
363
		</div>
364
		</div>
528 stephane 365
<!--div id="debugPage" style="display:inline;">
366
<textarea id="debugarea" rows="20" cols="60">
367
</textarea>
734 richard 368
</div-->
369
		</div>
370
	</body>
528 stephane 371
</html>