Location: PHPKode > projects > WaveWatcher > wavewatcher3/html/graphpop.php
<?
/****************************************************************************
 * Name:		graphpop.php
 * Authors:		Niklas Påhlsson, Pierre Svärd, Petter Miller, Mats Hörberg
/***************************************************************************/

require_once("../classes/user.php");
session_start();										//Start session

$user = new User();

//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)
{
	$graphtype = $HTTP_GET_VARS["graphtype"];
	if($graphtype == "signoi")
	{
		$connection_id = $HTTP_GET_VARS["connection_id"];
		$mode = $HTTP_GET_VARS["mode"];
		$xpos = $HTTP_GET_VARS["xpos"];
		$scroll=$HTTP_GET_VARS["scroll"];
		if($scroll==""){
			$scroll=0;
		}
		$graph_src = "graph/signoi.php?connection_id=".$connection_id."&mode=".$mode."&xpos=".$xpos."&locsig_active=".$locsig_active."&remsig_active=".$remsig_active."&locnoi_active=".$locnoi_active."&remnoi_active=".$remnoi_active."&scroll=".$scroll;
	}
	elseif($graphtype == "datarate")
	{
		$node_id = $HTTP_GET_VARS["node_id"];
		$interface = $HTTP_GET_VARS["interface"];
		$mode = $HTTP_GET_VARS["mode"];
		$xpos = $HTTP_GET_VARS["xpos"];
		$scroll=$HTTP_GET_VARS["scroll"];
		if($scroll==""){
                        $scroll=0;
                }
		$graph_src = "graph/speed.php?node_id=".$node_id."&interface=".$interface."&mode=".$mode."&xpos=".$xpos."&scroll=".$scroll;
	}
	elseif($graphtype == "uptime")
	{
		$node_id = $HTTP_GET_VARS["node_id"];
		$drawmode = $HTTP_GET_VARS["drawmode"];
		$mode = $HTTP_GET_VARS["mode"];
		$xpos = $HTTP_GET_VARS["xpos"];
		$scroll=$HTTP_GET_VARS["scroll"];
		if($scroll==""){
                        $scroll=0;
                }
		$graph_src = "graph/uptime.php?node_id=".$node_id."&drawmode=".$drawmode."&mode=".$mode."&xpos=".$xpos."&scroll=".$scroll;
	}
	
}
else
	header("Location: index.php");



// Returns the browser that the user uses.
function GetBrowser()
{
	 if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || 
		(ereg("Gold", getenv("HTTP_USER_AGENT"))) || 
		(ereg("X11", getenv("HTTP_USER_AGENT"))) ||
		(ereg("Mozilla", getenv("HTTP_USER_AGENT"))) || 
		(ereg("Netscape", getenv("HTTP_USER_AGENT"))) AND 
		(!ereg("MSIE", getenv("HTTP_USER_AGENT")))) 
			return "Netscape";
	elseif(ereg("MSIE", getenv("HTTP_USER_AGENT")))
			return "MSIE";
	
	return "Other";
}
function PrintStyleTag()
{
	if (GetBrowser()!="Netscape")
	{

		print "<style>";
		print ".graph{background-image:url(img/loading.png);background-repeat:no-repeat;background-attachment:scroll;}";
		print "</style>";

	}
}

function PrintGraph($graph_src)
{
	if (GetBrowser()!="Netscape")
	{
		print "<table width=100% height=100%>";
		print "<tr>";
		print "<td class=\"graph\" valign=\"top\"><img src=\"$graph_src\"></td>";
		print "</tr>";
	}
	else
	{
		print "<div id=\"waitDiv\" style=\"position:absolute; visibility:visible\">Please wait while generating image, this could take a while.</div>";
		print "<img src=\"$graph_src\">";

		print "<script language=\"JavaScript\">";	
		print "HideLoadingText();";
		print "</script>";
	}
}
?>

<html>
	<head>
		<title>Graph</title>
		<script language="JavaScript">
			function HideLoadingText() 
			{   
				var hideItem = null;
	
				if (document.getElementById)
					hideItem = document.getElementById('waitDiv').style;
				else if (document.all) 
					hideItem = document.all['waitDiv'].style;
				else if (document.layers)
					hideItem = document.layers['waitDiv'];
				
				hideItem.visibility = 'hidden';
			}
			function Scroll(mode, connection_id, xpos, locsig_active, remsig_active, locnoi_active, remnoi_active, scroll){
				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 +"&scroll=" + scroll,"_blank", "height=310,width=470,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=no");
			}
		</script>
		<?PrintStyleTag()?>
	
	<link href="css/style1.css" rel="styleSheet" type="text/css">
	</head>
	<body>		
		<?
PrintGraph($graph_src);

$scrolldb = $scroll - 86400;
$scrolldf = $scroll + 86400;
$scrollwb = $scroll - 604800;
$scrollwf = $scroll + 604800;
$scrollmb = $scroll - 2592000;
$scrollmf = $scroll + 2592000;

if($graphtype == "signoi"){
	print"<tr><td><center><a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrolldb);\">&nbsp;&nbsp;&nbsp;<< Backwards in time 24 hours< </a> | <a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrolldf);\">> Forwards in time 24 hours >>&nbsp;&nbsp;&nbsp;&nbsp;</a></center></td></tr>";
	print"<tr><td><center><a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrollwb);\">&nbsp;<< Backwards in time one week< </a> | <a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrollwf);\">> Forwards in time one week >>&nbsp;</a></center></td></tr>";
	print"<tr><td><center><a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrollmb);\"><< Backwards in time one month< </a> | <a href=\"#\" OnClick=\"Javascript: Scroll($mode,$connection_id,$xpos,$locsig_active,$remsig_active,$locnoi_active,$remnoi_active,$scrollmf);\">> Forwards in time one month >></a></center></td></tr>";
print"</center>";
}	
?>

</body></html>
Return current item: WaveWatcher