Location: PHPKode > projects > RosInfo > rosinfo-1.30/signal.php
<? 
include_once('header.php');
include_once('include/config.inc');
include_once('include/functions.php');
include_once('graphs.php');
include_once("include/db.inc");
//pet template
include_once('include/pet.class.php');

////////////////////////////////
// HEADER
////////////////////////////////
$id = isset($_REQUEST["id"]) ? $_REQUEST["id"] : "-1";
if ($id == -1) die ("Error" . " File: " . __FILE__ . " on line: " . __LINE__);

$time_h = isset($_GET["time_h"]) ? $_GET["time_h"] : "0";
$time_d = isset($_GET["time_d"]) ? $_GET["time_d"] : "0";
$time_m = isset($_GET["time_m"]) ? $_GET["time_m"] : "0";

if($time_h == 0 && $time_d == 0 && $time_m == 0)
  $time_d = 1;

$showall = isset($_GET["showall"]) ? $_GET["showall"] : "0";
$customheader='<br/>Show:
  <a href="signal.php?id='.$id.'&amp;time_h='.$time_h.'&amp;time_d='.$time_d.'&amp;time_m='.$time_m.'&amp;showall=1">All</a>,
  <a href="signal.php?id='.$id.'&amp;time_h='.$time_h.'&amp;time_d='.$time_d.'&amp;time_m='.$time_m.'">Active only</a>
  ';
graphs_header("Signal", "signal.php", "&amp;showall=".$showall, $customheader);


$pet = new pet('signal.tpl');

$res = mysql_query("SELECT * FROM hosts WHERE id=".$id.";", GetMyConnection());
$arr = mysql_fetch_array($res);
if (!$arr) die ("Error" . " File: " . __FILE__ . " on line: " . __LINE__);

$pet->id = $id;
$pet->time_h = $time_h;
$pet->time_d = $time_d;
$pet->time_m = $time_m;

$timestamp = end(getdate());
$timestamp -= 60 * 60 * $time_h;
$timestamp -= 60 * 60 * 24 * $time_d;
$timestamp -= 60 * 60 * 24 * 30 * $time_m;

$lastinterface="";
$files = scandir($rrd_directory);
foreach($files as $i=>$file)
{
  if (strstr($file, "rosinfo-signal-"))
  {
    $file_r = explode("-", $file);
    $id_file = $file_r[2];

    if (strcmp($id_file, $id) == 0)
    {
      $interface = $file_r[3];
      $interface_printable = convert_alphabet_rev($interface);
      
      $mac = reset(explode(".", $file_r[4]));
      //$rrdtimestamp = filemtime($rrd_directory.$file);
      /*if ($phprrd)
      {
        $rrdtimestamp = rrd_last($rrd_directory.$file);
      }
      else
      {
        $cmd = "/usr/bin/rrdtool last ".$rrd_directory.$file;
        echo $cmd;
        $rrdtimestamp = exec($cmd);   
      }  */
      
      if (($showall == 1) || ($timestamp <= filemtime($rrd_directory.$file)))
      {
        if (strcmp($lastinterface, $interface) != 0)
        {
          $pet_loop = $pet->addLoop('array');
          $pet_loop->interface = $interface;
          $pet_loop->interface_printable = $interface_printable;
          $pet_loop->ip = $arr["ip"];
          $lastinterface = $interface;
        }
        $pet_loop_inner = $pet_loop->addLoop('array_inner');
        $pet_loop_inner->id = $id;
        $pet_loop_inner->interface_printable = $interface_printable;
        $pet_loop_inner->description = $arr["description"];
        $pet_loop_inner->interface = $interface;
        $pet_loop_inner->mac = $mac;	
        $pet_loop_inner->timestamp = $timestamp;	
        $pet_loop_inner->ip = $arr["ip"];
      }
    }
  }
}

echo $pet->fetch();
include_once('footer.php');
?>      
Return current item: RosInfo