init web ems all

This commit is contained in:
agtuser
2024-09-27 17:13:36 +08:00
parent 81c97acbe9
commit 5cc56f8078
4263 changed files with 798779 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
#!/bin/bash
tmptty=`tty`
tmptty=`basename $tmptty`
tmpname=`whoami`
ip="$1"
inputfile="inabc"
outputfile="out.log"
rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile
exec 7<>$outputfile
exec 8<>$inputfile
telnet $ip <&8 >&7 &
#tail -f $outputfile &
sleep 2; echo "reboot" >>$inputfile
sleep 2; echo "logout" >>$inputfile
rm -fr $inputfile
rm -fr $outputfile
#ps -ef | grep telnet | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", }' | sh
#ps -ef | grep tail | grep -v grep | grep -v telnetd | grep $tmptty | grep $tmpname | awk '{print " kill -9", }' | sh

View File

@@ -0,0 +1,40 @@
#!/bin/bash
tmptty=`tty`
tmptty=`basename $tmptty`
tmpname=`whoami`
ip="localhost"
inp1="ems
"
inp2="Ems123!
"
inputfile="inabc"
outputfile="out.log"
rm -fr $inputfile
rm -fr $outputfile
mknod $inputfile p
touch $outputfile
exec 7<>$outputfile
exec 8<>$inputfile
telnet $ip <&8 >&7 &
sleep 2; echo $inp1 >>$inputfile
sleep 2; echo $inp2 >>$inputfile
#tail -f $outputfile &
sleep 3; echo "su -" >>$inputfile
sleep 2; echo "rootaa" >>$inputfile
sleep 2; echo "kill -9 `pidof bsscomm`" >>$inputfile
sleep 2; echo "kill -9 `pidof alive`" >>$inputfile
sleep 2; echo "/usr/local/omc/bin/bsscomm &" >>$inputfile
sleep 2; echo "/usr/local/omc/bin/alive &" >>$inputfile
sleep 2; echo "exit" >>$inputfile
sleep 2; echo "exit" >>$inputfile
rm -fr $inputfile
rm -fr $outputfile

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,699 @@
<?php
{
//
require("../sub_inc/commfunc.php");
require("../../account/pubSubsMng/sendComm.inc");
{//some path define.
$archivePath='/usr/local/apache/htdocs/db_backup/archive/';
$tmpPath='/usr/local/apache/htdocs/db_backup/archive/tmpPath/';
$paramDir = "params";
$paremerPath = $tmpPath . $paramDir . '/';
$subsDir = "subs";
$subsPath = $tmpPath . $subsDir . '/';
$bssDir = "bssDir";
$bssPath = $tmpPath . $bssDir . '/';
$bssOmcTlbDir = "omcTlb";
$bssOmcTlbPath = $bssPath . $bssOmcTlbDir . '/';
$bssDbDir = "dbs";
$bssDbPath = $bssPath . $bssDbDir . '/';
// $tgzName = "allBackup.tgz";
$tgzDir = "tgzFile";
$tgzPath=$archivePath.$tgzDir.'/';
}//end path define.
}
?>
<STYLE TYPE="text/css" MEDIA="screen, print, projection">
<!--
.inner {align: right;
width: 40px }
-->
</STYLE>
<?php
$helpId = isset($helpId)?$helpId:'5.1.6';
$ThisPage="Configuration &nbsp;>&nbsp;Network&nbsp;>&nbsp;Backup";
$DEBUG = 0;
$pubDb = "OMC_PUB";
set_time_limit(3600);
function MsgBox($str)
{
echo "<script language=\"javascript\">";
echo "alert(\"$str\");";
echo "history.go(-1)";
echo "</script>";
}//end MsgBox
function createParamCVS($path,$tbNameArr)
{
$pubDb = "OMC_PUB";
for($i=0; $i<sizeof($tbNameArr); $i++)
{
$tableName = $tbNameArr[$i];
$filePath = $path . $tableName.".csv";
if (is_file($filePath))
unlink($filePath);
$csvFileUpdateSql=" SELECT *
INTO OUTFILE '{$filePath}'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FROM $tableName
";
$csvFileUpdateResult = mysqli_query($pubConn ,$csvFileUpdateSql);
echo mysqli_error($pubConn);
}
}//end createParamCVS
function getSubsData($sysId,$dataTypeNo)
{
$pubDb = 'OMC_PUB';
$sysSubsConfTable = 'OMC_PUB.sysSubsConf';
$systemConfTable = 'OMC_PUB.sysConf';
$sysIdArr = explode('_',$sysId);
$sysTypeNo = $sysIdArr[0];
$sysNo = $sysIdArr[1];
$subSysNo = $sysIdArr[2];
$nLoadIndexComm = 5;
$commType = $nLoadIndexComm;
$objDb = 'OBJ_'.$sysTypeNo;
if($sysTypeNo==390){
$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'
";
}
$getConfResult=mysqli_query($pubConn,$getConfSql);
echo mysqli_error($pubConn);
$getConfRows=mysqli_fetch_array($getConfResult);
$sysTypeName =$getConfRows[sysTypeName];
$indexFieldName =$getConfRows[indexFieldName];
$srcDataTable =$getConfRows[subsDataTable];
$tmpDataTable =$getConfRows[tmpDataTable];
$clearDataSql="DELETE FROM $srcDataTable";
mysqli_query($pubConn,$clearDataSql);
$clearDataSql="DELETE FROM $tmpDataTable";
mysqli_query($pubConn,$clearDataSql);
$commIdStr = subsCommSend($sysId,$dataTypeNo,"","All",$commType);
$rtn = commScan($commIdStr);
return $rtn;
}
function commScan($commIdStr)
{
$nReadComm = 1;
$nChangeComm = 2;
$nCreateComm = 3;
$nDeleteComm = 4;
$nLoadIndexComm = 5;
$nReplaceIndexComm=6;
//commState's value
$nProcFail = 0;
$nWaitProc = 1;
$nInProc = 2;
$nOutProc = 3;
$pubDb = 'OMC_PUB';
$commTable = 'subscriberComm';
$sysConfTable ='sysConf';
if($commNum <= 0){
$commArr = explode('-',$commIdStr);
$commNum = sizeof($commArr);
}
$maxOverTime = $commNum * 5 + 10; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>5<EFBFBD><EFBFBD><EBA3A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$maxWaitTime = $commNum * 2;
$maxStopTime = $commNum * 5 + 10;
$maxOfCommId = 50000; //<2F><EFBFBD><E8B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
//echo "<br>(isFinish != 0) || (waitTime >= maxWaitTime) || (stopTime > maxStopTime)";
while(1) {
echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
flush();
//echo "<br>($isFinish != 0) || ($waitTime >= $maxWaitTime) || ($stopTime > $maxStopTime)";
if(($isFinish != 0) || ($waitTime >= $maxWaitTime) || ($stopTime > $maxStopTime)){
if($commId >= $maxOfCommId){ //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>
$dropSql = "DROP TABLE $commTable ";
mysqli_query($pubConn,$dropSql);
//<2F>ٽ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E1B9B9>ͬ<EFBFBD><CDAC><EFBFBD>±<EFBFBD>
$createSql="CREATE TABLE subscriberComm (
commId smallint(5) unsigned NOT NULL auto_increment,
commType tinyint(1) DEFAULT '0' NOT NULL,
dataTypeNo tinyint(4) DEFAULT '0' NOT NULL,
sysTypeNo smallint(5) unsigned DEFAULT '0' NOT NULL,
sysNo smallint(5) unsigned DEFAULT '0' NOT NULL,
subSysNo smallint(5) unsigned DEFAULT '0' NOT NULL,
indexValueList varchar(255) NOT NULL,
fieldNameList tinytext NOT NULL,
paramType tinyint(4) DEFAULT '0' NOT NULL,
commState tinyint(3) unsigned DEFAULT '0' NOT NULL,
totalNum smallint(5) unsigned DEFAULT '0' NOT NULL,
finishNum smallint(5) unsigned DEFAULT '0' NOT NULL,
sendTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
bgnTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
endTime datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
remark varchar(200) binary NOT NULL,
PRIMARY KEY (commId),
KEY sysTypeNo (sysTypeNo),
KEY sysNo (sysNo),
KEY subSysNo (subSysNo),
KEY bufferKey (indexValueList)
)
";
mysqli_query($pubConn,$createSql);
}else{
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$commArr = explode('-',$commIdStr);
for($i=0;$i<sizeof($commArr);$i++){
if(strlen($commArr[$i]) <=0){
continue;
}
$deleteSql = "DELETE FROM $commTable WHERE commId='$commArr[$i]'";
if($DEBUG) echo "<br>deleteSql = $deleteSql";
mysqli_query($pubConn,$deleteSql);
echo mysqli_error($pubConn);
}
}
// <20>ض<EFBFBD><D8B6>򷵻<EFBFBD>ָ<EFBFBD><D6B8>ҳ
if($isFinish != 0){
if($isFinish > 0){
echo "<b><font color=blue>Finished.</font></b>";
flush();
if($commType == $nLoadIndexComm){
sleep(8);//<2F><>8<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
}
return 1;
}elseif($isFinish == -1){
echo "<b><font color=black>Failed in some system!!</font></b>";
flush();
return 0;
}else{
echo "<b><font color=red>Failed!!</font></b>";
flush();
return 0;
}
}elseif($usedTime >= $maxOverTime && $stopTime == 1){
echo "<b><font color=red>Stoped!!</font></b>";
flush();
return 0;
}else{ //$usedTime >= $maxOverTime
echo "<b><font color=red>Timeout!!</font></b>";
flush();
return 0;
}
}//end of if($isFinish....)
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>״̬
//-----------------------------
$okNum = 0;
$failNum = 0;
$commNum = 0;
$commArr = explode('-',$commIdStr);
$thisTimeFinishNumStr = '';
$lastTimeFinishNumArr = explode('-',$lastTimeFinishNumStr);
for($i=0;$i<sizeof($commArr);$i++){
if(strlen($commArr[$i]) <=0){ continue;}
$commNum++;
$commSql = "SELECT * FROM $commTable WHERE commId= $commArr[$i]";
if($DEBUG) echo "<br>get command = $commSql";
$commResult = mysqli_query($pubConn,$commSql);
if(mysqli_num_rows($commResult) <= 0){
echo "<br>Can not find this command's info in datebase";
exit();
}
$commRows = @mysqli_fetch_array($commResult);
$sysTypeNo = $commRows[sysTypeNo];
$sysNo = $commRows[sysNo];
$subSysNo = $commRows[subSysNo];
$commType = $commRows[commType];
$paramType = $commRows[paramType];
$objId = $commRows[objId];
$commState = $commRows[commState];
$indexValueList = $commRows[indexValueList];
$fieldNameList = $commRows[fieldNameList];
$remark = $commRows[remark];
switch($commState){
case 0: //process failed
$failNum++;
echo "<b><font size=2 color=red> $commRows[remark] </font></b>";
flush();
return 0;
//break;
case 1: //wait process
$waitTime++;
break;
case 2: //in process
$waitTime = 0;
//ֻҪ<D6BB><D2AA>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD>ʱ
if($DEBUG) echo "====> {$commRows[finishNum]} > {$lastTimeFinishNumArr[$i]}";
if($commRows[finishNum] > $lastTimeFinishNumArr[$i]){
$stopTime = 0;
}else{
$stopTime++;
}
$thisTimeFinishNumStr .=$commRows[finishNum].'-';
break;
case 3: //process finished
$okNum++;
break;
default:
echo "<font size=3>Unknown Command State</font>";
flush();
exit();
}
}//end of for($i=0;$i<sizeof($commArr);$i++)
if($DEBUG) echo"<br>$commNum =?= $finishNum";
if($commNum == $okNum){
$isFinish = 1;
}elseif($failNum > 0 && $okNum > 0){
$isFinish = -1;
}elseif($commNum == $failNum){
$isFinish = -2;
}else{
$isFinish = 0;
}
if($DEBUG) echo"<br>lastTimeFinishNumStr=$lastTimeFinishNumStr";
if($DEBUG) echo"<br>thisTimeFinishNumStr=$thisTimeFinishNumStr";
$lastTimeFinishNumStr = $thisTimeFinishNumStr;
//ˢ<>·<EFBFBD><C2B7><EFBFBD>
//--------------
$usedTime++; //<2F><>ʱ<EFBFBD><CAB1>
sleep(5);
}//end while
}
function createSubsCVS($path,$subsTlbName,$sysId)
{
$pubDb = "OMC_PUB";
$filePath = $path . "$subsTlbName.$sysId.csv";
if (is_file($filePath))
unlink($filePath);
$csvFileUpdateSql=" SELECT *
INTO OUTFILE '{$filePath}'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FROM $subsTlbName limit 0,5000
";
//echo "<br>csvFileUpdateSql= $csvFileUpdateSql";
$csvFileUpdateResult = mysqli_query($pubConn ,$csvFileUpdateSql);
echo mysqli_error($pubConn);
}//end createSubsCVS
function getBssIp (&$bssIpArr)
{
$bssDb = "BssOmcDb";
$bssTable = "OMCR_BSSTABLE";
$selSql = "select ip,bssid from $bssTable";
$bssResult = mysqli_query($pubConn,$selSql);
while($bssRow = mysqli_fetch_array($bssResult))
{
$ip = $bssRow[ip];
if(strlen($ip)< 7) continue;
$bssIpArr[] = $ip;
}
}//end getBssIp
function getBssDb($bssDbPath,$bssIpAddr)
{
$fileArr = array('abis.db', 'bscadmin.db', 'calltrc.db', 'sysmon.db',
'aifadmin.db', 'BssGb.db', 'frmgr.db', 'trkadmin.db');
$remoteDir = "/hd0/iw07_00.010/compile/cfg/";
$ftpCon=@ftp_connect($bssIpAddr);
if($ftpCon < 0){
echo "<font color=\"#FF0000\">BSS's ip is error or connect $bssIpAddr Failed!</font>";
flush();
return 0;
}
if(!@ftp_login($ftpCon,'','')){
echo "<font color=\"#FF0000\">BSS's ip is error or login $bssIpAddr Failed!</font>";
@ftp_close($ftpCon);
flush();
return 0;
}
if(!@ftp_chdir($ftpCon, $remoteDir)){
echo "<font color=\"#FF0000\">Change dir error!</font>";
@ftp_close($ftpCon);
flush();
return 0;
}
$localDir = $bssDbPath . $bssIpAddr . '/';
mkdir($localDir, 0755);
for($i=0; $i< sizeof($fileArr); $i++) {
$file = $fileArr[$i];
$remoteFile=$remoteDir.$file;
$localFile=$localDir.$file;
if (!@ftp_get($ftpCon, $localFile, $remoteFile, FTP_BINARY)) {
flush();
echo "<font color=\"#FF0000\">Get file error!</font>";
@ftp_close($ftpCon);
return 0;
}
}//end for
@ftp_close($ftpCon);
return 1;
}//end get BssDb
?>
<body leftmargin=12 topmargin=5>
<?php
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "$ThisPage";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
?>
<?php
{//get allSysArr
$allPlatArr = array(
array('typeNo' => 111, 'name' => 'PLAT'),
array('typeNo' => 222, 'name' => 'PLAT'),
array('typeNo' => 223, 'name' => 'PLAT'),
array('typeNo' => 225, 'name' => 'PLAT')
);
$tmpAllSysArr = $needBackupArr;
for($i=0; $i<sizeof($tmpArrSysArr); $i++){
if($tmpArrSysArr[$i][typeNo] == 390)
$vssExist = 1;
if($tmpArrSysArr[$i][typeNo] == 311)
$aasExist = 1;
}
//print_r($needBackupArr);
//exit;
for($i=0; $i<sizeof($allPlatArr); $i++)
{
$tmpAllSysArr[] = $allPlatArr[$i];
}
$j=0;
for($i=0; $i<sizeof($tmpAllSysArr); $i++)
{
$curSys = $tmpAllSysArr[$i][typeNo];
$selSql = "select sysNo,subSysNo from OMC_PUB.sysInfo where sysTypeNo=$curSys";
//echo "<br>selSql:$selSql";
$result = mysqli_query($pubConn,$selSql);
$rowNum = mysqli_num_rows($result);
if($rowNum<=0) continue;
if($curSys < 300 && $curSys != 225)
{
$lastSysNo=-1;
while($rows = mysqli_fetch_array($result))
{
$sysNo=$rows[sysNo];
$subSysNo = $rows[subSysNo];
if($curSys > 200 && $sysNo==0) continue;
$sysId = $curSys."_".$sysNo."_99";
$slcsysId=-1;
$tlbNo = $sysNo;
if($curSys==222 || $curSys==223) {
if(($sysNo==8) || ($sysNo==11)) {
if((!$vssExist && $sysNo==8) || (!$aasExist && $sysNo==11)) continue;
$sysId = $curSys . '_' . $sysNo . '_' . $subSysNo;
}
else if($sysNo==9) {
$sysId = $curSys . '_99_99';
$slcsysId = $curSys . '_' . $sysNo . '_' . $subSysNo;
$tlbNo = 99;
}
}
if($curSys==111)
{
$slcsysId = $curSys."_".$sysNo."_".$subSysNo;
}
$oidsysArr[]= array('oid'=>'2', 'sysid'=> $sysId, 'selectsysid'=> $slcsysId);
if($sysNo != $lastSysNo)
$tbNameArr[] = "OBJ_".$curSys.".param_".$tlbNo;
$lastSysNo=$sysNo;
}
}
if($curSys > 300 || $curSys==225)
{
$slcsysId = -1;
$sysId = $curSys."_99_99";
$oidsysArr[]= array('oid'=>'2', 'sysid'=> $sysId, 'selectsysid'=> $slcsysId);
$tbNameArr[] = "OBJ_".$curSys.".param_99";
}
$allSysArr[$j] = $tmpAllSysArr[$i];
$allSysArr[$j][oidsysArr]=$oidsysArr;
$allSysArr[$j][tbNameArr]=$tbNameArr;
$j++;
unset($oidsysArr);
unset($tbNameArr);
}
}//end get allSysArr.
//print_r($allSysArr);
//exit;
{//get subsDbArr.
$tmpdbArr = array(
array('typeNo' => '330'), //HLR
//array('typeNo' => '325'), //VLR
array('typeNo' => '360'), //PPS
//array('typeNo' => '340'), //AUC
array('typeNo' => '380'), //EIR
array('typeNo' => '370'), //MNP
array('typeNo' => '390')//must be the last one.
);
for($i=0; $i< sizeof($tmpdbArr); $i++)
{
$tmpTypeNo = $tmpdbArr[$i][typeNo];
for($j=0; $j< sizeof($needBackupArr); $j++){
if($tmpTypeNo==$needBackupArr[$j][typeNo]){
$tmpsubsDbArr[] = $tmpdbArr[$i];
break;
}
}
}
for($i=0; $i<sizeof($tmpsubsDbArr); $i++) {
$sysTypeNo=$tmpsubsDbArr[$i][typeNo];
$slcSysTypeNo = $sysTypeNo;
if($sysType==325)$slcSysTypeNo=320;
$infoSelSql = "SELECT sysNo,subSysNo FROM OMC_PUB.sysInfo WHERE sysTypeNo='$slcSysTypeNo'
ORDER BY baseStat DESC,updateTime DESC,sysNo,subSysNo";
$infoResult = mysqli_query($pubConn,$infoSelSql);
if(mysqli_num_rows($infoResult) > 0){
if($sysTypeNo==390){
$j=$i;
while($infoRows = mysqli_fetch_array($infoResult))
{
$sysNo = $infoRows[sysNo];
$subSysNo = $infoRows[subSysNo];
$sysId = $sysTypeNo.'_'.$sysNo.'_'.$subSysNo;
$subsTlb = "VMS_DB.subscriberData_" . $sysNo;
$subsDbArr[$j][typeNo] = $sysTypeNo;
$subsDbArr[$j][sysId] = $sysId;
$subsDbArr[$j][name] = 'VMS';
$subsDbArr[$j][subsTlb] = $subsTlb;
$j++;
}
} else {
$sysSubsConfTable ='OMC_PUB.sysSubsConf';
$systemConfTable = 'OMC_PUB.sysConf';
$getConfSql="SELECT sysTypeName,dataTypeNo,indexFieldName,subsDataTable,tmpDataTable
FROM $sysSubsConfTable,$systemConfTable
WHERE $sysSubsConfTable.sysTypeNo='$sysTypeNo'
AND $systemConfTable.sysTypeNo='$sysTypeNo'
AND $sysSubsConfTable.dataTypeNo='$dataTypeNo'
";
$getConfResult=mysqli_query($pubConn,$getConfSql);
echo mysqli_error($pubConn);
$getConfRows=mysqli_fetch_array($getConfResult);
$sysTypeName =$getConfRows[sysTypeName];
//$indexFieldName =$getConfRows[indexFieldName];
$subsTlb =$getConfRows[subsDataTable];
//$tmpDataTable =$getConfRows[tmpDataTable];
$infoRows = mysqli_fetch_array($infoResult);
$sysNo = $infoRows[sysNo];
$subSysNo = $infoRows[subSysNo];
$sysId = $sysTypeNo.'_'.$sysNo.'_'.$subSysNo;
$subsDbArr[$i][typeNo] = $sysTypeNo;
$subsDbArr[$i][sysId] = $sysId;
$subsDbArr[$i][name] = $sysTypeName;
$subsDbArr[$i][subsTlb] = $subsTlb;
}
}
}
}//end get subsDbArr.
if($needGetParam)//get parameters from devices
{
echo "<font color=\"#0000FF\" size=\"3\"><br><b>Getting parameter data from devices ... </b></font>";
flush();
for($i=0; $i<sizeof($allSysArr); $i++)
{
$oidsysArr=$allSysArr[$i][oidsysArr];
$sysName = $allSysArr[$i][name];
if($sysName !== $oldName){
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">[&nbsp;<span class=\"inner\">$sysName</span>&nbsp;]</font>&nbsp;&nbsp;";
flush();
}
GetParam($oidsysArr,0,0);
$oldName = $sysName;
}
}//end get parameters from devices
if($needGetParam)//create parameters' cvs files
{
echo "<font color=\"#0000FF\"><br>&nbsp;&nbsp;&nbsp;&nbsp;<b>Creating tables</b></font>&nbsp;&nbsp;";
exec("mkdir $paremerPath -p");
exec("chmod -R 755 $paremerPath");
for($i=0; $i<sizeof($allSysArr); $i++)
{
$curSys = $allSysArr[$i][typeNo];
$sysName = $allSysArr[$i][name];
if($sysName !== $oldName) {
echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
flush();
}
$tbNameArr = $allSysArr[$i][tbNameArr];
createParamCVS($paremerPath,$tbNameArr);
$oldName = $sysName;
}
//========download the OBJ_222.param_8 OBJ_223.param_8 table
$vss_tbNameArr_222=array(0=>'OBJ_222.param_8');
$vss_tbNameArr_223=array(0=>'OBJ_223.param_8');
createParamCVS($paremerPath,$vss_tbNameArr_222);
createParamCVS($paremerPath,$vss_tbNameArr_223);
}//end create parameters' cvs files
if($needGetSubs) //get Subscriber data from devices
{
echo "<br>";
echo "<font color=\"#0000FF\" size=\"3\"><br><b>Getting subscribers data from devices ... </b></font>";
flush();
for($i=0; $i<sizeof($subsDbArr); $i++)
{
$sysId = $subsDbArr[$i][sysId];
$dataTypeNo = 0;
$sysName = $subsDbArr[$i][name];
if($sysName !== $oldName){
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">[&nbsp;<span class=\"inner\">$sysName</span>&nbsp;]</font>&nbsp;&nbsp;";
flush();
}
$rtn = getSubsData($sysId,$dataTypeNo);
$subsDbArr[$i][getSubsOk] = $rtn;
$oldName = $sysName;
}
}//end get subscriber data from devices.
//exit;
if($needGetSubs)//create subscribers' cvs files
{
exec("mkdir $subsPath -p");
exec("chmod -R 755 $subsPath");
echo "<font color=\"#0000FF\"><br>&nbsp;&nbsp;&nbsp;&nbsp;<b>Creating tables</b></font>&nbsp;&nbsp;";
for($i=0; $i< sizeof($subsDbArr); $i++)
{
if($subsDbArr[$i][getSubsOk]!=1) continue;
$subsTlbName = $subsDbArr[$i][subsTlb];
$sysId = $subsDbArr[$i][sysId];
$sysName = $subsDbArr[$i][name];
if($sysName !== $oldName) {
echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
flush();
}
createSubsCVS($subsPath,$subsTlbName,$sysId);
$oldName = $sysName;
}//end subscribers table.
}//end create subscribers cvs files.
if($needBss)//get bss data
{
echo "<br>";
echo "<font color=\"#0000FF\" size=\"3\"><br><b>Getting BSS data ... </b></font>";
flush();
exec("mkdir $bssOmcTlbPath -p");
exec("chmod -R 755 $bssOmcTlbPath");
$tbNameArr = array('BssOmcDb.OMCR_BSSTABLE');
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\"><b>Creating parameter tables ... </b></font>";
createParamCVS($bssOmcTlbPath,$tbNameArr);
echo "<font color=\"#0000FF\"><b>Finished.</b></font>";
//get bss db.
exec("mkdir $bssDbPath -p");
exec("chmod -R 755 $bssDbPath");
chdir($bssDbPath);
getBssIp ($bssIpArr);
for($i=0; $i<sizeof($bssIpArr); $i++) {
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\"><b>Getting $bssIpArr[$i] dbs ... <b></font>";
flush();
if(getBssDb($bssDbPath,$bssIpArr[$i])){
echo "<font color=\"#0000FF\"><b>Finished.</b></font>";
flush();
}
}
}//end get bss database.
$needCompress = $needGetParam||$needGetSubs||$needBss;
if($needCompress)//compress files
{
$time = date("Ymd_Hi");
$tgzName = "backup_".$time.'_';
if($needGetParam) $tgzName .= 'param_';
if($needGetSubs) $tgzName .= 'subs_';
if($needBss) $tgzName .= 'bss_';
$tgzName = rtrim($tgzName,'_');
$tgzName .= '.tgz';
echo "<br>";
echo "<font color=\"#0000FF\" size=\"3\"><br><b>Compressing files ... <b></font>";
flush();
if (is_dir($tgzPath))
exec("rm -rf $tgzPath");
exec("mkdir $tgzPath -p");
exec("chmod -R 755 $tgzPath");
chdir($tmpPath);
exec("tar zcvf $tgzName *");
exec("mv $tgzName $tgzPath");
exec("rm -rf $tmpPath");
echo "<font color=\"#0000FF\"><b>Finished.</b></font>";
flush();
}//end compress files.
sleep(3);
//exit;
echo "<script language=\"javascript\">";
echo "window.location=\"overview.php?backupShow=1\"";
//echo "history.go(-1)";
echo "</script>";
?>
</body>
</html>

View File

@@ -0,0 +1,526 @@
<?php
require("../../inc/lib.inc");
$DEBUG = 0;
$pubDb = 'OMC_PUB';
$sysInfoTable='OMC_PUB.sysInfo';
$sysStatTable='OMC_PUB.sysStat';
$initValue ='initValue';
$readValue ='readValue';
{//get all exist elements from elementExistConf
$elementConfTb = 'elementExistConf';
$selSql = " select elementTypeNo from $elementConfTb where existFlag='1' and elementTypeNo!='0' order by elementNo";
if($DEBUG) echo "<br>selSql=$selSql";
$res = @mysqli_query($pubConn,$selSql);
$i=0;
while($rows = mysqli_fetch_array($res))
{
$existElementArr[$i++] = $rows[elementTypeNo];
}
if(0)print_r($existElementArr);
}//end get all exisit elements
$localElementArr=array(
array('sysTypeName'=>'MSC', 'sysTypeNo'=>'320','sysTypeSSN'=>'8','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/msc.php?load_flag=$getflag"),
array('sysTypeName'=>'VLR', 'sysTypeNo'=>'325','sysTypeSSN'=>'7','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/vlr.php?load_flag=$getflag"),
array('sysTypeName'=>'HLR', 'sysTypeNo'=>'330','sysTypeSSN'=>'6','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/hlr.php?load_flag=$getflag"),
array('sysTypeName'=>'AUC', 'sysTypeNo'=>'340','sysTypeSSN'=>'10','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/auc.php?load_flag=$getflag"),
array('sysTypeName'=>'SMSC','sysTypeNo'=>'350','sysTypeSSN'=>'11','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/smsc.php?load_flag=$getflag"),
array('sysTypeName'=>'PPS', 'sysTypeNo'=>'360','sysTypeSSN'=>'147','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/pps.php?load_flag=$getflag"),
array('sysTypeName'=>'EIR', 'sysTypeNo'=>'380','sysTypeSSN'=>'9','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/eir.php?load_flag=$getflag"),
array('sysTypeName'=>'MNP', 'sysTypeNo'=>'370','sysTypeSSN'=>'32','GT'=>'--','existFlag'=>'0','license'=>'--','licenseColor'=>'','users'=>'--','usersColor'=>'','state'=>'1','stateColor'=>'','confLink'=>"../mss/mnp.php?load_flag=$getflag"));
if($DEBUG) echo "<br><3E><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>";
//==========================================================
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//==========================================================
?>
<?php
////////////////
$locEleParTab='OBJ_223.param_99';
for($i=0;$i< sizeof($localElementArr);$i++)
{
$canAdd = array_search($localElementArr[$i][sysTypeNo], $existElementArr);
for($k=0; $k<sizeof($existElementArr);$k++)
{
if($localElementArr[$i][sysTypeNo] == $existElementArr[$k])
{
$localElementArr[$i][existFlag]=1;
break;
}
}
}
if($localElementArr[0][existFlag]==1)
{
$localElementArr[1][existFlag]=1;
}
////////////////
for($i=0;$i<sizeof($localElementArr);$i++)
{
if($localElementArr[$i][existFlag]==1)
{
$getSql="SELECT baseStat,updateTime FROM $sysInfoTable WHERE sysTypeNo='{$localElementArr[$i][sysTypeNo]}'
ORDER BY sysNo,subSysNo";
if($DEBUG) echo "<BR>getSql=$getSql";
$result =mysqli_query($pubConn,$getSql);
if(mysqli_num_rows($result)==0)
{
$localElementArr[$i][state]=0;
$localElementArr[$i][stateColor]='#FF0000';
}
else
{
while($rows=mysqli_fetch_array($result))
{
$out_time=date("Y-m-d H:i:s",mktime(date("H"),date("i")-10,0,date("m"),date("d"),date("Y")));
//if(1&&$localElementArr[$i][sysTypeNo]==360) echo "<br>" . "{$rows[1]}< $out_time";
if($rows[0]==0||$rows[1]< $out_time)
{
$localElementArr[$i][state]=0;
$localElementArr[$i][stateColor]='#FF0000';
}
}
}
}
}
?>
<?php
function getLevelWhere($objIdStr)
{
$levelArr=explode('.',$objIdStr);
for($j=0;$j<sizeof($levelArr);$j++){
$levelNo=$j+1;
${"level_$levelNo"}=$levelArr[$j];
if($DEBUG) echo "<BR>levelArr[$j]={$levelArr[$j]}";
if($j == 0){
$levelWhere ="level_$levelNo='${"level_$levelNo"}'";
}else{
$levelWhere .=" AND level_$levelNo='${"level_$levelNo"}'";
}
}
return($levelWhere);
}
function getSubSyss($num)
{
$i=0;
do
{
$arr[$i++] = $num % 2;
}while($num = floor($num/2));
for($j=$i; $j<4; $j++)
$arr[$j] = 0;
return $arr;
}
function toAscii($byteValue){
$charValue = "";
$tmpLen=strlen($byteValue);
for($charCount=0; $charCount < $tmpLen; $charCount++){
$unitByte = substr($byteValue,$charCount,2);
$charCount++;
if($unitByte == 0) break;
$unitChar = chr(HexDec($unitByte)); // hex -> ascii
$charValue .= $unitChar;
}
return $charValue;
}
?>
<?php
///////////////////get e1 status
$e1selSql = "SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime
FROM sysStat WHERE sysTypeNo='111' order by sysNo,subSysNo";
$e1Result = @mysqli_query($pubConn,$e1selSql);
while($e1Row = @mysqli_fetch_array($e1Result))
{
$hex_mes = $e1Row[detailStat];
$sysNo = $e1Row[sysNo];
$subSysNo = $e1Row[subSysNo];
$bin_mes='';
for($i=0;$i<strlen($hex_mes);$i++)
{
$sig_hex_mes=substr($hex_mes,$i,1);
$sig_dec_mes=HexDec($sig_hex_mes);
$sig_bin_mes=DecBin($sig_dec_mes);
$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
$bin_mes.=$sig_bin_mes;
}
$e1HeartBeatArr[$sysNo][$subSysNo] = $bin_mes;
}
$ins_bgn = 22; //e1 installed
$phy_bgn = 24; //e1 layer1(physical layer)
$el2_bgn = 25; //e1 layer2
$E1state1=1;//OK
$E1state2=0;//DOWN
for($i=0; $i< 256; $i++)
{
$cardno = Floor($i/8);
$sysNo = $cardno > 15 ? 1 : 0;
$subSysNo = $cardno % 16;
$port = $i - $cardno*8;
//e1 install
$bin_mes = $e1HeartBeatArr[$sysNo][$subSysNo];
//if($DEBUG)echo "<br>$i: $bin_mes";
$bin_ins=substr($bin_mes,$ins_bgn*8+7-$port,1);//0:'--'; 1:'Y'
$tmp1 = bindec($bin_ins);
//e1 layer1
$bin_phy=substr($bin_mes,$phy_bgn*8+7-$port,1);//0:'Y'; 1:'N'; 2:'--'
$tmp2 = bindec($bin_phy);
$tmp2++;
$tmp2 = ($tmp2>1) ? 0 : $tmp2;
//e1 layer2 install
$bin_inl=substr($bin_mes,$el2_bgn*8+7-$port,1);//0:'N'; 1:'Y';
$tmp3 = bindec($bin_inl);
$E1stateArr1[$i] = $E1state1 & $tmp2 & $tmp3;
$E1stateArr2[$i] = $E1state2 | $tmp2 | $tmp3;
// echo "<br>E1stateArr1[$i]:{$E1stateArr1[$i]},E1stateArr2[$i]:{$E1stateArr2[$i]}";
}
$tmpObjIdStr='2.4.2';
$levelWhere = getLevelWhere($tmpObjIdStr);
$tmpTgValue=strtoupper(omc_keep_length($tmpTgValue,0,2));
$getSql="SELECT initValue,instanceNo FROM OBJ_322.param_99
WHERE $levelWhere and initValue!='EE' order by instanceNo";
$result =mysqli_query($pubConn,$getSql);
while($Rows = mysqli_fetch_array($result))
{
$tg = hexdec($Rows[initValue]);
if(!isset($e1StatAtTgArr1[$tg])) $e1StatAtTgArr1[$tg]=1;
if(!isset($e1StatAtTgArr2[$tg])) $e1StatAtTgArr2[$tg]=0;
$e1StatAtTgArr1[$tg] &= $E1stateArr1[$Rows[instanceNo]];
$e1StatAtTgArr2[$tg] |= $E1stateArr2[$Rows[instanceNo]];
// echo "<br>$Rows[instanceNo]:{$E1stateArr1[$Rows[instanceNo]]};e1StatAtTgArr1[$tg]:{$e1StatAtTgArr1[$tg]},e1StatAtTgArr2[$tg]:{$e1StatAtTgArr2[$tg]}";
}
////////////////get lins status
$out_time=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-30,date("m"),date("d"),date("Y")));
//E1 link status
$HbparamSql = " SELECT detailStat FROM OMC_PUB.sysStat
WHERE sysTypeNo='200' AND sysNo='9' AND (subSysNo='0' or subSysNo='1') AND updateTime>'$out_time'
";
$Hbresult = mysqli_query($pubConn,$HbparamSql);
while($Hbvalue_mpt3Arr[] = mysqli_fetch_array($Hbresult));//ȡmtp3 <20><>heartbeat
if(sizeof($Hbvalue_mpt3Arr)==3)
$isDualServ = 1;
//E1 link
$tmpObjIdStr='2.5.1';
$levelWhere = getLevelWhere($tmpObjIdStr);
$tmpValue=dechex($linkset);
$tmpValue=strtoupper(omc_keep_length($tmpValue,0,2));
$getSql="SELECT initValue,instanceNo FROM OBJ_222.param_99
WHERE $levelWhere order by instanceNo";
$result =mysqli_query($pubConn,$getSql);
while($rows=mysqli_fetch_array($result))
{
$linkflag = getBitValue($rows[initValue],'06.5-06.5');
$ls = hexdec(getBitValue($rows[initValue],'00.0-00.7'));
if($linkflag)
{
if(!isset($e1StatAtLsArr1[$ls])) $e1StatAtLsArr1[$ls]=1;
if(!isset($e1StatAtLsArr2[$ls])) $e1StatAtLsArr2[$ls]=0;
$Hboffset=39+Floor($rows[instanceNo]/4);
$tmpValue=substr($Hbvalue_mpt3Arr[0][detailStat],$Hboffset*2,2);
if($isDualServ && $rows[instanceNo]>=128)
$tmpValue=substr($Hbvalue_mpt3Arr[1][detailStat],$Hboffset*2,2);
$bitoff =$rows[instanceNo]%4;
$bitoff1=$bitoff*2;
$bitoff2=$bitoff1+1;
$bitoff='0.'.$bitoff1.'-0.'.$bitoff2;
//echo "<br>$bitoff";
$tmp=bindec(getBitValue($tmpValue,$bitoff));
if($tmp>1)
$tmp=0;
$e1StatAtLsArr1[$ls] &= $tmp;
$e1StatAtLsArr2[$ls] |= $tmp;
// echo "<br>$rows[instanceNo]: e1StatAtLsArr1[$ls]:{$e1StatAtLsArr1[$ls]},e1StatAtLsArr2[$ls]:{$e1StatAtLsArr2[$ls]}";
}
}
?>
<?php
{//element status
$othersElementObjIdStr='2.11';
$levelWhere = getLevelWhere($othersElementObjIdStr);
if($DEBUG) echo "<BR>levelWhere=$levelWhere";
$othersElementParamTable='OBJ_225.param_99';
$getSql="SELECT $initValue,instanceNo FROM $othersElementParamTable
WHERE $levelWhere and initValue LIKE '01%'
";
if($DEBUG) echo "<BR>getSql=$getSql";
$result =mysqli_query($pubConn,$getSql);
echo mysqli_error($pubConn);
$typeOffset = '1.0-1.7';
$sysNoOffset = '2.0-2.3';
$subSysNoOffset = '2.4-2.7';
$tgOffset = '3.0-3.7';
$lsOffset = '4.0-4.7';
$appTypeOffset = '5.0-5.7';
$appGrpOffset = '6.0-6.7';
$nameOffset = '14.0-23.7';
$i=0;
while($rows=mysqli_fetch_array($result))
{
if($DEBUG)echo "<BR>initValue=$rows[initValue]";
$typeValue=getBitValue($rows[initValue],$typeOffset);
if($typeValue==0)
continue;
$type = $elementsArr[$i][type]=hexdec($typeValue);
$ls2tg = $elementsArr[$i][tg]=hexdec(getBitValue($rows[initValue],$tgOffset));
$ls = $elementsArr[$i][ls]=hexdec(getBitValue($rows[initValue],$lsOffset));
$elementsArr[$i][appType]=hexdec(getBitValue($rows[initValue],$appTypeOffset));
$elementsArr[$i][name]=getBitValue($rows[initValue],$nameOffset);
if($elementsArr[$i][name]==0)
$elementsArr[$i][name]=$elementsArr[$i][tg];
else
$elementsArr[$i][name]=trim(toAscii($elementsArr[$i][name]));
if($type==17)//isdn switch
{
$e1State1 = $e1StatAtTgArr1[$ls2tg];
$e1State2 = $e1StatAtTgArr2[$ls2tg];
if($e1State1==1&&$e1State2==1)
$E1state='Available';
elseif($e1State1==0&&$e1State2==1)
$E1state='Alarm';
else
$E1state='Unavailable';
}
else if($type==18/* && $ls2tg==255*/)//only link, but no e1
{
$e1State1 = $e1StatAtLsArr1[$ls];
$e1State2 = $e1StatAtLsArr2[$ls];
if($e1State1==1&&$e1State2==1)
$E1state='Available';
elseif($e1State1==0&&$e1State2==1)
$E1state='Alarm';
else
$E1state='Unavailable';
}
else
{
$e1State1 = $e1StatAtTgArr1[$ls2tg] & $e1StatAtLsArr1[$ls];
$e1State2 = $e1StatAtTgArr2[$ls2tg] | $e1StatAtLsArr2[$ls];
if($e1State1==1&&$e1State2==1)
$E1state='Available';
elseif($e1State1==0&&$e1State2==1)
$E1state='Alarm';
else
$E1state='Unavailable';
}
// if($ls<=5)$E1state='Available';
$elementsArr[$i][state] = $E1state;
$i++;
}
}//end element status
//print_r($elementsArr);
for($i=0;$i<sizeof($elementsArr);$i++)
{
switch($elementsArr[$i][type])
{
case '1'://BSS
{
$bssElementNo=sizeof($bssElementArr);
$bssElementArr[$bssElementNo][state]=$elementsArr[$i][state];
$bssElementArr[$bssElementNo][name]=$elementsArr[$i][name];
break;
}
case '2'://AAS
{
$aasElementNo=sizeof($aasElementArr);
$aasElementArr[$aasElementNo][state]=$elementsArr[$i][state];
break;
}
case '3'://VMS
{
$vmsElementNo=sizeof($vmsElementArr);
$vmsElementArr[$vmsElementNo][state]=$elementsArr[$i][state];
break;
}
case '4'://PCR
{
$pcrElementNo=sizeof($pcrElementArr);
$pcrElementArr[$pcrElementNo][state]=$elementsArr[$i][state];
break;
}
case '5'://CNF <09><><EFBFBD><EFBFBD>cnf<6E><66><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>linkset<65><74><EFBFBD><EFBFBD>SubsysNo<4E><6F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>cnf 0001 0000 -> cnf-0-1; 1000 0000 -> cnf-0-4
{
$cnfElementNo=sizeof($cnfElementArr);
$cnfElementArr[$cnfElementNo][state] = $elementsArr[$i][state];
break;
}
case '16'://remote elements
{
$switchElementNo=sizeof($switchElementArr);
$switchElementArr[$switchElementNo][state]=$elementsArr[$i][state];
break;
}
case '17'://isdn switch
{
$switchElementNo=sizeof($switchElementArr);
$switchElementArr[$switchElementNo][state]=$elementsArr[$i][state];
break;
}
case '18'://application status
{
switch($elementsArr[$i][appType])
{
case 0 :
$mscElementNo=sizeof($mscElementArr);
$mscElementArr[$mscElementNo][state]=$elementsArr[$i][state];
break;
case 1 :
$hlrElementNo=sizeof($hlrElementArr);
$hlrElementArr[$hlrElementNo][state]=$elementsArr[$i][state];
break;
case 2 :
$vlrElementNo=sizeof($vlrElementArr);
$vlrElementArr[$vlrElementNo][state]=$elementsArr[$i][state];
break;
case 3 :
$mcElementNo=sizeof($mcElementArr);
$mcElementArr[$mcElementNo][state]=$elementsArr[$i][state];
break;
case 4 :
$sgsnElementNo=sizeof($sgsnElementArr);
$sgsnElementArr[$sgsnElementNo][state]=$elementsArr[$i][state];
break;
case 5 :
$newElementNo=sizeof($newElementArr);
$newElementArr[$newElementNo][state]=$elementsArr[$i][state];
break;
}
break;
}
default:
break;
}
}
?>
<?php
{//output data
for($i=0;$i<sizeof($localElementArr);$i++)
{
if($localElementArr[$i][existFlag]==1)
{
echo "###";
if($localElementArr[$i][state]>0)
echo "Normal";
else
echo "Alarm";
}
}
echo "end";
//To BSS
if(sizeof($bssElementArr)>0)
{
foreach($bssElementArr as $key => $row)
{
$name[$key] = $row['name'];
}
array_multisort($name, SORT_ASC, $bssElementArr);
}
for($i=0;$i<sizeof($bssElementArr);$i++)
{
echo "###";
echo $bssElementArr[$i][state];
}
echo "end";
//To Periphreal
for($i=0;$i<sizeof($aasElementArr);$i++)
{
echo "###";
echo $aasElementArr[$i][state];
}
echo "end";
for($i=0;$i<sizeof($vmsElementArr);$i++)
{
echo "###";
echo $vmsElementArr[$i][state];
}
echo "end";
for($i=0;$i<sizeof($pcrElementArr);$i++)
{
echo "###";
echo $pcrElementArr[$i][state];
}
echo "end";
for($i=0;$i<sizeof($cnfElementArr);$i++)
{
echo "###";
echo $cnfElementArr[$i][state];
}
echo "end";
//To Switch
for($i=0;$i<sizeof($switchElementArr);$i++)
{
echo "###";
echo $switchElementArr[$i][state];
}
echo "end";
//To Application msc
for($i=0;$i<sizeof($mscElementArr);$i++)
{
echo "###";
echo $mscElementArr[$i][state];
}
echo "end";
//To Application hlr
for($i=0;$i<sizeof($hlrElementArr);$i++)
{
echo "###";
echo $hlrElementArr[$i][state];
}
echo "end";
//To Application vlr
for($i=0;$i<sizeof($vlrElementArr);$i++)
{
echo "###";
echo $vlrElementArr[$i][state];
}
echo "end";
//To Application mc
for($i=0;$i<sizeof($mcElementArr);$i++)
{
echo "###";
echo $mcElementArr[$i][state];
}
echo "end";
//To Application sgsn
for($i=0;$i<sizeof($sgsnElementArr);$i++)
{
echo "###";
echo $sgsnElementArr[$i][state];
}
echo "end";
//To Application new
for($i=0;$i<sizeof($newElementArr);$i++)
{
echo "###";
echo $newElementArr[$i][state];
}
echo "end";
}//end output data
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,295 @@
<?php
/*********************************************************
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
<20><><EFBFBD>ù<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: commfunc.php
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>
<20><><EFBFBD>ߣ<EFBFBD>Yi Zane 2005-11-09
<EFBFBD>޸<EFBFBD>ע<EFBFBD>ͣ<EFBFBD>
NO.1
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ʱ<EFBFBD>
<EFBFBD>޸<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
**********************************************************/
require("../sub_inc/commfunc.php");
$DEBUG = 0;
//<2F><><EFBFBD><EFBFBD>oid
if($pageaction=="getall"||$pageaction=="setall")
{
$oidsysarr=array(
array('oid'=>'2', 'sysid'=>'390_99_99', 'selectsysid'=>'-1'),//VSS
//array('oid'=>'2', 'sysid'=>'222_8', 'selectsysid'=>'-1'),//VSS
//array('oid'=>'2', 'sysid'=>'223_8', 'selectsysid'=>'-1'),//VSS
array('oid'=>'2', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),//MSC
array('oid'=>'2', 'sysid'=>'222_99_99', 'selectsysid'=>'-1'),//MTP3
array('oid'=>'2', 'sysid'=>'223_99_99', 'selectsysid'=>'-1'),//SCCP
array('oid'=>'2', 'sysid'=>'225_99_99', 'selectsysid'=>'-1'),//XAPP
array('oid'=>'2', 'sysid'=>'330_99_99', 'selectsysid'=>'-1'),//HLR
array('oid'=>'2', 'sysid'=>'325_99_99', 'selectsysid'=>'-1'),//VLR
array('oid'=>'2', 'sysid'=>'350_99_99', 'selectsysid'=>'-1'),//SMSC
array('oid'=>'2', 'sysid'=>'360_99_99', 'selectsysid'=>'-1'),//PPS
array('oid'=>'2', 'sysid'=>'370_99_99', 'selectsysid'=>'-1'),//MNP
// array('oid'=>'2', 'sysid'=>'260_99_99', 'selectsysid'=>'-1'),//SMPP
array('oid'=>'2', 'sysid'=>'340_99_99', 'selectsysid'=>'-1'),//AUC
);
$database="OMC_PUB";
$sql="select * from sysInfo where sysTypeNo=390 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
$oidsysarr[]=array('oid'=>'2', 'sysid'=>'222_8', 'selectsysid'=>'-1');
$oidsysarr[]=array('oid'=>'2', 'sysid'=>'223_8', 'selectsysid'=>'-1');
}
if(1)
{//get all 8ke1 sysNo.
$sysInfoTab = 'sysInfo';
$selSql = "select sysNo,subSysNo from $sysInfoTab where sysTypeNo='111' order by sysNo,subSysNo";
$Result = mysqli_query($pubConn,$selSql);
$sysNo = -1;
$i = sizeof($oidsysarr);
while($Rows = mysqli_fetch_array($Result))
{
if($sysNo==$Rows[sysNo])
continue;
$sysNo = $Rows[sysNo];
$sysNoArr[$i] = $sysNo;
$sysId = '111_' . $sysNo . '_99';
$oidsysarr[$i] = array('oid'=>'2', 'sysid'=> $sysId,'selectsysid'=>'-1');
$i++;
}
}//end
$SaveArr=array(
array('oidstr'=>'3.1','setvalue'=>'01' ,'sysid'=>'390_99_99','selectsysid'=>'-1'),//VSS
//array('oidstr'=>'3.7','setvalue'=>'02' ,'sysid'=>'222_8','selectsysid'=>'-1'),//VSS-MTP3
//array('oidstr'=>'3.2','setvalue'=>'02' ,'sysid'=>'223_8','selectsysid'=>'-1'),//VSS-SCCP
array('oidstr'=>'3.2', 'setvalue'=>'B5' ,'sysid'=>'322_99_99','selectsysid'=>'-1'),//MSC
array('oidstr'=>'3.7', 'setvalue'=>'02' ,'sysid'=>'222_99_99','selectsysid'=>'-1'),//MTP3
array('oidstr'=>'3.2', 'setvalue'=>'02' ,'sysid'=>'223_99_99','selectsysid'=>'-1'),//SCCP
array('oidstr'=>'3.2', 'setvalue'=>'01' ,'sysid'=>'225_99_99','selectsysid'=>'-1'),//XAPP
array('oidstr'=>'2.2.2','setvalue'=>'01' ,'sysid'=>'330_0_0','selectsysid'=>'-1'),//HLR-0
array('oidstr'=>'2.2.2','setvalue'=>'01' ,'sysid'=>'330_1_0','selectsysid'=>'-1'),//HLR-1
array('oidstr'=>'3.3', 'setvalue'=>'01' ,'sysid'=>'325_0_0','selectsysid'=>'-1'),//VLR-0
array('oidstr'=>'3.3', 'setvalue'=>'01' ,'sysid'=>'325_1_0','selectsysid'=>'-1'),//VLR-1
array('oidstr'=>'3.3', 'setvalue'=>'01' ,'sysid'=>'350_99_99','selectsysid'=>'-1'),//SMSC
array('oidstr'=>'2.1.6.2','setvalue'=>'01','sysid'=>'360_99_99','selectsysid'=>'-1'),//PPS
array('oidstr'=>'2.1.32','setvalue'=>'01' ,'sysid'=>'370_99_99','selectsysid'=>'-1'),//MNP
// array('oidstr'=>'3.2', 'setvalue'=>'02' ,'sysid'=>'260_99_99','selectsysid'=>'-1'),/SMPP
array('oidstr'=>'2.2.2','setvalue'=>'01' ,'sysid'=>'340_99_99','selectsysid'=>'-1'),//AUC
);
$database="OMC_PUB";
$sql="select * from sysInfo where sysTypeNo=390 ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
$SaveArr[]=array('oidstr'=>'3.7','setvalue'=>'02' ,'sysid'=>'222_8','selectsysid'=>'-1');//VSS-MTP3
$SaveArr[]=array('oidstr'=>'3.2','setvalue'=>'02' ,'sysid'=>'223_8','selectsysid'=>'-1');//VSS-SCCP
}
//AAS
$getSql="SELECT sysTypeNo,sysNo,subSysNo FROM sysInfo WHERE sysTypeNo=311";
$result =mysqli_query($pubConn,$getSql);
echo mysqli_error($pubConn);
$count=0;
while($rows=mysqli_fetch_array($result)){
$AASoidsysarr[$count][oid]="2";
$AASoidsysarr[$count][sysid]="311_".$rows[sysNo]."_0";
$AASoidsysarr[$count][selectsysid]="-1";
$AAS_SaveArr[$count][oidstr]="3.1";
$AAS_SaveArr[$count][setvalue]="00";
$AAS_SaveArr[$count][sysid]="311_".$rows[sysNo]."_0";
$AAS_SaveArr[$count][selectsysid]="-1";
$count++;
//MTP3
$AASoidsysarr[$count][oid]="2";
$AASoidsysarr[$count][sysid]="222_11_99";
$AASoidsysarr[$count][selectsysid]="222_11_".$rows[sysNo];
$AAS_SaveArr[$count][oidstr]="3.7";
$AAS_SaveArr[$count][setvalue]="02";
$AAS_SaveArr[$count][sysid]="222_11_99";
$AAS_SaveArr[$count][selectsysid]="222_11_".$rows[sysNo];
$count++;
//SCCP
$AASoidsysarr[$count][oid]="2";
$AASoidsysarr[$count][sysid]="223_11_99";
$AASoidsysarr[$count][selectsysid]="223_11_".$rows[sysNo];
$AAS_SaveArr[$count][oidstr]="3.1";
$AAS_SaveArr[$count][setvalue]="02";
$AAS_SaveArr[$count][sysid]="223_11_99";
$AAS_SaveArr[$count][selectsysid]="223_11_".$rows[sysNo];
$count++;
}
}
else
{
$oidsysarr=array(
//MSC
array('oid'=>'2.1.4', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.4.1', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.4.2', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.4.3', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.2.6', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.2.7', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.4.2', 'sysid'=>'322_99_99', 'selectsysid'=>'-1'),
//MTP3
array('oid'=>'2.2', 'sysid'=>'222_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.3', 'sysid'=>'222_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.4.1', 'sysid'=>'222_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.5.1', 'sysid'=>'222_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2', 'sysid'=>'225_99_99', 'selectsysid'=>'-1'),//XAPP
//SCCP
array('oid'=>'2.1', 'sysid'=>'223_99_99', 'selectsysid'=>'-1'),
array('oid'=>'2.2', 'sysid'=>'223_99_99', 'selectsysid'=>'-1')
);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>oid<69><64>set/get<65><74><EFBFBD><EFBFBD>
if($pageaction=="getall"||$pageaction=="setall")
{
if($pageaction=="getall")
{
echo "<br>Get All Parameters<br>";
GetParam($oidsysarr,1,1);
$vss_count=0;
for($i=0;$i<10;$i++)
{
//==========set VSS Parameters======
$database="OBJ_PUB";
$sql="select distinct sysNo from sysInfo where sysTypeNo=390 and sysNo=$i ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
$temp='223_8_'.$i;
$vss_oid_arr[]=array('oid'=>'2', 'sysid'=>$temp, 'selectsysid'=>'-1');
$vss_count++;
}
}
if($vss_count!=0)
{
GetParam($vss_oid_arr,1,1);
}
//AAS<41><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
if($count) GetParam($AASoidsysarr,1,1);
echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
echo "<script LANGUAGE=\"JavaScript\">";
echo "\n window.location.href=\"./overview.php?upLoadResult=getsuccess\";";
echo "\n </script>";
exit();
}
else
{
echo "<br>Set All Parameters<br>";
Clear_readValud($oidsysarr);
SetParam($oidsysarr,1);
SaveParam($SaveArr);
//=========set vss parameter
$vss_count=0;
for($i=0;$i<10;$i++)
{
//==========set VSS Parameters======
$database="OBJ_PUB";
$sql="select distinct sysNo from sysInfo where sysTypeNo=390 and sysNo=$i ";
$result=@mysqli_query($pubConn,$sql);
$rows=@mysqli_fetch_array($result);
if($rows)
{
$temp='223_8_'.$i;
$vss_oid_arr[]=array('oid'=>'2', 'sysid'=>$temp, 'selectsysid'=>'-1');
$vss_save_arr[]=array('oidstr'=>'3.2', 'setvalue'=>'02', 'sysid'=>$temp, 'selectsysid'=>'-1');
$vss_count++;
}
}
if($vss_count!=0)
{
Clear_readValud($vss_oid_arr);
SetParam($vss_oid_arr,1);
SaveParam($vss_save_arr);
}
//AAS<41><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
if($count)
{
Clear_readValud($AASoidsysarr);
SetParam($AASoidsysarr,1);
SaveParam($AAS_SaveArr);
}
if(isset($resetDevice))//reset mss,sccp,mtp3 when restore an new system. (invoked by uploadFile.php)
{
$resetArr=array(
array('oidstr'=>'3.2', 'setvalue'=>'5A' ,'sysid'=>'322_99_99'),//MSC
array('oidstr'=>'3.7', 'setvalue'=>'01' ,'sysid'=>'222_99_99'),//mtp3
array('oidstr'=>'3.2', 'setvalue'=>'00' ,'sysid'=>'223_99_99'),//sccp
);
SaveParam($resetArr);
}//end reset.
echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
echo "<script LANGUAGE=\"JavaScript\">";
echo "\n window.location.href=\"./overview.php?upLoadResult=setsuccess\";";
echo "\n </script>";
exit();
}
}
else
{
$getSql="SELECT pubVarValue FROM omcPubVarConf
WHERE pubVarName='getparam_from'
";
if($DEBUG) echo "<BR>getSql=$getSql";
$result =mysqli_query($pubConn,$getSql);
echo mysqli_error($pubConn);
$rows=mysqli_fetch_array($result);
$getflag=$rows[0];//get param from omc or mss(omc:0,mss:1)
if($getflag)
{
echo "<br>Downloading the elements<br>";
GetParam($oidsysarr,1);
echo "<br><br><h4><font color=\"#0000ff\">Finished!</font></h4>";
echo "<script LANGUAGE=\"JavaScript\">";
echo "\n window.location.href=\"./overview.php?upLoadResult=success\";";
echo "\n </script>";
exit();
}
}
echo "<script LANGUAGE=\"JavaScript\">";
echo "\n window.location.href=\"./overview.php\";";
echo "\n </script>";
exit();
?>
</HTML>

View File

@@ -0,0 +1,621 @@
<?
require("../../inc/header.inc");
?>
<STYLE TYPE="text/css" MEDIA="screen, print, projection">
<!--
.inner {width: 40px }
-->
</STYLE>
<?
$helpId = isset($helpId)?$helpId:'5.1.6';
$ThisPage="Configuration &nbsp;>&nbsp;Network&nbsp;>&nbsp;Restore";
$DEBUG = 0;
$db=$omc_db;
set_time_limit(3600);
$strNoInput = "No file input!";
function MsgBox($str)
{
echo "<script language=\"javascript\">";
echo "alert(\"$str\");";
echo "history.go(-1)";
echo "</script>";
}
function getNameByTypeNo($sysTypeNo)
{
$pubDb = "OMC_PUB";
$selSql = "select sysTypeName from OMC_PUB.sysConf where sysTypeNo=$sysTypeNo";
$result = mysqli_query($pubConn,$selSql);
$row = mysqli_fetch_array($result);
$name = $row[sysTypeName];
return $name;
}
function getFileList($dir,&$fileListArr)
{
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fileListArr[] = $file;
}
}
closedir($handle);
}
}
function updateParamer($db_name,$table_name,$csvFileName)
{
$del_sql = "DELETE FROM $table_name";
if($DEBUG) echo "<br>del_sql = $del_sql";
$del_result = mysqli_query($pubConn,$del_sql);
if($DEBUG) echo "<br>del_result=$del_result";
$insert_sql = "LOAD DATA LOCAL INFILE '$csvFileName'
INTO TABLE $table_name
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
";
if(0) echo "<br>insert_sql=$insert_sql";
$insert_result=mysqli_query($pubConn,$insert_sql);
if($DEBUG) echo "<br>insert_result=$insert_result";
if ($insert_result)
return 1;
else
return 0;
}//end updateParamer
function updateSubs($sysId,$dataTypeNo,$impFile)
{
$nSetComm = 3;
$pubDb = 'OMC_PUB';
$sysSubsConfTable = 'OMC_PUB.sysSubsConf';
$sysInfoTable = 'OMC_PUB.sysInfo';
$sysIdArr=explode('_',$sysId);
$sysTypeNo =$sysIdArr[0];
$sysNo =$sysIdArr[1];
$subSysNo =$sysIdArr[2];
if($sysTypeNo==390)
$getConfSql="SELECT subsDataTable,impObjId,impFileName,ftpDir,ftpLoginName,ftpLoginPwd,
logFileName,maxSegmentNum,maxIndexNumPerSeg
FROM $sysSubsConfTable
WHERE sysTypeNo='$sysTypeNo' AND dataTypeNo='$dataTypeNo' AND sysNo='$sysNo'
";
else
$getConfSql="SELECT subsDataTable,impObjId,impFileName,ftpDir,ftpLoginName,ftpLoginPwd,
logFileName,maxSegmentNum,maxIndexNumPerSeg
FROM $sysSubsConfTable
WHERE sysTypeNo='$sysTypeNo' AND dataTypeNo='$dataTypeNo'
";
if($DEBUG) echo "<br>getConfSql=$getConfSql";
$getConfResult=mysqli_query($pubConn,$getConfSql);
echo mysqli_error($pubConn);
$getConfRows=mysqli_fetch_array($getConfResult);
$subsDataTable = $getConfRows[subsDataTable];
$impObjId = $getConfRows[impObjId];
$impFileName = $getConfRows[impFileName];
$logFileName = $getConfRows[logFileName];
$ftpDir = $getConfRows[ftpDir];
$ftpLoginName = $getConfRows[ftpLoginName];
$ftpLoginPwd = $getConfRows[ftpLoginPwd];
$maxSegmentNum = $getConfRows[maxSegmentNum];
$maxIndexNumPerSeg = $getConfRows[maxIndexNumPerSeg];
$maxTotalNum = $maxSegmentNum * $maxIndexNumPerSeg;
$maxImpFileSize = 5*1024*1024;
$maxImpRecordNum = 5000;
//Get the system name;
$selSql = "SELECT sysTypeName FROM sysConf WHERE sysTypeNo='$sysTypeNo'";
if ($DEBUG) echo "selSql = $selSql<br>";
$selRes = @mysqli_query($pubConn, $selSql);
echo mysqli_error($pubConn);
$selRow = @mysqli_fetch_array($selRes);
$sysName = $selRow[sysTypeName];
if($sysTypeNo==390)
$getSysIdSql = "SELECT sysNo,subSysNo,ip
FROM $sysInfoTable
WHERE sysTypeNo='$sysTypeNo' AND sysNo='$sysNo'
ORDER BY sysNo,subSysNo
";
else
$getSysIdSql = "SELECT sysNo,subSysNo,ip
FROM $sysInfoTable
WHERE sysTypeNo='$sysTypeNo' AND baseStat > '0'
ORDER BY sysNo,subSysNo
";
if($DEBUG) echo "<br>getSysIdSql=$getSysIdSql";
$getSysIdResult= mysqli_query($pubConn,$getSysIdSql);
echo mysqli_error($pubConn);
$runningServerNum = mysqli_num_rows($getSysIdResult);
if($runningServerNum <= 0){
echo "<font color=\"#FF0000\" >No system running normally</font>";
return 0;
}
if($DEBUG) echo "running server number = $runningServerNum<br>";
//<2F>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>еļ<D0B5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
$getTotalSql = "SELECT count(*) FROM $subsDataTable";
if($DEBUG) echo "<br>getTotalSql=$getTotalSql";
$getTotalRes = mysqli_query($pubConn,$getTotalSql);
$getTotalRow = @mysqli_fetch_array($getTotalRes);
$existNum = $getTotalRow[0];
if($DEBUG) echo "<br>existNum=$existNum";
//<2F><><EFBFBD><EFBFBD><E9B5BC><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
$impFileSize = filesize($impFile);
if($DEBUG) {
echo "<br>impFile=$impFile";
echo "<br>impFileSize=$impFileSize";
}
if($impFileSize > $maxImpFileSize){
$impFileSizeM=ceil($impFileSize/1024/1024);
echo "File size is too large!(Must <= 5M)</font>";
@unlink ($impFile);
return 0;
}
if($impFileSize <=0){
echo "<font color=\"#FF0000\" size=3>subscriber data is null.</font>";
@unlink ($impFile);
return 0;
}
$impRecordNum = count(file($impFile));
if($DEBUG) echo "<br>impRecordNum=$impRecordNum";
if($impRecordNum > $maxImpRecordNum){
echo "<font color=\"#FF0000\" size=3>Records are too much!(Must <= $maxImpRecordNum)</font>";
@unlink ($impFile);
return 0;
}
if($impRecordNum > $maxTotalNum-$existNum){
echo "<font color=\"#FF0000\" size=3>User number is too much!</font>";
@unlink ($impFile);
return 0;
}
for ($k=0; $k<$runningServerNum; $k++) {
$getSysIdRow=mysqli_fetch_array($getSysIdResult);
$sysId=$sysTypeNo.'_'.$getSysIdRow[sysNo].'_'.$getSysIdRow[subSysNo];
$dstSeverIp = $getSysIdRow[ip];
if($sysTypeNo==360)
$sysIdCyc[$k] = '360_99_99';
else if($sysTypeNo==390)
$sysIdCyc[$k]='390_'.$getSysIdRow[sysNo].'_99';
else
$sysIdCyc[$k] = $sysId;
if($DEBUG) echo "<br>sysId = $sysId";
if($DEBUG) echo "<br>dstSeverIp = $dstSeverIp";
$ftpCon=ftp_connect($dstSeverIp);
if($ftpCon < 0){
echo "<font color=\"#FF0000\">Connect Failed!</font>";
@unlink ($impFile);
return 0;
}
if(!ftp_login($ftpCon,$ftpLoginName,$ftpLoginPwd)){
echo "<font color=\"#FF0000\">Login Failed!</font>";
@unlink ($impFile);
return 0;
}
$remoteFileName=$ftpDir.$impFileName;
if(!ftp_put($ftpCon,$remoteFileName,$impFile,FTP_ASCII)){
echo "<font color=\"#FF0000\">Put file Failed</font>";
@unlink ($impFile);
return 0;
}
ftp_quit($ftpCon);
$logFile="/usr/local/apache/htdocs/ftpFile/$logFileName";
@unlink ($logFile);
}
@unlink ($impFile);
//<2F>޸<EFBFBD><DEB8><EFBFBD><E8B1B8><EFBFBD><EFBFBD>
if($sysTypeNo==340){
$k4_flag = 0; //should be 0 or 8.
$instanceNo = 0;
$commState = $k4_flag.'1';
$totalNum = DecHex($impRecordNum);
$totalNum = omc_keep_length($totalNum,'0',6);
if($k4_flag!=8)
$k4 = '0000000000000000';
else{
if(strlen($k4)<16){
echo "<font color=\"#FF0000\">K4 is incorrect!</font>";
return 0;
}
}
$newValue = $commState.$totalNum.$k4;
}else{
$instanceNo = 0;
$commState = '01';
$totalNum = DecHex($impRecordNum);
$totalNum = omc_keep_length($totalNum,'0',6);
$finishNum = '000000';
$newValue = $commState.$totalNum.$finishNum;
}
if($DEBUG)echo "<br>newValue=$newValue";
//send set command
for ($k=0; $k< $runningServerNum; $k++) {
$chgResult = setSysParamValue($sysIdCyc[$k],$impObjId,$instanceNo,$newValue);
$commStr = sysCommSend($sysIdCyc[$k],$nSetComm,$impObjId);
chkCommStat($sysId,$impObjId,$impRecordNum,$commStr);
}
}//end updateSubs
function chkCommStat($sysId,$impObjId,$impRecordNum,$commStr)
{
$nProcFail =0;
$nWaitProc =1;
$nInProc =2;
$nOutProc =3;
$sysIdArr=explode('_',$sysId);
$sysTypeNo =$sysIdArr[0];
$sysNo =$sysIdArr[1];
$subSysNo =$sysIdArr[2];
$maxSeconds = 20;
while(1) {
$paramValue = getSysParamValue($sysId,$impObjId,0,'readValue');
$impCommState = substr($paramValue,0,2);
$runSeconds += 2;
if($sysTypeNo==340){
$allNum=$impRecordNum;
$doneNum = substr($paramValue,2,6);
$doneNum = HexDec($doneNum);
}else{
$allNum = substr($paramValue,2,6);
$allNum = HexDec($allNum);
$doneNum = substr($paramValue,8,6);
$doneNum = HexDec($doneNum);
}
if($doneNum > $oldDoneNum){
$runSeconds = 0;
}
$oldDoneNum = $doneNum;
sleep(2);
if($runSeconds > $maxSeconds || $doneNum >= $allNum || $impCommState == '03' || $impCommState == '04')
{
if($impCommState == '04'){
echo "<FONT color=\"#FF0000\" ><b>Failed!</b></FONT>";
}elseif($runSeconds > $maxSeconds){
echo "<FONT color=\"#FF0000\" ><b>Response Time Out!</b></FONT>";
}else{
echo "<FONT color=\"#0000FF\" ><b>SUCCESS!</b></FONT>";
}
break;
}
$commIdArr = explode('-',$commStr);
$commId = $commIdArr[0];
$commSql = " SELECT commState FROM parameterComm WHERE commId = '$commId' ";
$commRes = mysqli_query($pubConn,$commSql);
$commRow = @mysqli_fetch_array($commRes);
$commStat = $commRow[commState];
if($commStat == $nOutProc || !isset($commStat)){
$commStr = sysCommSend($sysId,0,$impObjId);
}
}//end while
}//end chkCommStat
function updateBssDb($bssIpAddr,$localDir)
{
$remoteDir = "/hd0/iw07_00.010/compile/cfg/";
$ftpCon=@ftp_connect($bssIpAddr);
if($ftpCon < 0){
echo "<font color=\"#FF0000\">BSS's ip is error or connect $bssIpAddr Failed!</font>";
flush();
return 0;
}
if(!@ftp_login($ftpCon,'','')){
echo "<font color=\"#FF0000\">BSS's ip is error or login $bssIpAddr Failed!</font>";
@ftp_close($ftpCon);
flush();
return 0;
}
if(!@ftp_chdir($ftpCon, $remoteDir)){
echo "<font color=\"#FF0000\">Change dir error!</font>";
@ftp_close($ftpCon);
flush();
return 0;
}
$dir = @dir($localDir);
while(false !== ($entry=$dir->read())) {
if(is_file("$localDir$entry") && $entry!='.' && $entry!='..')
$fileArr[] = $entry;
}
for($i=0; $i< sizeof($fileArr); $i++) {
$file = $fileArr[$i];
$remoteFile=$remoteDir.$file;
$localFile=$localDir.$file;
if (!@ftp_put($ftpCon, $remoteFile, $localFile, FTP_BINARY)) {
flush();
echo "<font color=\"#FF0000\">Put file error!</font>";
@ftp_close($ftpCon);
return 0;
}
}//end for
@ftp_close($ftpCon);
return 1;
}//end get BssDb
?>
<body leftmargin=12 topmargin=5>
<?php
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "$ThisPage";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";
if(isset($inputFile)&&$inputFile!='')
{
$upload_file = $_FILES['inputFile']['tmp_name'];
$upload_file_name = $_FILES['inputFile']['name'];
$upload_file_size = $_FILES['inputFile']['size'];
$upload_file_type = $_FILES['inputFile']['type'];
$file_size_max = 20*1000*1000;// 20M<30><4D><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(bytes)
$accept_overwrite = 1;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD>ļ<EFBFBD>
//echo "<br>upload_file_type:$upload_file_type";
if($upload_file_type != 'application/x-gzip-compressed'
&&$upload_file_type != 'application/x-tgz')
MsgBox("File Type is not correct, it should be a tgz file!");
//exit;
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
if ($upload_file_size > $file_size_max)
{
MsgBox("The file size is too large!");
}
$uploadPath = "/usr/local/apache/htdocs/db_backup/archive/uploaded/";// <20>ϴ<EFBFBD><CFB4>ļ<EFBFBD><C4BC>Ĵ<EFBFBD><C4B4><EFBFBD>λ<EFBFBD><CEBB>
system("rm -rf $uploadPath");
exec("mkdir $uploadPath -p");
//exec("chmod -R 777 $uploadPath");
chmod($uploadPath,0777);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ļ<EFBFBD>
if (file_exists($uploadPath . $upload_file_name) && !$accept_overwrite)
{
MsgBox("The file is already existed!");
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ָ<EFBFBD><D6B8>Ŀ¼
if (!copy($upload_file,$uploadPath.$upload_file_name))
{
MsgBox("File copy error!");
}
//<2F><>ѹ<EFBFBD><D1B9><EFBFBD>ļ<EFBFBD>
chdir($uploadPath);
exec("tar zxvf $upload_file_name");
system("rm -f $upload_file_name");
sleep(2);
}
else
{
MsgBox($strNoInput);
}
//exit;
//////////////////////////////////////////
$allSuccess = 1;
$needUpdateParam = 1;
$needUpdateSubs = 1;
$needUpdateBSS = 1;
$needReboot = 1;
if($needUpdateParam && $allSuccess)
{//update parameters
$paramDir = 'params';
$paramPath = $uploadPath . $paramDir . '/';
if(is_dir($paramPath)) {//if there is exist paramPath.
echo "<br><font color=\"#0000FF\" size=\"3\"><b>Updating system parameters ... </b></font>";
flush();
getFileList($paramPath,$fileListArr);
// print_r($fileListArr);
// exit;
for($i=0; $i<sizeof($fileListArr); $i++)
{
$fileName = $fileListArr[$i];
$tmpArr = explode('.',$fileName);
if(sizeof($tmpArr)==3)
{
$csvFileName = $paramPath . $fileListArr[$i];
$db_name = $tmpArr[0];
$table_name = $tmpArr[1];
$tmpNameArr = explode('_',$db_name);
$sysTypeNo=$tmpNameArr[1];
if($sysTypeNo<300)$sysTypeName="PLAT";
else if($sysTypeNo==322) $sysTypeName="MSC";
else $sysTypeName = getNameByTypeNo($sysTypeNo);
if($sysTypeName=="VMS")
$sysTypeName="VSS";
if($oldName !== $sysTypeName){
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">Updating [&nbsp;<span class=\"inner\">$sysTypeName</span>&nbsp;] ... </font>";
flush();
}
$rtn = updateParamer($db_name,$table_name,$csvFileName);
if($oldName !== $sysTypeName){
if($rtn==1)
echo "<font color=\"#0000FF\"><b> SUCCESS</b></font>";
else
echo "<font color=\"#FF0000\"><b> FAIL</b></font>";
flush();
}
$oldName = $sysTypeName;
$allSuccess &= $rtn;
}
}
system("rm -rf $paramDir");
}//end if
}//end update parameters.
if($needUpdateSubs && $allSuccess)
{//update subscribers' data
$subsDir = 'subs';
$subsPath = $uploadPath . $subsDir . '/';
if(is_dir($subsPath)) {//if there is exist subsPath
echo "<br><br><font color=\"#0000FF\" size=\"3\"><b>Updating system subscribers ... </b></font>";
flush();
unset($fileListArr);
getFileList($subsPath,$fileListArr);
for($i=0; $i<sizeof($fileListArr); $i++)
{
$fileName = $fileListArr[$i];
$tmpArr = explode('.',$fileName);
if(sizeof($tmpArr)==4)
{
$csvFileName = $subsPath . $fileListArr[$i];
$db_name = $tmpArr[0];
$table_name = $tmpArr[1];
$sysId = $tmpArr[2];
$tmpNameArr = explode('_',$db_name);
$sysTypeName=$tmpNameArr[0];
if($sysTypeName=="VMS")
$sysTypeName="VSS";
$filesize = filesize($csvFileName);
if($filesize > 0) {
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">Updating [&nbsp;<span class=\"inner\">$sysTypeName</span>&nbsp;] ... </font>";
flush();
updateSubs($sysId,0,$csvFileName);
}
}
}
system("rm -rf $subsDir");
}
}//end update subscribers' data
if($needUpdateBSS && $allSuccess)
{//update bss.
$bssDir = "bssDir";
$bssPath = $uploadPath . $bssDir . '/';
$bssOmcTlbDir = "omcTlb";
$bssOmcTlbPath = $bssPath . $bssOmcTlbDir . '/';
$bssDbDir = "dbs";
$bssDbPath = $bssPath . $bssDbDir . '/';
if(is_dir($bssPath)){//if there exist this bssDir
echo "<br><br><font color=\"#0000FF\" size=\"3\"><b>Updating BSS ... </b></font>";
flush();
//1. update bss db.
if(1)
{
$dir = dir($bssDbPath);
while(false !== ($entry = $dir->read())) {
if(is_dir("$bssDbPath/$entry") && $entry != "." && $entry != "..")
$bssIpArr[] = $entry;
}
for($i=0; $i< sizeof($bssIpArr); $i++) {
$ip = $bssIpArr[$i];
//$ip = '172.18.128.111';
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">Updating BSS' Database [ $ip ] ... </font>";
flush();
$rtn = updateBssDb($ip,"$bssDbPath/$ip/");
if($rtn)
echo "<font color=\"#0000FF\"><b> SUCCESS</b></font><br>";
$allSuccess &= $rtn;
}
}//end update bss db.
//2. update bssomctable.
if($allSuccess)
{
unset($fileListArr);
getFileList($bssOmcTlbPath,$fileListArr);
for($i=0; $i<sizeof($fileListArr); $i++)
{
$fileName = $fileListArr[$i];
$tmpArr = explode('.',$fileName);
if(sizeof($tmpArr)==3)
{
$csvFileName = $bssOmcTlbPath . $fileListArr[$i];
$db_name = $tmpArr[0];
$table_name = $tmpArr[1];
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">Updating BSS' parameters ... </font>";
$rtn = updateParamer($db_name,$table_name,$csvFileName);
if($rtn==1)
echo "<font color=\"#0000FF\"><b> SUCCESS</b></font>";
else
echo "<font color=\"#FF0000\"><b> FAIL</b></font>";
flush();
$allSuccess &= $rtn;
}
}
{//2.2 insert bss info to sysInfo table
$lines = file($csvFileName);
foreach ($lines as $line_num => $line) {
//echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
$lineArr = explode(',',$line);
$bssInfoArr[$line_num][sysNo] = $lineArr[0];
$bssInfoArr[$line_num][ip] = $lineArr[1];
}
$sysInfoTable = "OMC_PUB.sysInfo";
$tmpSysType = 500;
$tmpSubSysNo = 0;
$isRemote = 0;
$pubDb = "OMC_PUB";
for($i=0; $i< sizeof($bssInfoArr); $i++){
if(strlen($bssInfoArr[$i][ip])<7) continue;
$bssIP = $bssInfoArr[$i][ip];
$tmpSysNo = $bssInfoArr[$i][sysNo];
$sysAlias='BSS'.$tmpSysNo;
$addSql = "REPLACE INTO $sysInfoTable (sysTypeNo,sysNo,subSysNo,isRemote,netId,DPC,ip,baseStat,sysAlias,updateTime )
VALUES('$tmpSysType','$tmpSysNo','$tmpSubSysNo','$isRemote','0','0','$bssIP','1','$sysAlias',CURRENT_TIMESTAMP)";
if($DEBUG) echo "<br>addSql = $addSql";
$result = mysqli_query($pubConn,$addSql);
echo mysqli_error($pubConn);
}
}//end nsert bss info to sysInfo table
}//end update bssomctable.
system("rm -rf $bssDir");
if($needReboot && $allSuccess)//3. reboot bss.
{
chdir("/usr/local/apache/htdocs/wxc2_omc/security/backupRestore");
for($i=0; $i< sizeof($bssIpArr); $i++) {
$ip = $bssIpArr[$i];
echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"#0000FF\">Rebooting BSS [ $ip ] ... </font>";
flush();
$tmpCmd ="/usr/local/apache/htdocs/wxc2_omc/element/overview/bssReboot".' '.$ip;
system($tmpCmd);
//$lastLine = system($tmpCmd, $rtn);
//echo "<br>$tmpCmd<br>$lastLine<br>$rtn";
}
//var_dump($bssIpArr);
}//end reboot bss.
$tmpCmd ="/usr/local/apache/htdocs/wxc2_omc/element/overview/bsscommRestart";
system($tmpCmd);
}
}//end update bss.
//exit;
if($allSuccess) {
//MsgBox("All needed success");
echo "<script language=\"javascript\">";
echo "alert('Resotre Completed Successfully!');";
echo "window.location=\"upLoadingElements.php?pageaction=setall&resetDevice=1\"";
echo "</script>";
}
else {
echo "<p align=\"left\"><a href=\"overview.php?restoreShow=1\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
}
?>