<?php
require("../../inc/header.inc");
require("../serverStatusImprove/function.inc");
?>

<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php

$global_id=0;
function AssignID()
{
	global $global_id;
	
	$id="ID_{$global_id}";
	$global_id++;
	return $id;
}

?>

<?php
adjust_head();

adjust_title_head();
echo "<FORM NAME=\"downForm\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "$strSysStatus > Platform";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		//showHelp($helpId);
		echo "</td>";
	echo "</tr>";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "&nbsp;";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "<a href=\"plat_status.php\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();

$platID=$_REQUEST['platID'];
$subSysNo=$_REQUEST['subSysNo'];
if(0)
{
	echo "subSysNo=$subSysNo,platID=$platID<br>";
}

$config=parse_ini_file("config.ini",true);
$config_count=sizeof($config);
foreach($config as $key => $val)
{
	if($config[$key][PlatformID] == $platID)
	{
		$thisconfig=$config[$key];
		break;
	}
}

$tmpconf[PlatNo]=$platID;
$plat=GetPlatInfo($tmpconf,$subSysNo);
if(0)
{
	echo "<pre>";
	print_r($plat);
	echo "</pre>";
}
echo "<br><center><font color=\"blue\">{$thisconfig[PlatformName]}_$subSysNo platform information</font></center>";
echo "<table width=100% border=1 cellpadding=1 cellspacing=0  bordercolor=#666666 bordercolordark=#FFFFFF bgcolor=\"#ffffff\">";
echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>Status</td>";
echo "<td>";
	//platform Status
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>Refresh Time</td>";
echo "<td>";
	//Refresh Time
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>Start Time</td>";
echo "<td>";
	//Start Time
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>CPU Usage</td>";
echo "<td>";
	//CPU Usage PN
	$id=AssignID();
	$val=GetProcessLabel(0);
	echo "<input id=\"{$id}\" value=\"{$val}\" readonly type=text size=18 style=\"font-family:Arial; color:#3366aa; background-color:#ffffff; padding:0px; border-style:double; border-width:1px;height:14px;border-color:#222222;font-size:12px;\">";
	
	echo "&nbsp;";
	
	//CPU Usage Rate
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";

echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>Physical Memory</td>";
echo "<td>";
	//Physical Memory Used/Total
	$id=AssignID();
	$val=GetProcessLabel(0);
	echo "<input id=\"{$id}\" value=\"{$val}\" readonly type=text size=18 style=\"font-family:Arial; color:#3366aa; background-color:#ffffff; padding:0px; border-style:double; border-width:1px;height:14px;border-color:#222222;font-size:12px;\">";
	
	echo "&nbsp;";
	
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
	echo "&nbsp;";
	
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";

	echo "&nbsp;";
	echo "(Used/Total)";
	echo "<br>";
	
	//Physical Memory Used/Swap
	$id=AssignID();
	$val=GetProcessLabel(0);
	echo "<input id=\"{$id}\" value=\"{$val}\" readonly type=text size=18 style=\"font-family:Arial; color:#3366aa; background-color:#ffffff; padding:0px; border-style:double; border-width:1px;height:14px;border-color:#222222;font-size:12px;\">";
	
	echo "&nbsp;";
	
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
	
	echo "&nbsp;";
	
	$id=AssignID();
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";

	echo "&nbsp;";
	echo "(Used/Swap)";
	echo "<br>";
	
	
	$id=AssignID();
	echo "Buffers:";
	echo "&nbsp;";
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
	
	echo ";&nbsp;";
	
	$id=AssignID();
	echo "Cached:";
	echo "&nbsp;";
	echo "<span id=\"{$id}\" style=\"color:#000000;\">";
	echo "--";
	echo "</span>";
	
	echo "<br>";
	
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=left bgcolor=\"#E6E6E6\" width=50%>Harddisk Space</td>";
echo "<td>";
	//Harddisk, support 16 harddisk
	for($i=0;$i<16;$i++)
	{
		$id=AssignID();
		if($i==0)
			echo "<span id=\"{$id}\">";
		else
			echo "<span id=\"{$id}\" style=\"display:none;\">";
		
		$id=AssignID();
		$val=GetProcessLabel(0);
		echo "<input id=\"{$id}\" value=\"{$val}\" readonly type=text size=18 style=\"font-family:Arial; color:#3366aa; background-color:#ffffff; padding:0px; border-style:double; border-width:1px;height:14px;border-color:#222222;font-size:12px;\">";
		
		echo "&nbsp;";
		
		$id=AssignID();
		echo "<span id=\"{$id}\" style=\"color:#000000;\">";
		echo "--";
		echo "</span>";
		
		echo "&nbsp;";
		
		$id=AssignID();
		echo "<span id=\"{$id}\" style=\"color:#000000;\">";
		echo "--";
		echo "</span>";
		
		echo "&nbsp;";
		
		$id=AssignID();
		echo "<span id=\"{$id}\" style=\"color:#000000;\">";
		echo "--";
		echo "</span>";
		
		echo "<br>";
		
		echo "</span>";
		
	}

echo "</td>";
echo "</tr>";
echo "</table>";

//Remark Table
echo "<table border=\"0\" width=\"100%\" cellpadding=1 cellspacing=0>";
	echo "<tr>";
		echo "<td width=\"50%\" align=\"left\">";
		echo "Remarks:  <font color=\"blue\">Y</font> = Normal,    <font color=\"red\">N</font> = Abnormal,   -- = None.";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "<a href=\"plat_status.php\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";

adjust_content_tail();
?>

<script language="JavaScript">

function updateStatus(platID,subSysNo)
{
	var fixurl="./plat_status_detail_update.php?platID="+platID+"&subSysNo="+subSysNo;
	var browserr = navigator.appName;
	if(browserr == "Microsoft Internet Explorer")
	{
		request_oo = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		request_oo = new XMLHttpRequest();
	}
	request_oo.open("GET",fixurl,"false");

	request_oo.onreadystatechange=function()
	{ 
		checUpdateState(); 
	}
	request_oo.send(null);
	setTimeout("updateStatus('"+platID+"','"+subSysNo+"')", 10000);
}


function checUpdateState()
{
	//not
	if(request_oo.readyState == 3)
	{
		//alert("not finish");
	}
	if(request_oo.readyState == 4)
	{
		var response = request_oo.responseText;
		response=response.replace(/(^\s*)|(\s*$)/g, "");
		if(response == "")
			return;

		var objects=response.split(';');
		//alert(objects.length);
		for(i=0;i<objects.length;i++)
		{
			
			var items=objects[i].split(',');
			var item_id=items[0].replace(/(^\s*)|(\s*$)/g, "");
			if(document.getElementById(item_id) == null)
				continue;
				
			var item_display=items[1].replace(/(^\s*)|(\s*$)/g, "");
			var item_value=items[2].replace(/(^\s*)|(\s*$)/g, "");
			var item_color=items[3].replace(/(^\s*)|(\s*$)/g, "");
			
			if(item_display == 'Rect')
			{
				document.getElementById(item_id).value=GetLabel(item_value);
				document.getElementById(item_id).style.color='#3366aa';
			}
			else if(item_display == 'layerShow')
			{
				document.getElementById(item_id).style.display='';
			}
			else if(item_display == 'layerHide')
			{
				document.getElementById(item_id).style.display='none';
			}
			else
			{
				document.getElementById(item_id).style.color=item_color;
				document.getElementById(item_id).innerHTML=item_value;
				if(item_display == 'none')
					document.getElementById(item_id).style.display='none';
				else
					document.getElementById(item_id).style.display='';
					
			}
			
		}
		
	}
}

function GetLabel(pn)
{
	switch(pn)
	{
		case '0':
		case 0:
			return '';
		case '1':
		case 1:
			return '>';
		case '2':
		case 2:
			return '>>';
		case '3':
		case 3:
			return '>>>';
		case '4':
		case 4:
			return '>>>>';
		case '5':
		case 5:
			return '>>>>>';
		case '6':
		case 6:
			return '>>>>>>';
		case '7':
		case 7:
			return '>>>>>>>';
		case '8':
		case 8:
			return '>>>>>>>>';
		case '9':
		case 9:
			return '>>>>>>>>>';
		case '10':
		case 10:
			return '>>>>>>>>>>';
	}
	return '';
}

</script>
<?php
	echo "\n<script language=\"JavaScript\">\n";
	echo "updateStatus('$platID','$subSysNo');\n";
	echo "</script>\n";
?>
