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

<script language="JavaScript">
function clearAll()
{
	window.location.href="./plat_test_status.php?clearAll=1";
}
</script>


<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\" action=\"./server_status.php\" method=\"post\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "Advanced > Plat Status";
		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=# onClick=\"javascript:clearAll();\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">Clear</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";


adjust_title_tail();
adjust_content_head();



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


if(0)
{
	echo "config_count=$config_count<br>";
	echo "<pre>";
	print_r($config);
	echo "</pre>";
}



if($clearAll == 1)
{
	//echo "clear<br>";
	$sql="delete from OMC_PUB.sysInfo where sysTypeNo=200 ";
	@mysqli_query($pubConn,$sql);
	echo mysqli_error($pubConn);
}



echo "<br><center><font color=\"blue\">Platform summary information</font></center>";
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#ffffff\">";

echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>Item</td>";
echo "<td>Application status</td>";
echo "<td>IPTRANS</td>";
echo "<td>MTP3</td>";
echo "<td>SCCP</td>";
echo "<td>TCAP</td>";
echo "<td>SNMP</td>";
echo "<td>DEBUG</td>";
echo "<td>SMPP</td>";
echo "<td>PLAT STATUS</td>";
echo "<td>Refresh Time</td>";
echo "<td>IP Address</td>";
echo "</tr>";


echo "<tr id=\"blank_line\">";
echo "<td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td><td>--</td>";
echo "</tr>";



foreach($config as $key => $val)
{
	if(strcmp($key,"PlatSysTypeNo")==0)
	{
		continue;
	}
	
	
	if($config[$key][PlatformID] == 0)
	{
	  for($j=0;$j<2;$j++)
	  {	 
		  //Rowline
		  $id=AssignID();
		  echo "<tr id=\"$id\" style=\"display:none;\">";
		  //Item Name	
		  echo "<td>{$config[$key][PlatformName]}_{$j}</td>";
		
		  //Application status
		  $id=AssignID();
		  echo "<td>";		
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
		  //IPTRANS
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./iptrans_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  
		  echo "</td>";
		
		
		  //MTP3
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./linksetStatus_show.php\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SCCP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./sccp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
			
		  //TCAP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SNMP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./snmp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //DEBUG
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		  //SMPP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./smpp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
	  	//PLAT STATUS
      $id=AssignID();
	  	echo "<td>";
		  echo "<a href=\"./plat_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
   
        				
		  //Refresh Time
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		
		  //IP Address
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</td>";
		
	  	echo "</tr>";
	  }
  }

  if($config[$key][PlatformID] == 8)
	{
	  for($j=0;$j<10;$j++)
	  {
	 
		  //Rowline
		  $id=AssignID();
		  echo "<tr id=\"$id\" style=\"display:none;\">";
		  //Item Name	
		  echo "<td>{$config[$key][PlatformName]}_{$j}</td>";
		
		  //Application status
		  $id=AssignID();
		  echo "<td>";		
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
		  //IPTRANS
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./iptrans_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  
		  echo "</td>";
		
		
		  //MTP3
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./linksetStatus_show.php\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SCCP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./sccp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
			
		  //TCAP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SNMP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./snmp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //DEBUG
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		  //SMPP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./smpp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
	  	//PLAT STATUS
      $id=AssignID();
	  	echo "<td>";
		  echo "<a href=\"./plat_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
   
        				
		  //Refresh Time
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		
		  //IP Address
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</td>";
		
	  	echo "</tr>";
	  }
  }
  
  if($config[$key][PlatformID] == 9)
	{
	  for($j=0;$j<2;$j++)
	  {
	 
		  //Rowline
		  $id=AssignID();
		  echo "<tr id=\"$id\" style=\"display:none;\">";
		  //Item Name	
		  echo "<td>{$config[$key][PlatformName]}_{$j}</td>";
		
		  //Application status
		  $id=AssignID();
		  echo "<td>";		
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
		  //IPTRANS
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./iptrans_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  
		  echo "</td>";
		
		
		  //MTP3
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./linksetStatus_show.php\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SCCP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./sccp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
			
		  //TCAP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SNMP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./snmp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //DEBUG
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		  //SMPP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./smpp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
	  	//PLAT STATUS
      $id=AssignID();
	  	echo "<td>";
		  echo "<a href=\"./plat_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
   
        				
		  //Refresh Time
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		
		  //IP Address
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</td>";
		
	  	echo "</tr>";
	  }
  }
  
  if($config[$key][PlatformID] == 18)
	{
	  for($j=0;$j<2;$j++)
	  {
	 
		  //Rowline
		  $id=AssignID();
		  echo "<tr id=\"$id\" style=\"display:none;\">";
		  //Item Name	
		  echo "<td>{$config[$key][PlatformName]}_{$j}</td>";
		
		  //Application status
		  $id=AssignID();
		  echo "<td>";		
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
		  //IPTRANS
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./iptrans_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  
		  echo "</td>";
		
		
		  //MTP3
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./linksetStatus_show.php\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SCCP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./sccp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
			
		  //TCAP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./tcap_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //SNMP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./snmp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		  //DEBUG
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		  //SMPP
		  $id=AssignID();
		  echo "<td>";
		  echo "<a href=\"./smpp_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#FF0000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
		
	  	//PLAT STATUS
      $id=AssignID();
	  	echo "<td>";
		  echo "<a href=\"./plat_status.php?sysNo={$config[$key][PlatformID]}&subSysNo=$j\">";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</a>";
		  echo "</td>";
		
   
        				
		  //Refresh Time
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">--</span>";
		  echo "</td>";
		
		
		  //IP Address
		  $id=AssignID();
		  echo "<td>";
		  echo "<span id=\"{$id}\" style=\"color:#000000;\">$id</span>";
		  echo "</td>";
		
	  	echo "</tr>";
	  }
  }
}


echo "<table>";



echo "<table border=\"0\" width=\"100%\">";
	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=# onClick=\"javascript:clearAll();\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">Clear</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";

if($clearAll)
{
	echo "<script language=\"JavaScript\">\n";
	echo "document.getElementById('blank_line').style.display='';\n";
	echo "</script>\n";
}

echo "</form>";
adjust_content_tail();

?>



<script language="JavaScript">




function updateStatus()
{
	var fixurl="./plat_test_status_update.php";
	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()", 10000);
}







function checUpdateState()
{
	//not
	if(request_oo.readyState == 3)
	{
		//alert("not finish");
	}
	if(request_oo.readyState == 4)
	{
		var response = request_oo.responseText;
		//alert(response);
		
		var module=response.split(';');
		//alert("module.length="+module.length);
		for(i=0;i<module.length;i++)
		{
			var items=module[i].split(',');
			//alert(items.length);
			if(items.length != 4)
				continue;
			var item_id=items[0].replace(/(^\s*)|(\s*$)/g, "");
			var item_state=items[1].replace(/(^\s*)|(\s*$)/g, "");
			var item_value=items[2].replace(/(^\s*)|(\s*$)/g, "");
			var item_color=items[3].replace(/(^\s*)|(\s*$)/g, "");
			//alert("item_id="+item_id+",item_state="+item_state+",item_value="+item_value+",item_color="+item_color);
			if(item_state == 'block')
			{
				document.getElementById(item_id).style.display='';
			}
			else
			{
				document.getElementById(item_id).style.display='none';
			}
			
			if(item_value != 'none')
			{
				document.getElementById(item_id).innerHTML=item_value;
			}
			if(item_color != 'none')
			{	
				document.getElementById(item_id).style.color=item_color;
			}			
		}
	}
}

updateStatus();
</script>

