<?php
/*********************************************************      
 程序说明:(和paramEditPreview.php保持一致)          
    功能说明:本程序实现参数编辑模板代码的产生，保存，预览

    调用关系:调用: connectdb.inc，inc/header.inc     
    被调用:      
 
    变量说明:

    返回值:无

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

//==========================================================
//变量定义
//==========================================================
$canwrite_flag=checkWritePrivilege();

$nReadComm			= 1;
$nChangeComm		= 2;
$nCreateComm		= 3;
$nDeleteComm		= 4;
$nLoadIndexComm		= 5;
$nReplaceIndexComm	= 6;

$sysSubsConfTable	='OMC_PUB.sysSubsConf';
$systemConfTable	= 'OMC_PUB.sysConf';

$sysConfTable = 'OMC_PUB.sysConf';
$sysTypeNo	= (isset($sysTypeNo)?$sysTypeNo:0);
$objDb 			= omcGetObjDb($sysTypeNo);
$paramConfTable	= omcGetObjTbl($sysTypeNo,paramConf,$dataTypeNo);

$pubDb			='OMC_PUB';
$maxLevelNum	= 10;
//value Type
$nInteger = 2;
$nAscStr = 3;
$nOctStr = 4;
$seqNo=0;

//==========================================================
//输入变量
//==========================================================
$canSetNum = isset($canSetNum)?$canSetNum:'all';
//显示用户数据编辑页面，需要的变量
if($DEBUG) echo "<br>sysId=$sysId";
if($DEBUG) echo "<br>canSetNum=$canSetNum";
if($DEBUG) echo "<br>keyValue=$keyValue";
if($DEBUG) echo "<br>sysTypeNo=$sysTypeNo";
if($DEBUG) echo "<br>sysNo=$sysNo";
if($DEBUG) echo "<br>subSysNo=$subSysNo";
if($DEBUG) echo "<br>dataTypeNo=$dataTypeNo";

function omcGetObjDb($sysTypeNo){
	$dbName = 'OBJ_'.$sysTypeNo;
	return($dbName);
}

function omcGetObjTbl($sysTypeNo,$tableType,$dataTypeNo){
	$dbName = 'OBJ_'.$sysTypeNo;
	$tableName = $dbName.'.subsParamConf_'.$dataTypeNo;
	return($tableName);
}
if($sysTypeNo =="")
{
  $sysType=explode('_',$sysId);
  $sysTypeNo=$sysType[0];
 }
if($sysTypeNo==325)
	$file='vlrSubsConfig';
elseif($sysTypeNo==330)
	$file='hlrSubsConfig';
elseif($sysTypeNo==360)	
 	$file='ppsSubsConfig';
elseif($sysTypeNo==340)
	$file='aucSubsConfig';
elseif($sysTypeNo==380)	
 	$file='eirSubsConfig';
elseif($sysTypeNo==390)	
 	$file='vmsSubsConfig';
elseif($sysTypeNo==370)
	$file='mnpSubsConfig';
elseif($sysTypeNo==375)	
 	$file='oprSubsConfig';
elseif($sysTypeNo==378)	
 	$file='ipalimrSubsConfig';

//read config file
function readConfigFile($file){ 	
	$fp=fopen($file,"r");
	if (!$fp)
	{
  	echo "<br>$file file do not exist!";
   	exit();
	}
	$buffer=file_get_contents($file);
	$paraArr = explode('[para]',$buffer);
	fclose($fp);
	return($paraArr);
}
$paraArr=readConfigFile($file);
$paraNum=sizeof($paraArr);
//----------------------
//选择语言版本
if($language == 'eng'){
	$objNameField=name_2;
	$objSetField=setTemplate_2 ; //语种2
}else{	
	$objNameField=name_1;
	$objSetField=setTemplate_1 ; //语种1(默认语种)
}
//-----------------------
$canSetNum = isset($canSetNum)?$canSetNum:'all';


//write log message
if($_SERVER['REQUEST_METHOD'] == "POST"){
	//system("echo '-------------------------------------'>>/tmp/test.txt");
	$preValueInfo="Change $pre_keyvalue ";
	$isChangeFlag=0;
	debug_log("/tmp/debug.txt",write_log_message);
	debug_log("/tmp/debug.txt",$paraNumber);
	debug_log("/tmp/debug.txt",$beginNo);
	for($i=$beginNo;$i<$paraNumber;$i++){
		
		$remarkArr = explode('[remark]',$paraArr[$i]);
		$sqlArr = explode('[sqlName]',$remarkArr[0]);
		$nameArr = explode('[Name]',$sqlArr[0]);
		$paraName = $nameArr[1];
		$paraName=chop($paraName);
		//explode by '[t]'
		$tArr = explode('[t]',$sqlArr[1]);
		$sqlName=$tArr[0];
		for($ii=0;$ii<sizeof($tArr);$ii++)
		{
			$vArr = explode('[v]',$tArr[1]);
			$unitArr=explode('[unit]',$tArr[1]);
			$inputName	='unit_'.$i.'_'.$ii;
			$inputValue	=${$inputName};
			debug_log("/tmp/debug.txt",$inputValue);
			$ppName=$inputName."_oldValue";
			$ddName=$inputName."_ddoldValue";
			$cdName=$inputName."_cdoldValue";
			$nnName=$inputName."_Name";
			if(strlen($inputValue)){
			debug_log("/tmp/debug.txt",$inputValue);
				if(isset($$ddName))
				{
					$newValue="";
					for($j=1;$j<sizeof($vArr);$j++){						
						$defArr = explode('[opt]',$vArr[$j]);
						if($defArr[0]==$inputValue)
							$NewValue=$defArr[1];
					}
					$val2=$NewValue;
					$oldValue="";
					for($j=1;$j<sizeof($vArr);$j++){						
						$defArr = explode('[opt]',$vArr[$j]);
						if($defArr[0]==$$ddName)
							$oldValue=$defArr[1];
					}
					$val1=$$oldValue;
					if($$ddName == "")
						$val1="NoValue";
				
					if(strcasecmp($val1,$val2) != 0)
					{
						$isChangeFlag=1;
						$preValueInfo.="[{$$nnName},{$val1}->{$val2}]";
					}
				}
				else if(isset($$cdName))
				{
					$newValue="";
					for($iii=1;$iii<sizeof($unitArr);$iii++)
					{
						$defArr = explode('[u]',$unitArr[$iii]);
						$chkname=$inputName.$defArr[0];
						if($$chkname == '1')
							$newValue.=$defArr[0].",";
					}
					$newValue=substr($newValue,0,strlen($newValue)-1);
					if(strcasecmp($$cdName,$newValue) != 0)
					{
						$isChangeFlag=1;
						$preValueInfo.="[{$$nnName},({$$cdName})->({$newValue})]";
					}
				}
				else
				{
					if(strlen($$ppName) == 0)
						$$ppName="NoValue";
					if(strcasecmp($$ppName,$inputValue) != 0)
					{
						$isChangeFlag=1;
						$preValueInfo.="[{$$nnName},{$$ppName}->$inputValue]";
					}
				}
			}else{
				//echo "<br>Can not find $inputName's value";
			}
		}
	}
			if($isChangeFlag==1)
			{
				$preValueInfo.=" in {$log_sysTypeName}_{$log_sysNo}_{$log_subSysNo}";
				debug_log("/tmp/debug.txt",preValueInfo);
				debug_log("/tmp/debug.txt",$preValueInfo);
				insertLog($preValueInfo);
			}

}

//=======================set value From submit===================

if($_SERVER['REQUEST_METHOD'] == "POST"){
	if($isCreate){
		//$imsi
		for($i=strlen($imsi);$i<16;$i++){
			$imsi='0'.$imsi;
		}
		//debug_log("/tmp/debug.txt",$imsi);
	}
	
	$bgnNo=0;
	$endNo=0;
	//sort by offset
	for($a=$beginNo;$a <= $paraNumber;$a++)
	{
		$lastValue = '';
		$k = 0;
		//explode by '[remark]'
		$remarkArr = explode('[remark]',$paraArr[$a]);
		$sqlArr = explode('[sqlName]',$remarkArr[0]);
		//explode by '[t]'
		$tArr = explode('[t]',$sqlArr[1]);
		$sqlName=$tArr[0];	
		$type=explode('[unit]',$tArr[1]);
		$typeName=$type[0];
		$oldDateSql="SELECT * FROM $paramConfTable WHERE fieldName='$sqlName'";
		$result=@mysqli_query($pubConn,$oldDateSql);
		echo mysqli_error($pubConn);
		$rows=@mysqli_fetch_array($result);
		$orgValue=$rows[minValue];
		$valuetype=$rows[valueType];
		$length=$rows[length];

		if($orgValue == '')
		{
			if($valuetype==$nInteger || $valuetype==$nAscStr)
			{
				for($i=1;$i<=$length;$i++)
					$orgValue ='0'.$orgValue;
			}
			elseif($valuetype==$nOctStr)
			{
				for($i=1;$i<=$length;$i++)
					$orgValue ='00'.$orgValue;
			}
		}
		//if($a>=44)
			//echo "<br>[$a]:orgValue=$orgValue,$sqlName";

		for($i=1;$i <= ${'unitNum_'.$a};$i++)
		{

			$tmpDef = ${'unitDef_'.$a.'_'.$i};
			$tmpValue = ${'unit_'.$a.'_'.$i};
			//if($a>=44)
				//echo "<br>tmpDef=$tmpDef,tmpValue = $tmpValue";
			//debug_log("/tmp/debug.txt",$tmpDef);
			//debug_log("/tmp/debug.txt",$tmpValue);
			$defArr = $tmpDef;
			$tmpDefArr=explode('-',$tmpDef);
			$x=sizeof($tmpDefArr);
			$specialDo=$tmpDefArr[$x-1];

			$sqlname=$tmpDefArr[0];
			$unitValue = $tmpValue;
		
			$sqlnameNum=explode($sqlname.'-',$tmpDef);
			$num=sizeof($sqlnameNum);
			if($specialDo == 'code')
			{
				$xx=$num-1;
				$unitDefArr = explode('-',$sqlnameNum[$xx]);
				$bgnOffset1	= $unitDefArr[0];
				$unitDefArr = explode('-',$sqlnameNum[1]);
				$endOffset1	= $unitDefArr[1];			
				$inputOffset = $bgnOffset1.'-'.$endOffset1;
				//debug_log("/tmp/debug.txt",inputOffset);
				//debug_log("/tmp/debug.txt",$inputOffset);
				$unitValue=encodeTelNumber($unitValue);
				$orgValue=setBitValue($orgValue,$inputOffset,$unitValue);
			}
			else
			{
				for($j=$num-1;$j>0;$j--)
				{
					$bit=0;
					$unitDefArr = explode('-',$sqlnameNum[$j]);
				
					$bgnOffset	= $unitDefArr[0];
					$endOffset	= $unitDefArr[1];
					$inputOffset = $bgnOffset.'-'.$endOffset;
					//if($a>=44)
						//echo "<br>inputOffset=$inputOffset";
					$operType	= $unitDefArr[2];
					$valueType  = $unitDefArr[3];
					$fillWay	= $unitDefArr[4];
					$fillChar	= $unitDefArr[5];
					$fillChar = chop($fillChar);
					$bgnOffsetArr = explode('.',$bgnOffset);
					$bgnByte = $bgnOffsetArr[0];
					$bgnBit  = $bgnOffsetArr[1];
					$endOffsetArr = explode('.',$endOffset);
					$endByte = $endOffsetArr[0];
					$endBit  = $endOffsetArr[1];
					$byteLen = $endByte - $bgnByte + 1;
					$byteValue = '';
					$bitLen = $byteLen*8 - $bgnBit - (7 - $endBit) ;
					$valueType=chop($valueType);
					
					if($num>2)
					{
						$beginBye=$bgnByte*8+$bgnBit;
						if($valueType == 'keepHex')
						{
							if($bgnBit == 0)
							{
								$bgnHex=$bgnByte*2;
								$hexLen=$byteLen*2;
								$unitValue = substr($tmpValue,$bgnHex,$hexLen);
							}
							elseif($bgnBit == 4)
							{
								$bgnHex=$bgnByte*2+1;
								$hexLen=$byteLen*2-1;
								$unitValue = substr($tmpValue,$bgnHex,$hexLen);
							}
						}
						else
						{
							$unitValue = substr($tmpValue,$beginBye,$bitLen);
						}
					}
					//if($specialDo == 'code')
					//	$unitValue=encodeTelNumber($unitValue);
					//if($a>=44)
						//echo "<br>unitValue=$unitValue";
					//if($a>=44)
					//	echo "[$valueType]";
					if($operType=='specialInputHlr')
					{
						if(${'unit_'.$a.'_'.($i-1)}==289){
							$tmpValue1="04";
							$tmpValueArr=explode(".",${'unit_'.$a.'_'.$i});
							$iplen=sizeof($tmpValueArr);
							for($xx=0;$xx<sizeof($tmpValueArr);$xx++){
								$tmpValue_1=omc_keep_length(DECHEX($tmpValueArr[$xx]),"0","2","1");
								$tmpValue=$tmpValue1.$tmpValue_1;
							}			
							if($iplen != 4)
								$tmpValue1="0000000000";
						}else if(${'unit_'.$a.'_'.($i-1)}==343){
							$tmpValue1="10";
							$tmpValueArr=explode(":",${'unit_'.$a.'_'.$i});
							for($xx=0;$xx<sizeof($tmpValueArr);$xx++){
								$tmpValue_1=omc_keep_length($tmpValueArr[$xx],"0","4","1");
								$tmpValue1=$tmpValue1.$tmpValue_1;
							}
						}else{
							$tmpValue1=strlen(${'unit_'.$a.'_'.$i})/2;
							$tmpLenArr=explode(".",$tmpValue1);
							$tmpValue1=$tmpLenArr[0];
							
							$tmpValue1=omc_keep_length($tmpValue1,"0","2","1");
							$tmpValue1=$tmpValue1.${'unit_'.$a.'_'.$i};
						}
						$tmpValue1=omc_keep_length($tmpValue1,"E","34","0");
						$inputOffset='03.0-19.7';
						$byteValue=$tmpValue1;										
					}
					else
					{
						switch($valueType){
							case 'toDec':
								if($bgnBit == 0 && $endBit == 7){
									$byteValue = DecHex($unitValue);
									$byteValue = omcStrFill($byteValue,$byteLen*2,$fillWay,$fillChar);
									//if($a>=44)
										//echo "<br>[2]byteValue = $byteValue";
								}
								else
								{
									$bitValue = DecBin($unitValue);
									$bitValue  = omcStrFill($bitValue,$bitLen,$fillWay,$fillChar);
					 				$bit=1;
					 				//if($a>=44)
					 					//echo "<br>[2]bitValue = $bitValue";
								}
								break;
							case 'keepDec':
								//if($a>=44)
									//echo "<br>unitValue = $unitValue";
								$byteValue = $unitValue - 0;
								//echo "<br>[1]byteValue = $byteValue";
								if($bgnBit == 0 && $endBit == 7){
									$byteValue = DecHex($byteValue);
									$byteValue = omcStrFill($byteValue,$byteLen*2,$fillWay,$fillChar);
									//if($a>=44)
									//	echo "<br>[2]byteValue = $byteValue";
								}
								else
								{
									$bitValue = DecBin($byteValue);
									$bitValue  = omcStrFill($bitValue,$bitLen,$fillWay,$fillChar);
					 				$bit=1;
					 				//if($a>=44)
					 					//echo "<br>[2]bitValue = $bitValue";
								}
								break;
							case 'toHex':
								echo "<br>Error:toHex";
								break;
							case 'keepHex':
								if($bgnBit > 0 || $endBit < 7){//这里的处理不够全面,没有对=7的进行收尾
									$byteValue = $unitValue;
									$strLen = $byteLen;
									$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
									$bitValue = DecBin(HexDec($byteValue));
									$byteValue='';
									$bitLen = $byteLen*8 - $bgnBit - (7 - $endBit) ; //1 BYTE = 8 bit
									$bitValue  = omcStrFill($bitValue,$bitLen,'high','0');
									if($DEBUG) echo "<br>bitValue = $bitValue";
									$bitValueArr[$k] = $bitValue;
									$k++;
								}else{
									$k=0;
									$byteValue = $unitValue;
									$strLen = $byteLen*2;
									$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
								}
								break;
							case 'toAsc':
								if($bgnBit > 0 ||$endBit < 7){
									echo "<br>Error:toAsc";
									exit(1);
								}else{
									$tmpLen=strlen($unitValue);
									for($n=0;$n<$tmpLen;$n++){
										$unitChar = substr($unitValue,$n,1);
										$decValue = ord($unitChar); //ascii -> dec
										$byteValue .= DecHex($decValue);
										if(strlen($byteValue) < 2){
											$byteValue = '0'.$byteValue;
										}
									}
									$strLen = $byteLen*2;
									$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
								}
								break;
							case 'keepAsc':
								$byteValue = $unitValue;
								break;
							default: 
								echo "Error:Unknown valueType";
								break;
						}
					}
					if($DEBUG) echo "<br>byteValue  = $byteValue ";
					if(strlen($orgValue) != 0 && $bit==0)
					{
						//if($a==19) echo "<br>byteValue=$byteValue";
						$orgValue=setBitValue($orgValue,$inputOffset,$byteValue);
						//if($a==19) echo "<br>orgValue=$orgValue";
					}
					else
					{
						//if($a>=44) echo "<br>bit=$bit";
						$orgValue=setBitValue($orgValue,$inputOffset,$bitValue);
						//if($a>=44) echo "<br>orgValue=$orgValue";
					}
				}//end for($j)
			}
			$lastValue = $orgValue;
		}//end for($i)
		
		if($typeName !='readOnly' && $typeName !='show')
		{ 
			$tmpFieldName = $sqlName;
			if($sqlName=='inter_msisdn' || $sqlName=='fax_num' || $sqlName=='data_num')
			{
				//debug_log("/tmp/debug.txt",${'tmp_value_'.$a});
				if(${'tmp_value_'.$a}==$lastValue)
					continue;
			}
			
			${'checkBox_'.$endNo} =1;
			${'fieldName_'.$endNo}=$tmpFieldName;
			${'editValue_'.$endNo}=$lastValue;
			//debug_log("/tmp/debug.txt",${'checkBox_'.$endNo});
			//debug_log("/tmp/debug.txt",${'fieldName_'.$endNo});
			//debug_log("/tmp/debug.txt",${'editValue_'.$endNo});
			$endNo++;
			if($canSetNum != 'all' && $endNo > $canSetNum){
				break;
			}
		//	debug_log("/tmp/debug.txt",$updateDateSql);
		}
	}//end for($a)
	//debug_log("/tmp/debug.txt",$endNo);
}//end of if($set == 1)

//数据处理
?>
<base target="_self">
<body leftmargin="15" rightmargin="10" onload="javascript:adjust_frame('down');" onresize="javascript:adjust_frame('down');" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php
require("../pubSubsMng/sendComm.inc");
require("../pubSubsMng/dataProc.inc");
$seqNo=0;
?>

<?php
adjust_head_frame("down");
adjust_title_head_frame("down");
adjust_title_tail_frame("down");

adjust_content_head_frame("down");	
echo "<br>";

//=======================Show GUI ========================
?> 

<script LANGUAGE="JavaScript"> 

function selCheckBox(thisCheckBox)
{
	if(thisCheckBox.checked == true){
		thisCheckBox.value=1;
	}else{
		thisCheckBox.value=0;
	}
}

function askSureToDel(keyName,keyId)
{
	var answer = confirm("Are you sure to delete this subscriber( "+keyName+"="
                          + keyId + ")?");
    if (answer == true){
		window.location.href = "<?php echo "$PHP_SELF?sysId=$sysId&dataTypeNo=$dataTypeNo&bufferNo=$bufferNo&keyValue=$keyValue&isDelete=1";?>";
		//alert('Try to send delete command');
	}else{
		return(false);
	}
}

function askSureToReplace(keyName,keyId)
{
	var answer = confirm("Are you sure to replace this subscriber's IMSI( "+keyName+"="
                          + keyId + ")?");
    if (answer == true){

		window.location.href = "<?php echo "$PHP_SELF?sysId=$sysId&dataTypeNo=$dataTypeNo&bufferNo=$bufferNo&keyValue=$keyValue&isReplaceIndex=1";?>";
	}else{
		return(false);
	}
}

function keepCheckBox(thisCheckBox)
{
	if(thisCheckBox.value == 1){
		thisCheckBox.checked = true;
	}else{
		thisCheckBox.checked = false;
	}
}

</script>
<form method="POST" name="update" action="<?php echo"$PHP_SELF";?>" >
  <?php
	//显示用户参数编辑页面
	?>
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
	<td><nobr>
	<?php 
	if($sysTypeNo ==360)
		echo "Server ID:";
	else
		echo "Server Id:";?>
	<select name="sysId" size="1">
	<?php
	$selSysIdSql="SELECT sysNo,subSysNo,sysTypeName 
				FROM sysInfo,sysConf 
				WHERE sysInfo.sysTypeNo='$sysTypeNo' AND sysConf.sysTypeNo='$sysTypeNo'
				ORDER BY baseStat DESC,updateTime DESC
				";
//	if($DEBUG) echo "<br>$selSysIdSql";
	$sysIdResult=mysqli_query($pubConn,$selSysIdSql);
	echo mysqli_error($pubConn);
	while($sysIdRows=mysqli_fetch_array($sysIdResult)){
		echo "<option value=\"$sysTypeNo"."_$sysIdRows[sysNo]"."_$sysIdRows[subSysNo]\"";
		if(($sysNo == $sysIdRows[sysNo]) && ($subSysNo == $sysIdRows[subSysNo]))
			echo " selected";
		echo " >$sysIdRows[sysTypeName]"."_$sysIdRows[sysNo]"."_$sysIdRows[subSysNo]";
		echo "</option>";
	}
	?>
	</select>
	</nobr>
	</td>  
	<td><nobr>
	<?php
	if(!isset($isTryCreate)||$isTryCreate <= 0){
		if($sysTypeNo==325 || $sysTypeNo==360 || $sysTypeNo==375)
			$showkeyValue= $keyValue;
		else
			$showkeyValue= substr($keyValue,1);
		if($sysTypeNo==330||$sysTypeNo==340||$sysTypeNo==325)
		{
			$keyValueName='IMSI';
			$keyValuename='imsi';
		}
		else
		{
			$keyValueName='MSISDN';
			$keyValuename='msisdn';
		}
		echo "&nbsp;&nbsp;$keyValueName:$showkeyValue";

		//echo "<input type=\"hidden\" name=\"keyValue\" value=\"$keyValue\">";
	}
	?>
	
	</nobr></td>
	<?php 
	if($isTryCreate > 0){	
		if($isBatchCreate> 0){
		?>
			<TD><NOBR>
				&nbsp;&nbsp;&nbsp;
				Batch amount(<=100):<input type="text" name="batchNum" class="text"  maxlength="3" size="3">
			</NOBR></TD>
		<?php 
		}
		?>
		<td >
		<?php
			if($canwrite_flag)
				echo "<input type=\"submit\" value=\"Create in $sysTypeName\" name=\"create\" title=\"\" class=\"button\" onClick=\"javascript:document.update.isCreate.value=1;\">";
			else
				echo "<input type=\"submit\" disabled value=\"Create in $sysTypeName\" name=\"create\" title=\"\" class=\"button\" onClick=\"javascript:document.update.isCreate.value=1;\">";
		?>
		<input type="hidden" value="0" name="isCreate">
		<input type="hidden" value="0" name="isChange">
		<input type="hidden" value="<?php echo "$isBatchCreate"; ?>" name="isBatchCreate">
		</td>
		<?php
			$myPrivilege = $userInfo[privilege];
			if($myPrivilege >=4){
		?>
		<td>
		<input type="submit" value="Create in OMC" name="create" title=""  class="button" onClick="javascript:document.update.isCreate.value=2;">
		</td>
		<?php
			}
		?>
	<?php
	}else{
	?>
		<td>
		
		<input type="submit" value="Get" name="read" title=""  class="button" onClick="javascript:document.update.isRead.value=1;">

		<input type="hidden" value="0" name="isRead">
		</td>

		<td>
		<?php
		if($sysTypeNo != 325)
		{
			if($canwrite_flag)
				echo "<input type=\"submit\" value=\"Set\" name=\"change\" title=\"\"  class=\"button\" onClick=\"javascript:document.update.isChange.value=1;\">";
			else
				echo "<input type=\"submit\" disabled value=\"Set\" name=\"change\" title=\"\"  class=\"button\" onClick=\"javascript:document.update.isChange.value=1;\">";
		}
		?>
		<input type="hidden" value="0" name="isChange">
		<input type="hidden" value="0" name="isCreate">
		</td>
		
		<td>
		<?php
		if($sysTypeNo != 325)
		{
			if($canwrite_flag)
				echo "<input type=\"button\" value=\"Delete\" name=\"delete\" title=\"Delete this subscriber\"  class=\"button\" onClick=\"askSureToDel('$keyValueName','$keyValue');\">";
			else
				echo "<input type=\"button\" disabled value=\"Delete\" name=\"delete\" title=\"Delete this subscriber\"  class=\"button\" onClick=\"askSureToDel('$keyValueName','$keyValue');\">";
		}
		?>
		<input type="hidden" value="0" name="isDelete">
		</td>

		<td>
		<?php
		if($sysTypeNo==330)
		{
			if($canwrite_flag)
				echo "<input type=\"button\" value=\"Replace IMSI\" name=\"replace\" title=\"Replace this subscriber's IMSI\"  class=\"button\" onClick=\"askSureToReplace('$keyValueName','$keyValue');\">";
			else
				echo "<input type=\"button\" disabled value=\"Replace IMSI\" name=\"replace\" title=\"Replace this subscriber's IMSI\"  class=\"button\" onClick=\"askSureToReplace('$keyValueName','$keyValue');\">";
		}
		?>
		<input type="hidden" value="0" name="isReplaceIndex">
		</td>

	<?php
	}
	?>
  <td width="100%">&nbsp;</td>
  </tr>  
</table>
<br>
<?php
//将已取出的用户数据显示出来
//$tmpRow[fieldName]
?>
<table border="1" width="100%" cellpadding="2" cellspacing="0"  bordercolor="#666666" bordercolordark="#FFFFFF" bgcolor="#FFFFFF">    
<tr bgcolor="#E6E6E6"> 
<?php
if($sysTypeNo==325)
{
	echo "<td width=\"10%\">$strID</td>";
	echo "<td width=\"45%\">$strField</td>";
	echo "<td width=\"45%\">$strValue</td>";
	echo "</tr>";
}
else
{
	echo "<td width=\"5%\"> No.</td>";   
	echo "<td width=\"25%\">Name</td>";   
	echo "<td width=\"20%\">Value</td>";     
	echo "<td width=\"50%\">Description</td>";    
	echo "</tr>";
}
//<?php

$sysConfTable = 'OMC_PUB.sysConf';
$sysTypeNo	= (isset($sysTypeNo)?$sysTypeNo:0);

$objDb 			= omcGetObjDb($sysTypeNo);
$paramConfTable	= omcGetObjTbl($sysTypeNo,paramConf,$dataTypeNo);

//echo "sysId=$sysId,sysTypeNo=$sysTypeNo";
if($DEBUG) echo "<br>setValue = $setValue ,inputName = $inputName";

/**************************************
*objName
*[unit]name[u]xx.xx-yy.yy[u]input[v]toDec-fillHigh-fillChar
*[unit]name[u]xx.xx-yy.yy[u]select[v]value1[opt]desc1[v]value2[opt]desc2
*[remark]
***************************************/
if($isTryCreate > 0){
$beginNo=1;}
else
{
	$beginNo=2;
	
}
echo "<input type=\"hidden\" name=\"beginNo\"	value=\"$beginNo\">";
		

		
echo "<input type=\"hidden\" name=\"log_sysTypeName\" value=\"$sysTypeName\">";
echo "<input type=\"hidden\" name=\"log_sysNo\" value=\"$sysNo\">";
echo "<input type=\"hidden\" name=\"log_subSysNo\" value=\"$subSysNo\">";
echo "<input type=\"hidden\" name=\"pre_keyvalue\" value=\"{$keyValue}'s\">";
//get imsi
//$imsi=$showkeyValue;
//for($i=strlen($imsi);$i<16;$i++){
		//$imsi='0'.$imsi;
//}
//echo "\n<input type=\"hidden\" name=\"imsi\"	value=\"$imsi\">";

for($m=$beginNo;$m < sizeof($paraArr);$m++)
{
	echo "<tr>";
	echo "<td>$seqNo </td>";
	$seqNo++;

	//explode by '[remark]'
	$remarkArr = explode('[remark]',$paraArr[$m]);
	$remark  = $remarkArr[1];

	$sqlArr = explode('[sqlName]',$remarkArr[0]);
	$nameArr = explode('[Name]',$sqlArr[0]);
	$paraName = $nameArr[1];
	$paraName=chop($paraName);
	//explode by '[t]'
	$tArr = explode('[t]',$sqlArr[1]);
	$sqlName=$tArr[0];
	echo "<td>$paraName</td>";
	$number=$tmpRow[$sqlName];
	$tmp_value='tmp_value_'.$m;
	echo "<input type=\"hidden\" name=\"$tmp_value\"	value=\"$number\">";

	$DateSqlGetType="SELECT * FROM $paramConfTable WHERE fieldName='$sqlName'";
	$resultGet=@mysqli_query($pubConn,$DateSqlGetType);
	echo mysqli_error($pubConn);
	$rowsGet=@mysqli_fetch_array($resultGet);
	$valueType = $rowsGet[valueType];
	echo "<td>";
	echo "<table border=\"0\">";
	for($i=1;$i < sizeof($tArr);$i++){
	
		//unit input name
		$unitName = "unit_".$m.'_'.$i;
		$unitArr=explode('[unit]',$tArr[$i]);
		$operType = chop($unitArr[0]);

		$tempDef = '';
		$inputValue = '';
		$readValue = '';
		$checkboxValue = '';
		$radioValue = '';
		$size = 0;
		for($n=1;$n < sizeof($unitArr);$n++){
			//explode by '[u]'
			$tlvArr = explode('[u]',$unitArr[$n]);
			if(sizeof($tlvArr) <= 1 ){
			echo "<u><b>{$unitArr[$i]}</b></u>";
			continue;
			}
				
			$firstValue= '';
			//echo "$tlvArr[1]";
			$setValue=$number;
 			//echo "<br>$setValue";
			if($DEBUG) echo "$tlvArr[1]";
			//explode by '-'
			$offsetArr = explode('-',$tlvArr[1]);
			$bgnOffsetArr = explode('.',$offsetArr[0]);
			$bgnByte = $bgnOffsetArr[0];
			$bgnBit  = $bgnOffsetArr[1];
			$endOffsetArr = explode('.',$offsetArr[1]);
			$endByte = $endOffsetArr[0];
			$endBit  = $endOffsetArr[1];
			$byteLen = $endByte - $bgnByte + 1;
			$byteValue = substr($setValue,$bgnByte*2,$byteLen*2);
			$specialDo=explode('[v]',$tlvArr[2]);
			
			$specialDo[0]=chop($specialDo[0]);
			
			//echo "byteValue=$byteValue";
			if($DEBUG) echo "<br>byteValue = $byteValue";
			$bitValue = '';
			$charValue = '';
			if($bgnBit > 0 ||$endBit < 7){
				if($DEBUG) echo "<br>$bgnBit > 0 ||$endBit < 7";
				$bitValue = HexDec($byteValue);
				$bitValue = DecBin($bitValue);
				if($DEBUG) echo "<br>bitValue = $bitValue";
				$bitLen   = $byteLen*8;//1 byte = 8 bit
				$bitValue = omcStrFill($bitValue,$bitLen,'high','0');
				if($DEBUG) echo "<br>omcStrFill($bitValue,$bitLen,'high','0')";
				$bitValue = strrev($bitValue);
				$catBitLen = $endByte*8+$endBit - ($bgnByte*8+$bgnBit) + 1; //1 byte = 8 bit
				if($DEBUG) echo "<br>bitValue = substr($bitValue,$bgnBit,$catBitLen)";
				$bitValue = substr($bitValue,$bgnBit,$catBitLen);
				$bitValue = strrev($bitValue);
				if($DEBUG) echo "<br>bitValue = $bitValue";
			}
			
			//explode by '[v]'
			$valueArr = explode('[v]',$tlvArr[2]);
			$valueArr[1] = chop($valueArr[1]);
			//echo "<br>valueArr[1]=$valueArr[1]";
			if($DEBUG) echo "<br>operType = $operType";
			
			switch($operType){
				case 'input'://
					echo "<tr>";
					//show Unit Name
					if(sizeof($tArr)>2)
						echo "<td>$tlvArr[0]:</td>";
					//explode by '-'
					$firstValue=$inputValue;
					$firstmp = $tempDef;
					$defArr = explode('-',$valueArr[1]);
					if($DEBUG) echo "<br>defArr = $defArr[0],$defArr[1],$defArr[2]";
					switch($defArr[0]){
						case 'toDec':
							if(strlen($bitValue) > 0){
								$inputValue = BinDec($bitValue);
							}else{
									$inputValue = HexDec($byteValue);
							} 
							break;
						case 'keepDec':
							$inputValue = $byteValue;
							break;
						case 'toHex':
							echo "<br>Error:toHex";
							break;
						case 'keepHex':
							$inputValue = $byteValue;
							break;
						case 'toAsc':
							if($bgnBit > 0 ||$endBit < 7){
								echo "<br>toAsc Error:bgnBit > 0 ||endBit < 7";
								exit(1);
							}else{
								$tmpLen=strlen($byteValue);
								for($charCount=0;$charCount < $tmpLen;$charCount++){
									$unitByte = substr($byteValue,$charCount,2);
									$unitChar = chr(HexDec($unitByte)); // hex -> ascii
									if($DEBUG) echo "<br>unitChar=$unitChar";
									$charValue .= $unitChar;
									$charCount++;
								}
								$inputValue = $charValue;
							}
							break;
						case 'keepAsc':
							$inputValue = $byteValue;
							break;
						default: 
							echo "<br>Error:valueType=$defArr[0]";
							break;
					}
					if($DEBUG) echo "<br>inputValue = $inputValue";
					switch($defArr[1]){
						case 'high':
							switch($defArr[2]){
								case '0':
									if($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
										//$inputValue = str_replace('0','',$inputValue);
									}else{
										$inputValue = $inputValue - 0;
									}
									break;
								case 'E':
									echo "Error:high fill E";
									break;
								default: break;
							}
							break;
						case 'low':
							switch($defArr[2]){
								case '0':
										$inputValue = str_replace('00','',$inputValue);
									break;
								case 'E':
										$inputValue = str_replace('E','',$inputValue);
									break;
								default: break;
							}
							break;
						default: break;
					}
					$inputValue=$firstValue.$inputValue;
					$tempDef =$sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.$valueArr[1].'-'.$firstmp;
					echo "<td>";
					if($valueType == $nOctStr && $n==sizeof($unitArr)-1){				
						if($DEBUG) echo "<br>$valueType =$nOctStr= OctStr";
						if($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
							$inputLen = $byteLen *2;
						}else{
							$inputLen = $byteLen *3;
						}	
						if($inputLen > 40)
						{
							$size = $size + $byteLen;
							echo "<input type=\"hidden\" name=\"size\" value=\"$size\" class=\"text\">";

						}
						else
						{
							$size = $size + $inputLen;
							echo "<input type=\"hidden\" name=\"size\" value=\"$size\" class=\"text\">";

						}
						//echo "specialDo[0]=$specialDo[0]";
						if($specialDo[0] == 'code')
							$inputValue=decodeTelNumber($inputValue);
						if($specialDo[0]=='size')
							echo "<input type=\"text\" size=\"$size\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";
						else
							echo "<input type=\"text\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";											
					}elseif($valueType == $nAscStr && $n==sizeof($unitArr)-1){
						if($specialDo[0] == 'code')
							$inputValue=decodeTelNumber($inputValue);
						if($DEBUG) echo "<br>$valueType == AscStr";
						$inputLen = $byteLen;
						if($sqlName=='imsi')
						{	
							$inputLen=16;
							echo "<input type=\"hidden\" name=\"imsi\" value=\"$inputValue\">";													
						}
						if($sqlName=='msisdn')
						{	
							$inputLen=16;	
							echo "<input type=\"hidden\" name=\"msisdn\" value=\"$inputValue\">";													
						}
						if($specialDo[0]=='size')
							echo "<input type=\"text\" size=\"$size\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";	
						else
							echo "<input type=\"text\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";													
					}elseif($n==sizeof($unitArr)-1){ 				
						if($specialDo[0] == 'code')
							$inputValue=decodeTelNumber($inputValue);
						if($DEBUG) echo "<br>$valueType == Integer";
						if($specialDo[0]=='size')
							echo "<input type=\"text\" size=\"8\" name=\"$unitName\" value=\"$inputValue\" onchange=\"checkInt(this)\" class=\"text\">";
						else
							echo "<input type=\"text\" name=\"$unitName\" value=\"$inputValue\" onchange=\"checkInt(this)\" class=\"text\">";							
						echo "<input type=\"hidden\" name=\"$unitName"."_min\" value=\"$minValue\">";
						echo "<input type=\"hidden\" name=\"$unitName"."_max\" value=\"$maxValue\">";
					}
					echo "<input type=\"hidden\" name=\"$unitName"."_oldValue\" value=\"$inputValue\">";

					echo "</td>";
					echo "</tr>";
					$tmpInputValue=$inputValue;
					//echo "inputLen=$inputLen,byteLen=$byteLen";
					break;
				case 'select':
					//show Unit Name
					echo "<tr>";
					if(sizeof($tArr)>2)
					{
						echo "<td>$tlvArr[0]:</td>";
						echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName $tlvArr[0]\">";							
					}
					else
						echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName\">";													
					if($bitValue != ''){
						$selectValue = BinDec($bitValue);
					}else{
						$selectValue = HexDec($byteValue);
					}		
					if($DEBUG) echo "<br>bitValue = $bitValue";
					//echo "<br>selectValue = $selectValue";
					$defArr = explode('[opt]',$valueArr[1]);
					//echo "<br>defArr = $defArr[1]";
					echo "<td>";
					echo "<select size=\"1\" name=\"$unitName\">";
					$isSelected = 0;
					for($j=1;$j<sizeof($valueArr);$j++){						
						//explode by '[opt]'
						$defArr = explode('[opt]',$valueArr[$j]);
						if(sizeof($defArr) < 2){
							echo "<option value=\"$defArr[0]\" selected >Reserved Value</option>";
							//echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"Reserved Value\">";
						//	echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName $tlvArr[0]\">";							
							break;
						}elseif($defArr[0] ==  $selectValue){
							echo "<option value=\"$defArr[0]\" selected >$defArr[1]</option>";
							//echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"$defArr[1]\">";
							//echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName $tlvArr[0]\">";							
							$isSelected = 1;
						}else{
							echo "<option value=\"$defArr[0]\">$defArr[1]</option>";
						}					
					}
					if($isSelected ==0 && $j == sizeof($valueArr)){
						echo "<option value=\"$defArr[0]\" selected >Undefined Value</option>";
						//echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"Undefined Value\">";					
					}
					echo "</select>";
					echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"$selectValue\">";
					echo "</td>";
					echo "</tr>";
					$tmpInputValue=$selectValue;
					//echo "<br>selectValue=$selectValue";
					break;
				case 'checkbox':
					if($bitValue != ''){
						$checkboxValue = BinDec($bitValue);
					}else{
						$checkboxValue = HexDec($byteValue);
					}
					if($DEBUG) echo "<br>bitValue = $bitValue";
					if($DEBUG) echo "<br>checkboxValue = $checkboxValue";

					//echo "<br>checkboxValue=$checkboxValue";
					if($checkboxValue == '1'){
						echo "<nobr><input type=\"checkbox\" name=\"$unitName\"";
						echo "onClick=selCheckBox(this) value=\"1\" checked  >$tlvArr[0]</nobr><br>";							
					}else{
						echo "<nobr><input type=\"checkbox\" name=\"$unitName\"";
						echo "onClick=selCheckBox(this) value=\"0\" >$tlvArr[0]</nobr><br>";
					}
					echo "<input type=\"hidden\" name=\"unit_$m_$i_$tlvArr[0]\" value=\"$checkboxValue\">";						
					echo "<input type=\"hidden\" name=\"unit_$m_$i_cdoldValue\" value=\"$tlvArr[0]\">";
					echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName\">";
					$tmpInputValue=$checkboxValue;
					break;
				case 'radio':
					//show Unit Name
					echo "<tr>";
					if(sizeof($tArr) > 2)
					{
						echo "<td>$tlvArr[0]:</td>";
						echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName $tlvArr[0]\">";							
					}
					else
						echo "<input type=\"hidden\" name=\"unit_$m_$i_Name\" value=\"$paraName\">";													
					if($bitValue != ''){
						$radioValue = BinDec($bitValue);
					}else{
						$radioValue = HexDec($byteValue);
					}
					if($DEBUG) echo "<br>bitValue = $bitValue";
					if($DEBUG) echo "<br>radioValue = $radioValue";
					//var_dump($valueArr); 
					$defArr_0 = explode('[opt]',$valueArr[1]);
					$defArr_1 = explode('[opt]',$valueArr[2]);
					//var_dump($defArr_0);echo '<br>';
					//var_dump($defArr_1);echo '<br>';
					//echo 'xxxxx='.$defArr[0];
					//echo 'xxxxx='.$radioValue;		
					if($defArr_0[0] == $radioValue){
						echo "<td>";
						echo "<input type=\"radio\" name=\"$unitName\" value=\"$defArr_0[0]\" checked>$defArr_0[1]";
						//echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"$defArr_0[0]\">";					
						echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ";
						echo "<input type=\"radio\" name=\"$unitName\" value=\"$defArr_1[0]\">$defArr_1[1]";
						echo "</tr>";
					}else{
						echo "<td>";
						echo "<input type=\"radio\" name=\"$unitName\" value=\"$defArr_0[0]\">$defArr_0[1]";
						echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ";
						echo "<input type=\"radio\" name=\"$unitName\" value=\"$defArr_1[0]\" checked>$defArr_1[1]";
						echo "</tr>";
					}
					echo "</td>";	
					echo "<input type=\"hidden\" name=\"unit_$m_$i_ddoldValue\" value=\"$radioValue\">";										
					$tmpInputValue=$radioValue;
					//echo "$radioValue";
					break;
				case 'show':  //显示
					//show Unit Name
					if(sizeof($tArr) > 2)
						echo "<br>$tlvArr[0]:";
					if($bitValue != ''){
						$showValue = BinDec($bitValue);
					}else{
						$showValue = HexDec($byteValue);
					}
					if($DEBUG) echo "<br>bitValue = $bitValue";
					if($DEBUG) echo "<br>radioValue = $radioValue";
					for($j=1;$j < sizeof($valueArr);$j++){
						$defArr = explode('[opt]',$valueArr[$j]);
						if($defArr[0] ==  $showValue)
						{
							echo "$defArr[1]";
							echo "<input type=\"hidden\" name=\"$unitName\"	value=\"$showValue\">";
						}
					}
					break;	
				case 'readOnly':
					//show Unit Name
					if(sizeof($tArr)>2)
						echo "<br>$tlvArr[0]:";
					//explode by '-'
					$firstValue = $readValue;
					$firstmp = $tempDef;
					$defArr = explode('-',$valueArr[1]);
					if($DEBUG) echo "<br>defArr = $defArr[0],$defArr[1],$defArr[2]";
					switch($defArr[0]){
						case 'toDec':
							if(strlen($bitValue) > 0){
								$readValue = BinDec($bitValue);
							}else{
								$readValue = HexDec($byteValue);
							} 
							break;
						case 'keepDec':
							$readValue = $byteValue;
							break;
						case 'toHex':
							echo "<br>Error:toHex";
							break;
						case 'keepHex':
							$readValue = $byteValue;
							break;
						case 'toAsc':
							if($bgnBit > 0 ||$endBit < 7){
								echo "<br>toAsc Error:bgnBit > 0 ||endBit < 7";
								exit(1);
							}else{
								$tmpLen=strlen($byteValue);
								for($charCount=0;$charCount < $tmpLen;$charCount++){
									$unitByte = substr($byteValue,$charCount,2);
									$unitChar = chr(HexDec($unitByte)); // hex -> ascii
									if($DEBUG) echo "<br>unitChar=$unitChar";
									$charValue .= $unitChar;
									$charCount++;
								}
								$readValue = $charValue;
							}
							break;
						case 'keepAsc':
							$readValue = $byteValue;
							break;
						default: 
							echo "<br>Error:valueType=$defArr[0]";
							break;
					}
					if($DEBUG) echo "<br>readValue = $readValue";
					debug_log("/tmp/debug.txt",readValue1);
						debug_log("/tmp/debug.txt",$readValue);
					switch($defArr[1]){
						case 'high':
							switch($defArr[2]){
								case '0':
									if($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
										//$inputValue = str_replace('0','',$inputValue);
									}else{
										//$readValue = $readValue - 0;
									}
									break;
								case 'E':
									echo "Error:high fill E";
									break;
								default: break;
							}
							break;
						case 'low':
							switch($defArr[2]){
								case '0':
									$readValue = str_replace('00','',$readValue);
									break;
								case 'E':
									$readValue = str_replace('E','',$readValue);
									break;
								case 'F':
									$readValue = str_replace('F','',$readValue);
									break;	
								default: break;
							}
							break;
						default: break;
					}
					
					$tempDef =$sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.$valueArr[1].'-'.$firstmp;
					if($specialDo[0] == 'code')
							$readValue=decodeTelNumber($readValue);
					$readValue=$firstValue.$readValue;
					
					if( $n == sizeof($unitArr)-1 )
					{
						
						$readNumber='';
						if($specialDo[0] == 'showComma')
						{
							$readValue=showComma($readValue);
						}
						elseif($specialDo[0] != "")
						{
							$readNumber=explode(' ',$specialDo[0]);
							debug_log("/tmp/debug.txt",readValue4);
						debug_log("/tmp/debug.txt",$readValue);
							if($readNumber[1] != "")
								$readValue=substr($readValue,0,$readNumber[1]);
						debug_log("/tmp/debug.txt",readValue5);
						debug_log("/tmp/debug.txt",$readValue);
						}		
						debug_log("/tmp/debug.txt",readValue);
						debug_log("/tmp/debug.txt",$readValue);
						if(trim($readValue)=="" && $specialDo[0] == '--')
							echo "--";
						elseif(trim($readValue)=="" && ($specialDo[0]=='-' || $readNumber[2]=='-'))
							echo "-";
						else
							echo "$readValue";
					}
					break;
				
				case 'specialInputHlr':
				//echo "byteValue=$byteValue,bitValue=$bitValue,tmpInputValue=$tmpInputValue";
					echo "<tr>";
					if(sizeof($tArr) > 2)
						echo "<td>$tlvArr[0]:</td>";
					if(strlen($bitValue) > 0){
						$inputValue = BinDec($bitValue);
					}else{
						$inputValue = $byteValue;
					} 
					$tmpoffset='03.0-03.7';
					$addressLen=hexdec(getBitValue($setValue,$tmpoffset));
					echo "<td>";
					if('289' == $tmpInputValue){
						$tmpValue=HEXDEC(substr($inputValue,0,2)).'.'.HEXDEC(substr($inputValue,2,2)).'.'.HEXDEC(substr($inputValue,4,2)).'.'.HEXDEC(substr($inputValue,6,2));						
						if($addressLen == 0)
							$tmpValue="";
						echo "<input type=\"text\" name=\"$unitName\" maxlength=\"39\" size=\"39\" value=\"$tmpValue\" class=\"text\">";
					}else if('343' == $tmpInputValue){
						$tmpValue=substr($inputValue,0,4).':'.substr($inputValue,4,4).':'.substr($inputValue,8,4).':'.substr($inputValue,12,4).':'.substr($inputValue,16,4).':'.substr($inputValue,20,4).':'.substr($inputValue,24,4).':'.substr($inputValue,28,4);
						echo "<input type=\"text\" name=\"$unitName\" maxlength=\"39\" size=\"39\" value=\"$tmpValue\" class=\"text\">";
					}else{
						$tmpArr=explode("E",$inputValue);
						$tmpValue=$tmpArr[0];
						echo "<input type=\"text\" name=\"$unitName\" maxlength=\"39\" size=\"39\" value=\"$tmpValue\" class=\"text\">";
					}
					echo "</td>";
					echo "</tr>";
					echo "<input type=\"hidden\" name=\"$unitName"."_oldValue\" value=\"$tmpValue\">";
					//echo "inputValue=$inputValue,tmpValue=$tmpValue";
					$tempDef = $sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.$valueArr[1];
					break;
				case 'vlrSpecialRead':
					$MCC=substr($setValue,0,2);
					$MCC=strrev($MCC);
					$MCC=$MCC.strrev(substr($setValue,2,2));
					$MCC=str_replace("F","",$MCC);
					$MNC=substr($setValue,4,2);
					$MNC=strrev($MNC);
					$MNC=str_replace("F","",$MNC);
					$LAC=substr($setValue,-4);
					echo "$MCC-$MNC-$LAC";
					break;
				case 'password':
					echo "******";
					break;
				default: echo "<br>Error:operType =|$operType|";
					break;
			}//end of switch(..)
			//like:unitDef_1 = 1.0-2.0-select-keepHex-high-0 -->$tlvArr[1]-$operType-
		}//end for(n..)
		if($operType == 'select' || $operType == 'show' || $operType == 'radio' || $operType == 'checkbox')
		{ //select
			//echo "valueType=$valueType,nOctStr=$nOctStr";
			if($valueType == $nOctStr){
				$tempDef = $sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.'toDec-high-0';
			}else{
				$tempDef = $sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.'keepDec-high-0';
			}
			if($specialDo[0] != '')
			{
				$tempDef = $sqlName.'-'.$tlvArr[1].'-'.$operType.'-'.$specialDo[0].'-high-0';
			}
		}
		
		$tempDef = str_replace(" ", "", $tempDef);
		$tempDef = chop($tempDef);
		if($specialDo[0] == 'code')
			$tempDef=$tempDef.'-code';
		$unitDefName='unitDef_'.$m.'_'.$i;
		//echo "$unitDefName";
		echo "<input type=\"hidden\" name=\"$unitDefName\" value=\"$tempDef\">";

		//echo "<br>tempDef=$tempDef";
	}//end of for(i..)
	$unitNum=$i-1;
	$unitNumName='unitNum_'.$m;
	echo "<input type=\"hidden\" name=\"$unitNumName\" value=\"$unitNum\">";
	echo "</table>";
	echo "</td>";
	if($sysTypeNo != 325)
	{
		$remark=nl2br($remark);
		echo "<td>$remark</td>";
	}
}//end of for(m..)

$paraNumber=sizeof($paraArr)-1;
echo "<input type=\"hidden\" name=\"paraNumber\"		value=\"$paraNumber\">";
echo "</table>"; 

//*****************************************隐藏输入框,用于传递值****************************************
echo "\n<input type=\"hidden\" name=\"inputName\"	value=\"$inputName\">";
echo "\n<input type=\"hidden\" name=\"keyId\"		value=\"$keyId\">";
echo "\n<input type=\"hidden\" name=\"sysTypeNo\"	value=\"$sysTypeNo\">";
echo "\n<input type=\"hidden\" name=\"dataTypeNo\"	value=\"$dataTypeNo\">";
echo "\n<input type=\"hidden\" name=\"setValue\"	value=\"$setValue\">";
echo "\n<input type=\"hidden\" name=\"indexFieldName\"	value=\"$indexFieldName\">";
echo "\n<input type=\"hidden\" name=\"keyValue\"		value=\"$keyValue\">";

echo "</Form>";

echo "</table>"; 
?>

</form>
&nbsp;
<?php
adjust_content_tail("down");
?>
</body>
</html>
<?php
flush();
?>