<?php
/*********************************************************      
 程序说明：         
    功能说明：E1参数配置

    调用关系：调用: header.inc     
              被调用:   
 
    变量说明：

     返回值：无

 作者：    
      
修改注释：      
NO.1      
姓名：            
时间：      
修改说明：      
*********************************************************/  
require("../../inc/header.inc");
$DEBUG = 0;
?>
<script LANGUAGE="JavaScript">           
function openSet(){
	URL="./scEdit.php";
	var msgWindow = open(URL, 'newWin', 'toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=yes,width=400,height=420');
	msgWindow.focus();
}
</script>
<?
$sysTypeNo = "350";

$db = "OBJ_".$sysTypeNo;

$tb_0 = "param_0";
$tb_1 = "param_1";
$tb_2 = "param_99";

$maxNum = 20;

$nPubFlag = 99;
$nSubSysParam		= 0;
$nGlobalSubSysParam = 1;
$nGlobalSysParam	= 2;

$nGetComm = 0;
$nSetComm = 3;

$nInteger = 2;
$nOctStr = 4;

$nProcFail = 0;
$nWaitProc = 1;
$nInProc   = 2;	
$nOutProc  = 3;

$wSc = " AND level_1 = 2 AND (level_2 = 2 OR level_2 = 3)";

$pTypeArr = array('unknown','unknown','SMPP UDP','SMPP TCP');
if($set)
{	
	if($oType == 2){
		$udtNum = 14;
		$showValue[5] = "00";//Address type
		$showValue[6] = omc_keep_length($showValue[6],E,18,0);//GTT number
		$showValue[7] = omc_keep_length(DecHex($showValue[7]),0,8);
		$showValue[8] = omc_keep_length(DecHex($showValue[8]),0,8);
		$showValue[9] = omc_keep_length(DecHex($showValue[9]),0,8);
		$showValue[10] = omc_keep_length(DecHex($showValue[10]),0,8);
	}elseif($oType == 3){
		$udtNum = 14;
		$showValue[5] = "01";
		$p6 = explode('.',$showValue[6]);//Service address
		$showValue[6] = omc_keep_length(DecHex($p6[0]),0,2).omc_keep_length(DecHex($p6[1]),0,2).omc_keep_length(DecHex($p6[2]),0,2).omc_keep_length(DecHex($p6[3]),0,2);

		$p7 = explode('.',$showValue[7]);//Service address
		$showValue[7] = omc_keep_length(DecHex($p7[0]),0,2).omc_keep_length(DecHex($p7[1]),0,2).omc_keep_length(DecHex($p7[2]),0,2).omc_keep_length(DecHex($p7[3]),0,2);
		$showValue[8] = omc_keep_length(DecHex($showValue[8]),0,8);
		$showValue[9] = omc_keep_length(DecHex($showValue[9]),0,8);
		$showValue[10] = omc_keep_length(DecHex($showValue[10]),0,8);	
		$showValue[11] = omc_keep_length(DecHex($showValue[11]),0,8);
	
	}

	$showValue[12] = omc_keep_length(DecHex($showValue[12]),0,2);

	$showValue[13] = omc_keep_length(DecHex($showValue[13]),0,8);

	for($i=1;$i<4;$i++){
		$valueLen = strLen($showValue[$i]);
		//echo "<br>valueLen=$valueLen";
		for($j=0;$j<$valueLen;$j++){
			$temValue[$j] = substr($showValue[$i],$j,1);
			$temValue[$j] = omc_keep_length(DecHex(Ord($temValue[$j])),0,2);	
		}
		$aNum = $j;
		$tValue = '';
		for($j=0;$j<$aNum;$j++){
			$tValue = $tValue.$temValue[$j];
		}
		if($DEBUG)echo "<br>tValue=$tValue";
		
		if($i == 1)
			$showValue[$i] = omc_keep_length($tValue,0,32,0);
		elseif($i == 2)
			$showValue[$i] = omc_keep_length($tValue,0,30,0);
		elseif($i == 3)
			$showValue[$i] = omc_keep_length($tValue,0,16,0);
	}
		
	$showValue[4] = omc_keep_length($showValue[4],E,16,0);//Service number
	
	for($i=1;$i<$udtNum;$i++){
		if($oType==2&&$i==11)
			continue;
		$udtSql = " UPDATE $tb_2 SET initValue = '$showValue[$i]' WHERE subSysNo = '99' AND level_2 = '$oType' AND level_3 = '$i' AND 				instanceNo = '$iNum' ".$wSc;
		//echo "<br>udtSql=$udtSql";
		$udtRes = @mysqli_query($pubConn,$udtSql);
		echo mysqli_error($pubConn);
	}
	echo "<script LANGUAGE=\"JavaScript\">";
	echo "window.opener.location.href='./smscConf.php?scroll_x=$scroll_x&scroll_y=$scroll_y';";		
	echo "\n window.close();";
	echo "\n </script>";
}

/************select value to see************/
$scSql = " SELECT level_2,level_3,instanceNo,initValue,editValue,readValue FROM $tb_2 WHERE subSysNo = '99' AND level_2 = '$oType' AND instanceNo = '$iNum' ".$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_2 = $scRow[level_2];
	$level_3 = $scRow[level_3];
	if($DEBUG)echo "<br>level_3=$level_3";
	$instanceNo = $scRow[instanceNo];
	//$showValue[$level_3] = $scRow[initValue];
	//if($DEBUG)echo "<br>showValue[$level_3]={$showValue[$level_3]}";

	if($level_3 > 0 && $level_3 < 4){
		$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];
		}
		//echo "<br>tValue=$tValue";
		$showValue[$level_3] = $tValue;
	}elseif($level_3 == 4){
		$p4 = explode("E",$scRow[initValue]);
		$showValue[$level_3] = $p4[0];
	}elseif($level_3 == 6){
		if($level_2 == 2){
			$p6 = explode("E",$scRow[initValue]);
			$showValue[$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_3] = $temValue[0].".".$temValue[1].".".$temValue[2].".".$temValue[3];
		}
	}elseif($level_3 == 7){
		if($level_2 == 2){
			$showValue[$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_3] = $temValue[0].".".$temValue[1].".".$temValue[2].".".$temValue[3];
		}
	}else{
		$showValue[$level_3] = HexDec($scRow[initValue]);
	}

}while($scRow = @mysqli_fetch_array($scRes));



echo "<form method=\"POST\" name=\"confForm\" action=\"$PHP_SELF\">";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">";

echo "<tr>";
echo "<td colspan=\"4\"><b>$pTypeArr[$oType]   $iNum</b></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Name</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[1]\" size=\"32\" value=\"$showValue[1]\" maxLength=\"32\" class=\"input\"></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>System ID</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[2]\" size=\"32\" value=\"$showValue[2]\" maxLength=\"32\" class=\"input\"></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Password</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[3]\" size=\"16\" value=\"$showValue[3]\" maxLength=\"16\" class=\"input\"></td>";
echo "</tr>";

echo "<tr>";
echo "<td width=\"60\" valign=middle><nobr>Service number</nobr></td>";
echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[4]\" size=\"16\" value=\"$showValue[4]\" maxLength=\"16\" class=\"input\"></td>";
echo "</tr>";

if($oType == 2){
	echo "<input type=\"hidden\" name=\"showValue[5]\" value =\"00\">";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>GTT number</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[6]\" size=\"18\" value=\"$showValue[6]\" maxLength=\"18\" 	class=\"input\"></td>";
	echo "</tr>";
	
	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Session timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[7]\" size=\"8\" value=\"$showValue[7]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Enquire link timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[8]\" size=\"8\" value=\"$showValue[8]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Inactivity timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[9]\" size=\"8\" value=\"$showValue[9]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Response timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[10]\" size=\"8\" value=\"$showValue[10]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>DCS</td>";
	$arr_DCS=array(
		array('num' => '0',   'remark' => 'To smpp=7bit,default=7bit'),
		array('num' => '1',   'remark' => 'To smpp=8bit,default=7bit'),
		array('num' => '16',  'remark' => 'To smpp=7bit,default=8bit'),
		array('num' => '17',  'remark' => 'To smpp=8bit,default=8bit')
	);
	
	echo "<td>";
	echo "<select size=\"1\" name=\"showValue[12]\">";
	for ($i=0;$i<4;$i++){
		 if($arr_DCS[$i][num] != $showValue[12]){
			 echo "<option value=\"{$arr_DCS[$i][num]}\">{$arr_DCS[$i][remark]}</option>";       
         }else{
			 echo "<option value=\"{$arr_DCS[$i][num]}\" selected>{$arr_DCS[$i][remark]}</option>";
         }       
	}
	echo "</select>";
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Time to live</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[13]\" size=\"10\" value=\"$showValue[13]\" maxLength=\"10\" class=\"input\"></td>";
	echo "</tr>";
}
elseif($oType == 3)
{
	echo "<input type=\"hidden\" name=\"showValue[5]\" value =\"01\">";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Service IP</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[6]\" size=\"16\" value=\"$showValue[6]\" maxLength=\"16\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Local IP</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[7]\" size=\"16\" value=\"$showValue[7]\" maxLength=\"16\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Session timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[8]\" size=\"8\" value=\"$showValue[8]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Enquire link timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[9]\" size=\"8\" value=\"$showValue[9]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Inactivity timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[10]\" size=\"8\" value=\"$showValue[10]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Response timer</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[11]\" size=\"8\" value=\"$showValue[11]\" maxLength=\"8\" class=\"input\"></td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>DCS</td>";
	$arr_DCS=array(
		array('num' => '0',   'remark' => 'To smpp=7bit,default=7bit'),
		array('num' => '1',   'remark' => 'To smpp=8bit,default=7bit'),
		array('num' => '16',  'remark' => 'To smpp=7bit,default=8bit'),
		array('num' => '17',  'remark' => 'To smpp=8bit,default=8bit')
	);
	
	echo "<td>";
	echo "<select size=\"1\" name=\"showValue[12]\">";
	for ($i=0;$i<4;$i++){
		 if($arr_DCS[$i][num] != $showValue[12]){
			 echo "<option value=\"{$arr_DCS[$i][num]}\">{$arr_DCS[$i][remark]}</option>";       
         }else{
			 echo "<option value=\"{$arr_DCS[$i][num]}\" selected>{$arr_DCS[$i][remark]}</option>";
         }       
	}
	echo "</select>";
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td width=\"60\" valign=middle><nobr>Time to live</nobr></td>";
	echo "<td colspan=\"2\"><input type=\"text\" name=\"showValue[13]\" size=\"10\" value=\"$showValue[13]\" maxLength=\"10\" class=\"input\"></td>";
	echo "</tr>";

}
echo "</table>";
echo "<br>";
echo "<input type=\"submit\" name=\"set\" value = \"Set\" class=\"button\">";
echo "&nbsp;&nbsp;";
echo "<input type=\"hidden\" name=\"iNum\" value =\"$iNum\">";
echo "<input type=\"hidden\" name=\"oType\" value =\"$oType\">";
echo "<input type=\"reset\" name=\"Reset\" value =\"Reset\" class=\"button\">";
echo "<input type=\"hidden\" name=\"scroll_x\" value =\"$scroll_x\">";
echo "<input type=\"hidden\" name=\"scroll_y\" value =\"$scroll_y\">";

echo "</form>";
?>
<B>Remarks:</B><br><br>
Name: Name of the SMPP connection, can be any name, generally use the name of the connected device<br><br>
System ID: Character string used to identify a SMPP connection. The System ID must be same as that of the connected device<br><br>
Password: Password for setting up the SMPP connection. The password must be same as that of the connected device<br><br>
Service number: SMSC number used for MO number display on MT MS, can be any number<br><br>
GTT number: E.164 number of the connected device, only for UDP SMPP<br><br>
Service IP: IP address of the connected device, only for TCP SMPP<br><br>
Local IP: IP address of the connected device, only for TCP SMPP<br><br>
Session timer: Specify the time lapse allowed between a network connection being established and a bind_transmitter or bind_receiver request being sent to the SMSC<br><br>
Enquire link timer: Specify the time lapse allowed between operations after which an SMPP entity should interrogate whether it's peer still has an active session<br><br>
Inactivity timer: Specify the maximum time lapse allowed between transactions, after which period of inactivity, an SMPP entity may assume that the session is no longer active<br><br>
Response timer: Specify the time lapse allowed between an SMPP request and the corresponding SMPP response<br><br>


</html>