39,27 → 39,31 |
fclose($ouvre); |
|
$organisme = $conf["ORGANISM"]; |
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ""; |
|
$remote_ip = ($_SERVER['REMOTE_ADDR']); |
$connection_history = ""; |
$nb_connection_history = 3; |
|
// Wait for chilli (uptade its tables) |
//On récupère le nom de connexion de la session active. on attend que chilli ait mis à jour ses tables |
sleep (1); |
// Retrieve user info in tab $user[] |
exec ("sudo /usr/sbin/chilli_query list | grep 'pass' | grep -Ew '($remote_ip)'" , $tab); |
if(isset($tab[0])) |
$user = explode (" ", $tab[0]); |
|
#### Time conversion |
#### Affichage des 3 dernières connexions de $user[5] |
function secondsToDuration($seconds = null){ |
if ($seconds == null) return ""; |
|
$temp = $seconds % 3600; |
$time[0] = ( $seconds - $temp ) / 3600 ; // hours |
$time[2] = $temp % 60 ; // seconds |
$time[1] = ( $temp - $time[2] ) / 60; // minutes |
|
return $time[0]." h ".$time[1]." m ".$time[2]." s"; |
} |
|
|
|
# Choice of language |
//reste quelques traductions à faire |
$Language = 'en'; |
260,15 → 264,18 |
$l_a_connection_time = "active connections on the network"; |
} |
|
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement |
if (isset($user[5])){ |
// Retrieve the last connections |
if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){ |
include_once("/etc/freeradius-web/config.php"); |
include_once("./acc/manager/lib/sql/drivers/mysql/functions.php"); |
|
$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history"; |
$link = @da_sql_pconnect($config); |
$link = @da_sql_pconnect($config); // on affiche pas les erreurs |
|
if ($link){ |
$res = @da_sql_query($link,$config,$sql); |
$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs |
|
if ($res){ |
$a_connection = ""; $a_connected=0; $connection_history.= "<ul>"; |
while(($row = @da_sql_fetch_array($res,$config))){ |
288,22 → 295,17 |
$a_connection = $l_a_connection." ".$a_connected." ".$l_a_connection_time; } |
} |
} |
// Retrieve first name & last name |
// $search = $login; $search_IN = 'username'; // is user in database ? |
// if (is_file("../lib/sql/find.php")) |
// include("../lib/sql/find.php"); |
// if (isset ($found_users)) // user is in database |
// { |
// if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn) |
// include("../lib/sql/user_info.php"); |
// } |
// if (! isset ($cn)){ $cn='-';} |
//store the user @IP in a file (to test if he is still active). |
|
//store in a file user @IP who can join this page. |
$filename='/var/tmp/havp/current_users.txt'; |
$change_me = 1; //avoid duplicate user @IP |
//change me avoid duplicate user @IP |
$change_me = 1; |
//check if filename exists |
if(file_exists($filename)){ |
$fichier = fopen($filename, "r"); |
$content = file($filename); |
|
//if file is empty, we put user @IP in it. |
if(empty($content)) |
{ |
file_put_contents($filename, $_SERVER['REMOTE_ADDR']); |
310,7 → 312,7 |
} |
else |
{ |
// if we found duplicate IP, we will not write user @IP (just set change_me = 0) |
//if we found duplicate IP, it will not write user @IP in filename (set change_me = 0) |
foreach($content as $line){ |
$line = preg_replace('/\s+/', '', $line); |
if($line == $_SERVER['REMOTE_ADDR']) |
317,19 → 319,24 |
{ |
$change_me = 0; |
} |
|
} |
// if user @IP does not exist, we write it |
|
//if user @IP does not exist, we will write it in filename |
if($change_me) |
{ |
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL , FILE_APPEND); |
} |
} |
|
} |
else |
{ |
//we create filename and we write user @IP. |
//we create filename and we put user @IP in it. |
file_put_contents($filename, $_SERVER['REMOTE_ADDR'].PHP_EOL); |
} |
|
|
} |
} |
?> |