Subversion Repositories ALCASAR

Rev

Rev 1023 | Rev 1030 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1023 Rev 1026
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: status.php 1023 2013-02-06 01:20:06Z franck $
2
# $Id: status.php 1026 2013-02-06 22:55:43Z richard $
3
#
3
#
4
# status.php for Alcasar captive portal
4
# status.php for Alcasar captive portal
5
# by steweb57 & Rexy
5
# by steweb57 & Rexy
6
# 
6
# 
7
/****************************************************************
7
/****************************************************************
Line 42... Line 42...
42
 
42
 
43
$remote_ip = ($_SERVER['REMOTE_ADDR']);
43
$remote_ip = ($_SERVER['REMOTE_ADDR']);
44
$connection_history =  "";
44
$connection_history =  "";
45
$nb_connection_history = 3;
45
$nb_connection_history = 3;
46
 
46
 
47
//On récupère le nom de connexion de la session active. //on a l'info en ajax, mais trop tard -> A MODIFIER
47
//On récupère le nom de connexion de la session active. on attend que chilli ait mis à jour ses tables
-
 
48
sleep (1);
48
exec ("sudo /usr/sbin/chilli_query list | grep 'pass' | egrep -w '($remote_ip)'" , $tab);
49
exec ("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab);
49
$user = explode (" ", $tab[0]);
50
$user = explode (" ", $tab[0]);
50
 
51
 
51
#### Affichage des 3 dernières connexions de $user[5]
52
#### Affichage des 3 dernières connexions de $user[5]
52
function secondsToDuration($seconds = null){
53
function secondsToDuration($seconds = null){
53
	if ($seconds == null) return "";
54
	if ($seconds == null) return "";
Line 230... Line 231...
230
		
231
		
231
		if ($link){
232
		if ($link){
232
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
233
			$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
233
			
234
			
234
			if ($res){
235
			if ($res){
235
				$connection_history.= "<ul>";
236
				$a_connection = ""; $a_connected=0; $connection_history.= "<ul>";
236
				while(($row = @da_sql_fetch_array($res,$config))){
237
				while(($row = @da_sql_fetch_array($res,$config))){
237
					$connected = "";
238
					$connected = "";
238
					$start_conn = date_create($row['acctstarttime']);
239
					$start_conn = date_create($row['acctstarttime']);
239
					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (";
240
					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (";
240
					if ($row['acctstoptime'] == "") {
241
					if ($row['acctstoptime'] == "") {
241
						$connected = $l_connected;
242
						$connected = $l_connected;
-
 
243
						$a_connected = $a_connected +1;
242
					}else{
244
					}else{
243
						$connected = secondsToDuration($row['acctsessiontime']);
245
						$connected = secondsToDuration($row['acctsessiontime']);
244
					}
246
					}
245
					$connection_history.= "$connected)</li>";
247
					$connection_history.= "$connected)</li>";
246
//					$connection_history.="<li>".date_format($start_conn, 'd M Y - H:i:s')." - (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
-
 
247
				}
248
				}
248
				$connection_history.="</ul>";
249
				$connection_history.="</ul>";
249
			}
-
 
250
		}
-
 
251
		$sql_2 = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' AND AcctStopTime IS NULL ORDER BY AcctStartTime DESC";
-
 
252
		$link_2 = @da_sql_pconnect($config); // on affiche pas les erreurs
-
 
253
		
-
 
254
		if ($link_2){
-
 
255
			$res_2 = @da_sql_query($link_2,$config,$sql_2); // on affiche pas les erreurs
-
 
256
			$a_connection = "";
-
 
257
			if ($res_2){
-
 
258
				while(($row_2 = @da_sql_fetch_array($res_2,$config))){
-
 
259
					$a_connected = 1;
-
 
260
					if ($row_2['acctstoptime'] == "") $a_connected = $a_connected + 1;
-
 
261
				}
-
 
262
				if ($a_connected > 1){
250
				if ($a_connected > 1){
263
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time;
251
					$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time; }
264
				}
-
 
265
			}
252
			}
266
		}
253
		}
267
	}
254
	}
268
}
255
}
269
?>
256
?>