getSysIdSql=$getSysIdSql";
//debug_log("/tmp/debug.txt",$getSysIdSql);
$getSysIdResult=mysqli_query($pubConn,$getSysIdSql);
echo mysqli_error($pubConn);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-1");
if(mysqli_num_rows($getSysIdResult) > 0){
$getSysIdRows=mysqli_fetch_array($getSysIdResult);
$sysNo = $getSysIdRows[sysNo];
$subSysNo = $getSysIdRows[subSysNo];
$sysId = $sysTypeNo.'_'.$sysNo.'_'.$subSysNo;
}else{
echo "
Can not find this system's IP in system List,";
echo "Please add it!";
exit(0);
}
}else{
echo "Can not find sysTYpeNo!!";
exit(0);
}
if(($isBatchCreate>0&&$isCreate>0)&&(!isset($batchNum)||$batchNum>100||$batchNum<=0)){
echo "";
echo " ";
exit();
}
$objDb='OBJ_'.$sysTypeNo;
$objConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], $objDb);
$dataTypeNo = (strlen($dataTypeNo) > 0)?$dataTypeNo:0;
$confTable = 'subsParamConf_'.$dataTypeNo;
if($sysTypeNo==390 || $sysTypeNo == 365 || $sysTypeNo == 366){
$getConfSql="SELECT sysTypeName,dataTypeNo,indexFieldName,subsDataTable,tmpDataTable
FROM $sysSubsConfTable,$systemConfTable
WHERE $sysSubsConfTable.sysTypeNo='$sysTypeNo'
AND $systemConfTable.sysTypeNo='$sysTypeNo'
AND $sysSubsConfTable.dataTypeNo='$dataTypeNo'
AND $sysSubsConfTable.sysNo='$sysNo'
";
}else{
$getConfSql="SELECT sysTypeName,dataTypeNo,indexFieldName,subsDataTable,tmpDataTable
FROM $sysSubsConfTable,$systemConfTable
WHERE $sysSubsConfTable.sysTypeNo='$sysTypeNo'
AND $systemConfTable.sysTypeNo='$sysTypeNo'
AND $sysSubsConfTable.dataTypeNo='$dataTypeNo'
";
}
//if($DEBUG)
//echo "
getConfSql=$getConfSql";
//exit();
$getConfResult=mysqli_query($pubConn,$getConfSql);
echo mysqli_error($pubConn);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-2");
$getConfRows=mysqli_fetch_array($getConfResult);
$sysTypeName =$getConfRows['sysTypeName'];
$indexFieldName =$getConfRows['indexFieldName'];
$srcDataTable =$getConfRows['subsDataTable'];
$tmpDataTable =$getConfRows['tmpDataTable'];
global $userName;
if($sysTypeName=="VSS") $sysTypeName="VMS";
$srcDataConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], $sysTypeName."_DB");
if($DEBUG)echo "
srcDataTable:$srcDataTable
tmpDataTable:$tmpDataTable";
//�����û��Ƿ������˲���
$editFlag = false;
if($editFlag < 0){
$chkFlagSql = "SELECT editFlag FROM $tmpDataTable WHERE $indexFieldName = '$keyValue'";
if($DEBUG) echo "
chkFlagSql=$chkFlagSql";
$result=mysqli_query($objConn,$chkFlagSql);
echo mysqli_error($objConn);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-3");
$flagRow=mysqli_fetch_array($result);
$editFlag = $flagRow[0];
if($editFlag > 0){
echo "This subscriber is be other one editing!!,please wait and try again";
}else{
$setFlagSql = "UPDATE $tmpDataTable SET editFlag = '1' WHERE $indexFieldName = '$keyValue'";
mysqli_query($objConn,$setFlagSql);
}
}
$needSaveEditValue = 0;
$needSendComm = 0;
$indexValueList = $keyValue;
//*********��ȡһ���û�***************************
if($isRead > 0){//$getFromSys
$commType = $nReadComm;
$needSendComm = 1;
}
//*********��һ���û�*************************
if($isChange > 0){
$needSaveEditValue = 1;
$commType = $nChangeComm;
$needSendComm = 1;
}
//*********����һ���û�***************************
if($isCreate > 0){
if($isCreate == 2){//create in omc
$needSaveEditValue = 1;
}else{//$isCreate == 2,create in server
$commType = $nCreateComm;
$needSendComm = 1;
$needSaveEditValue = 1;
}
}
//*********ɾ��һ���û�***************************
if($isDelete > 0){
$commType = $nDeleteComm;
$needSendComm = 1;
}
//*********���������û�***************************
if($isLoadIndex > 0){
$commType = $nLoadIndexComm;
$needSendComm = 1;
}
//*********�滻�û�index����***************************
if($isReplaceIndex > 0){
$chkIndexPass = 0;
if($isConfirmed > 0){
$chkIndexPass=1;
if($DEBUG) echo "
newIndexValue=$newIndexValue";
//���newIndexValue������
switch($sysTypeNo){
case '330':
//���㳤��
for($i=strlen($newIndexValue);$i<16;$i++){
$imsi='0'.$newIndexValue;
}
$oldMccMnc=substr($keyValue,0,6);
$newMccMnc=substr($newIndexValue,0,6);
/*
if($oldMccMnc != $newMccMnc){
echo "Please Check new IMSI's MCC AND MNC!";
$chkIndexPass=0;
}*/
if($newIndexValue == $keyValue){
echo "New IMSI Number same as old's!";
$chkIndexPass=0;
}
break;
default:
echo "Unknown sysTypeNo($sysTypeNo)!";
exit();
}
if($chkIndexPass > 0){
$commType = $nReplaceIndexComm;
$needSendComm = 1;
}
}
if($chkIndexPass == 0){
if($DEBUG) echo "
";
echo "\n ";
exit();
}
}
//---------�������------------------------------
if($needSaveEditValue == 1){
if($isBatchCreate>0&&$isCreate>0){
$stopFlag=0;
for($tmpNum=0;$tmpNum<$batchNum;$tmpNum++){
$counter=0;
for($i=$bgnNo;$i<$endNo;$i++){
if(${'checkBox_'.$i} > 0){
$editValue=${'editValue_'.$i};
$tmpFieldName = ${'fieldName_'.$i};
if($tmpFieldName == $indexFieldName){
if($tmpNum==0)
$indexValueList = $editValue;
$tmpLen=strlen($editValue);
$tmpEditValue=$editValue[$tmpLen-4].$editValue[$tmpLen-3].$editValue[$tmpLen-2].$editValue[$tmpLen-1];
$tmpEditValue = $tmpEditValue+$tmpNum;
if($tmpEditValue%10000==0 && $tmpNum!=0){
$batchNum=$tmpNum;
$stopFlag=1;
}
$tmpEditValue=''.$tmpEditValue;//ȷ��tmpEditValueΪ�ַ���
$tmpEditValue=omc_keep_length($tmpEditValue,'0',4);
$editValue[$tmpLen-4]= $tmpEditValue[0];
$editValue[$tmpLen-3]= $tmpEditValue[1];
$editValue[$tmpLen-2]= $tmpEditValue[2];
$editValue[$tmpLen-1]= $tmpEditValue[3];
//echo "
editValue=$editValue";
}
if($sysTypeNo==330&&$tmpFieldName == 'inter_msisdn'){
$tmpEditValueArr=explode("E",$editValue);
$editValue=$tmpEditValueArr[0];
$tmpLen=strlen($editValue);
$tmpEditValue=$editValue[$tmpLen-4].$editValue[$tmpLen-3].$editValue[$tmpLen-2].$editValue[$tmpLen-1];
$tmpEditValue = $tmpEditValue+$tmpNum;
if($tmpEditValue%10000==0 && $tmpNum!=0){
$batchNum=$tmpNum;
$stopFlag=1;
}
$tmpEditValue=''.$tmpEditValue;//ȷ��tmpEditValueΪ�ַ���
$tmpEditValue=omc_keep_length($tmpEditValue,'0',4);
$editValue[$tmpLen-4]=$tmpEditValue[0];
$editValue[$tmpLen-3]=$tmpEditValue[1];
$editValue[$tmpLen-2]=$tmpEditValue[2];
$editValue[$tmpLen-1]=$tmpEditValue[3];
$editValue=omc_keep_length($editValue,'E',18,0);
//echo "
editValue=$editValue";
}
if($counter == 0){
$setValueStr = "$tmpFieldName = '$editValue'";
$fieldNameList = "$tmpFieldName";
}else{
$setValueStr .= ", $tmpFieldName = '$editValue'";
$fieldNameList .= ",$tmpFieldName";
}
$counter++;
}
}
if($stopFlag==1)
break;
if($isCreate == 2){//��omc�ϴ���
$saveSql = "REPLACE $srcDataTable SET $setValueStr";
$saveResult = mysqli_query($srcDataConn,$saveSql);
}else{
$saveSql = "REPLACE $tmpDataTable SET $setValueStr";
$saveResult = mysqli_query($objConn,$saveSql);
echo mysqli_error($objConn);
}
if($DEBUG)
echo "
saveSql = $saveSql
objDb=$objDb";
echo mysqli_error($pubConn);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-4");
}
$keyValue=$indexValueList;
if($isCreate == 2){//��omc�ϴ���
echo "";
exit();
}
}else{
$counter=0;
//echo "bgnNo=$endNo
";
for($i=$bgnNo;$i<$endNo;$i++){
//echo "checkBox_$i=".${'checkBox_'.$i}."
";
if(${'checkBox_'.$i} > 0){
$editValue=${'editValue_'.$i};
$tmpFieldName = ${'fieldName_'.$i};
if($isCreate > 0){
if($tmpFieldName == $indexFieldName){
$indexValueList = $editValue;
}
}else{
if($tmpFieldName == $indexFieldName){
continue;
}
}
if($counter == 0){
$setValueStr = "$tmpFieldName = '$editValue'";
$fieldNameList = "$tmpFieldName";
}else{
$setValueStr .= ", $tmpFieldName = '$editValue'";
$fieldNameList .= ",$tmpFieldName";
}
$counter++;
}
}
if($isCreate){
$keyValue=$indexValueList;
if($isCreate == 2){//��omc�ϴ���
$saveSql = "REPLACE $srcDataTable SET $setValueStr";
$saveResult = mysqli_query($srcDataConn,$saveSql);
}else{
$saveSql = "REPLACE $tmpDataTable SET $setValueStr";
$saveResult = mysqli_query($objConn,$saveSql);
echo mysqli_error($objConn);
}
}else{
$saveSql = "UPDATE $tmpDataTable SET $setValueStr
WHERE $indexFieldName = '$keyValue'
";
$saveResult = mysqli_query($objConn,$saveSql);
echo mysqli_error($objConn);
}
if($DEBUG) echo "
saveSql = $saveSql
objDb=$objDb";
//if(mysql_errno())
//debug_log("/tmp/debug.txt","remark-5:$saveSql,tmpFieldName=$tmpFieldName,editValue'=$editValue'");
echo mysqli_error($pubConn);
}
}
//if($DEBUG && $_SERVER['REQUEST_METHOD'] == "POST") exit();
//echo "$sysId";
//exit();
//---------���������תҳ��----------------------------
global $objConn, $srcDataConn;
if($needSendComm == 1 && isset($commType)){
if($commType == $nLoadIndexComm || $commType == $nDeleteComm){
if($commType == $nLoadIndexComm){
$okURL ="./subscriberListDown.php?sysTypeNo=$sysTypeNo&dataTypeNo=$dataTypeNo&sysNo=$sysNo&sysId=$sysId";
$failURL ="./subscriberListDown.php?sysTypeNo=$sysTypeNo&dataTypeNo=$dataTypeNo&sysNo=$sysNo&sysId=$sysId";
}else{
$okURL ="./subscriberListDown.php?sysTypeNo=$sysTypeNo&dataTypeNo=$dataTypeNo&sysNo=$sysNo&sysId=$sysId&commType=$nDeleteComm&keyValue=$keyValue";
$failURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$keyValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo";
}
}else{
if($commType == $nReplaceIndexComm){
$okURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$newIndexValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo&isRead=1";
}elseif($commType == $nCreateComm){
if($isBatchCreate==1)
$okURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$keyValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo&isBatchCreate=$isBatchCreate";
else
$okURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$keyValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo&isRead=1";
}else{
$okURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$keyValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo";
}
$failURL = "$PHP_SELF?sysId=$sysId&bgnNo=$bgnNo&keyValue=$keyValue&canSetNum=$canSetNum&bufferNo=$bufferNo&dataTypeNo=$dataTypeNo&isBatchCreate=$isBatchCreate";
}
if($DEBUG) echo "
okURL =$okURL ";
sleep(1);
if($commType == $nReplaceIndexComm){
if($DEBUG) echo "
subsCommSend(sysId,dataTypeNo,indexValueList,fieldNameList,commType,newIndexValue)";
if($DEBUG) echo "
subsCommSend($sysId,$dataTypeNo,$indexValueList,$fieldNameList,$commType,$newIndexValue)";
$commIdStr = subsCommSend($sysId,$dataTypeNo,"$indexValueList","$fieldNameList",$commType,$newIndexValue);
}else{
if($DEBUG) echo "
subsCommSend(sysId,dataTypeNo,indexValueList,fieldNameList,commType)";
if($DEBUG) echo "
subsCommSend($sysId,$dataTypeNo,$indexValueList,$fieldNameList,$commType)";
if($isBatchCreate==1){
for($tmpNum=0;$tmpNum<$batchNum;$tmpNum++){
$tmpCommIdStr = subsCommSend($sysId,$dataTypeNo,"$indexValueList","$fieldNameList",$commType);
$tmpLen=strlen($indexValueList);
$tmpIndexValueList=$indexValueList[$tmpLen-4].$indexValueList[$tmpLen-3].$indexValueList[$tmpLen-2].$indexValueList[$tmpLen-1];
$tmpIndexValueList = $tmpIndexValueList+1;
$tmpIndexValueList=''.$tmpIndexValueList;//ȷ��tmpIndexValueListΪ�ַ���
$tmpIndexValueList=omc_keep_length($tmpIndexValueList,'0',4);
$indexValueList[$tmpLen-4]=$tmpIndexValueList[0];
$indexValueList[$tmpLen-3]=$tmpIndexValueList[1];
$indexValueList[$tmpLen-2]=$tmpIndexValueList[2];
$indexValueList[$tmpLen-1]=$tmpIndexValueList[3];
//echo "
commIdStr=subsCommSend($sysId,$dataTypeNo,\"$indexValueList\",\"$fieldNameList\",$commType)";
$commIdStr=$commIdStr.$tmpCommIdStr;
}
}else
$commIdStr = subsCommSend($sysId,$dataTypeNo,"$indexValueList","$fieldNameList",$commType);
//exit();
}
if($DEBUG) {
echo "
commIdStr=subsCommSend($sysId,$dataTypeNo,\"$indexValueList\",\"$fieldNameList\",$commType)";
}
if(isset($commIdStr) && $commIdStr != -1){
if($commType == $nLoadIndexComm){
$srcDataTableArr=explode('.',$srcDataTable);
$srcDataDb=$srcDataTableArr[0];
$clearDataSql="DELETE FROM $srcDataTable";
mysqli_query($srcDataConn,$clearDataSql);
if($DEBUG)
echo "mysqli_query($srcDataConn,$clearDataSql);
";
$clearDataSql="DELETE FROM $tmpDataTable";
if($DEBUG)
echo "mysqli_query($srcDataConn,$clearDataSql);
";
mysqli_query($objConn,$clearDataSql);
mysqli_error($srcDataConn);
mysqli_error($objConn);
}
$failURL = urlencode($failURL);
$okURL = urlencode($okURL);
$scanURL = "commIdStr=$commIdStr&okURL=$okURL&failURL=$failURL";
if($DEBUG) echo "
scanURL = $scanURL";
if($DEBUG) exit();
echo " ";
exit();
}else{
echo "
SEND COMMAND ERROR!
";
}
}
//��Ҫ�༭�����ݵ�����ʱ��
$getDataSql="SELECT * FROM $srcDataTable WHERE $indexFieldName='$keyValue'";
if($DEBUG)
echo "
getDataSql=$getDataSql";
$result=mysqli_query($srcDataConn,$getDataSql);
$fieldNum=mysqli_num_fields($result);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-6");
echo mysqli_error($srcDataConn);
if($DEBUG)
echo "
fieldNum=$fieldNum";
$tmpRow=mysqli_fetch_array($result);
if($DEBUG) echo "
tmpRow[mo_expiration_date]=$tmpRow[mo_expiration_date]";
#if($DEBUG) echo "
valuestr=$valueStr,bufferNo=$bufferNo";
for($i=0;$i<$fieldNum;$i++){
$valueStr = "$valueStr ,'$tmpRow[$i]'";
# if($DEBUG) echo "
i:$i,tmpRow:$tmpRow[$i],valuestr=$valueStr";
}
$updateSql = "REPLACE $tmpDataTable VALUES('0' $valueStr)";
mysqli_query($objConn,$updateSql);
#if($DEBUG) echo "
bufferNo=$bufferNo";
if($DEBUG) echo "
updateSql=$updateSql";
//exit();
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-7");
echo mysqli_error($objConn);
// echo"
objDb =$isTryCreate
ParamSql = $paramSql
";
//����������û�������ȱʡֵ
if($isTryCreate > 0){
//�ڲ��������ȡ��˵��������ʱ������ȡ����ص�ֵ
$paramSql = " SELECT * FROM $confTable
WHERE $confTable.operType > '0'
ORDER BY level_1,level_2,level_3,level_4,level_5,level_6,level_7,level_8,level_9,level_10
";
if($DEBUG)
echo"
objDb =$objDb
ParamSql = $paramSql
";
$paramResult = mysqli_query($objConn,$paramSql);
if(mysql_errno())
debug_log("/tmp/debug.txt","remark-8");
echo mysqli_error($objConn);
$i=0;
while($paramRows = @mysqli_fetch_array($paramResult)){
$tmpRow[$paramRows[fieldName]]=$paramRows[initValue];
}
if($DEBUG) echo "
tmpRow[mo_expiration_date]=$tmpRow[mo_expiration_date]";
}
?>