<?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($sys=0;$sys<$config[$key][PlatformNo];$sys++)
	{
		$sql="select * from OMC_PUB.sysInfo where sysTypeNo={$config[PlatSysTypeNo]} and sysNo={$config[$key][PlatformID]} and subSysNo={$sys} ";
		$res=mysqli_query($pubConn,$sql);
		$num=mysqli_num_rows($res);
		
	//	$module_vertion=GetModuleVersion({$config[PlatSysTypeNo]},{$config[$key][PlatformID]},{$sysNo});
		
		
		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();
			$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],$sys,9999);
			$debug_message="GetDetailPlatInfo($config[$key][PlatformID],$sys,9999);<br>";
			debug_log("/tmp/test.txt",$debug_message);
			
			//Application status
			$id=AssignID();
			if(strcmp($platDetailInfo[Application][Status][Value],"--"))
				$platDetailInfo[Application][Status][Value]="Y";
			$total_response.="$id,block,{$platDetailInfo[Application][Status][Value]},{$platDetailInfo[Application][Status][Color]};";
			
			//IPTRANS
			$id=AssignID();
			if(strcmp($platDetailInfo[IPTRANS][Status][Value],"--"))
				$platDetailInfo[IPTRANS][Status][Value]="<a href=\"./iptrans_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[IPTRANS][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[IPTRANS][Status][Value]},{$platDetailInfo[IPTRANS][Status][Color]};";

			
			//MTP3
			$id=AssignID();
			if(strcmp($platDetailInfo[MTP3][Status][Value],"--"))
				//$platDetailInfo[MTP3][Status][Value]="<a href=\"./mtp3_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[MTP3][Status][Value]."</a>";
			  $platDetailInfo[MTP3][Status][Value]="<a href=\"../linksetStatus/linksetStatus_show.php\">".$platDetailInfo[MTP3][Status][Value]."</a>";

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

			//SCCP
			$id=AssignID();
			if(strcmp($platDetailInfo[SCCP][Status][Value],"--"))
				$platDetailInfo[SCCP][Status][Value]="<a href=\"./sccp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[SCCP][Status][Value]."</a>";		
			$total_response.="$id,block,{$platDetailInfo[SCCP][Status][Value]},{$platDetailInfo[SCCP][Status][Color]};";

			//TCAP
			$id=AssignID();
			if(strcmp($platDetailInfo[TCAP][Status][Value],"--"))
				$platDetailInfo[TCAP][Status][Value]="<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[TCAP][Status][Value]."</a>";	
			$total_response.="$id,block,{$platDetailInfo[TCAP][Status][Value]},{$platDetailInfo[TCAP][Status][Color]};";

			//SNMP
			$id=AssignID();
			if(strcmp($platDetailInfo[SNMP][Status][Value],"--"))
				$platDetailInfo[SNMP][Status][Value]="<a href=\"./snmp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[SNMP][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[SNMP][Status][Value]},{$platDetailInfo[SNMP][Status][Color]};";

			//DEBUG
			$id=AssignID();
			if(strcmp($platDetailInfo[DEBUG][Status][Value],"--"))
				$platDetailInfo[DEBUG][Status][Value]="<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[DEBUG][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[DEBUG][Status][Value]},{$platDetailInfo[DEBUG][Status][Color]};";
      
      //SMPP
      $id=AssignID();
      if(strcmp($platDetailInfo[SMPP][Status][Value],"--"))
				$platDetailInfo[SMPP][Status][Value]="<a href=\"./smpp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[SMPP][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[SMPP][Status][Value]},{$platDetailInfo[SMPP][Status][Color]};";
      
      
      
      //PLAT Status
      $id=AssignID();
			if(strcmp($platDetailInfo[Application][Status][Value],"--"))
				$platDetailInfo[Application][Status][Value]="<a href=\"../create/plat_status_detail.php?sysNo={$config[$key][PlatformID]}&subSysNo=$sys\">".$platDetailInfo[Application][Status][Value]."</a>";
			$total_response.="$id,block,{$platDetailInfo[Application][Status][Value]},{$platDetailInfo[SMPP][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;

?>
