Commit 86634428 authored by José Luis  Gutiérrez's avatar José Luis Gutiérrez Committed by Alessandro Rubini

www: ports info updates every 15 seconds

Ports info (header) was updated only in index.php. Now it is refreshed
every 15 seconds.
parent ebb5400d
......@@ -32,8 +32,16 @@ function wrs_header_ports(){
// Check whether $WRS_MANAGEMENT is set or we take the program
// by default.
if(!file_exists("/tmp/ports.conf")){
session_start();
if(empty($_SESSION['portsupdated'])){
$_SESSION['portsupdated'] = intval(shell_exec("date +%s"));
}
// Let's update endpoints info every 15 seconds.
$currenttime = intval(shell_exec("date +%s"));
$interval = $currenttime - $_SESSION['portsupdated'];
if(!file_exists("/tmp/ports.conf") || $interval>15){
$cmd = wrs_env_sh();
shell_exec("killall wr_management");
$str = shell_exec($cmd." ports");
......@@ -41,10 +49,11 @@ function wrs_header_ports(){
fwrite($fp, $str);
fclose($fp);
$ports = $str;
$_SESSION['portsupdated'] = intval(shell_exec("date +%s"));
}else{
$ports = shell_exec("cat /tmp/ports.conf");
}
$ports = explode(" ", $ports);
// We parse and show the information comming from each endpoint.
......
......@@ -4,7 +4,7 @@
<div class="page">
<div class="header" >
<!--<h1>White-Rabbit Switch Tool</h1>-->
<div class="header-ports" ><?php shell_exec("rm /tmp/ports.conf"); wrs_header_ports(); ?></div>
<div class="header-ports" ><?php wrs_header_ports(); ?></div>
<div class="topmenu">
<?php include 'topmenu.php' ?>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment