<?php
/*********************************************************      
 程序说明：         
    功能说明：显示七号信令中的 Local node
              
    调用关系：调用: header.inc    
              被调用:        
 
    变量说明：

    作者：     
      
修改注释：      
NO.1      
姓名：          
时间：
修改说明：
*********************************************************/
require("../../inc/header.inc");
$DEBUG = 0;

if($DEBUG) echo "<br>正在调试中！！";
//==========================================================
//变量定义
//==========================================================
$pubDb			= 'OMC_PUB';
$paramTable		='OBJ_223.param_99';
$maxNum = 30;

$sysId		='223_99_99';
$instanceNo	='0';
$initValue	='initValue';
$readValue	='readValue';

$nGetComm	= 0;

$nProcFail = 0;//failure
$nWaitProc = 1;//wait
$nInProc   = 2;
$nOutProc  = 3;

if($DEBUG) echo "<br>setObjIdStr = $setObjIdStr";
if($DEBUG) echo "<br>setInstanceNo = $setInstanceNo";

//==========================================================
//数据处理
//==========================================================
$localNodeObjId='2.1';
$localNodeArr=array(
	array('2.1.4',	'OMC'),
	array('2.1.6',	'HLR'), 
   	array('2.1.7',	'VLR'), 
   	array('2.1.8',	'MSC'), 
   	array('2.1.9',	'EIR'), 
   	array('2.1.10',	'AUC'), 
   	array('2.1.11',	'SMSC'),
   	array('2.1.19',	'SMPP-PPS'), 
   	array('2.1.20',	'SMPP-SMSC'), 
   	array('2.1.21',	'SMPP-OMC'), 
   	array('2.1.32',	'MNP'), 
   	array('2.1.146','SSF'), 
   	array('2.1.147','SCF'), 
   	array('2.1.254','AIF')
);

$localNodeConfArr=array(
	array('NetID',		'00.0-00.7'),
	array('MSISDN',		'01.0-10.7'),
	array('IP0',		'11.0-14.7'),
	array('IP1',		'15.0-18.7')
);

$NetIdConfArr=array(
	array('0','international'),
	array('1','international spare'),
	array('2','national'),
	array('3','national spare')
);

if($getFlag==1){
	if($DEBUG) echo "<br>sysId=$sysId";
	$objIdStr=$localNodeObjId;
	if($DEBUG) echo "<br>objIdStr=$objIdStr";
	$commIdStr	= sysCommSend($sysId,$nGetComm,$objIdStr);
	$showType="Get";

	$i = 0;
	while(1)
	{
		//echo "<br>i=$i";
		if($i == 0)
			echo "<br>$showType Local node";
		if($i > $maxNum){
			echo "<br><font size=\"2\" color=\"#FF0000\">Timeout</font>";
			break;
		}
		echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
		flush();	
		$sysId = "223_99_99";
		$chkType = "0";
		$chRes=ChComm($sysId,$chkType);
		if($chRes == $nOutProc || $chRes == $nProcFail){
			if($chRes == $nProcFail)
				echo "<br><font size=\"2\" color=\"#FF0000\">$remark</font><br>";
			elseif($remark == 'response timeout')
				echo "<br><font size=\"2\" color=\"#FF0000\">$remark</font><br>";
			else
				echo "<br><font size=\"2\" color=\"#0000FF\">$remark</font><br>";
			break;
		}
		sleep(1);
		$i++;
	}
}

//==========================================================
//输出并显示数据
//==========================================================
if($DEBUG) echo "<BR>";
?>

<body topmargin="0" leftmargin="12">
<form name="selectform">
<?php
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"../overview/overview.php?scroll_y=1000\">Network</a> > <a href=\"#\">Local Node</a>";
echo "</td>";
//echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
//showHelp($helpId);
//echo "</td>";
echo "<td>";
echo "<p align=\"right\"><a href=\"../../element/overview/overview.php?scroll_y=1000\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
?>
<br>

<table border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<?php
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td>Entity</td>";
echo "<td>MSISDN</td>";
echo "<td>Network indicator</td>";
echo "<td>IP0 (Server 0)</td>";
echo "<td>IP1 (Server 1)</td>";
echo "</tr>";
for($i=0;$i<sizeof($localNodeArr);$i++){
	$objIdStr=$localNodeArr[$i][0];
	$serverName	=$localNodeArr[$i][1];
	$levelArr=explode('.',$objIdStr);
	for($j=0;$j<sizeof($levelArr);$j++){
		$levelNo=$j+1;
		${"level_$levelNo"}=$levelArr[$j];
		if($DEBUG) echo "<BR>levelArr[$j]={$levelArr[$j]}";
	}
	$getSql="SELECT $initValue
			FROM $paramTable 
			WHERE level_1='$level_1' AND level_2='$level_2' AND level_3='$level_3' AND instanceNo='$instanceNo'
		";
	if($DEBUG) echo "<BR>getSql=$getSql";
	$result	=mysqli_query($pubConn,$getSql);
	echo mysqli_error($pubConn);
	$rows	=mysqli_fetch_array($result);
	echo mysqli_error($pubConn);
	$value=$rows[0];
	//$value	=getSysParamValue($sysId,$objIdStr,$instanceNo,$valueName);
	$netId	=getBitValue($value,$localNodeConfArr[0][1]);
	for($j=0;$j<sizeof($NetIdConfArr);$j++){
		if($netId == $NetIdConfArr[$j][0]){
			$netIdName= $NetIdConfArr[$j][1];
			break;
		}
	}

	$msisdn	=getBitValue($value,$localNodeConfArr[1][1]);
	$msisdn =str_replace('F','',$msisdn);
	if($msisdn == ''){
		$msisdn='--';
	}
	
	$ip_0	=getBitValue($value,$localNodeConfArr[2][1]);
	if($ip_0 == 'FFFFFFFF')
		$ipStr_0='--';
	else
		$ipStr_0=byte2ip($ip_0);
	$ip_1	=getBitValue($value,$localNodeConfArr[3][1]);
	if($ip_1 == 'FFFFFFFF')
		$ipStr_1='--';
	else
		$ipStr_1=byte2ip($ip_1);
//	$ipStr_1=byte2ip($ip_1);
	if($DEBUG) echo "<BR>value=$value";	
	if($instanceNo == $setInstanceNo && $objIdStr==$setObjIdStr)
		echo "<tr bgcolor=#CCFFCC>";
	else
		echo "<tr>";
	echo "<td>$serverName</a></td>";
	echo "<td>$msisdn</td>";
	echo "<td>$netIdName</td>";
	echo "<td>$ipStr_0</td>";
	echo "<td>$ipStr_1</td>";
	echo "</tr>";
}
?>

</table>
</form>
&nbsp;
</body>
</html>
