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

function getmicrotime()
{
	$mtime=list($usec, $sec) = explode(" ", microtime());
	return ((float)$usec + (float)$sec);
}
$time_start=getmicrotime();

$selectedLanguage=$userInfo[language];

?>
<html>


<?php
adjust_head();
$DEBUG=0;
getSerial();

$db=$omc_db;
$sys_id	= isset($sys_id)?$sys_id:'all';
$showRange = isset($showRange) ? $showRange : 'low';
$mod_type	= isset($mod_type) ? $mod_type : '0';
if($DEBUG)echo "<br>sys_id=$sys_id";
if($DEBUG)echo "<br>showRange=$showRange";
if($DEBUG)echo "<br>mod_type=$mod_type";

if($showRange == 'low')
{
	$helpId = "1.2.2"; 
}
else
{
	$helpId = "1.2.2.1"; 
}

$due_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-$heatbeat_overtime,date("m"),date("d"),date("Y")));
$ove_date	= date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+$heatbeat_overtime,date("m"),date("d"),date("Y")));

/*<body topmargin="5" onload="javascript:parent.header.document.location='<?php echo "../../fault/serverStatus/serverStatusUp.php?sys_id=$sys_id&mod_type=$mod_type&showRange=$showRange&backpage=$backpage"; ?>';" onunload="javascript:parent.header.document.location=null;" leftmargin="12">
<body leftmargin="5" style="BACKGROUND-IMAGE: url(../../images/main_top_L.gif);BACKGROUND-REPEAT: no-repeat;BACKGROUND-POSITION:top left;BACKGROUND-COLOR: #f0efef;">
*/
?>
<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
	
	
<?php
adjust_title_head();
echo "<FORM NAME=\"downForm\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "$strSysStatus > Subsystem > $strServer";
		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=\"$PHP_SELF?clear=1&showRange=$showRange&backpage=$backpage\" target=\"_self\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";
		echo "</td>";
	echo "</tr>";
echo "</table>";

adjust_title_tail();
adjust_content_head();



$defineIptransStatus=array(
		array('num' => '0',  'remark' => '--', 'color' => '#000000'),
		array('num' => '1',  'remark' => 'Y', 'color' => '#0000FF')
);

$defineMtp3Status=array(
		array('num' => '0',  'remark' => 'N', 'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Y', 'color' => '#0000FF'),
		array('num' => '2',  'remark' => '--', 'color' => '#000000'),
		array('num' => '3',  'remark' => '--', 'color' => '#000000')
);

$defineSnmpStatus=array(
		array('num' => '0',  'remark' => 'N', 'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Y', 'color' => '#0000FF')
);

$defineSccpStatus=array(
		array('num' => '0',  'remark' => 'Fail', 'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Congest', 'color' => '#FF0000'),
		array('num' => '2',  'remark' => 'Y', 'color' => '#0000FF')
);

$defineTcapStatus=array(
		array('num' => '0',  'remark' => 'Not used', 'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'Y', 'color' => '#0000FF')
);

$defineDebugStatus=array(
		array('num' => '0',  'remark' => 'N', 'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Y', 'color' => '#0000FF')
);

$defineSyncStatus=array(
		array('num' => '0',  'remark' => 'Y',		'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'Restart', 'color' => '#0000FF'),
		array('num' => '2',  'remark' => 'Init',	'color' => '#0000FF'),
		array('num' => '3',  'remark' => 'suspend', 'color' => '#0000FF'),
		array('num' => '4',  'remark' => 'Stop',	'color' => '#FF0000')
);



//deal with summary
if($sys_id == 'all')
{
	//clear heartbeat
	
	if($clear){
		$delSql = " Delete FROM OMC_PUB.sysStat
				WHERE sysTypeNo='200' 
					OR sysTypeNo='0'
					OR sysTypeNo='320'
					OR sysTypeNo='330'
					OR sysTypeNo='340'
					OR sysTypeNo='350'
					OR sysTypeNo='355'
					OR sysTypeNo='360'
					OR sysTypeNo='370'
					OR sysTypeNo='380'
					OR sysTypeNo='390'
					OR sysTypeNo='311'
				";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		$tmpSql="SELECT sysTypeNo FROM sysConf WHERE needInstall = 1";
		
		$tmpRes = mysqli_query($pubConn,$tmpSql);
		$tmpRow = @mysqli_fetch_array($tmpRes);
		$i=0;
		do{
			if($i==0)
				$tmpWhere="sysTypeNo != $tmpRow[sysTypeNo]";
			else
				$tmpWhere=$tmpWhere." AND sysTypeNo != $tmpRow[sysTypeNo]";
			$i++;
		}while($tmpRow = @mysqli_fetch_array($tmpRes));
		
		//echo "tmpWhere=$tmpWhere";
		
		$delSql = " Delete FROM OMC_PUB.sysInfo ";// WHERE $tmpWhere";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
		
		$delSql = "Delete FROM OMC_PUB.sysLedStat";
		//echo "<br>delSql=$delSql";
		$delRes = @mysqli_query($pubConn,$delSql);
		echo mysqli_error($pubConn);
	}
	
	//get plat message
	$selSql = " SELECT * FROM $sysStat_table  WHERE sysTypeNo='200' ";
	if($DEBUG)	echo "selSql=$selSql<br>";
	$selRes = mysqli_query($pubConn,$selSql);
	$selRow = @mysqli_fetch_array($selRes);
	do
	{
		$sysNo = $selRow[sysNo];
		$subSysNo = $selRow[subSysNo];
		if($DEBUG) echo "<br>sysNo=$sysNo; subSysNo=$subSysNo";
		$hexMes = $selRow[detailStat];
		
		if($DEBUG)echo "<br>hexMes=$hexMes";
		$refreshTime = $selRow[updateTime];
		$sysType = $PlatTypeDefArr[$sysNo][remark];
		$sysNum=get_sys_total($sysType);
		$subSysNum=get_subsys_total($sysType);
		if($DEBUG)echo "<br>sysNum=$sysNum; subSysNum=$subSysNum";		
		if($subSysNum)
		{
			$rSysNo = floor($subSysNo/$subSysNum);
		}
		$rSubSysNo = $subSysNo-$rSysNo*$subSysNum;
		$arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][0] = $refreshTime;
		if($refreshTime < $due_date || $refreshTime > $ove_date)
		{
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][1] = "#FF0000";
		}
		else
		{
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][1] = "#0000FF";
		}
		
		if($DEBUG)
		echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][0]}";
		if($DEBUG)
		echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][8][1]}";
		
		$iptrans_bgn_byt=21;
		if($DEBUG)echo "<br>iptrans_bgn_byt=$iptrans_bgn_byt";
		$iptrans_len_hex=substr($hexMes,$iptrans_bgn_byt*2,4);//iptrans所占长度,19bytes
		$iptrans_len_dec=HexDec($iptrans_len_hex);
		if($DEBUG)echo "<br>iptrans_len_dec=$iptrans_len_dec";
		//status
		if($iptrans_len_dec)
		{
			$iptrans_state_hex=substr($hexMes,($iptrans_bgn_byt+5)*2,2);
			$iptrans_state_dec=HexDec($iptrans_state_hex);
			if($DEBUG)
				echo "<br>iptrans_state_dec=$iptrans_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0]=$defineIptransStatus[$iptrans_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1]=$defineIptransStatus[$iptrans_state_dec][color];
			if($defineIptransStatus[$iptrans_state_dec][color] == '#FF0000')
				$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1]}";

		$mtp3_bgn_byt=$iptrans_bgn_byt+4+$iptrans_len_dec;
		if($DEBUG)echo "<br>mtp3_bgn_byt=$mtp3_bgn_byt";
		$mtp3_len_hex=substr($hexMes,$mtp3_bgn_byt*2,4);//mtp3所占长度
		$mtp3_len_dec=HexDec($mtp3_len_hex);
		if($DEBUG)echo "<br>mtp3_len_dec=$mtp3_len_dec";
		//status
		if($mtp3_len_dec)
		{
			$mtp3_state_hex=substr($hexMes,($mtp3_bgn_byt+5)*2,2);
			$mtp3_state_dec=HexDec($mtp3_state_hex);
			if($DEBUG)
				echo "<br>mtp3_state_dec=$mtp3_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][0]=$defineMtp3Status[$mtp3_state_dec][remark];
		
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][1]=$defineMtp3Status[$mtp3_state_dec][color];
			if($defineMtp3Status[$mtp3_state_dec][color] == '#FF0000')
			$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][2][1]}";

		$sccp_bgn_byt=$mtp3_bgn_byt+4+$mtp3_len_dec;
		$sccp_len_hex=substr($hexMes,$sccp_bgn_byt*2,4);//sccp所占长度
		$sccp_len_dec=hexDec($sccp_len_hex);
		if($DEBUG)echo "<br>sccp_len_dec=$sccp_len_dec";
		//status
		if($sccp_len_dec)
		{
			$sccp_state_hex=substr($hexMes,($sccp_bgn_byt+5)*2,2);
			$sccp_state_dec=HexDec($sccp_state_hex);
			if($DEBUG)
				echo "<br>sccp_state_dec=$sccp_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][0]=$defineSccpStatus[$sccp_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][1]=$defineSccpStatus[$sccp_state_dec][color];
		
			if($defineSccpStatus[$sccp_state_dec][color] == '#FF0000')
				$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][3][1]}";
		
		$tcap_bgn_byt=$sccp_bgn_byt+4+$sccp_len_dec;
		$tcap_len_hex=substr($hexMes,$tcap_bgn_byt*2,4);//tcap所占长度
		$tcap_len_dec=HexDec($tcap_len_hex);
		if($DEBUG)echo "<br>tcap_len_dec=$tcap_len_dec";
		//status
		if($tcap_len_dec)
		{
			$tcap_state_hex=substr($hexMes,($tcap_bgn_byt+5)*2,2);
			$tcap_state_dec=HexDec($tcap_state_hex);
			if($DEBUG)
				echo "<br>tcap_state_dec=$tcap_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][0]=$defineTcapStatus[$tcap_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][1]=$defineTcapStatus[$tcap_state_dec][color];
			if($defineTcapStatus[$tcap_state_dec][color] == '#FF0000')
				$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][4][1]}";

		$snmp_bgn_byt=$tcap_bgn_byt+4+$tcap_len_dec;
		$snmp_len_hex=substr($hexMes,$snmp_bgn_byt*2,4);//snmp所占长度
		$snmp_len_dec=HexDec($snmp_len_hex);
		if($DEBUG)echo "<br>snmp_len_dec=$snmp_len_dec";
		//status
		if($snmp_len_dec)
		{
			$snmp_state_hex=substr($hexMes,($snmp_bgn_byt+5)*2,2);
			$snmp_state_dec=HexDec($snmp_state_hex);
			if($DEBUG)
				echo "<br>snmp_state_dec=$snmp_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][0]=$defineSnmpStatus[$snmp_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][1]=$defineSnmpStatus[$snmp_state_dec][color];
			if($defineSnmpStatus[$snmp_state_dec][color] == '#FF0000')
				$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;

		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][5][1]}";

		$debug_bgn_byt=$snmp_bgn_byt+4+$snmp_len_dec;
		$debug_len_hex=substr($hexMes,$debug_bgn_byt*2,4);//debug所占长度
		$debug_len_dec=HexDec($debug_len_hex);
		if($DEBUG)echo "<br>debug_len_dec=$debug_len_dec";
		//status
		if($debug_len_dec)
		{
			$debug_state_hex=substr($hexMes,($debug_bgn_byt+5)*2,2);
			$debug_state_dec=HexDec($debug_state_hex);
			if($DEBUG)
				echo "<br>debug_state_dec=$debug_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][0]=$defineDebugStatus[$debug_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][1]=$defineDebugStatus[$debug_state_dec][color];
		
			if($defineDebugStatus[$debug_state_dec][color] == '#FF0000')
				$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = 1;
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][6][1]}";
	
		$syn_bgn_byt=$debug_bgn_byt+4+$debug_len_dec;
		if($DEBUG)echo "<br>syn_bgn_byt=$syn_bgn_byt";
		$syn_len_hex=substr($hexMes,$syn_bgn_byt*2,4);//syn所占长度
		$syn_len_dec=HexDec($syn_len_hex);
		if($DEBUG)echo "<br>syn_len_dec=$syn_len_dec";
		//status

		if($syn_len_dec)
		{
			$syn_state_hex=substr($hex_mes,($syn_bgn_byt+5)*2,2);
			$syn_state_dec=HexDec($syn_state_hex);
			if($DEBUG)
				echo "<br>syn_state_dec=$syn_state_dec";
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][0]=$defineSyncStatus[$syn_state_dec][remark];
			$arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][1]=$defineSyncStatus[$syn_state_dec][color];
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][7][1]}";
		
		if($DEBUG) echo "<br>ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo] = {$ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo]}";
		if($showRange == 'low')
		{
			if($ttlPlatArr[$sysNo][$rSysNo][$rSubSysNo])
			{
				$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0] = "N";
				$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1] = "#FF0000";
			}
			else
			{
				$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0] = "Y";
				$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1] = "#0000FF";
			}
		}
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][0]}";
		if($DEBUG)echo "<br>arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1]={$arrBeat[$sysNo][$rSysNo][$rSubSysNo][1][1]}";

	}while($selRow = @mysqli_fetch_array($selRes));
	

	//get basic status
	$plat_num=count($PlatTypeDefArr);
	if($DEBUG) echo "<br>plat_num=$plat_num ";
	$sumWhere = " WHERE ";
	for($i=0;$i<$plat_num;$i++)
	{
		$sysTypeNo = $PlatTypeDefArr[$i][sysTypeNo];
		if($i==0)
		{
			$sumWhere = $sumWhere." sysTypeNo = $sysTypeNo " ;
		}
		else
		{
			$sumWhere = $sumWhere." OR sysTypeNo = $sysTypeNo  ";
		}
	}
	if($DEBUG)echo "<br>sumWhere=$sumWhere";
	$selPlat="SELECT *  FROM sysConf" . $sumWhere;
	if($DEBUG)echo "<br>selPlat=$selPlat";
	$resPlat=@mysqli_query($pubConn,$selPlat);
	$rowPlat=@mysqli_fetch_array($resPlat);
	do{
		$sysTypeNo = $rowPlat[sysTypeNo];
		$platHeart = $rowPlat[platHeart];
		if($DEBUG)echo "<br>platHeart=$platHeart";
		for($i=0;$i<sizeof($PlatTypeDefArr);$i++)
		{
			if($sysTypeNo == $PlatTypeDefArr[$i][sysTypeNo])
			{
				$selPlatNo[$i]= $platHeart;
			}
			//if(DEBUG) echo "<br>selPlatNo[$i]=$selPlatNo[$i]";
		}
	}while($rowPlat=@mysqli_fetch_array($resPlat));

	$basSql = " SELECT * FROM sysInfo ".$sumWhere;
	if($DEBUG)	echo "<br>basSql=$basSql";
	$basRes = mysqli_query($pubConn,$basSql);
	$basRow = @mysqli_fetch_array($basRes);
	echo mysqli_error($pubConn);
	do
	{
		$sysTypeNo = $basRow[sysTypeNo];
		if($DEBUG)echo "<br>sysTypeNo=$sysTypeNo";
		$sysNo = $basRow[sysNo];
		if($DEBUG)echo "<br>sysNo=$sysNo";
		$subSysNo = $basRow[subSysNo];
		if($DEBUG)echo "<br>subSysNo=$subSysNo";
		$baseStat = $basRow[baseStat];
		if($DEBUG)echo "<br>baseStat=$baseStat";
		$sysIp = $basRow[ip];
		if($DEBUG)echo "<br>sysIp=$sysIp";
		$okStat = 0;
		for($i=0;$i<$plat_num;$i++)
		{
			if($DEBUG)echo "<br>i=$i";
			$platNo = $selPlatNo[$i];

			if($okStat)
			{
				break;
			}
			$selSysType=$PlatTypeDefArr[$i][remark];
			$selSysTypeNo=$PlatTypeDefArr[$i][sysTypeNo];
			if($DEBUG)echo "<br>selSysTypeNo=$selSysTypeNo";

			if($selSysTypeNo != $sysTypeNo)
			{
				if($DEBUG)echo "<br>continue i=$i";
				continue;
			}
			$sysNum=get_sys_total($selSysType);
			if($DEBUG)echo "<br>sysNum=$sysNum";

			$subSysNum=get_subsys_total($selSysType);
			if($DEBUG)echo "<br>subSysNum=$subSysNum";
			if($DEFAULT_SYS=='GMSC' && ($selSysType=='MSC' || $selSysType=='AUC' || $selSysType=='PPS' || $selSysType=='SMSC'))
			{
				continue;
			}
			elseif($DEFAULT_SYS=='MSC' && $selSysType=='GMSC')
			{
				continue;
			}
			elseif($DEFAULT_SYS=='HBSC' && $selSysType!='EMS')
			{
				continue;
			}

			for($j=0;$j<$sysNum;$j++)
			{
				if($DEBUG)echo "<br>j=$j";	
				if($okStat)
				{
					break;
				}
				if($j != $sysNo)
				{
					if($DEBUG)echo "<br>continue j=$j";
					continue;
				}
				for($k=0;$k<$subSysNum;$k++)
				{
					if($DEBUG)echo "<br>k=$k";
					if($k != $subSysNo)
					{
						continue;
					}
					if($DEBUG)echo "<br>arrBeat[$platNo][$j][$k][8][0]={$arrBeat[$platNo][$j][$k][8][0]}";
					//echo "due_date=$due_date,ove_date=$ove_date<br>";
					//$i == 2  MSC
					//$i == 6  SMSC
					if ( ($platNo == 9) && ($i!=2) && ($i!=6) )
					{
						if($baseStat && $arrBeat[$platNo][$j][$k][8][0] > $due_date && $arrBeat[$platNo][$j][$k][8][0] < $ove_date)
						{
							$arrBeat[$i][$j][$k][0][0]="Y";
							$arrBeat[$i][$j][$k][0][1]="#0000FF";
						}
						
						else
						{
							$arrBeat[$i][$j][$k][0][0]="N";
							$arrBeat[$i][$j][$k][0][1]="#FF0000";
						}
						
					}
					else
					{
						if($baseStat && $arrBeat[$platNo][$j][$k][8][0] > $due_date && $arrBeat[$platNo][$j][$k][8][0] < $ove_date)
						{
							$arrBeat[$i][$j][$k][0][0]="Y";
							$arrBeat[$i][$j][$k][0][1]="#0000FF";
						}
						else
						{
							$arrBeat[$i][$j][$k][0][0]="N";
							$arrBeat[$i][$j][$k][0][1]="#FF0000";
						}
						if($i==0 && $arrBeat[$i][$j][$k][0][0]=='Y') {//OMC状态为Y，还要进一步判断其进程是否全部起来了add by arwean 2006-11-30 16:09
							$sel_mes_sql="SELECT detailStat,updateTime FROM $sysStat_table 
									  WHERE 
									  sysTypeNo='$sysTypeNo' AND sysNo='$sysNo' AND subSysNo='$subSysNo' 
									 ";
							if(0)echo "<br>sel_mes_sql=$sel_mes_sql";
							
							//echo "<br>sel_mes_sql=$sel_mes_sql";
							$sel_mes_res=mysqli_query($pubConn,$sel_mes_sql);
							$sel_mes_row=@mysqli_fetch_array($sel_mes_res);
							$hex_mes=$sel_mes_row[detailStat];
							$num_bgn=66;//进程数目
							$pro_bgn=67;//服务器进程状态
							//进程数目
							$hex_pro_num=substr($hex_mes,$num_bgn*2,2);
							$pro_num=HexDec($hex_pro_num);
							for($ix=0;$ix< $pro_num;$ix++)
							{
								${hex_process_.$ix}=substr($hex_mes,$pro_bgn*2+$ix*2,2);
								${dec_process_.$ix}=HexDec(${hex_process_.$ix});
								if($DEBUG)echo "<br>dec_process_$ix=${dec_process_.$ix}";
								if(${dec_process_.$ix} < 1){
									$arrBeat[$i][$j][$k][0][0]="N";
									$arrBeat[$i][$j][$k][0][1]="#FF0000";
								}
							}
						}//end add
					}
							//$arrBeat[$i][$j][$k][0][0]="Y";
							//$arrBeat[$i][$j][$k][0][1]="#0000FF";
					if($DEBUG)
					{
						echo "<br>arrBeat[$i][$j][$k][0][0]={$arrBeat[$i][$j][$k][0][0]}";
						echo "<br>arrBeat[$i][$j][$k][0][1]={$arrBeat[$i][$j][$k][0][1]}";
					}
					$okStat = 1;
					if(0)
					{
						echo "<br>noSrlStt: $noSrlStt, baseStat: $baseStat";
						echo "<br>arrBeat[$i][$j][$k][0][0]={$arrBeat[$i][$j][$k][0][0]}";
						echo "<br>";
					}
					//echo the each system's ip address

					$arrBeat[$i][$j][$k][10][0]=$sysIp;
					if($DEBUG)echo "<br>arrBeat[$i][$j][$k][10][0]={$arrBeat[$i][$j][$k][10][0]}";

					break;
				}
			}
		}
	}while($basRow = @mysqli_fetch_array($basRes));


if ($selectedLanguage == 'eng')
{
	$arrModName[0] = 'Application status';
	$arrModName[1] = 'IPTRANS'; 
	if($showRange == 'low')
	{
		$arrModName[1] = 'Platform module'; 
	}
	$arrModName[2] = 'MTP3'; 
	$arrModName[3] = 'SCCP'; 
	$arrModName[4] = 'TCAP'; 
	$arrModName[5] = 'SNMP';
	$arrModName[6] = 'DEBUG'; 
	$arrModName[7] = 'DATA SYNC'; 
	$arrModName[8] = 'Refresh time'; 
	$arrModName[9] = 'Version';
	$arrModName[10] = 'IP address';
}
elseif ($selectedLanguage == 'chn')
{
	$arrModName[0] = '基本状态'; 
	$arrModName[1] = 'IPTRANS'; 
	if($showRange == 'low')
	{
		$arrModName[1] = '平台模块'; 
	}
	$arrModName[2] = 'MTP3'; 
	$arrModName[3] = 'SCCP'; 
	$arrModName[4] = 'TCAP'; 
	$arrModName[5] = 'SNMP';
	$arrModName[6] = 'DEBUG'; 
	$arrModName[7] = 'DATA SYNC'; 
	$arrModName[8] = '刷新时间'; 
	$arrModName[9] = '版本号'; 
	$arrModName[10] = 'IP 地址';
}

	echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\">";
		echo "<tr>";  
			echo "<td>";              
				echo "<p align=\"right\">";/*
				if($showRange=='low')//show back
				{
					if($backpage=='overview')
						echo "<a href=\"../../element/overview/overview.php\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
					else
						echo "<a href=\"../networkStatus/mapStatus.php?showingPageType=0\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
				}		
				echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";*/
				echo "&nbsp;</p>";     
			echo "</td>";    
		echo "</tr>";   
		echo "<input type=\"hidden\" name=\"backpage\" value=\"$backpage\">";
		echo "<tr><td><p align=\"center\"><font color=\"#0000FF\" size=\"2\">$strServerSummaryInfo</font></p></td></tr>";
	echo "</table>";
	
	//echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		//echo "<tr bgcolor=\"#E6E6E6\">";
		$modNum = count($arrModName);
		//echo "<td>$strItem</td>";
		for($i=0;$i<$modNum;$i++)
		{
			if($i == 7 || ($showRange == 'low') && $i > 1 && $i < 7)
			{
				continue;
			}
			//echo "<td>$i: $arrModName[$i]</td>";
		}
		//echo "</tr>";		
		
		for($i=0;$i<$plat_num;$i++)
		{
			if($DEBUG)	echo "plat_num=$plat_num<br>";
			$selSysType=$PlatTypeDefArr[$i][remark];
			if($DEBUG)	echo "selSysType=$selSysType<br>";
			$selSysTypeNo=$PlatTypeDefArr[$i][sysTypeNo];
			$tmpSql = " SELECT * FROM elementExistConf WHERE  elementTypeNo='$selSysTypeNo' AND existFlag='1'";
			if($DEBUG)	
			echo "<br>tmpSql=$tmpSql";
			$tmpRes = mysqli_query($pubConn,$tmpSql);
			if(mysqli_num_rows($tmpRes)<=0)
				continue;
			$platNo = $selPlatNo[$i];
			if($DEBUG)echo "i=$i,platNo=$platNo<br>";
			if($DEBUG) echo "<br>selSysTypeNo=$selSysTypeNo";
			$sysNum=get_sys_total($selSysType);
			if($DEBUG) echo "sysNum=$sysNum,<br>";
			$subSysNum=get_subsys_total($selSysType);
			if($DEBUG)echo "<br>subSysNum=$subSysNum";
			
			if($DEFAULT_SYS=='GMSC' && ($selSysType=='MSC' || $selSysType=='AUC' || $selSysType=='PPS' || $selSysType=='SMSC'))
			{
				continue;
			}
			elseif($DEFAULT_SYS=='MSC' && ($selSysType=='GMSC' || $selSysType=='SN'||$selSysType=='MSS'))
			{
				continue;
			}
			elseif($DEFAULT_SYS=='HBSC' && $selSysType!='EMS')
			{
				continue;
			}
			elseif($DEFAULT_SYS=='SN' && $selSysType!='EMS' && $selSysType!='SN')
			{
				continue;
			}
			elseif($selSysTypeNo == 388)
			{//wxc2
				continue;
			}
	
			for($j=0;$j<$sysNum;$j++)
			{
				for($k=0;$k<$subSysNum;$k++)
				{
					static $rows_of_show=0;
					$sysName=$selSysType."_".$j."_".$k;
					if($DEBUG)echo "<br>sysName=$sysName<br>";
					//echo "<tr>";
					//echo "<td>$sysName</td>"; //Item
					
					$show_sysName[$rows_of_show]=$sysName;//add by arwean
					
					
					/****************  Get Module's Version *****************/
					//$selTypeNoSQL = "SELECT sysTypeNo from OMC_PUB.sysConf WHERE sysTypeName='{$PlatTypeDefArr[$platNo][remark]}'";
					$selTypeNoSQL = "SELECT sysTypeNo from OMC_PUB.sysConf WHERE sysTypeName='$selSysType'";
					if($DEBUG) echo "sysNum=$sysNum,subSysNum=$subSysNum<br>";
					if ($DEBUG) echo "selTypeNoSQL=$selTypeNoSQL<br>";
					$selTypeNoRes = mysqli_query($pubConn,$selTypeNoSQL);
					$selTypeNoRow = @mysqli_fetch_array($selTypeNoRes);
					echo mysqli_error($pubConn);
					do{
						$sysTypeNo = $selTypeNoRow[sysTypeNo];
						//echo "sysTypeNo=$sysTypeNo<br>";
						$selSQL = "SELECT detailStat from OMC_PUB.sysStat WHERE sysTypeNo=$sysTypeNo and sysNo=$j and subSysNo=$k";
						if($DEBUG) echo "selSQL=$selSQL<br>";
						$selRes = mysqli_query($pubConn,$selSQL);
						$selRow = @mysqli_fetch_array($selRes);
						echo mysqli_error($pubConn);
						$hexMes = $selRow[detailStat];
						if ($DEBUG) echo "hexMes=$hexMes<br>";
						$versionLen = 3;
						$versionBgnByte=23;
					
						if($versionLen)
						{
							$versionHex_0 = substr($hexMes,$versionBgnByte*2,2);
							$versionDec_0 = HexDec($versionHex_0);
							//$versionDec_0=omc_keep_length($versionDec_0,0,2);
	
							$versionHex_1 = substr($hexMes,($versionBgnByte+1)*2,2);
							$versionDec_1 = HexDec($versionHex_1);
							$versionDec_1=omc_keep_length($versionDec_1,0,2);
	
							$versionHex_2 = substr($hexMes,($versionBgnByte+2)*2,2);
							$versionDec_2 = HexDec($versionHex_2);
							$versionDec_2=omc_keep_length($versionDec_2,0,2);
	
							$version = $versionDec_0.".".$versionDec_1.".".$versionDec_2;
							if($version == '0.00.00')
							{
								$version ='--';
							}
							if($DEBUG) echo "sysTypeNo=$sysTypeNo,";
							$arrBeat[$i][$j][$k][9][0] = $version;
							if($DEBUG) echo "arrBeat[$i][$j][$k][9][0]=$version<br>";
						}
					}while($selTypeNoRow=@mysqli_fetch_array($selTypeNoRes));
					
					
					for($t=0;$t<$modNum;$t++)
					{
						$color_fields[$rows_of_show][$t] = "#000000";
						if($t == 7 || ($showRange == 'low') && $t > 1 && $t < 7)
						{
							continue;
						}
						
						if($t==9)
						{
							if ((isset($arrBeat[$i][$j][$k][$t][0]))&&($arrBeat[$i][$j][$k][$t][0]!='0.0.0'))
							{
								//echo "<td>";
								//echo "{$arrBeat[$i][$j][$k][$t][0]}";//Version
								//echo "</td>";
								$show_fields[$rows_of_show][$t] = $arrBeat[$i][$j][$k][$t][0];
							}
							else
							{
								//echo "<td>--</td>";
								$show_fields[$rows_of_show][$t] = "--";
							}							
						}
						else
						{
							if($DEBUG)
								echo "<br>arrBeat[$platNo][$j][$k][0][0]={$arrBeat[$platNo][$j][$k][0][0]}";

							if(isset($arrBeat[$platNo][$j][$k][$t][0]))
							{
								$platSys=$i;
								$platSubSys=$j*$subSysNum+$k;
								$platId=PLAT."_".$platSys."_".$platSubSys;
								if($t==0)
								{
									
									if(isset($arrBeat[$platNo][$j][$k][8][0]))
									{
										//echo "<td><a href=\"$PHP_SELF?sys_id=$platId&backpage=$backpage&showRange=$showRange&mod_type=$t&platStatus={$ttlPlatArr[$platNo][$j][$k]}\">
										//<font color=\"{$arrBeat[$i][$j][$k][$t][1]}\">{$arrBeat[$i][$j][$k][$t][0]}</a></td>";
										$show_fields[$rows_of_show][$t] = $arrBeat[$i][$j][$k][$t][0];
										$color_fields[$rows_of_show][$t] = $arrBeat[$i][$j][$k][$t][1];
									
									}
									else
									{
										
										//echo "<td>--</td>";
										$show_fields[$rows_of_show][$t] = "--";
										$color_fields[$rows_of_show][$t] = "#000000";
									}
								}
								elseif($t==10)
								{
									if(isset($arrBeat[$platNo][$j][$k][8][0]))
									{
										//echo "<td>{$arrBeat[$i][$j][$k][$t][0]}</td>";
										$show_fields[$rows_of_show][$t] = $arrBeat[$i][$j][$k][$t][0];
									}
									else
									{
										//echo "<td>--</td>";
										$show_fields[$rows_of_show][$t] = "--";
									}
								}
								elseif($t==$modNum-1)
								{
									//echo "<td><font color=\"{$arrBeat[$platNo][$j][$k][$t][1]}\">{$arrBeat[$platNo][$j][$k][$t][0]}</td>";
									$show_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][0];
									$color_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][1];
								}
								elseif($showRange == 'low')
								{
									//echo "<td><font color=\"{$arrBeat[$platNo][$j][$k][$t][1]}\">{$arrBeat[$platNo][$j][$k][$t][0]}</td>";
									$show_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][0];
									$color_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][1];
								}
								else
								{
									//echo "<td><a href=\"$PHP_SELF?sys_id=$platId&backpage=$backpage&showRange=$showRange&mod_type=$t\"><font color=\"{$arrBeat[$platNo][$j][$k][$t][1]}\">{$arrBeat[$platNo][$j][$k][$t][0]}</a></td>";
									$show_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][0];
									$color_fields[$rows_of_show][$t] = $arrBeat[$platNo][$j][$k][$t][1];
								}
							}
							else
							{
								//echo "<td>--</td>";
								$show_fields[$rows_of_show][$t] = "--";
								$color_fields[$rows_of_show][$t] = "#000000";

							}
							if (ord($show_fields[$rows_of_show][$t])==0)
								$show_fields[$rows_of_show][$t]="--";
						}
						
					}
					//echo "</tr>";
					$rows_of_show++;//add by arwean
				}
			}			
		}

	//echo "</table>";		

	//define frame items 
	for($i=0; $i<$rows_of_show; $i++)
	{
		$input_sysName[$i]="input_sysName" . "_$i";	
		for($t=0; $t<$modNum; $t++)
		{
			$fields_id[$i][$t]="fields_id" . "_$i" . "_$t";
		}		
	}
	
	//show items
	echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
		echo "<tr bgcolor=\"#E6E6E6\">";
		$modNum = count($arrModName);
			echo "<td>$strItem</td>";
			for($i=0;$i<$modNum;$i++)
			{
				if($i == 7 || ($showRange == 'low') && $i > 1 && $i < 7)
				{
					continue;
				}
				echo "<td>$arrModName[$i]</td>";
			}
		echo "</tr>";		
		
		for($i=0;$i< $rows_of_show; $i++)
		{
			$size="10%";
			echo "<tr>";
				echo "<td>";				
					echo "$show_sysName[$i]";
				echo "</td>";				
				for($t=0;$t< $modNum;$t++)
				{
					if($t==0)
						$size="1";
					else if($t==8)
						$size="20%";
					else if($t==9)
						$size="10%";
					else if($t==10)
						$size="16%";
					else
						$size="1";
					if(isset($show_fields[$i][$t]))
					{
						echo "<td>";
							echo "<span id=\"{$fields_id[$i][$t]}\" style=\"color:{$color_fields[$i][$t]}\">{$show_fields[$i][$t]}</span>";
						echo "</td>";
					}
				}				
			echo "</tr>";			
		}			
	echo "</table>";	
	
	echo "<table border=\"0\" width=\"100%\">";  
		echo "<tr>";  
			echo "<td>";  
			echo "<p align=\"left\">$strRemark:&nbsp;&nbsp;<font color=\"#0000FF\">Y</font> = $strNormal, &nbsp; &nbsp;<font color=#FF0000>N</font> = $strAbnormal,&nbsp; &nbsp;-- = $strNothing.</td>";     
			echo "<td>";              
			echo "<p align=\"right\">";/*
			if($showRange=='low')
			{
				if($backpage=='overview')
					echo "<a href=\"../../element/overview/overview.php\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
				else
					echo "<a href=\"../networkStatus/mapStatus.php?showingPageType=0\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
			}		
			echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";*/
			echo "<a href=\"$PHP_SELF?clear=1&showRange=$showRange&backpage=$backpage\" target=\"_self\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";
			echo "</p>";     
			echo "</td>";    
		echo "</tr>";   
	echo "</table>";
		
	$time_end=getmicrotime();
	$time = $time_end-$time_start;
	//echo "deal with datas in $time seconds.<br>";
	
}
adjust_content_tail();
?>

</body>
</html>    
