Location: PHPKode > projects > WaveWatcher > wavewatcher3/html/nodepop.php
<?
/****************************************************************************
 * Name:		nodepop.php
/***************************************************************************/
require_once("../classes/network.php");
require_once("../classes/user.php");
session_start();										//Start session

$user = new User();
$network = new Network();

//If the user hasn't logged in then we should send him to the loginpage.
if (!$user->IsLoggedIn())
	header("Location: index.php");

if ($HTTP_GET_VARS)
{
	$node_id = $HTTP_GET_VARS["node_id"];
}
else
	header("Location: index.php");

if($node_id == 0)
	header("Location: index.php");

$result = $network->GetNodeDetails($node_id);
if(List($node_type_id, $network_id, $parent_node_id, $node_name, $node_pass, $node_ip, $location, $monitor, $log, $signal, $alarm, $node_type_name, $network_name) = $network->FetchRow($result))
{
	$parent_node_name = $network->GetNodeName($parent_node_id);

	$clients_up = $network->GetClientsUpCount($node_id);
	$clients_dn = $network->GetClientsDnCount($node_id);
	$clients_wn = $network->GetClientsWnCount($node_id);

	$status = $network->GetNodeStatus($node_id);
	if($status == 0)
		$status_text = "Up";
	else if($status == 1)
		$status_text = "Down";
	else if($status == 2)
		$status_text = "Unknown";

	$interfaces = $network->GetNumberOfInterfaces($node_id);
}

function PrintGraphs($node_id, $interfaces)
{
	print "<tr>";
	print "<td width=\"120\" bgcolor=\"#F2F2F2\">Uptime graph</td>";
	print "<td width=\"200\">";
	print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryGraphPopup($node_id, 2, 1, 24);\">24 hours</a>, ";
	print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryGraphPopup($node_id, 2, 2, 7);\">1 week</a>, ";
	print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryGraphPopup($node_id, 2, 3, 30);\">1 month (30 days)</a>";
	print "</td>";
	print "</tr>";

	print "<tr>";
        print "<td width=\"120\" bgcolor=\"#F2F2F2\">Uptime table</td>";
        print "<td width=\"200\">";
        print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryTablePopup($node_id, 1);\">24 hours</a>, ";
        print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryTablePopup($node_id, 7);\">1 week</a>, ";
        print "<a href=\"#\" OnClick=\"Javascript: UptimeHistoryTablePopup($node_id, 30);\">1 month (30 days)</a>";
        print "</td>";
        print "</tr>";

	for($i=1; $i<=$interfaces; $i++)
	{
		print "<tr>";
		print "<td width=\"120\" bgcolor=\"#F2F2F2\">Data rate (interface "."$i".")</td>";
		print "<td width=\"200\">";
		print "<a href=\"#\" OnClick=\"Javascript: DataRateGraphPopup($node_id, $i, 1, 24);\">24 hours</a>, ";
		print "<a href=\"#\" OnClick=\"Javascript: DataRateGraphPopup($node_id, $i, 2, 7);\">1 week</a>, ";
		print "<a href=\"#\" OnClick=\"Javascript: DataRateGraphPopup($node_id, $i, 3, 30);\">1 month (30 days)</a>";
		print "</td>";
		print "</tr>";
	}
        	for($i=1; $i<=$interfaces; $i++)
	{
		print "<tr>";
		print "<td width=\"120\" bgcolor=\"#F2F2F2\">Data total (interface "."$i".")</td>";
		print "<td width=\"200\">";
		print "<a href=\"#\" OnClick=\"Javascript: DataTotalPopup($node_id, $i, 1, 24);\">24 hours</a>, ";
		print "<a href=\"#\" OnClick=\"Javascript: DataTotalPopup($node_id, $i, 2, 7);\">1 week</a>, ";
		print "<a href=\"#\" OnClick=\"Javascript: DataTotalPopup($node_id, $i, 3, 30);\">1 month (30 days)</a>";
		print "</td>";
		print "</tr>";
	}
}

?>
<html>
<head>
<title><?=$node_name?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/style1.css" rel="styleSheet" type="text/css">
<script language="JavaScript">

	function DataRateGraphPopup(node_id, inter, mode, xpos)
	{
		window.open("graphpop.php?graphtype=datarate&node_id=" + node_id + "&interface=" + inter + "&mode=" + mode + "&xpos=" + xpos, "_blank", "height=250,width=470,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no");
	}
        function DataTotalPopup(node_id, inter, mode, xpos)
	{
		window.open("datatotalpop.php?graphtype=datatotal&node_id=" + node_id + "&interface=" + inter + "&mode=" + mode + "&xpos=" + xpos, "_blank", "height=350,width=400,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
	}
	function UptimeHistoryGraphPopup(node_id, drawmode, mode, xpos)
	{
		window.open("graphpop.php?graphtype=uptime&node_id=" + node_id + "&drawmode=" + drawmode + "&mode=" + mode + "&xpos=" + xpos, "_blank", "height=120,width=470,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no");
	}
	function UptimeHistoryTablePopup(node_id, days)
        {
                window.open("tablepop.php?node_id=" + node_id + "&days=" + days, "_blank", "height=470,width=470,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");
        }
	function Report(node_id)
	{
		window.open("nodereport.php?node_id=" + node_id, "_blank");
	}

	function Refresh()
	{
		window.location = "nodepop.php?node_id=<?=$node_id?>";
	}

</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<table width="320" border="0">
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Name</td>
    <td width="200"> <?=$node_name?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">IP address</td>
    <td width="200"> <?=$node_ip?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Network</td>
    <td width="200"> <?=$network_name?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Parent node</td>
    <td width="200"> <?=$parent_node_name?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Type</td>
    <td width="200"> <?=$node_type_name?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Clients</td>
    <td width="200"> <?="$clients_up"."up, "."$clients_dn"."dn, "."$clients_wn"."wn"?></td>
  </tr>
  <tr> 
    <td width="120" bgcolor="#F2F2F2">Status</td>
    <td width="200"> <?=$status_text?></td>
  </tr>
  <tr>
    <td width="120" bgcolor="#F2F2F2">Location</td>
    <td width="200"> <?=$location?></td>
  </tr>
  <?PrintGraphs($node_id, $interfaces)?>
  <tr>
    <td width="100" bgcolor="#F2F2F2"></td>
    <td width="200"> <a href="#" OnClick="Javascript: Report(<?=$node_id?>);">Report</a></td>
  </tr>
  <tr>
    <td width="100" bgcolor="#FFFFFF"></td>
    <td width="200"><input type="button" onCLick="Javascript: Refresh()" value="Reload data"></td>
  </tr>
</table>
</body>
</html>
Return current item: WaveWatcher