Location: PHPKode > projects > WaveWatcher > wavewatcher3/html/clientpop.php
<?
/****************************************************************************
 * Name:		clientpop.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 the window was opened from monitor.php
if($HTTP_GET_VARS)
{
	$connection_id = $HTTP_GET_VARS["connection_id"];
 	$locsig_active =1;
        $remnoi_active =0;
        $remsig_active =0;
        $locnoi_active =1;
}

//the page was posted, and the database should be updated
elseif($HTTP_POST_VARS)
{
        $locsig_active = $HTTP_POST_VARS["locsig_active"];
        $remsig_active = $HTTP_POST_VARS["remsig_active"];
        $locnoi_active = $HTTP_POST_VARS["locnoi_active"];
        $remnoi_active = $HTTP_POST_VARS["remnoi_active"];
        $alarm_refreshed = $HTTP_POST_VARS["alarm_refreshed"];
	if($locsig_active =="on"){
		$locsig_active = 1;
	}
	else{
		$locsig_active=0;
	}
 if($remsig_active =="on"){
                $remsig_active = 1;
        }
        else{
                $remsig_active=0;
        }
	 if($locnoi_active =="on"){
                $locnoi_active = 1;
        }
        else{
                $locnoi_active=0;
        }
	 if($remnoi_active =="on"){
                $remnoi_active = 1;
        }
        else{
                $remnoi_active=0;
        }
//the page was posted, and the database should be updated
if($HTTP_POST_VARS && $user->IsAdmin() && ($alarm_refreshed != ""))
{
	$connection_id = $HTTP_POST_VARS["connection_id"];
	$alias = $HTTP_POST_VARS["alias"];
	$sig_alarm_level = $HTTP_POST_VARS["sig_alarm_level"];
	$sig_alarm_active = $HTTP_POST_VARS["sig_alarm_active"];
	$noise_alarm_level = $HTTP_POST_VARS["noise_alarm_level"];
	$noise_alarm_active = $HTTP_POST_VARS["noise_alarm_active"];

	if($sig_alarm_active != "")
		$sig_alarm_active = "Y";
	else
		$sig_alarm_active = "N";

	if($noise_alarm_active != "")
		$noise_alarm_active = "Y";
	else
		$noise_alarm_active = "N";

	$network->SetClientDetails($connection_id, $alias, $sig_alarm_level, $noise_alarm_level, $sig_alarm_active, $noise_alarm_active);
	$parent_window_location_script = "window.opener.Update();\n";
	$window_location_script = "window.location = \"clientpop.php?connection_id=$connection_id\"\n";
}
}
else
	header("Location: index.php");

$result = $network->GetClientDetails($connection_id);
List($mac, $if_name, $alias, $sig_alarm_level, $noise_alarm_level, $sig_alarm_active, $noise_alarm_active, $locsig, $locnoi, $remsig, $remnoi, $status, $node_name) = $network->FetchRow($result);

if($sig_alarm_active == "Y")
	$sig_alarm_active_check = "checked";
else
	$sig_alarm_active_check = "";

if($noise_alarm_active == "Y")
	$noise_alarm_active_check = "checked";
else
	$noise_alarm_active_check = "";

//Check if the client exists. if it doesnt the client should close this window.
if($network->ClientExists($connection_id) == false)
	$client_removed_script = "window.opener.location = \"monitor.php\";\nwindow.close();\n";
else
	$client_removed_script = "";

//Set the page title
if($alias != "")
	$title = $alias;
elseif($if_name != "")
	$title = $if_name;
else
	$title = $mac;

?>
<html>
<head>
<title><?=$title?></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">
	<?=$parent_window_location_script?>
	<?=$window_location_script?>
	<?=$client_removed_script?>
	function SigNoiHistoryPopup(mode, connection_id, xpos, locsig_active, remsig_active, locnoi_active, remnoi_active)
	{
		window.open("graphpop.php?graphtype=signoi&connection_id=" + connection_id + "&mode=" + mode + "&xpos=" + xpos + "&locsig_active=" + locsig_active + "&remsig_active=" + remsig_active + "&locnoi_active=" + locnoi_active + "&remnoi_active=" + remnoi_active,"_blank", "height=310,width=470,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no");
	}

	function Report(connection_id)
	{
		window.open("clientreport.php?connection_id=" + connection_id, "_blank");
	}

	function Change()
	{
		document.change.submit;
	}

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

	function ConfirmRemoveClient(connection_id)
	{
		if(confirm("Are you sure you want to remove the client?"))
		{
			window.opener.RemoveClient(0, 0, connection_id);
			window.close();
		}		
	}

	function Update()
	{
		window.opener.Update();
		window.close();
	}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<?
	if($user->IsAdmin())
		print "<form name=\"change\" method=\"post\" action=\"clientpop.php\">";
?>
<table width="420" border="0">
	<?
		print "<tr>";
		print "<td width=\"120\" bgcolor=\"#F2F2F2\">Alias:</td>";
		if($user->IsAdmin())
			print "<td width=\"300\"><input name=\"alias\" type=text value=\"$alias\"></td>";
		else
			print "<td width=\"300\">$alias</td>";
		print "</tr>";
		if($locsig==0){
                        $locsig="---";
                }
                if($remsig==0){
                        $remsig="---";
                }
                if($locnoi==0){
                        $locnoi="---";
                }
                if($remnoi==0){
                        $remnoi="---";
                }
	?>
	<tr> 
		<td width="120" bgcolor="#F2F2F2">Interface name</td>
		<td width="300"><?=$if_name?><?=$db?></td>
	</tr>
	<tr>
		<td width="120" bgcolor="#F2F2F2">MAC address</td>
		<td width="300"><?=$mac?></td>
	</tr>
	<tr> 
		<td width="120" bgcolor="#F2F2F2">Local signal</td>
		<td width="25" align="right"><?=$locsig?></td>
	</tr>
	<tr> 
		<td width="120" bgcolor="#F2F2F2">Remote signal</td>
		<td width="25" align="right"><?=$remsig?></td>
	</tr>
	<tr> 
		<td width="120" bgcolor="#F2F2F2">Local noise</td>
		<td width="25" align="right"><?=$locnoi?></td>
	</tr>
	<tr>
		<td width="120" bgcolor="#F2F2F2">Remote noise</td>
		<td width="25" align="right"><?=$remnoi?></td>
	</tr>

	<?
		print "<tr>";
		print "<td width=\"120\" bgcolor=\"#F2F2F2\">Signal alarm level</td>";
		if($user->IsAdmin())
			print "<td width=\"300\"><input name=\"sig_alarm_level\" type=text size=\"3\" value=\"$sig_alarm_level\"><input type=\"checkbox\" name=\"sig_alarm_active\" $sig_alarm_active_check>active?</td>";
		else
			print "<td width=\"25\" align=\"right\">$sig_alarm_level</td>";
		print "</tr>";
		print "<tr>";
		print "<td width=\"120\" bgcolor=\"#F2F2F2\">Noise alarm level</td>";
		if($user->IsAdmin())
			print "<td width=\"300\"><input name=\"noise_alarm_level\" type=text size=\"3\" value=\"$noise_alarm_level\"><input type=\"checkbox\" name=\"noise_alarm_active\" $noise_alarm_active_check>active?</td>";
		else
			print "<td width=\"25\" align=\"right\">$noise_alarm_level</td>";
		print "</tr>";
	
		print "<tr>";
		print "<td width=\"120\">";
		print "<input type=\"button\" onCLick=\"Javascript: Refresh()\" value=\"Reload page\">";
		print "</td>";
		if($user->IsAdmin())
		{
			print "<td>";
			print "<input type=\"submit\" value=\"Update settings\">";
			print "</td>";
			print "</tr>";
			print "<tr>";
			print "<td width=\"120\">";
			print "<td>";
			print "<input type=\"button\" onCLick=\"Javascript: ConfirmRemoveClient($connection_id)\" value=\"Remove client\">";
			print "</td>";
			print "</tr>";
		}
	
	if($user->IsAdmin())
	{
		print "<input type=\"hidden\" name=\"connection_id\" value=\"$connection_id\">";
                print "<input type=\"hidden\" name=\"alarm_refreshed\" value=\"1\">";
	}
print "</form>";
?>
<tr>
                <td width="120" bgcolor="#F2F2F2">Signal / noise history</td>
                <td width="300"><a href="#" OnClick="Javascript: SigNoiHistoryPopup(1, <?=$connection_id?>, 24, <?=$locsig_active?>, <?=$remsig_active?>, <?=$locnoi_active?>, <?=$remnoi_active?>);"> 24 hours</a> , <a href="#" OnClick="Javascript: SigNoiHistoryPopup(2, <?=$connection_id?>, 7, <?=$locsig_active?>, <?=$remsig_active?>, <?=$locnoi_active?>, <?=$remnoi_active?>);">1 week</a> , <a href="#" OnClick="Javascript: SigNoiHistoryPopup(3, <?=$connection_id?>, 30, <?=$locsig_active?>, <?=$remsig_active?>, <?=$locnoi_active?>, <?=$remnoi_active?>);">1 month (30 days)</a></td>
        </tr>
        <?
	if($locsig_active ==1)$locsig_active_flag = "checked";
        if($remsig_active ==1)$remsig_active_flag = "checked";
        if($locnoi_active ==1)$locnoi_active_flag = "checked";
        if($remnoi_active ==1)$remnoi_active_flag = "checked";
	if($locsig_active ==0)$locsig_active_flag = "";
        if($remsig_active ==0)$remsig_active_flag = "";
        if($locnoi_active ==0)$locnoi_active_flag = "";
        if($remnoi_active ==0)$remnoi_active_flag = "";
        print"<tr><td><form name=\"changegraph\" method=\"post\" action=\"clientpop.php\">";
	// 4 hidden values to take care of unchecked checkboxes
	print "<input type=\"hidden\" name=\"locsig_active\" value=\"$locsig_active_flag\">";
	print "<input type=\"hidden\" name=\"remsig_active\" value=\"$remsig_active_flag\">";
	print "<input type=\"hidden\" name=\"locnoi_active\" value=\"$locnoi_active_flag\">";
	print "<input type=\"hidden\" name=\"remnoi_active\" value=\"$remnoi_active_flag\">";
        print "<input type=\"checkbox\" name=\"locsig_active\" $locsig_active_flag>local signal?<br>";
        print "<input type=\"checkbox\" name=\"remsig_active\" $remsig_active_flag>remote signal?</td>";
        print "<td>";
        print "<input type=\"checkbox\" name=\"locnoi_active\" $locnoi_active_flag>local noise?<br>";
        print "<input type=\"checkbox\" name=\"remnoi_active\" $remnoi_active_flag>remote noise?</td></tr>";
        print "<input type=\"hidden\" name=\"connection_id\" value=\"$connection_id\">";
 	print "<input type=\"hidden\" name=\"graph_refreshed\" value=\"Y\">";
	print "<tr><td><input type=\"submit\" value=\"Change graph\">";

	print "</form></td></tr>";
        ?>	
</body>
</html>
Return current item: WaveWatcher