<?php
/*********************************************************
 程序说明：        
    功能说明：
    调用关系：调用: commfunc.php
              被调用:        
    变量说明：
    作者：Yi Zane   2005-11-09      
修改注释：      
NO.1     
姓名：          
时间：
修改说明：
**********************************************************/
	require("../sub_inc/commfunc.php");
	$DEBUG = 0;
	//填充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')
		);	
	}
	//根据填充oid，set/get参数
	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与其他参数分开设置
			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与其他参数分开设置
			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>
