<?php
//require("../sub_inc/commfunc.php");
require("../sub_inc/operwebfunc.inc");
$DEBUG = 0;
if($DEBUG) echo "<br>正在调试中！！";
?>

<body topmargin="0" leftmargin="12">

<?php

//
$sccp_Id	= '223_99_99';
$sccp_oid	= array('2.1.7','2.2');
$sqltable_sccp = 'OBJ_223.param_99';
$mtp3_sqlTable = 'OBJ_222.param_99';
$sqltable_spc = 'OBJ_222.param_99';
$sqltable = 'OBJ_325.param_99';
$sysStatTable='OMC_PUB.sysStat';
$pubDb = 'OMC_PUB';
$sysinfo = 'OMC_PUB.sysInfo';
$sysTypeNo = '322';

$sysId_arr=array(
	array('oid'=>'2.1',			'sysid'=> '325_99_99',		'selectsysid'=>'-1'), 										
	array('oid'=>'2.1.7',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.2.0',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
);

$SaveArr=array(
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99'),
);	

$getsql = "SELECT sysNo FROM $sysinfo where sysTypeNo = $sysTypeNo";
if($DEBUG) echo "getsql = $getsql<br>";
$Result = @mysqli_query($pubConn,$getsql);
while($Rows = mysqli_fetch_array($Result))
{
	$vlrSysId = "325_".$Rows[sysNo]."_0";
	$SaveArr[] = array('oidstr'=>'3.3',	'setvalue'=>'01'	,'sysid'=> $vlrSysId);
}

//loading
if($load_flag == 1)
{
	echo "<br>Loading";
	
	GetParam($sysId_arr,1);//1 means return to overview if getting parameters fails.
			
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG){
		echo "\n window.location.href=\"./vlr.php\";";
	} 
	else exit();
	echo "\n </script>";
}

{//set system ip
	for($i=0; $i < 2; $i++)
	{
		$getsql = "SELECT ip FROM $sysinfo where sysTypeNo = $sysTypeNo and sysNo = '$i'";
		if($DEBUG) echo "getsql = $getsql<br>";
		$ip_init = @mysqli_query($pubConn,$getsql);
		$ip_init = mysqli_fetch_array($ip_init);
		$ip_init = $ip_init[0];
		$ip_array = explode('.',$ip_init);
		
		for($j = 0;$j < sizeof($ip_array);$j++)
		{
			$ip = $ip_array[$j];
			$mss_ip[$i] .= omc_keep_length(dechex($ip),'0','2');
		}	
	}
	$mss_ip[0] = strtoupper(omc_keep_length($mss_ip[0],'0','8'));
	$mss_ip[1] = strtoupper(omc_keep_length($mss_ip[1],'0','8'));
	if($DEBUG)
	{
		echo "<br>mss0_ip = $mss_ip[0]<br>";	
		echo "mss1_ip = $mss_ip[1]<br>";	
	}
	
	$sysId = "223_99_99";
	//vlr
	$oidStr = "2.1.7";
	setParamValue($mss_ip[0],$sysId,$oidStr,3);
	setParamValue($mss_ip[1],$sysId,$oidStr,4);
}//end set system ip

if($_SERVER['REQUEST_METHOD'] == "POST")
{
	if(isset($setSys) || isset($getSys))
	{
		if(isset($setSys))
		{
			echo "<br>Setting parameters<br>";
			SetParam($sysId_arr);	
			session_register("vlrSetFlag");
						
			$showType="Set";
			echo "<br>Sending save command<br>";
			SaveParam($SaveArr);
			echo "<script LANGUAGE=\"JavaScript\">";
			if(!$DEBUG)
				//echo "\n window.location.href=\"../overview/overview.php\";";
			echo "\n </script>";	
			//exit();	
		}
		else
		{ 
			echo "<br>Getting parameters<br>";
			session_register("GetFlag");
			GetParam($sysId_arr);
			$showType="Get";
		}
	}

	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG)
		echo "\n window.location.href=\"./vlr.php\";";
	echo "\n </script>";	
	exit();		
}	

//==========================================================
//输出并显示数据
//========================================================== 
echo "<form method=\"POST\" name=\"Set\" action=\"$PHP_SELF\">";

echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Configuration > <a href=\"../overview/overview.php\">Network</a> > <a href=\"#\">VLR</a>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
$helpId = '2.1.1.2';
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";

{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">&nbsp";
			//echo "<b>Visitor Location Register:&nbsp;&nbsp;</b>";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
				echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
				echo "&nbsp;&nbsp;&nbsp;";
				echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../overview/overview.php?scroll_y=$page_top\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}
?>

<TABLE  width=100%   border="1"  cellpadding="1" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> 
<?php

{//Signaling point
	{
		$spcTree_array = array(
		array('INT',				'14-bit',	'spc_int_14',	 '2.3.1'),
		array('INT-S',				'14-bit',	'spc_int_sp_14', '2.3.2'),
		array('NAT',				'14-bit',	'spc_nat_14',	 '2.3.3'),
		array('NAT-S',				'14-bit',	'spc_nat_sp_14', '2.3.4'),
		array('International',		'24-bit',	'spc_int_24',	 '2.3.5'),
		array('International spare','24-bit',	'spc_int_sp_24', '2.3.6'),
		array('National',			'24-bit',	'spc_nat_24',	 '2.3.7'),
		array('National spare',		'24-bit',	'spc_nat_sp_24', '2.3.8')
		);
			
		$querysql = "select initValue from $mtp3_sqlTable where level_1 = '2' and level_2 = '2'  and level_3 = '0'";
		$result = mysqli_query($pubConn,$querysql);
		$indicator = mysqli_fetch_array($result);
		echo mysqli_error($pubConn);
		if($DEBUG)echo "<br>indicator = {$indicator[0]}<br>";
			
		for($i = 0; $i < 4; $i++)
		{
			$flag = getBitValue($indicator[0],"0.$i");
			if ($flag == 0)
				$spc_index[$i] = $i;
			else
				$spc_index[$i] = $i+4;					
		}
			
		for($i = 0; $i < 4; $i ++)
		{
			$level_array = explode('.',$spcTree_array[$spc_index[$i]][3]);
			
			for($j = 0;$j < sizeof($level_array);$j ++)
			{
				$level_no = $j + 1;
				${level_.$level_no} = $level_array[$j];
			}
			$getsql = "select initValue from $mtp3_sqlTable 
			where level_1 = '$level_1' and level_2 = '$level_2' and level_3 = '$level_3' ";
			$result = mysqli_query($pubConn,$getsql);
			$row[$i] = mysqli_fetch_array($result);
			$row[$i] = hexdec($row[$i][0]);
			if($DEBUG)echo "getsql = $getsql<br>";
			if($DEBUG)echo "spc_$i=$row[$i]<br>";
		}
	}
	
	echo "<tr>" ;
	echo "<td width=\"20%\" bgcolor=\"#E6E6E6\"><b>Signaling point code</b></td>";
	echo "<td><table width=100%><tr>";
	for($i=0; $i<4; $i++)
		echo "<td align=\"left\" width=\"25%\">{$spcTree_array[$i][0]}:&nbsp;{$spcTree_array[$spc_index[$i]][1]}&nbsp;{$spcTree_array[$spc_index[$i+4]][1]}&nbsp;$row[$i]</td>";
	echo "</tr></table></td>";
	echo "</tr>";
}//end Signaling point

{//gtt
	$sysId = "223_99_99";
	$oidStr = "2.1.7";
	$instanceNo=0;
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>$strE164Number</b></td><td><table width=100%>";
		echo "<td align=\"left\" width=50%>";
			showParameter($sysId,$oidStr,2,1);
		echo "</td>";
		
		echo "<td align=\"left\" width=50% >";
			showParameter($sysId,$oidStr,1,1);
		echo "</td>";
	echo "</table></td></tr>";
}//end gtt

{//purge
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>VLR purge</b></td>";
	echo "<td>&nbsp;";
	$sysId = "325_99_99";
	$oidStr = "2.1.9";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}//end purge

{//Idle period to purge
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Idle period to purge</b></td>";
	echo "<td>&nbsp;";
		$sysId = "325_99_99";
		$oidStr = "2.1.10";
		showParameter($sysId,$oidStr,1,1);
	echo " <font style=\"font-family:monospace\">*</font>6 Minutes</td>";	
	echo "</tr>";
}//end Idle period to purge

{//cdr
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>CDR flag</b></td>";
	echo "<td>&nbsp;";
	$sysId = "325_99_99";
	$oidStr = "2.1.11";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}//end cdr

{//emgAllow
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Emergency call</b></td>";
	echo "<td>&nbsp;";
	$sysId = "325_99_99";
	$oidStr = "2.1.7";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}//end emgAllow

{//ciphering
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Ciphering</b></td>";
	echo "<td>&nbsp;";
	$sysId = "325_99_99";
	$oidStr = "2.1.3";
	showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
}//end ciphering

{//cipAlg
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Ciphering algorithm</b></td>";
	echo "<td>&nbsp;";
		$sysId = "325_99_99";
		$oidStr = "2.1.4";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	
}//end cipAlg

{//alloTmsi
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>TMSI Allocation</b></td>";
	echo "<td>&nbsp;";
		$sysId = "325_99_99";
		$oidStr = "2.1.5";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
}//end alloTmsi

{//Authentication
	$auc_array = array(
		array('Location update','location_auc',1),
		array('MO Call','mo_call_auc',2),
		array('MT Call','mt_call_auc',3)
	);//2.1.1
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Authentication</b></td>";
	echo "<td>";
	echo "<table border=\"0\" width=\"100%\">";
	$sysId = "325_99_99";
	$oidStr = "2.1.1";
	for($i = 0;$i < sizeof($auc_array);$i++ )
	{
		echo "<tr><td width=\"30%\">{$auc_array[$i][0]}</td>";		
		echo "<td>";
			$order=$auc_array[$i][2];
			showParameter($sysId,$oidStr,$order,1);
		echo "</td>";
	}

	echo "</table></td>";
	echo "</tr>";
}//en Authentication

{//reuAucTrip
	$reuAucTrip_array = array(
		array('Reuse Triplets','OptReuseTriplets',1),
		array('	Double Authentication','doubleAut',2)
	);//2.1.2
	
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Reuse authentication triplet</b></td>";
	echo "<td>";
	echo "<table border=\"0\" width=\"100%\">";
	$sysId = "325_99_99";
	$oidStr = "2.1.2";
	for($i = 0;$i < sizeof($reuAucTrip_array);$i++ )
	{
		echo "<tr><td width=\"30%\">{$reuAucTrip_array[$i][0]}</td>";		
		echo "<td>";
			$order=$reuAucTrip_array[$i][2];
			showParameter($sysId,$oidStr,$order,1);
		echo "</td>";	
	}
	echo "</table></td>";
	echo "</tr>";
}//end reuAucTrip

{//checkImei
	$checkimsi_array = array(
		array('Location update','location_checkimsi',1),
		array('MO Call','mo_call_checkimsi',2),
		array('MT Call','mt_call_checkimsi',3)
	);//2.1.8
	
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Validate IMEI</b></td>";
	echo "<td>";
	echo "<table border=\"0\" width=\"100%\">";
	$sysId = "325_99_99";
	$oidStr = "2.1.8";
	for($i = 0;$i < sizeof($checkimsi_array);$i++ )
	{
		echo "<tr><td width=\"30%\">{$checkimsi_array[$i][0]}</td>";		
		echo "<td>";
			$order=$checkimsi_array[$i][2];
			showParameter($sysId,$oidStr,$order,1);
		echo "</td>";
	}
	echo "</table></td>";
	echo "</tr>";
}//end checkImei


{//Location update flag
	$LocUpFlg_array = array(
		array('Normal LU to HLR','Normal_lu',1),
		array('Periodic LU','Periodic_lu',2),
		array('IMSI Attach','IMSI_lu',3)
	);//2.1.15
	$sysId = "325_99_99";
	$oidStr = "2.1.15";
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>Location update flag</b></td>";
	echo "<td>";
	echo "<table border=\"0\" width=\"100%\">";
	for($i = 0;$i < sizeof($LocUpFlg_array);$i++ )
	{
		echo "<tr><td width=\"30%\">{$LocUpFlg_array[$i][0]}</td>";		
		echo "<td>";
			$order=$LocUpFlg_array[$i][2];
			showParameter($sysId,$oidStr,$order,1);
		echo "</td>";	
	}
	echo "</table></td>";
	echo "</tr>";
}//end Location update flag

/*
{//license
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>License control</b></td>";
	echo "<td>&nbsp;";
		$sysId = "325_99_99";
		$oidStr = "2.1.16";
		showParameter($sysId,$oidStr,1,1,0,'','','Update');
	echo "</td>";	
	echo "</tr>";
}//end license
*/
echo "</table>";
{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "&nbsp;&nbsp;";
		echo "</td>";
		echo "<td width=\"20%\" align=\"right\">";
			echo "<input type=\"submit\" title=\"$strTitleGet\" name=\"getSys\" value=\"$strGet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
			echo "&nbsp;&nbsp;&nbsp;";
			echo "<input type=\"submit\" title=\"$strTitleSet\" name=\"setSys\" value=\"$strSet\" class=\"button\" style=\"cursor:pointer; left: 1; top: 2; width: 60; height: 25; position: relative\">";
		echo "</td>";
		echo "<td width=\"10%\">";
			echo "<p align=\"right\"><a href=\"../overview/overview.php?scroll_y=$page_top\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "</td>";
	echo "</tr>";
	echo "</table>";
}
echo "</form>";
?>
