<?php
require("../../inc/lib.inc");
require("../serverStatusImprove/function.inc")
?>
<?php
$global_id=0;
function AssignID()
{
	global $global_id;
	
	$id="ID_{$global_id}";
	$global_id++;
	return $id;
}
?>

<?php

$config=parse_ini_file("../platStatus/config.ini",true);
$config_count=sizeof($config);

$total_response="";
$show_num=0;

foreach($config as $key => $val)
{
	if(strcmp($key,"PlatSysTypeNo")==0)
	{
		continue;
	}
	for($sysNo=0;$sysNo<$config[$key][PlatformNo];$sysNo++)
	{
		$sql="select * from OMC_PUB.sysInfo where sysTypeNo={$config[PlatSysTypeNo]} and sysNo={$config[$key][PlatformID]} and subSysNo={$sysNo} ";
		$res=mysqli_query($pubConn,$sql);
		$num=mysqli_num_rows($res);
		
		if($num == 0)
		{
			$id=AssignID();
			$total_response.="$id,none,none,none;";
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			$id=AssignID();
			continue;
		}
		else
		{			
			$row=@mysqli_fetch_array($res);
			$id=AssignID();
			$total_response.="$id,block,none,none;";
			
			
			$platDetailInfo=GetDetailPlatInfo($config[$key][PlatformID],$sysNo,9999);
			//IPTRANS
			$id=AssignID();
			if(strcmp($platDetailInfo[IPTRANS][Status][Value],"--"))
				$platDetailInfo[IPTRANS][Status][Value]="<a href=#>".$platDetailInfo[IPTRANS][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[IPTRANS][Status][Value]},{$platDetailInfo[IPTRANS][Status][Color]};";

			//MTP3
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[MTP3][Status][Value]},{$platDetailInfo[MTP3][Status][Color]};";

			//SCCP
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[SCCP][Status][Value]},{$platDetailInfo[SCCP][Status][Color]};";

			//TCAP
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[TCAP][Status][Value]},{$platDetailInfo[TCAP][Status][Color]};";

			//SNMP
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[SNMP][Status][Value]},{$platDetailInfo[SNMP][Status][Color]};";

			//DEBUG
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[DEBUG][Status][Value]},{$platDetailInfo[DEBUG][Status][Color]};";

			
			//Refresh Time
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[RefreshTime][Value]},{$platDetailInfo[RefreshTime][Color]};";
				
			//IP Address
			$id=AssignID();
			$total_response.="$id,block,{$platDetailInfo[IPAddress][Value]},{$platDetailInfo[IPAddress][Color]};";
			
			$show_num++;
		}
	}
}
if($show_num)
	$total_response.="blank_line,none,none,none;";
else
	$total_response.="blank_line,block,none,none;";
debug_log("/tmp/test.txt",$total_response);
echo $total_response;
?>
