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

    作者：      
      
修改注释：      
NO.1      
姓名： Cui Ticun         
时间：2004-4-21
修改说明：Suport OMC7.0,从advanced移到configuration中，修改
		 和添加了上方的操作按钮
*********************************************************/
require("../../inc/header.inc");
$DEBUG = 0;

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

$sysId		='223_99_99';
//$instanceNo	='0';
$listPageUrl = "gttLocalList.php?setObjIdStr=$objIdStr&setInstanceNo=$instanceNo";

$valueName	='initValue';
$totalLen=19;

$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')
);

$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.22', 'SRF0'),
   	array('2.1.23', 'SRF1'),
   	array('2.1.24', 'SRF2'),
   	array('2.1.25', 'SRF3'),
   	
   	array('2.1.32',	'MNP'), 
   	array('2.1.33',	'OPPS'), 
   	array('2.1.146','SSF'), 
   	array('2.1.147','SCF-CAP'),
   	array('2.1.153','SCF-MAP'), 
   	array('2.1.254','AIF')
);

if(isset($setSys)){
	if($DEBUG){
		echo "<br>nServerName=$nServerName";
		echo "<br>nMsisdn=$nMsisdn";
		echo "<br>nNetIDName=$nNetIDName";
		echo "<br>nIpStr_0=$nIpStr_0";
		echo "<br>nIpStr_1=$nIpStr_1";
	}

	for($i=0;$i<$totalLen;$i++){
		$totalValue=$totalValue."00";
	}
	if($DEBUG) echo "<br>totalValue=$totalValue<br>";
	
	if($nIpStr_0=='')
		$nIpStr_0="FFFFFFFF";
	else
		$nIpStr_0=ip2byte($nIpStr_0);

	if($nIpStr_1=='')
		$nIpStr_1="FFFFFFFF";
	else{
		$ip1Des = explode('.',$nIpStr_1);
		$nIpStr_1=ip2byte($nIpStr_1);
	}

	if($DEBUG) echo "<br>nIpStr_0=$nIpStr_0";
	if($DEBUG) echo "<br>nIpStr_1=$nIpStr_1";


	$nMsisdn =str_replace('-','F',$nMsisdn);
	//补齐msisdn
	$nMsisdn = omc_keep_length($nMsisdn,"F","22","0");
	if($DEBUG) echo "<br>nMsisdn=$nMsisdn";

	$totalValue=setBitValue($totalValue,$localNodeConfArr[0][1],$nNetIDName);
	$totalValue=setBitValue($totalValue,$localNodeConfArr[1][1],$nMsisdn);
	$totalValue=setBitValue($totalValue,$localNodeConfArr[2][1],$nIpStr_0);
	$totalValue=setBitValue($totalValue,$localNodeConfArr[3][1],$nIpStr_1);

	if($DEBUG) echo "<br><br>sysId=$sysId";
	if($DEBUG) echo "<br>objIdStr=$objIdStr";
	if($DEBUG) echo "<br>instanceNo=$instanceNo";
	if($DEBUG) echo "<br>totalValue=$totalValue<br>";
	$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]}";
	}

	$updSql = "UPDATE $paramTable SET initValue = '$totalValue'   
					WHERE level_1='$level_1' AND level_2='$level_2' AND level_3='$level_3' AND instanceNo='$instanceNo'
					";
	if($DEBUG) echo "<BR>updSql=$updSql";
	mysqli_query($pubConn,$updSql);
	echo mysqli_error($pubConn);
	//setSysParamValue($sysId,$objIdStr,$instanceNo,$totalValue);
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "\n window.opener.location.href=\"$listPageUrl\";";
	if(!$DEBUG){
		echo "\n window.close();";
	} 
	echo "\n </script>";
	exit();
}

//==========================================================
//输入变量
//==========================================================
if($DEBUG) echo "<BR>sysId		=$sysId";
if($DEBUG) echo "<BR>instanceNo	=$instanceNo";
if($DEBUG) echo "<BR>objIdStr	=$objIdStr";

//==========================================================
//数据处理
//==========================================================

//==========================================================
//输出并显示数据
//==========================================================
if($DEBUG) echo "<BR>";
?>
<br>
<body topmargin="0" leftmargin="12">
<form name="selectform">
<table border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<?php 
echo "<tr bgcolor=\"#E6E6E6\"><td>Name</td><td>Value</td></tr>";
for($i=0;$i<sizeof($localNodeArr);$i++){
	if($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 $valueName
				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]){
				$NetID= $NetIdConfArr[$j][1];
				break;
			}
		}
		*/

		$msisdn	=getBitValue($value,$localNodeConfArr[1][1]);
		$msisdn =str_replace('F','',$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);
		if($DEBUG) echo "<BR>value=$value";	

		echo "<tr>";
		echo "<td>Server name</td>";
		echo "<td>$serverName</td>";
		echo "</tr>";

		echo "<tr>";
		echo "<td>MSISDN</td>";
		echo "<td><input type=\"text\" maxlength=\"22\" value='$msisdn' class=\"text\" name=\"nMsisdn\"></td>";
		echo "</tr>";

?>
		<tr>
			<td>Network indicator</td>
			<td>
				<select name="nNetIDName">
				<?php
					if($netId==0){
						echo "<option value=\"00\" selected>$strInternationalNetwork";
						echo "<option value=\"01\">$strInternationalNetworkSpare";
						echo "<option value=\"02\">$strNationalNetwork";
						echo "<option value=\"03\">$strNationalNetworkSpare";
					}elseif($netId==1){
						echo "<option value=\"00\">$strInternationalNetwork";
						echo "<option value=\"01\" selected>$strInternationalNetworkSpare";
						echo "<option value=\"02\">$strNationalNetwork";
						echo "<option value=\"03\">$strNationalNetworkSpare";
					}elseif($netId==2){
						echo "<option value=\"00\">$strInternationalNetwork";
						echo "<option value=\"01\">$strInternationalNetworkSpare";
						echo "<option value=\"02\" selected>$strNationalNetwork";
						echo "<option value=\"03\">$strNationalNetworkSpare";
					}elseif($netId==3){
						echo "<option value=\"00\">$strInternationalNetwork";
						echo "<option value=\"01\">$strInternationalNetworkSpare";
						echo "<option value=\"02\">$strNationalNetwork";
						echo "<option value=\"03\" selected>$strNationalNetworkSpare";
					}
					else{
						echo "<option value=\"00\" selected>$strInternationalNetwork";
						echo "<option value=\"01\">$strInternationalNetworkSpare";
						echo "<option value=\"02\">$strNationalNetwork";
						echo "<option value=\"03\">$strNationalNetworkSpare";
					}
				?>
				</select>
			</td>
		</tr>

<?php
		echo "<tr>";
		echo "<td>Plane 0's IP</td>";
		echo "<td><input type=\"text\" maxlength=\"15\" value='$ipStr_0' class=\"text\" name=\"nIpStr_0\"></td>";
		echo "</tr>";

		echo "<tr>";
		echo "<td>Plane 1's IP</td>";
		echo "<td><input type=\"text\" maxlength=\"15\" value='$ipStr_1' class=\"text\" name=\"nIpStr_1\"></td>";
		echo "</tr>";

		break;
	}
}
?>
</table>

<br>
<input type="submit" value=<?php echo "$strSet"; ?> class="button" name="setSys">
<input type="reset" name="Reset" value ="Reset" class="button">
<input type="hidden" name="sysId" value="<?php echo "$sysId"; ?>">
<input type="hidden" name="instanceNo" value="<?php echo "$instanceNo"; ?>">
<input type="hidden" name="objIdStr" value="<?php echo "$objIdStr"; ?>">

</form>
<b>Remark:</b><br>
<br>
The local node table contains overall SCCP (MAP and CAP) addressing setup for all entities of the WXC2 System. The local table is used for SCCP addressing. The IP 0 and 1 are IP addresses of the dual server 0 and 1 respectively. Generally the SSN, IP 0 and IP1 are fixed in the local node table, and only MSISDN field needs filling. For All-in-one server (MSS), the IP addresses of MSC, VLR HLR, PPS, SSF, AUC and EIR are same, MSS 0 IP is 172.18.98.1, MSS 1 IP is 172.18.99.1. To modify the local node of a server, click on the name of the server to open the local node set window.<br><br>
<table border="1" width="100%" cellpadding="1" cellspacing="0" bordercolor="#666666" bordercolordark="#FFFFFF">
<tr bgcolor="#E6E6E6"><td>Entity</td><td> SSN</td><td> MSISDN</td><td> IP 0</td><td> IP 1</td></tr>
<tr><td>MSC</td><td> 0x08</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>VLR</td><td> 0x07</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>HLR</td><td> 0x06</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr> 
<tr><td>PPS</td><td> 0x93</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SMSC</td><td>0x0B</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SSF</td><td> 0x93</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>AIF</td><td> 0xFE</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>AUC</td><td> 0x0A</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>EIR</td><td> 0x09</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>VMS</td><td> 0x0C</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>OMC</td><td> 0x04</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>EIR</td><td> 0x09</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SMPP-EMSE</td><td> 0x13</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SMPP-SMSC</td><td> 0x14</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SMPP-OMC</td><td> 0x15</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SRF0</td><td> 0x16</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SRF1</td><td> 0x17</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SRF2</td><td> 0x18</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SRF3</td><td> 0x19</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>MNP</td><td> 0x20</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>OPPS</td><td> 0x21</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SSF</td><td> 0x92</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SCF-CAP</td><td> 0x93</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
<tr><td>SCF-MAP</td><td> 0x99</td><td> &nbsp;&nbsp;</td><td>--</td><td>--</td></tr>
</table>
</body>
</html>

