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

<script LANGUAGE="JavaScript">       
function delFirm(No,flag,init,thisCheck)
{
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
    
	if(confirm('Do you want to delete the selected?') != true)
	{
		if(thisCheck.checked == true){
			thisCheck.checked=false;
		}else{
			thisCheck.checked=true;
		}
	}
	else
		window.location.href='<?php echo $PHP_SELF;?>?&delflag='+flag+'&delValue='+No+'&init='+init;
}

function lockFirm(No,flag,type1)
{
	var delValue,x,y;
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
	
	if(type1 == 'E1lock')
	{
		if(confirm('Do you want to Lock the Link?')==true)
			window.location.href='<?php echo $PHP_SELF;?>?E1lock=1&delValue='+No+'&flag='+flag;
	}
	if(type1 == 'E1unlock')
	{
		if(confirm('Do you want to Unlock the Link?')==true)
			window.location.href='<?php echo $PHP_SELF;?>?E1unlock=1&delValue='+No+'&flag='+flag;
	}		
}

function checkIP(item)
{
	var pattern =/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	if(!pattern.test(item.value))		
	{
		alert("IP address format error!");
		this.focus();
	}
}

//=======
function linkToSubPage(linkURL)
{
	var y=document.body.scrollTop;
	linkURL=linkURL+"&sub_page_top="+y;
	//alert(linkURL);
	window.location.href=linkURL;
}

//=======This function called when click the more and hide button=========================
//Parameter
//where:specify which buttons group of more and hide to click
//num:specify how many the elements for showing
//oper:specify which button to click,more or hide
function clickOnMoreHide(where,num,oper)
{
	var cmd;
	//to change the more button to hide button or reverse
	if(oper=='show')
	{
		cmd="document.all.show"+where+".style.display='none'";
		eval(cmd);
		cmd="document.all.hide"+where+".style.display='block'";
		eval(cmd);
			
		for(var i=4;i<num;i++)
		{
			cmd="document.all."+where+i+".style.display='block'";
			eval(cmd);
		}	
	}
	else
	{
		cmd="document.all.show"+where+".style.display='block'";
		eval(cmd);
		cmd="document.all.hide"+where+".style.display='none'";
		eval(cmd);
		
		for(var i=4;i<num;i++)
		{
			cmd="document.all."+where+i+".style.display='none'";
			eval(cmd);
		}	
	}
}
</script>

<?php
function alert($msg)
{
	echo "<script language=\"JavaScript\">\n";
	echo "alert('$msg')";
	echo "</script>";
}
$scroll_y = isset($scroll_y) ? $scroll_y : 0;

echo "<body topmargin=\"0\" onLoad=\"self.scrollBy(0,$scroll_y);\" leftmargin=\"12\">";

$backurl = './smsc.php';
$nProcFail = 0;//failure
$nWaitProc = 1;//wait
$nInProc   = 2;
$nOutProc  = 3;

$nGetComm = 0;
$nSetComm = 3;
	
$maxNum = 60;

$sysId	= '350_99_99';
$oidarr	= array('2.1.1','2.1.3','2.2.0');

$smpp_id	= '260_99_99';
$smpp_oid	= "2.1.0";

$sccp_id = '223_99_99';
$sccp_oid = array('2.1.11','2.1.20');

$sqltable = 'OBJ_350.param_99';
$mtp3_sqlTable = 'OBJ_222.param_99';
$sqltable_conf = 'OBJ_350.paramConf';
$sqltable_smpp = 'OBJ_260.param_99';
$sqltable_sccp = 'OBJ_223.param_99';
$sqltable_pub = 'OMC_PUB.sysStat';
$sqlConf_pub = 'OMC_PUB.sysConf';
$pubDb = 'OMC_PUB';
$sqltable_spc = 'OBJ_222.param_99';
$sysinfo = 'OMC_PUB.sysInfo';
$sysTypeNo = '322';

$net_paramTable		='OBJ_225.param_99';//xapp
$net_paramConf		='OBJ_225.paramConf';


$sysId_arr=array(
	array('oid'=>'2.2',			'sysid'=> '222_99_99',		'selectsysid'=>'-1'), 										
	array('oid'=>'2.3',			'sysid'=> '222_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.1',			'sysid'=> '350_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.2',			'sysid'=> '350_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.3',			'sysid'=> '350_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.5',			'sysid'=> '350_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.9.0',		'sysid'=> '225_99_99',		'selectsysid'=>'-1'),
	
	array('oid'=>'2.1.11',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.1.20',		'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
	array('oid'=>'2.2',			'sysid'=> '223_99_99',		'selectsysid'=>'-1'),
);

$size=sizeof($sysId_arr);
$selSql = "select sysNo,subSysNo from OMC_PUB.sysStat where sysTypeNo='350'";
$result = mysqli_query($pubConn,$selSql);
$no=0;
while($rows = mysqli_fetch_array($result))
{
	$smscSysNo[$no] = $rows[sysNo];
	$smscTable[$no] = "OBJ_350.param_".$rows[sysNo];
	$tmpsysId = '350_'.$rows[sysNo].'_0';
	$sysId_arr[$size++]	= array('oid'=>'2.1.6',	'sysid'=> $tmpsysId,'selectsysid'=>'-1');
	$no++;
}

$SaveArr=array(
				array('oidstr'=>'3.3',	'setvalue'=>'01'	,'sysid'=>'350_99_99'),
				array('oidstr'=>'3.2',	'setvalue'=>'02'	,'sysid'=>'223_99_99'),				
);	
$getsql = "SELECT sysNo FROM $sysinfo where sysTypeNo = 322";
if($DEBUG) echo "getsql = $getsql<br>";
$Result = @mysqli_query($pubConn,$getsql);
while($Rows = mysqli_fetch_array($Result))
{
	$xappSysId = "225_9"."_".$Rows[sysNo];
	$SaveArr[] = array('oidstr'=>'3.2',	'setvalue'=>'01'	,'sysid'=> '225_99_99','selectsysid' => $xappSysId);
}

$url_add = './smsc.php';
$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')
);


//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=\"./smsc.php\";";
	} 
	else exit();
	echo "\n </script>";
}
{//get upd and tcp default value
	$wSc = " AND level_1 = 2 AND (level_2 = 2 OR level_2 = 3)";
	
	$defSql = " SELECT level_1,level_2,level_3,initValue FROM $sqltable_conf WHERE keyId > 0 ".$wSc." ORDER BY level_2,level_3 ";
	if($DEBUG)echo "<br>defSql=$defSql";
	$defRes = @mysqli_query($pubConn,$defSql);
	$defRow = @mysqli_fetch_array($defRes);
	
	do
	{
		$level_1 = $defRow[level_1];
		$level_2 = $defRow[level_2];
		$level_3 = $defRow[level_3];
		$defaultValue[$level_2][$level_3] = $defRow[initValue];
		if($DEBUG) echo "<br>defaultValue[$level_2][$level_3]={$defaultValue[$level_2][$level_3]}";
		
	}while($defRow = @mysqli_fetch_array($defRes));
}//end get default value

$getsql = "select initValue from $net_paramConf where level_1 = '2' and level_2 = '9'";  
$result = @mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);
$cli_conv_def = mysqli_fetch_array($result);
$cli_conv_def = $cli_conv_def[0];

if(isset($doingOtherFlag))
{
	{//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";
		if($setMapGtt==1)//MAP
		{
			$oidStr = "2.1.11";
			setParamValue($mss_ip[0],$sysId,$oidStr,3);
			setParamValue($mss_ip[1],$sysId,$oidStr,4);
		}
		if($setSmppGtt==1)//smpp
		{
			$oidStr = "2.1.20";
			setParamValue($mss_ip[0],$sysId,$oidStr,3);
			setParamValue($mss_ip[1],$sysId,$oidStr,4);
		}
	}//end set system ip	
	exit;
}
	
if($_SERVER['REQUEST_METHOD'] == "POST")
{

	for($i=0; $i<2; $i++)
	{
		$updTable = 'OBJ_350.param_' . $i;
		$updSql = "update $updTable set initValue = '{$mss_ip[$i]}' 
		where level_1='2' and level_2='1' and level_3='6' ";
		mysqli_query($pubConn,$updSql);
	}	

	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("mcSetFlag");
						
			$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=\"./smsc.php\";";
	echo "\n </script>";	
	//exit();	
}	

if (isset($delflag))
{
	$delNoStr = rtrim($delNoStr,'.');
	$delNoArr = explode('.',$delNoStr);
	$instNoWhereStr = '';
	for($i=0; $i< sizeof($delNoArr); $i++)
	{
		if($i==0)
			$instNoWhereStr = "(instanceNo='$delNoArr[$i]'";
		else
			$instNoWhereStr .= " or instanceNo='$delNoArr[$i]'" ;
	}
	$instNoWhereStr .= ')';
		
	if($delflag == 'msisdn')
	{
		$getsql = "select initValue from $sqltable_conf
		where level_1 = '2' and level_2 = '1' and level_3 = '4'";
		$msisdn_result = mysqli_query($pubConn,$getsql);
		echo mysqli_error($pubConn);
		$msisdn_org = mysqli_fetch_array($msisdn_result);
		$msisdn_org = $msisdn_org[0];

		$setsql = "update $sqltable set initValue = '$msisdn_org'
			where level_1 = '2' and level_2 = '1' and level_3 = '4' and $instNoWhereStr ";
			
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
		if(0) echo "<br>$setsql<br>";
	}
	if($delflag == 'udp'||$delflag=='tcp')
	{
		if($delflag=='udp')
			$tmp_level_2 = 2;
		else
			$tmp_level_2 = 3;
		$setsql = "SELECT level_3 FROM $sqltable 
				WHERE subSysNo = '99' AND level_1 = 2 AND level_2 = $tmp_level_2
				ORDER BY level_3 ";
		$Result = mysqli_query($pubConn,$setsql);
		while($rows = mysqli_fetch_array($Result))
		{
			$level_3 = $rows[0];
			$updSql = "update $sqltable set initValue = '{$defaultValue[$tmp_level_2][$level_3]}'
			      where level_1='2' and level_2='$tmp_level_2' and level_3='$level_3' and $instNoWhereStr";
			mysqli_query($pubConn,$updSql);
			echo mysqli_error($pubConn);
			if($DEBUG) echo "<br>$setsql<br>";
		}
	}
	if ($delflag == 'cli')	//CLI prefix
	{
		$delNoStr = rtrim($delNoStr,'.');
		$delNoArr = explode('.',$delNoStr);
		$instNoWhereStr = '';
		for($i=0; $i< sizeof($delNoArr); $i++)
		{
			if($i==0)
				$instNoWhereStr = "(instanceNo='$delNoArr[$i]'";
			else
				$instNoWhereStr .= " or instanceNo='$delNoArr[$i]'" ;
		}
		$instNoWhereStr .= ')';
		$objWhereStr = getLevelWhere('2.9.0');
		
		$setsql = "update $net_paramTable set initValue = '$cli_conv_def' 
			where $objWhereStr and $instNoWhereStr";	
		if($DEBUG) echo "<br>setsql:$setsql<br>";
		//exit;
		mysqli_query($pubConn,$setsql);
		echo mysqli_error($pubConn);
	}
}

if(1==$E1lock || 1==$E1unlock)
{
	if($flag == 'udp') 
		$level2 = 2;
	else
		$level2 = 3;
	$getsql = "select initValue from $sqltable
	where level_1 = '2' and level_2 = '$level2' and level_3 = '14'";
	$result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$Row = mysqli_fetch_array($result);
	$setValue = $Row[initValue];
	if(1==$E1lock)
		$bitValue=0;
	if(1==$E1unlock)
		$bitValue=1;
	$offset = '00.1-00.1';

	$setValue = setBitValue($setValue,$offset,$bitValue);
	
	$setsql = "update $sqltable set initValue = '$setValue'
		where level_1 = '2' and level_2 = '$level2' and level_3 = '14' and instanceNo='$delValue'";
	
	mysqli_query($pubConn,$setsql);
	echo mysqli_error($pubConn);
	$oidstr = "2.$level2.14";
	$commIdStr	=oidSysCommSend($sysId,$nSetComm,$oidstr);
	if($commIdStr=='-1')
	{
		DelComm($commArr);
		echo "<br><br><b>Error while getting/setting parameters. Please check the device state!<br>";
		echo "oidSysCommSend($tmpSysId,$nSetComm,$tmpObjIdStr)<br>";
		echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";			
		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=\"#\">SMSC</a>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
$helpId = '2.1.1.5';
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br>";

{
	echo "<table width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"70%\">";
			echo "<b>&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 ++)
	{
		$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%\">{$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>";


//==========================================================
//输出Global Title
//========================================================== 
$sysId = "223_99_99";
$oidStr = "2.1.11";
$instanceNo=0;
echo "<tr>";
echo "<td bgcolor=\"#E6E6E6\" ><b>$strE164Number(MAP)</b></td>";
echo "<td><table width=100%><tr>";
	echo "<td align=\"left\" width=50%>";
	$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setMapGtt=1";
		showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
	echo "</td>";
	
	echo "<td align=\"left\" width=50% >";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
echo "</tr></table></td></tr>";

echo "<tr >" ;
$oidStr = "2.1.20";
echo "<td bgcolor=\"#E6E6E6\" ><b>$strE164Number(SMPP)</b></td>";
echo "<td><table width=100%><tr>";
echo "<td align=\"left\" width=50%>";
	$doingOtherUlr="$PHP_SELF?doingOtherFlag=1&setSmppGtt=1";
		showParameter($sysId,$oidStr,2,1,$instanceNo,$doingOtherUlr);
	echo "</td>";
	
	echo "<td align=\"left\" width=50% >";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
echo "</tr></table></td></tr>";

{//输出SMS validity
	$getsql = "select initValue from $sqltable
	where level_1 = '2' and level_2 = '1' and level_3 = '3'";
	$count_result = mysqli_query($pubConn,$getsql);
	echo mysqli_error($pubConn);
	$count_result = @mysqli_fetch_array($count_result);
	$sms_time = hexdec(getBitValue($count_result[0],'00.0-03.7'));
	$sms_time = $sms_time / 3600;
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"><b>SMS validity</b></td>";
	$sysId = "350_99_99";
	$oidStr = "2.1.3";
	echo "<td>&nbsp;";
		showParameter($sysId,$oidStr,1,1);
	echo "&nbsp;Seconds</td>";
	echo "</tr>";
}//end SMS validity

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

{//输出log
	echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\"><b>Log flag</b></td>";
	
	$oidStr = "2.1.10";
	echo "<td>&nbsp;";
	$sysId = "350_99_99";
		showParameter($sysId,$oidStr,1,1);
	echo "</td>";
	echo "</tr>";
	
	echo "<input type=\"hidden\" name=\"log_init\" value=\"$log_result[0]\">";
}//end log


{//输出MSISDN range
$getsql = "select initValue from $sqltable_conf
where level_1 = '2' and level_2 = '1' and level_3 = '4'";
$msisdn_result = mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);
$msisdn_org = mysqli_fetch_array($msisdn_result);
$msisdn_org = $msisdn_org[0];

echo "<input type=\"hidden\" name=\"msisdn_org\" value=\"$msisdn_org\">";

$getsql = "select initValue from $sqltable
where level_1 = '2' and level_2 = '1' and level_3 = '4'";
$msisdn_result = mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);

$n = 0;
$i = 0;
//if($DEBUG) echo "msisdn_org = $msisdn_org<br>";
while($msisdn_row = mysqli_fetch_array($msisdn_result))
{
	//if($DEBUG) echo "msisdn_row = $msisdn_row[0]<br>";
	$msisdn_row = $msisdn_row[0];
	//$ms_ins[$i]
	
	if($msisdn_row != $msisdn_org)
	{
		$ms_row[$n] = $msisdn_row;
		if($DEBUG) echo "msisdn_row = $msisdn_row<br>";
		$ms_start[$n] = getBitValue($msisdn_row,'0.0-8.7');
		if($DEBUG) echo "ms_start = $ms_start[$n]<br>";	
		$ms_start[$n] = str_replace('E','',$ms_start[$n]);		
		if($ms_start[$n] == '')
			$ms_start[$n] = 0;
		$ms_end[$n] = getBitValue($msisdn_row,'9.0-17.7');	
		if($DEBUG) echo "ms_end = $ms_end[$n]<br>";	
		$ms_end[$n] = str_replace('E','',$ms_end[$n]);
		if($ms_end[$n] == '')
			$ms_end[$n] = 0;
		$ms_ins[$n] = $i;
		$n++;
	}	
	else if(!isset($unused_no))
	{
		$unused_no = $i;	
	}
	$i++;	
}

if(!isset($unused_no))
	$unused_no = -1;
$nrow = $n + 1;
echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\" >";
		echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
			echo "<tr >";
				echo "<td align=left><b>Subscriber segment</b></td>";
				//href=\"./ra_default.php?typeFlag=MSISDN&instanceNo=$unused_no&backurl=./smsc.php\"
				echo "<td align=\"right\"><a href=\"javascript:linkToSubPage('./ra_default.php?typeFlag=MSISDN&instanceNo=$unused_no&backurl=./smsc.php')\"
							onClick=\"javascript:CheckInsNo('$unused_no','$url_add');\">&nbsp;<font size=4>+</font></a></td>";
			echo "</tr>";
		echo "</table>";
	echo "</td>";

	if($n == 0)
	{
		echo "<td  >&nbsp--</td>";
	}
	else
	{
			$flag = 'msisdn';
			echo "<td>";
				echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
					echo "<tr bgcolor=\"#E6E6E6\">";
						echo "<td align=\"left\" width=\"10%\">No.</td>";
						echo "<td colspan=\"3\" align=\"left\" width=\"40%\">Start MSISDN</td>";
						echo "<td colspan=\"3\" align=\"left\" width=\"40%\">End MSISDN</td>";
						//echo "<td align=\"right\" width=\"10%\">Delete</td>";
						echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$n)\" title=\"Delete all selected.\">Delete</a>";
						echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$n)>";
						echo "</td>";
					echo "</tr>";
		for($i=0; $i < $n; $i++)
		{
			$checkBoxName=$flag . 'checkBox_'.$i;
			$deleteNo = $flag . 'deleteno_'.$i;
			if($i>3)
				echo "<tr id='msisdn$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			else
				echo "<tr id='msisdn$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
			//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				echo "<td align=\"left\" width=\"10%\"><a href=\"javascript:linkToSubPage('./ra_default.php?typeFlag=MSISDN
					&instanceNo=$ms_ins[$i]&backurl=./smsc.php')\">&nbsp;$ms_ins[$i]</a></td>";
				echo "<td colspan=\"3\" align=\"left\" width=\"40%\">$ms_start[$i]</td>";
				echo "<td colspan=\"3\" align=\"left\" width=\"40%\">$ms_end[$i]</td>"; 
				/*echo "<td align=\"right\" width=\"10%\"><input type=\"checkbox\" name=\"$ms_del_$i\" value=\"ON\" 
				onClick=\"javascript:delFirm('$ms_ins[$i]','msisdn','$msisdn_org',this)\" ></td>";*/
			
				echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
				echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$ms_ins[$i]}\"";
			echo "</tr>";
		}
		//==more button====
		if($n>4)
		{
			echo "<tr id='showmsisdn' style=\"display:block\"><td><a href=\"javascript:clickOnMoreHide('msisdn',$n,'show')\">More >></a></td></tr>"; 
			echo "<tr id='hidemsisdn' style=\"display:none\"><td><a href=\"javascript:clickOnMoreHide('msisdn',$n,'hide')\">Hide >></a></td></tr>"; 
		}
		echo "</table>";
		echo "</td>";
	}
}//end msisdn range

{//show udp and tcp smpp
	{//get upd and tcp status from heartbeat
		$linkStatArray = array('Unavailable','Available');
		$selSql = "select detailStat from sysStat where sysTypeNo='350' ";
		$result = mysqli_query($pubConn,$selSql);
		$Rows = mysqli_fetch_array($result);
		if($DEBUG) echo $Rows[0];
		$updStart = 47;
		$hexStr = substr($Rows[0],$updStart*2,2);
		$binStr = omc_keep_length(decbin(hexdec($hexStr)),'0',8);
		for($i=strlen($binStr)-1; $i>=0; $i--)
		{
			$udpLinkStat[$i] = $linkStatArray[substr($binStr,7-$i,1)];
			//echo "<br>udpLinkStat[$i]: ".$udpLinkStat[$i];
		}
		$tcpStart = 48;
		for($i=0; $i< 4; $i++)
		{
			$hexStr = substr($Rows[0],($tcpStart+$i)*2,2);
			$binStr = omc_keep_length(decbin(hexdec($hexStr)),'0',8);
			//echo "<br>$binStr";
			for($j=7; $j>=0; $j--)
			{
				$no = $i*8+$j;
				$tcpLinkStat[$no] = $linkStatArray[substr($binStr,7-$j,1)];
			}
		}
	}//end get status
	{//get udp and tcp value
		/************select value to see************/
		$scSql = " SELECT level_1,level_2,level_3,instanceNo,initValue,readValue FROM $sqltable WHERE subSysNo = '99' ".$wSc." ORDER BY level_3 "; 
		if($DEBUG) echo "<br>scSql=$scSql";
		$scRes = @mysqli_query($pubConn,$scSql);
		$scRow = @mysqli_fetch_array($scRes);
		echo mysqli_error($pubConn);
		do
		{
			$level_1 = $scRow[level_1];
			$level_2 = $scRow[level_2];
			$level_3 = $scRow[level_3];
			$instanceNo = $scRow[instanceNo];
		
//			if($level_3 > 1){//if no.1=="--",then all="--"
//				if($showValue[$level_2][$instanceNo][1] == '--')
//				{
//					$showValue[$level_2][$instanceNo][$level_3] = "--";
//					continue;
//				}
//			}
			
			if($scRow[initValue] == $defaultValue[$level_2][$level_3] && (($level_2 == 2 && $level_3 < 7) OR ($level_2 == 3 && $level_3 < 8)) ){
				$showValue[$level_2][$instanceNo][$level_3] = "--";
				continue;
			}
				
			if($level_3 > 0 && $level_3 < 4){//name,sysid,password
				$valueLen = floor(strLen($scRow[initValue])/2);
				for($i=0;$i<$valueLen;$i++){
					$temValue[$i] = substr($scRow[initValue],$i*2,2);
					if($temValue[$i] == '00'){
						break;
					}else{
						$temValue[$i] = Chr(HexDec($temValue[$i]));
					}
				}
				$aNum = $i;
				$tValue = '';
				for($i=0;$i<$aNum;$i++){
					$tValue = $tValue.$temValue[$i];
				}
				if($DEBUG)echo "<br>tValue=$tValue";
				$showValue[$level_2][$instanceNo][$level_3] = $tValue;
			}elseif($level_3 == 4){
				$p4 = explode("E",$scRow[initValue]);
				$showValue[$level_2][$instanceNo][$level_3] = $p4[0];
			}elseif($level_3 == 6){
				if($level_2 == 2){
					$p6 = explode("E",$scRow[initValue]);
					$showValue[$level_2][$instanceNo][$level_3] = $p6[0];
				}elseif($level_2 == 3){
					$valueLen = floor(strLen($scRow[initValue])/2);
					for($i=0;$i<$valueLen;$i++){
						$temValue[$i] = HexDec(substr($scRow[initValue],$i*2,2));
					}
					$showValue[$level_2][$instanceNo][$level_3] = $temValue[0].".".$temValue[1].".".$temValue[2].".".$temValue[3];
				}
			}elseif($level_3 == 7){
				if($level_2 == 2){
					$showValue[$level_2][$instanceNo][$level_3]	= HexDec($scRow[initValue]);
				}else{
					$valueLen = floor(strLen($scRow[initValue])/2);
					for($i=0;$i<$valueLen;$i++){
						$temValue[$i] = HexDec(substr($scRow[initValue],$i*2,2));
					}
					$showValue[$level_2][$instanceNo][$level_3] = $temValue[0].".".$temValue[1].".".$temValue[2].".".$temValue[3];
				}
			}elseif($level_3 == 12){
				if($scRow[initValue]==0||HexDec($scRow[initValue])==16)
					$showValue[$level_2][$instanceNo][$level_3]='7bit';
				else
					$showValue[$level_2][$instanceNo][$level_3]='8bit';
			}else{
				$showValue[$level_2][$instanceNo][$level_3]	= HexDec($scRow[initValue]);
			}
			if($DEBUG) echo "<br>showValue[$level_2][$instanceNo][$level_3]={$showValue[$level_2][$instanceNo][$level_3]}";
		}while($scRow = @mysqli_fetch_array($scRes));
	}//end get value
	{//$showUdpmArr
	$showUdpmArr = array(
					"",
					"Name",
					"System&nbsp;ID",
					"Password",
					"Service&nbsp;Number",
					"Destination&nbsp;addr.&nbsp;type",
					"GTT&nbsp;Number",
					"Session&nbsp;timer",
					"Enquire&nbsp;link&nbsp;timer",
					"Inactivity&nbsp;timer",
					"Response&nbsp;timer",
					"",
					"DCS",
					"Time to live",
					);
	}
	
	{//find not used instanceNo
	for($i=2;$i< 8;$i++)//find from instanceNo=2; instanceNo 0,1:reserved for pps Global title(EMSE), 0:Inquiry number, 1:Recharge via recharge card
	{
		$enable = getBitValue($showValue[2][$i][14],'0.0-0.0');
		if($enable==0)
		{
			$newInstNo=$i;
			break;
		}
	}
	if(!isset($newInstNo))
		$newInstNo=-1;
	}
	
	
	
	$flag = 'udp';
	$showNum=0;
	for($i=0;$i< 8;$i++)
	{
		$enable = getBitValue($showValue[2][$i][14],'0.0-0.0');
		if($enable==1)
			$showNum++;
	}
	echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\" >";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
				echo "<tr >";
					echo "<td align=left><b>SMPP link(UDP)</b></td>";
					//alert($showNum);
					if($showNum>=8)
						echo "<td>&nbsp</td>";
					else
						echo "<td align=\"right\"><a href=javascript:openSet('udp',$newInstNo,'$backurl')><font size=4>+</font></a></td>";
				echo "</tr>";
			echo "</table>";
		echo "</td>";
		
	
	if($showNum==0)
	{
		echo "<td >&nbsp;--</td>";
	}
	else
	{
		echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=\"5%\">No.</td>";
					for($j=1;$j< 14;$j++)
					{
						if($j==1 || $j==4 || $j==6)
						echo "<td align=\"left\" width=\"15\">{$showUdpmArr[$j]}</td>";
					}
					echo "<td width=\"20%\">Status</td>";
					echo "<td width=\"20%\">Admin State</td>";
					echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$showNum)\" title=\"Delete all selected.\">Delete</a>";
					echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$showNum)>";
					echo "</td>";
				echo "</tr>";
			$showNum=0;
			for($i=0;$i< 8;$i++)
			{
				$enable = getBitValue($showValue[2][$i][14],'0.0-0.0');
				if($enable==0)
					continue;
				$checkBoxName=$flag . 'checkBox_'.$showNum;
				$deleteNo = $flag . 'deleteno_'.$showNum;
				if($showNum>3)
					echo "<tr id='udp$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='udp$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				
				
				$showNum++;
			
				//echo "<tr  onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					echo "<td width=\"5%\"><a href=javascript:openSet('udp',$i,'$backurl')>$i</a></td>";
						for($j=1;$j< 14;$j++)
						{
							if($j==1 || $j==4 || $j==6)
								echo "<td width=\"20%\" align=\"left\"><nobr>{$showValue[2][$i][$j]}&nbsp;</nobr></td>";
						}
					{//link status
						if($udpLinkStat[$i]=='Available')
							$color="#0000ff";
						else
							$color = "#FF0000";
						$input_name = 'udplinkStat_' . $i;
						//echo "<td width=\"10%\"><span id=\"$input_name\" style=\"color:$color\">{$udpLinkStat[$i]}</span></td>";
						echo "<td width=\"10%\"><span id=\"$input_name\">--</span></td>";
					}//end link status
					//echo "<td width=\"10%\">{$udpLinkStat[$i]}</td>";

					$udpflag =getBitValue($showValue[2][$i][14],'00.1-00.1');
					if($udpflag)
						echo "<td><a href=\"javascript:lockFirm('$i','udp','E1lock')\" title=\"to lock this Link\">Unlocked</a>";
					else
						echo "<td><a href=\"javascript:lockFirm('$i','udp','E1unlock')\" title=\"to unlock this Link\">Locked</a>";

					echo "<td width=\"15%\"align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
					echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$i\"";
				echo "</tr>";  
			}
			if($showNum>4)
			{
					echo "<tr id='showudp' style=\"display:block\"><td colspan=7><a href=\"javascript:clickOnMoreHide('udp',$showNum,'show')\">More >></a></td></tr>"; 
					echo "<tr id='hideudp' style=\"display:none\"><td colspan=7><a href=\"javascript:clickOnMoreHide('udp',$showNum,'hide')\">Hide >></a></td></tr>"; 
			}
			echo "</table>";
		echo "</td>";
	}
	
	//show tcp smpp
	$showTcpmArr = array(
					"",
					"Name",
					"System&nbsp;ID",
					"Password",
					"Service&nbsp;Number",
					"Destination&nbsp;addr.&nbsp;type",
					"Service&nbsp;IP",
					"Local&nbsp;IP&nbsp;address",
					"Session&nbsp;timer",
					"Enquire&nbsp;link&nbsp;timer",
					"Inactivity&nbsp;timer",
					"Response&nbsp;timer",					
					"DCS",
					"Time&nbsp;to&nbsp;live",
					);
	{//find not used instanceNo
	for($i=0;$i< 32;$i++)
	{
		$enable = getBitValue($showValue[3][$i][14],'0.0-0.0');
		if($enable==0)
		{
			$newInstNo=$i;
			break;
		}
	}
	if(!isset($newInstNo))
		$newInstNo=-1;
	}
	
	
	$flag = 'tcp';
	$showNum=0;
	for($i=0;$i< 32;$i++)
	{
		$enable = getBitValue($showValue[3][$i][14],'0.0-0.0');
		if($enable==1)
			$showNum++;
	}
	echo "<tr>" ;
		echo "<td bgcolor=\"#E6E6E6\" >";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" >";
				echo "<tr >";
					echo "<td align=left><b>SMPP link(TCP)</b></td>";
					//alert($showNum);
					if($showNum>=32)
						echo "<td>&nbsp</td>";
					else
						echo "<td align=\"right\"><a href=javascript:openSet('tcp',$newInstNo,'$backurl')><font size=4>+</font></a></td>";
				echo "</tr>";
			echo "</table>";
		echo "</td>";
	
	
	if($showNum==0)
	{
		echo "<td >&nbsp;--</td>";
	}
	else
	{
		echo "<td>";
			echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=\"5%\">No.</td>";
					for($j=1;$j< 14;$j++)
					{
						if($j==1 || $j==4 || $j==6)
						echo "<td align=\"left\" width=\"15\">{$showTcpmArr[$j]}</td>";
					}
					echo "<td width=\"20%\">Status</td>";
					echo "<td width=\"20%\">Admin State</td>";
					echo "<td width=\"15%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$showNum)\" title=\"Delete all selected.\">Delete</a>";
					echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$showNum)>";
					echo "</td>";
				echo "</tr>";
			$showNum=0;
			for($i=0;$i< 32;$i++)
			{
				$enable = getBitValue($showValue[3][$i][14],'0.0-0.0');
				if($enable==0)
				{
					continue;
				}
				$checkBoxName=$flag . 'checkBox_'.$showNum;
				$deleteNo = $flag . 'deleteno_'.$showNum;
				if($showNum>3)
					echo "<tr id='tcp$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
				else
					echo "<tr id='tcp$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					
				
				
				$showNum++;
				//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
					echo "<td width=\"5%\"><a href=javascript:openSet('tcp',$i,'$backurl')>$i</a></td>";
						for($j=1;$j< 14;$j++)
						{
							if($j==1 || $j==4 || $j==6)
								echo "<td width=\"20%\" align=\"left\"><nobr>{$showValue[3][$i][$j]}&nbsp;</nobr></td>";
						}
					{//link status
						if($tcpLinkStat[$i]=='Available')
							$color="#0000ff";
						else
							$color = "#FF0000";
						$input_name = 'tcplinkStat_' . $i;
						echo "<td width=\"10%\"><span id=\"$input_name\" style=\"color:$color\">{$tcpLinkStat[$i]}</span></td>";
					}//end link status
					$tcpflag =getBitValue($showValue[3][$i][14],'00.1-00.1');
					if($tcpflag)
						echo "<td><a href=\"javascript:lockFirm('$i','tcp','E1lock')\" title=\"to lock this Link\">Unlocked</a>";
					else
						echo "<td><a href=\"javascript:lockFirm('$i','tcp','E1unlock')\" title=\"to unlock this Link\">Locked</a>";

					echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
					echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"$i\"";
				echo "</tr>";  
			}
			//====more button====
			if($showNum>4)
			{
				echo "<tr id='showtcp' style=\"display:block\"><td colspan=7><a href=\"javascript:clickOnMoreHide('tcp',$showNum,'show')\">More >></a></td></tr>"; 
				echo "<tr id='hidetcp' style=\"display:none\"><td colspan=7><a href=\"javascript:clickOnMoreHide('tcp',$showNum,'hide')\">Hide >></a></td></tr>"; 
			}
			echo "</table>";
		echo "</td>";
	}
}//end show udp and tcp smpp

	
{//输出CLI conversion prefix
//show text define

$cli_conv_showText_define = array('','IDD','NDD','Unknown');

$getsql = "select instanceNo,initValue from $net_paramTable where level_1 = '2' and level_2 = '9'
	and initValue != '$cli_conv_def'";  
$result = @mysqli_query($pubConn,$getsql);
echo mysqli_error($pubConn);

$cli_conv_num = 0;
while($cli_conv_row = @mysqli_fetch_array($result))
{
	$cli_prefix[$cli_conv_num][instanceNo] = $cli_conv_row[instanceNo];
	$cli_prefix[$cli_conv_num][in_property] = hexdec(getBitValue($cli_conv_row[initValue],'00.0-00.7'));
	$cli_prefix[$cli_conv_num][Prefix] = trim(toAscii(getBitValue($cli_conv_row[initValue],'01.0-16.7')));
	$cli_prefix[$cli_conv_num][delete_length] = hexdec(getBitValue($cli_conv_row[initValue],'17.0-17.7'));
	$cli_prefix[$cli_conv_num][out_property] = hexdec(getBitValue($cli_conv_row[initValue],'18.0-18.7'));
	$cli_prefix[$cli_conv_num][add_length] = hexdec(getBitValue($cli_conv_row[initValue],'19.0-19.7'));
	$cli_prefix[$cli_conv_num][add_digits] = toAscii(getBitValue($cli_conv_row[initValue],'20.0-35.7'));
	$cli_prefix[$cli_conv_num][valid_length] = hexdec(getBitValue($cli_conv_row[initValue],'36.0-36.7'));
	$cli_conv_num++;
}

if ($cli_conv_num != 0)
{
	for($i=0; $i < 256; $i++)
	{
		if($i != $cli_prefix[$i][instanceNo])
		{
			$unused_cli_ins = $i;
			break;
		}	
	}
}
else
	$unused_cli_ins = 0;
if($DEBUG) echo "cli_conv_num = $cli_conv_num<br>";
$cli_conv_nrow = $cli_conv_num+1;
if($cli_conv_num>10)
	$cli_conv_nrow = $cli_conv_num+2;

$objIdStr='no-2.9';
$sysId_xapp = '225_99_99';
$webname="MSC";
$setname="CLI Manipulation";

echo "<tr>" ;
	echo "<td bgcolor=\"#E6E6E6\">";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" ><tr >";
	echo "<td align=left><b>CLI manipulation</b></td>";
	echo "<td align=\"right\"><a  href=\"javascript:openCliPrefix('$unused_cli_ins','$objIdStr','$sysId_xapp','$webname','$setname','$backurl')\"><font size=4>+</font></a></td>";
	echo "</tr></table></td>";
if($cli_conv_num == 0) echo "<td>&nbsp;--</td>";
else
{
	echo "<td>";
	echo "<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">";
	$flag = 'cli';
	echo "<tr bgcolor=\"#E6E6E6\">";
		echo "<td width=5%>No.</td>";
		echo "<td width=9%>In</td>";
		echo "<td width=18%>Prefix</td>";
		echo "<td width=12%>Del len</td>";
		echo "<td width=9%>Out</td>";
		echo "<td width=12%>Add len</td>";
		echo "<td width=18%>Add digits</td>";
		echo "<td width=12%>Valid len</td>";
		//echo "<td align=right>Delete";
		echo "<td align=right><a href=\"javascript:delSelected('Set','$flag',0,$cli_conv_num)\" title=\"Delete all selected.\">Delete</a>";
		echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$cli_conv_num)>";
		echo "</td>";
	echo "</tr>";
	
	for($i=0; $i < $cli_conv_num; $i++)
	{
		$checkBoxName=$flag . 'checkBox_'.$i;
		$deleteNo = $flag . 'deleteno_'.$i;
		$cli_prefix[$i][Prefix] = ord($cli_prefix[$i][Prefix])==0 ? '--' : $cli_prefix[$i][Prefix];
		$cli_prefix[$i][add_digits] = ord($cli_prefix[$i][add_digits])==0 ? '--' : $cli_prefix[$i][add_digits];
//		$cli_prefix[$i][delete_length] = strlen($cli_prefix[$i][delete_length])==0 ? '--' : $cli_prefix[$i][delete_length];
//		$cli_prefix[$i][in_property] = strlen($cli_prefix[$i][in_property])==0 ? '--' : $cli_prefix[$i][in_property];
//		$cli_prefix[$i][out_property] = strlen($cli_prefix[$i][out_property])==0 ? '--' : $cli_prefix[$i][out_property];
//		$cli_prefix[$i][add_length] = strlen($cli_prefix[$i][add_length])==0 ? '--' : $cli_prefix[$i][add_length];
//		$cli_prefix[$i][valid_length] = strlen($cli_prefix[$i][valid_length])==0 ? '--' : $cli_prefix[$i][valid_length];
		if($i>3)
			echo "<tr id='cli$i' style=\"display:none\" onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		else
			echo "<tr id='cli$i' onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		
		
		//echo "<tr onMouseOver=\"this.bgColor='#D2F0FF'\" onMouseOut=\"this.bgColor='#ffffff'\">";
		echo "<td width=5%><a  href=\"javascript:openCliPrefix('{$cli_prefix[$i][instanceNo]}','$objIdStr','$sysId_xapp','$webname','$setname','$backurl')\">$i</td>";
		echo "<td width=9%>{$cli_conv_showText_define[$cli_prefix[$i][in_property]]}</td>";
		echo "<td width=18%>{$cli_prefix[$i][Prefix]}</td>";
		echo "<td width=12%>{$cli_prefix[$i][delete_length]}</td>";
		echo "<td width=9%>{$cli_conv_showText_define[$cli_prefix[$i][out_property]]}</td>";
		echo "<td width=12%>{$cli_prefix[$i][add_length]}</td>";
		echo "<td width=18%>{$cli_prefix[$i][add_digits]}</td>";
		echo "<td width=12%>{$cli_prefix[$i][valid_length]}</td>";
		//echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:delFirm('cli',{$cli_prefix[$i][instanceNo]},'',this)\"></td>";
		echo "<td align=right><input type=\"checkbox\" name=\"$checkBoxName\" value=\"0\" onClick=\"javascript:selectToDel(this)\"></td>";
		echo "<input type=\"hidden\" name=\"$deleteNo\" value=\"{$cli_prefix[$i][instanceNo]}\"";
		echo "</tr>";
	}
	if($cli_conv_num>10)
	{
		echo "<tr>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td ></td>";
		echo "<td width=\"10%\" align=right><a href=\"javascript:delSelected('Set','$flag',0,$cli_conv_num)\" title=\"Delete all selected.\">Delete</a>";
		echo "<input type=\"checkbox\" name=\"seleceAll\" title=\"Select all to delete\"  value=\"1\" onClick=selectAllToDel('Set','$flag',this,0,$cli_conv_num)>";
		echo "</td>";
		echo "</tr>";
	}
	
	//==more button====
	if($cli_conv_num>4)
	{
		echo "<tr id='showcli' style=\"display:block\"><td colspan=7><a href=\"javascript:clickOnMoreHide('cli',$cli_conv_num,'show')\">More >></a></td></tr>"; 
		echo "<tr id='hidecli' style=\"display:none\"><td colspan=7><a href=\"javascript:clickOnMoreHide('cli',$cli_conv_num,'hide')\">Hide >></a></td></tr>"; 
	}
	echo "</table></td>";
}
echo "</tr>";

}//end CLI conversion prefix
/*
{//license
	echo "<tr >" ;
	echo "<td bgcolor=\"#E6E6E6\"  ><b>License control</b></td>";
	echo "<td>&nbsp;";
	  $sysId = '350_99_99';
		$oidStr = "2.5";
		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 "<b>&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>";
?>

<script LANGUAGE="JavaScript"> 
function openCliPrefix(instanceNo,objIdStr,sysId,webname,setname,backurl)
{
	y = document.body.scrollTop;
	backurl = backurl+'?scroll_y='+y;
	backurl=escape(backurl);
	
	URL="./paramconf.php?instanceNo="+instanceNo+"&objIdStr="+objIdStr+"&sysId="+sysId+"&webname="+webname+"&setname="+setname+"&backurl="+backurl+"&sub_page_top="+y;	
	window.location.href=URL;
}
function openSet(flag,instanceNo,backurl)
{
	y = document.body.scrollTop;
	backurl = backurl+'?scroll_y='+y;
	backurl=escape(backurl);
	
	if(instanceNo==-1)
	{
		alert("There is no more instance to add!");
		return;
	}
	if (flag == "csrr")
	{
		URL="./csrr.php?instanceNo="+instanceNo;
	}
	else if (flag == "gtt")	
	{
		URL="./gtt_edit.php?instanceNo="+instanceNo;
	}
	else if (flag == "udp")	
	{
		URL="./smscEdit.php?oType=2&iNum="+instanceNo;
	}
	else if (flag == "tcp")	
	{
		URL="./smscEdit.php?oType=3&iNum="+instanceNo;
	}
	URL += "&backurl="+backurl;
	window.location.href=URL;
}
</script>
