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

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

<?php


$sysId	= '340_99_99';

$sqltable_sccp = 'OBJ_223.param_99';
$sysStatTable='OMC_PUB.sysStat';
$sqltable = 'OBJ_340.param_99';
$pubDb = 'OMC_PUB';
$sysinfo = 'OMC_PUB.sysInfo';
$sysTypeNo = '322';

$mtp3_sqlTable = 'OBJ_222.param_99';

$sysId_arr=array(
	array('oid'=>'2.2.3',		'sysid'=> '340_99_99',		'selectsysid'=>'-1'), 										
	array('oid'=>'2.1.10',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
);

$NI_arr=array('International','International spare','National','National spare');
$SaveArr=array(
	array('oidstr'=>'2.2.2',	'setvalue'=>'01'	,'sysid'=>'340_99_99'),
	array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99')				
);	
$backurl = "./auc.php";
//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=\"./auc.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";
	//auc
	$oidStr = "2.1.10";
	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>Getting parameters<br>";
//			GetParam(0,1);
						
			echo "<br>Setting parameters<br>";
			SetParam($sysId_arr);	
			session_register("acSetFlag");
						
			$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";
		}
	}
//	elseif(isset($undoSet))
//	{		
//		echo "<br>Setting parameters<br>";
//		SetParam(1);
//		session_unregister("acSetFlag");		
//		
//	}
	
	echo "<script LANGUAGE=\"JavaScript\">";
	if(!$DEBUG)
		echo "\n window.location.href=\"./auc.php\";";
	echo "\n </script>";	
	exit();	
}	
																								
//==========================================================
//输出并显示数据
//========================================================== 
echo "<form method=\"POST\" name=\"Set\" action=\"$PHP_SELF\">";

?>

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

{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">&nbsp";
			//echo "<b>Authentication Center:&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>";
}
echo "<br>";
?>

<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 ++)
	{
		$levelWhere = getLevelWhere($spcTree_array[$spc_index[$i]][3]);
		
		$getsql = "select initValue from $mtp3_sqlTable where $levelWhere";
		$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 width=\"25%\" align=\"left\">{$spcTree_array[$i][0]}&nbsp;:&nbsp;{$spcTree_array[$spc_index[$i]][1]}&nbsp;:&nbsp;$row[$i]</td>";
echo "</tr></table></td>";
echo "</tr>";

{//gtt
	$sysId = "223_99_99";
	$oidStr = "2.1.10";
	$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

$getSql="SELECT detailStat FROM $sysStatTable WHERE sysTypeNo='340' ORDER BY sysNo,subSysNo";
if($DEBUG) echo "<BR>getSql=$getSql";
$result	=mysqli_query($pubConn,$getSql);
$rows=mysqli_fetch_array($result);
		
$max_lic=hexdec(substr($rows[0],62,8));
$used_lic=hexdec(substr($rows[0],70,8));
		
$license_arr=array(
	array('Subscriber',	'used_lic'),
	array('License',	'max_lic')	
);

if($DEBUG)
{
	echo "<br>Max = $max_lic<br>";	
	echo "Used = $used_lic<br>";
}
	echo "<tr>";
	echo "<td bgcolor = \"#E6E6E6\"><b>{$license_arr[0][0]}</b></td>";
	echo "<td>&nbsp;${$license_arr[0][1]}</td>";
	echo "</tr>";
/*	
	{//license
		echo "<tr >" ;
		echo "<td bgcolor=\"#E6E6E6\"  ><b>License control</b></td>";
		echo "<td>&nbsp;";
	    	$sysId = '340_99_99';
			$oidStr = "2.2.3";
			showParameter($sysId,$oidStr,1,1,0,'','','Update');
		echo "</td>";	
		echo "</tr>";
	}//end license
*/
//==========================================================
//输出Command
//========================================================== 
/*
echo "<tr><td bgcolor=\"#E6E6E6\" ><b>Command</b></td>";
echo "<td><table width=100%><tr>";
echo "<td width=10%>AC0</td>";
echo "<td width=10%><a href='$PHP_SELF'>Lock</a></td>";
echo "<td width=10%>AC1</td>";
echo "<td><a href='$PHP_SELF'>Lock</a></td>";
echo "</tr></table></td></tr>";
*/
echo "</table>";
?>

<?php
echo "</form>";
?>
