"; echo "replacingMSISDN=$replacingMSISDN
"; echo "page_num=$page_num,order_field=$order_field
"; } //check the status $check_server_systype=array(330,360,375); $check_server_name=array("HLR","PPS","OPPS"); for($i=0;$i{$check_server_name[$i]} is not online
"); else { $rows=@mysqli_fetch_array($res); $sysNo=$rows[sysNo]+0; $server_sysId[$i]="{$check_server_systype[$i]}_{$sysNo}_0"; //echo "server_sysId[$i]={$server_sysId[$i]}
"; } } //get HLR IMSI by replaced msisdn $replacedMSISDN91=omc_keep_length("91".$replacedMSISDN,'E',18,0); $replacingMSISDN91=omc_keep_length("91".$replacingMSISDN,'E',18,0); $sql="select imsi from HLR_DB.subscriberData where inter_msisdn = '{$replacedMSISDN91}' "; //echo "$sql
"; $res=@mysqli_query($pubConn,$sql); $num=mysqli_num_rows($res); if($num == 0) { echo "Can not find HLR subscriber by MSISDN={$replacedMSISDN}
"; exit(); } $rows=@mysqli_fetch_array($res); $HLR_IMSI=$rows[imsi]; $HLR_replaced_IMSI=substr($HLR_IMSI,1); //read HLR subscriber by IMSI printInfo("Read HLR subscriber IMSI=$HLR_IMSI, MSISDN=$replacedMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[0],0,$HLR_IMSI,"ALL",1,0); checkComm($commId); //read PPS subscriber by MSISDN printInfo("Read PPS subscriber MSISDN=$replacedMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[1],0,$replacedMSISDN,"ALL",1,0); checkComm($commId); //save the PPS subscriber data $sql="desc PPS_DB.user_info "; $res=@mysqli_query($pubConn,$sql); $pps_field_num=mysqli_num_rows($res); if($pps_field_num <= 0) printInfo("PPS_DB.user_info table is null
"); $i=0; while($rows=@mysqli_fetch_array($res)) { $pps_field_name[$i]=$rows[Field]; if(stristr($rows[Type],"int")) $pps_field_type[$i]="int"; else $pps_field_type[$i]="char"; $i++; } $sql="select * from PPS_DB.user_info where msisdn='{$replacedMSISDN}' "; $res=@mysqli_query($pubConn,$sql); $rows=@mysqli_fetch_array($res); $i=0; while($i<$pps_field_num) { if(trim($rows[$i]) == "") $pps_field_value[$i]=""; else $pps_field_value[$i]=$rows[$i]; $i++; } //read OPPS subscriber by MSISDN printInfo("Read OPPS subscriber MSISDN=$replacedMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[2],0,$replacedMSISDN,"ALL",1,0); checkComm($commId); //Modify the HLR MSISDN printInfo("Modify HLR subscriber MSISDN from $replacedMSISDN to $replacingMSISDN","blue"); $sql="update OBJ_330.tmpSubsData_0 set inter_msisdn='{$replacingMSISDN91}' where imsi='{$HLR_IMSI}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //echo "$sql
"; clearCommTable(); $commId=subsCommSend($server_sysId[0],0,$HLR_IMSI,"inter_msisdn",2,0); checkComm($commId); //read the new HLR subscriber printInfo("Read HLR subscriber IMSI=$HLR_IMSI, MSISDN=$replacingMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[0],0,$HLR_IMSI,"ALL",1,0); checkComm($commId); //get the replaced OPPS subscriber data $sql="select * from OBJ_375.tmpSubsData_0 where msisdn='{$replacedMSISDN}' "; $res=@mysqli_query($pubConn,$sql); $num=mysqli_num_rows($res); if($num < 1) { printInfo("Can not find OPPS subscriber msisdn=$replacedMSISDN","red"); exit(); } $rows=@mysqli_fetch_array($res); $replaced_opps_userType=$rows[userType]+0; //modify the replaced OPPS subscriber printInfo("Modify OPPS subscriber MSISDN=$replacedMSISDN 's User Type from OPR-1 to OPR-0","blue"); //,imsi='$HLR_replacing_IMSI' $sql="update OBJ_375.tmpSubsData_0 set oprFlag='0',imsi=' ' where msisdn='{$replacedMSISDN}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //echo "$sql
"; clearCommTable(); $commId=subsCommSend($server_sysId[2],0,$replacedMSISDN,"oprFlag,imsi",2,0); checkComm($commId); //read the replaced OPPS subscriber printInfo("Read OPPS subscriber MSISDN=$replacedMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[2],0,$replacedMSISDN,"ALL",1,0); checkComm($commId); //modify the replacing OPPS subscriber printInfo("Modify OPPS subscriber MSISDN=$replacingMSISDN 's User Type from OPR-0 to OPR-1","blue"); // $sql="update OBJ_375.tmpSubsData_0 set oprFlag='1',imsi='$HLR_replaced_IMSI',userType='$replaced_opps_userType' where msisdn='{$replacingMSISDN}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //echo "$sql
"; clearCommTable(); $commId=subsCommSend($server_sysId[2],0,$replacingMSISDN,"oprFlag,imsi,userType",2,0); checkComm($commId); //read the replacing OPPS subscriber printInfo("Read OPPS subscriber MSISDN=$replacingMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[2],0,$replacingMSISDN,"ALL",1,0); checkComm($commId); //delete old PPS subscriber printInfo("Delete PPS subscriber MSISDN=$replacedMSISDN","blue"); clearCommTable(); $commId=subsCommSend($server_sysId[1],0,$replacedMSISDN,"ALL",4,0); checkComm($commId); $sql="delete from OBJ_360.tmpSubsData_0 where msisdn='{$replacedMSISDN}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); $sql="delete from PPS_DB.user_info where msisdn='{$replacedMSISDN}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //create new PPS subsriber printInfo("Create PPS subsriber MSISDN=$replacingMSISDN","blue"); //INSERT INTO omcPubVarConf (instance, pubVarName, pubVarValue, remark) VALUES ('24', '1', '1', '1') $sql="insert into OBJ_360.tmpSubsData_0 ("; $field_sql=" values("; $pps_field_list=""; for($i=0;$i<$pps_field_num;$i++) { $sql.=$pps_field_name[$i]; if($pps_field_type[$i] == "int") $field_sql.=$pps_field_value[$i]; else { if($pps_field_name[$i] == "msisdn") $field_sql.="'".$replacingMSISDN."'"; else $field_sql.="'".$pps_field_value[$i]."'"; } if($i == $pps_field_num-1) { $field_sql.=")"; $sql.=")"; $pps_field_list.=$pps_field_name[$i]; } else { $field_sql.=", "; $sql.=", "; $pps_field_list.=$pps_field_name[$i].","; } } $sql.=$field_sql; $update_sql.=" where msisdn='{$replacingMSISDN}' "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //echo "

$sql

"; $sql=str_replace("OBJ_360.tmpSubsData_0","PPS_DB.user_info",$sql); $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); //echo "

$sql
"; //echo "

$pps_field_list
"; clearCommTable(); $commId=subsCommSend($server_sysId[1],0,$replacingMSISDN,$pps_field_list,3,0); checkComm($commId); clearCommTable(); $commId=subsCommSend($server_sysId[0],0,$HLR_IMSI,"ALL",1,0); checkComm($commId); echo "\n\n"; } $maxRecordPerPage=20; if(!isset($classValue)) $classValue=0; $classValue=$classValue-1; //All if($classValue == -1) $classWhere=" "; //Ordinary else $classWhere=" and class=$classValue "; $sql="select * from OPR_DB.subscriberData where msisdn is not null $classWhere "; $res=@mysqli_query($pubConn,$sql); $record_total_num=mysqli_num_rows($res); $page_num_total=ceil($record_total_num/$maxRecordPerPage); //echo "record_total_num=$record_total_num
"; $select_fields=array("msisdn","oprFlag","class"); $show_fields=array("MSISDN","User Type","Class"); $oprClassLabel=array(0=>"Ordinary",1=>"Premier",2=>"VIP"); $select_fields_flip=array_flip($select_fields); $oprFlagFiledPos=$select_fields_flip['oprFlag']; $limit_from=$page_num*$maxRecordPerPage; $sql="select * from OPR_DB.subscriberData where msisdn is not null $classWhere order by $order_field LIMIT $limit_from,$maxRecordPerPage "; $res=@mysqli_query($pubConn,$sql); $record_num=0; $field_num=sizeof($select_fields); while($rows=@mysqli_fetch_array($res)) { for($i=0;$i<$field_num;$i++) { $records[$record_num][$i]=$rows[$select_fields[$i]]; } $record_num++; } echo mysqli_error($pubConn); if($record_num == 0) exit("No record found!
"); echo "

"; echo ""; echo ""; echo ""; echo ""; echo "
"; if((($page_num+1)*$maxRecordPerPage) > $record_total_num) $tmp=$record_total_num; else $tmp=($page_num+1)*$maxRecordPerPage; echo "Record ".($page_num*$maxRecordPerPage+1)." - ".($tmp)."(Total:$record_total_num)"; echo ""; if($page_num > 0) echo ""; echo "PreviousPrevious"; if($page_num > 0) echo ""; echo ""; if($page_num < ($page_num_total-1)) echo ""; echo "NextNext"; if($page_num < ($page_num_total-1)) echo ""; echo "
"; echo ""; echo ""; for($i=0;$i<$field_num;$i++) echo ""; echo ""; for($i=0;$i<$record_num;$i++) { echo ""; for($j=0;$j<$field_num;$j++) { if($select_fields[$j] == "msisdn") { echo ""; } else if($select_fields[$j] == "oprFlag") { echo ""; } else if($select_fields[$j] == "class") { echo ""; } else { echo ""; } } echo ""; } echo "
{$show_fields[$i]}
"; if($records[$i][$oprFlagFiledPos] == 0) echo "{$records[$i][$j]}"; else echo "{$records[$i][$j]}"; echo ""; if($records[$i][$j] == 0) echo "Idle"; else echo "In Use"; echo ""; $showValue=$oprClassLabel[$records[$i][$j]]; echo "$showValue"; echo "{$records[$i][$j]}
"; echo ""; echo "
"; function checkComm($commId) { $sep=explode("-",$commId); for($i=0;$i"; //echo "commId={$sep[$i]},remark=$remark
"; if(stristr($remark,"process finished")) printInfo("...successful
","blue"); else { printInfo("...fail
","red"); exit(); } } } function clearCommTable() { $sql="delete from OMC_PUB.subscriberComm "; $res=@mysqli_query($pubConn,$sql); echo mysqli_error($pubConn); } function printInfo($info,$color) { echo "$info"; } function subsCommSend($sysId,$dataTypeNo,$indexValueList,$fieldNameList,$commType,$newIndexValue=0){ //global $pubDb,$commTable; $DEBUG = 0; $pubDb = 'OMC_PUB'; $commTable = 'subscriberComm'; $ipTable = 'sysInfo'; $nReadComm = 1; $nChangeComm = 2; $nCreateComm = 3; $nDeleteComm = 4; $nLoadIndexComm = 5; $nReplaceIndexComm=6; $sysIdArr = explode('_',$sysId); $sysTypeNo = $sysIdArr[0]; $sysNo = $sysIdArr[1]; $subSysNo = $sysIdArr[2]; $comm="echo 'subsCommSend(<$sysId>,<$dataTypeNo>,<$indexValueList>,<$fieldNameList>,<$commType>,<0>)' >> /tmp/subCommand.txt"; system($comm); //step 1: delete overtime and imcompetent command $overTime = date("Y-m-d H:i:s", mktime(date("H"),date("i")-1,date("s"),date("m"),date("d"),date("Y"))); $delSql = "DELETE FROM $commTable WHERE (commState ='0' OR commState ='3') AND sendTime < '$overTime'"; if($DEBUG) echo"
delete command sql = $delSql"; mysqli_query($pubConn,$delSql); echo mysqli_error($pubConn); $overTime = date("Y-m-d H:i:s", mktime(date("H"),date("i")-30,date("s"),date("m"),date("d"),date("Y"))); $delSql = "DELETE FROM $commTable WHERE sendTime < '$overTime'"; if($DEBUG) echo"
delete command sql = $delSql"; mysqli_query($pubConn,$delSql); echo mysqli_error($pubConn); /* //step 2: check the system's ip $chkIpSql = "SELECT ip FROM $ipTable WHERE sysTypeNo='$sysTypeNo' AND sysNo='$sysNo' AND subSysNo='$subSysNo' "; if($DEBUG) echo"
chkIpSql = $chkIpSql"; $chkIpResult = mysqli_query($pubConn,$chkIpSql); echo mysqli_error($pubConn); $rowsNum = @mysqli_num_rows($chkIpResult); if($rowsNum > 0){ echo ""; return(-1); } */ //step 3: check the command(............................) $chkSql = "SELECT commId FROM $commTable WHERE sysTypeNo='$sysTypeNo' AND indexValueList='$indexValueList' "; if($DEBUG) echo"
check command sql = $chkSql"; $chkResult = mysqli_query($pubConn,$chkSql); echo mysqli_error($pubConn); $rowsNum = @mysqli_num_rows($chkResult); if($rowsNum <= 0){ //step 4:insert commands into command table if($commType == $nReplaceIndexComm){ $sendSql="INSERT INTO $commTable (commType,dataTypeNo,sysTypeNo,sysNo,subSysNo,indexValueList, fieldNameList,paramType,commState,sendTime,remark) VALUES ('$commType','$dataTypeNo','$sysTypeNo','$sysNo','$subSysNo','$indexValueList', '$fieldNameList','0','1',CURRENT_TIMESTAMP,'$newIndexValue') "; }else{ $sendSql="INSERT INTO $commTable (commType,dataTypeNo,sysTypeNo,sysNo,subSysNo,indexValueList,fieldNameList,paramType,commState,sendTime) VALUES ('$commType','$dataTypeNo','$sysTypeNo','$sysNo','$subSysNo','$indexValueList', '$fieldNameList','0','1',CURRENT_TIMESTAMP) "; } if($DEBUG)echo"
send command sql = $sendSql"; $sendResult=mysqli_query($pubConn,$sendSql); //echo mysqli_error($pubConn); } //step 5:Return commIdStr $selSql = "SELECT commId FROM $commTable WHERE sysTypeNo='$sysTypeNo' AND sysNo='$sysNo' AND subSysNo='$subSysNo' AND indexValueList='$indexValueList' "; if($DEBUG) echo"
get command id sql = $selSql"; $selResult=mysqli_query($pubConn,$selSql); echo mysqli_error($pubConn); $commIdStr=''; while($selRows = mysqli_fetch_array($selResult)){ $commIdStr .= $selRows[commId].'-'; } if($DEBUG)echo "
commIdStr = $commIdStr"; if($DEBUG) exit(); return($commIdStr); }//end of function sendComm() adjust_content_tail("down"); ?>