<?php
function GetModuleVersion($sysTypeNo,$sysNo,$subSysNo=0)
{
	$version_pos=46;
	$sql="select detailStat from OMC_PUB.sysStat where sysTypeNo=$sysTypeNo and sysNo=$sysNo and subSysNo=$subSysNo ";
	//echo "$sql<br>";
	global $pubConn;
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return "--";
	
	$row=mysqli_fetch_array($res);
	
	if(strlen($row['detailStat']) < 6)
		return "--";
	if($sysTypeNo == 362)
	    $version_string=substr($row['detailStat'],36,6);
	else
	    $version_string=substr($row['detailStat'],46,6);
	$version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	return $version_string;
}

function GetModuleInfo($conf)
{
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo={$conf['SysTypeNo']} order by sysNo,subSysNo ";
	//echo "$sql<br>";
	global $pubConn;
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	//echo "num=$num";
	if($num<=0)
		return 0;

	for($i=0;$i<$num;$i++)
	{
		$row=mysqli_fetch_array($res);
		
		$sql_plat="select * from OMC_PUB.sysInfo where sysTypeNo=200 and sysNo={$conf['PlatNo']} and subSysNo={$row['sysNo']} ";
		//echo "$sql_plat<br>";
		$res_plat=mysqli_query($pubConn,$sql_plat);
		$num_plat=mysqli_num_rows($res_plat);
		
		$module[$i]['sysNo']=$row['sysNo']+0;
		
		$module[$i]['Name']['Value']=$conf['Module']."_".$row['sysNo'];
		$module[$i]['Name']['Color']="#000000";
		
		$module[$i]['Version']['Value']=GetModuleVersion($conf['SysTypeNo'],$row['sysNo'],$row['subSysNo']);
		$module[$i]['Version']['Color']="#000000";
		
		$module[$i]['IPAddress']['Value']=$row['ip'];
		$module[$i]['IPAddress']['Color']="#000000";
		
		if($num_plat != 1)
		{
			$module[$i]['PlatStatus']['Value']="N";
			$module[$i]['PlatStatus']['Color']="#ff0000";
		}
		else
		{
			$module[$i]['PlatStatus']['Value']="Y";
			$module[$i]['PlatStatus']['Color']="#0000ff";
		}
			
		
		$refresh_time=$row['updateTime'];
		$due_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-60,date("m"),date("d"),date("Y")));
		$ove_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+60,date("m"),date("d"),date("Y")));
		if($refresh_time < $due_date || $refresh_time > $ove_date)
		{
			$module[$i]['RefreshTime']['Value']="$refresh_time";
			$module[$i]['RefreshTime']['Color']="#ff0000";
			$valid_time=0;
		}
		else
		{
			$module[$i]['RefreshTime']['Value']="$refresh_time";
			$module[$i]['RefreshTime']['Color']="#0000ff";
			$valid_time=1;
		}
		
		$baseStat=$row['baseStat']+0;
		if($valid_time && $baseStat)
		{
			$module[$i]['AppStatus']['Value']="Y";
			$module[$i]['AppStatus']['Color']="#0000ff";
		}
		else
		{
			$module[$i]['AppStatus']['Value']="N";
			$module[$i]['AppStatus']['Color']="#ff0000";
		}
	}
	
	return $module;
}

function GetSingleModuleInfo($sysTypeNo,$sysNo)
{
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo={$sysTypeNo} and sysNo={$sysNo} ";
	//echo "$sql<br>";
	global $pubConn,$strStatusIsNormal,$strStatusIsAbnormal,$strStatusNone,$strStatusIsAlarm;
	$res=mysqli_query($pubConn,$sql);
	if ($res)$num=mysqli_num_rows($res);
	if($num == 0)
		return 0;
	$row=mysqli_fetch_array($res);
	//echo print_r($row);
	$baseStat=$row['baseStat']+0;
	
	$sql="select * from OMC_PUB.sysStat where sysTypeNo={$sysTypeNo} and sysNo={$sysNo} ";
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num == 0)
		return 0;
	$row=mysqli_fetch_array($res);
	$detailStat=$row['detailStat'];
	
	//Refresh Time
	$refresh_time=$row['updateTime'];
	$due_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-60,date("m"),date("d"),date("Y")));
	$ove_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+60,date("m"),date("d"),date("Y")));
	if($refresh_time < $due_date || $refresh_time > $ove_date)
	{
		$module['RefreshTime']['Value']="$refresh_time";
		$module['RefreshTime']['Color']="#ff0000";
		$module['RefreshTime']['Display']="block";
		$valid_time=0;
	}
	else
	{
		$module['RefreshTime']['Value']="$refresh_time";
		$module['RefreshTime']['Color']="#0000ff";
		$module['RefreshTime']['Display']="block";
		$valid_time=1;
	}
	
	//Application Status
	if($baseStat && $valid_time)
	{
		$module['AppStatus']['Value']="Y";
		$module['AppStatus']['Color']="#0000ff";
		$module['AppStatus']['Display']="block";
	}
	else
	{
		$module['AppStatus']['Value']="N";
		$module['AppStatus']['Color']="#ff0000";
		$module['AppStatus']['Display']="block";
	}
	
	//Serial Number
	$module['SerialNumber']['Value']=substr($detailStat,78,8);
	$module['SerialNumber']['Color']="#000000";
	$module['SerialNumber']['Display']="block";
	
	switch($sysTypeNo)
	{
	//EMS
	case 0:
		//IOTotalMasterLogFile
		$IOTotalMasterLogFile=hexdec(substr($detailStat,92,8));
		$IOTotalMasterLogFile=omc_keep_length($IOTotalMasterLogFile,'0',$length=6,1);
		$IOTotalMasterLogPos=hexdec(substr($detailStat,100,8));
		$IOCurrentMasterLogFile=hexdec(substr($detailStat,108,8));
		$IOCurrentMasterLogFile=omc_keep_length($IOCurrentMasterLogFile,'0',$length=6,1);
		$IOCurrentMasterLogPos=hexdec(substr($detailStat,116,8));
		$SQLTotalRelayLogFile=hexdec(substr($detailStat,124,8));
		$SQLTotalRelayLogFile=omc_keep_length($SQLTotalRelayLogFile,'0',$length=6,1);
		$SQLTotalRelayLogPos=hexdec(substr($detailStat,132,8));
		$SQLCurrentRelayLogFile=hexdec(substr($detailStat,140,8));
		$SQLCurrentRelayLogFile=omc_keep_length($SQLCurrentRelayLogFile,'0',$length=6,1);
		$SQLCurrentRelayLogPos=hexdec(substr($detailStat,148,8));

		$module['IOSyncInfo']['Value']="$IOCurrentMasterLogFile $IOCurrentMasterLogPos => $IOTotalMasterLogFile $IOTotalMasterLogPos";
		$module['IOSyncInfo']['Color']="#000000";
		$module['IOSyncInfo']['Display']="block";
		
		$module['SQLSyncInfo']['Value']="$SQLCurrentRelayLogFile $SQLCurrentRelayLogPos => $SQLTotalRelayLogFile $SQLTotalRelayLogPos";
		$module['SQLSyncInfo']['Color']="#000000";
		$module['SQLSyncInfo']['Display']="block";
		
		//Dual Server Status
		$dual_server_status_label=array(
				0=>"Offline",
				1=>"Initial",
				2=>"Detect",
				3=>"Slave",
				4=>"Sync",
				5=>"Master",
				6=>"Degrade",
				7=>"Single"
		);
		$val=hexdec(substr($detailStat,52,2));
		$module['DualServerStatus']['Value']=$dual_server_status_label[$val];
		$module['DualServerStatus']['Color']="#0000ff";
		$module['DualServerStatus']['Display']="block";
		
		//Process Num
		$process_name_label=array(
					0=>"mysqld",
					1=>"apache2",
					2=>"omcMain",
					3=>"iptrans",
					4=>"paraComm",
					5=>"subsComm",
					6=>"logCollector",
					7=>"omcCleaner",
					8=>"smcli",
					9=>"cdrCollector",
					10=>"subsDataBackup",
					11=>"ftpSend",
					12=>"alarmAgent",
					13=>"nrtrde",
					14=>"sftpSend",
					15=>"cstaCollector"
		);
		

		$process_status_label=array(
				0=>"stopped",
				1=>"working",
				2=>"suspended"
		);
		
		$process_status_color=array(
				0=>"#ff0000",
				1=>"#0000ff",
				2=>"#ff0000"
		);
		
		$module['CurrentProcessNum']=hexdec(substr($detailStat,156,2));
		$module['TotalProcessNum']=sizeof($process_name_label);
		for($i=0;$i<$module['TotalProcessNum'];$i++)
		{
			$module['Process'][$i]['Name']=$process_name_label[$i];
			$module['Process'][$i]['Value']=hexdec(substr($detailStat,158+$i*2,2));
			$module['Process'][$i]['Color']=$process_status_color[$module['Process'][$i]['Value']];
			$module['Process'][$i]['Value']=$process_status_label[$module['Process'][$i]['Value']];
			if($i<$module['CurrentProcessNum'])
			{
				$module['Process'][$i]['Display']="block";
			}
			else
			{
				$module['Process'][$i]['Display']="none";
			}
		}
		
		break;
	//MSC
	case 320:
		//Dual Server Status
		$dual_server_status_label=array(
			0=>"Normal",
			1=>"Restart",
			2=>"Initial",
			3=>"Suspended",
			4=>"Stop",
			5=>"Wait",
			6=>"Single"
		);
		$dual_server_status_color=array(
			0=>"#0000ff",
			1=>"#ff8c00",
			2=>"#ff8c00",
			3=>"#ff8c00",
			4=>"#ff0000",
			5=>"#ff8c00",
			6=>"#0000ff"
		);
		$module['DualServerStatus']['Value']=$dual_server_status_label[hexdec(substr($detailStat,52,2))];
		$module['DualServerStatus']['Color']=$dual_server_status_color[hexdec(substr($detailStat,52,2))];
		$module['DualServerStatus']['Display']="block";
		
		//E1 License
		$module['E1License']['Value']=hexdec(substr($detailStat,62,8));
		$module['E1License']['Color']="#0000ff";
		$module['E1License']['Display']="block";
		
		//E1 Used
		$module['E1Used']['Value']=hexdec(substr($detailStat,70,8));
		$module['E1Used']['Color']="#0000ff";
		$module['E1Used']['Display']="block";
		
		//VLR Version
		$version_string=substr($detailStat,94,6);
		$version_string=(substr($version_string,0,2)+0).".".substr($version_string,2,2).".".substr($version_string,4,2);
		$module['VLR']['Version']=$version_string;
		
		//VLR Refresh Time
		$module['VLR']['RefreshTime']['Value']=$module['RefreshTime']['Value'];
		$module['VLR']['RefreshTime']['Color']=$module['RefreshTime']['Color'];
		$module['VLR']['RefreshTime']['Display']=$module['RefreshTime']['Display'];
		
		//VLR Status
		$status_label=array(
			0=>"Initial",
			1=>"Server VLR",
			2=>"Sync",
			3=>"Single",
			4=>"Dual"
		);
		$status_color=array(
			0=>"#0000ff",
			1=>"#0000ff",
			2=>"#0000ff",
			3=>"#0000ff",
			4=>"#0000ff"
		);
		$module['VLR']['AppStatus']['Value']=$status_label[hexdec(substr($detailStat,100,2))];
		$module['VLR']['AppStatus']['Color']=$status_color[hexdec(substr($detailStat,100,2))];
		$module['VLR']['AppStatus']['Display']="block";
		
		//VLR Subscriber Number
		$module['VLR']['SubscriberNumber']['Value']=hexdec(substr($detailStat,118,8));
		$module['VLR']['SubscriberNumber']['Color']="#0000ff";
		$module['VLR']['SubscriberNumber']['Display']="block";
		
		//License
		$module['VLR']['License']['Value']=hexdec(substr($detailStat,110,8));
		$module['VLR']['License']['Color']="#0000ff";
		$module['VLR']['License']['Display']="block";
		
		break;
	//HLR
	case 330:
	//AUC
	case 340:
	//PPS
	case 360:
	case 395:
	//EIR
	case 380:
	//MNP
	case 370:
		//License
		$module['License']['Value']=hexdec(substr($detailStat,62,8));
		$module['License']['Color']="#0000ff";
		$module['License']['Display']="block";
		
		//User
		$module['User']['Value']=hexdec(substr($detailStat,70,8));
		$module['User']['Color']="#0000ff";
		$module['User']['Display']="block";
		break;
	//SMEG
	case 355:
		//License
		$module['License']['Value']=hexdec(substr($detailStat,62,8));
		$module['License']['Color']="#0000ff";
		$module['License']['Display']="block";
		
		//User
		$module['User']['Value']=hexdec(substr($detailStat,70,8));
		$module['User']['Color']="#0000ff";
		$module['User']['Display']="block";
		
		//SMPP TX Status
		$value=hexdec(substr($detailStat,86,2));
		if($value == 0)
		{
			$module['SMPPTXStatus']['Value']="Y";
			$module['SMPPTXStatus']['Color']="#0000ff";
		}
		else
		{
			$module['SMPPTXStatus']['Value']="N";
			$module['SMPPTXStatus']['Color']="#ff0000";
		}
		$module['SMPPTXStatus']['Display']="block";
		
		//SMPP RX Status
		$value=hexdec(substr($detailStat,88,2));
		if($value == 0)
		{
			$module['SMPPRXStatus']['Value']="Y";
			$module['SMPPRXStatus']['Color']="#0000ff";
		}
		else
		{
			$module['SMPPRXStatus']['Value']="N";
			$module['SMPPRXStatus']['Color']="#ff0000";
		}
		$module['SMPPRXStatus']['Display']="block";
		
		//SMTP TX Status
		$value=hexdec(substr($detailStat,90,2));
		if($value == 0)
		{
			$module['SMTPTXStatus']['Value']="Y";
			$module['SMTPTXStatus']['Color']="#0000ff";
		}
		else
		{
			$module['SMTPTXStatus']['Value']="N";
			$module['SMTPTXStatus']['Color']="#ff0000";
		}
		$module['SMTPTXStatus']['Display']="block";
		
		//SMTP RX Status
		$value=hexdec(substr($detailStat,92,2));
		if($value == 0)
		{
			$module['SMTPRXStatus']['Value']="Y";
			$module['SMTPRXStatus']['Color']="#0000ff";
		}
		else
		{
			$module['SMTPRXStatus']['Value']="N";
			$module['SMTPRXStatus']['Color']="#ff0000";
		}
		$module['SMTPRXStatus']['Display']="block";
		
		break;
	//MME
	case 361:
	    //SystemID
	    $module['SystemID']['Value']=substr($detailStat,0,2)+0;
	    $module['SystemID']['Color']="#0000ff";
	    $module['SystemID']['Display']="block";

	    //SubsystemID
	    $module['SubsystemID']['Value']=substr($detailStat,2,2)+0;
	    $module['SubsystemID']['Color']="#0000ff";
	    $module['SubsystemID']['Display']="block";

	    //TimeStamp
	    $module['TimeStamp']['Value']=$module['RefreshTime']['Value'];
	    $module['TimeStamp']['Color']=$module['RefreshTime']['Color'];
	    $module['TimeStamp']['Display']=$module['RefreshTime']['Display'];

	    //Software Version
	    $software_string=substr($detailStat,46,6);
	    $software_string=hexdec(substr($software_string,0,2)).".".hexdec(substr($software_string,2,2)).".".hexdec(substr($software_string,4,2));
	    $module['SoftwareVersion']['Value']=$software_string;
	    $module['SoftwareVersion']['Color']="#0000ff";
	    $module['SoftwareVersion']['Display']="block";

	    //Status          0->unconnected;1->connected
	    $Status=substr($detailStat,52,2)+0;
	    if($Status == 0)
	    {
	        $module['Status']['Value']="N";
	        $module['Status']['Color']="#ff0000";
	    }
	    else
	    {
	        $module['Status']['Value']="Y";
	        $module['Status']['Color']="#0000ff";
	    }
	    $module['Status']['Display']="block";

	    // Checksum
	    $module['Checksum']['Value']=hexdec(substr($detailStat,54,8));
	    $module['Checksum']['Color']="#0000ff";
	    $module['Checksum']['Display']="block";

	    //LicenseUser            12345
	    $module['LicenseUser']['Value']=hexdec(substr($detailStat,62,8));
	    $module['LicenseUser']['Color']="#0000ff";
	    $module['LicenseUser']['Display']="block";

	    //RegisterUES            12345
	    $module['RegisterUES']['Value']=hexdec(substr($detailStat,70,8));
	    $module['RegisterUES']['Color']="#0000ff";
	    $module['RegisterUES']['Display']="block";

	    //ConnectedUES            12345
	    $module['ConnectedUES']['Value']=hexdec(substr($detailStat,78,8));
	    $module['ConnectedUES']['Color']="#0000ff";
	    $module['ConnectedUES']['Display']="block";

	    //OnlineENBNum            12345
	    $module['OnlineENBNum']['Value']=hexdec(substr($detailStat,86,8));
	    $module['OnlineENBNum']['Color']="#0000ff";
	    $module['OnlineENBNum']['Display']="block";

	    //SequenceNum            12345
	    $module['SequenceNum']['Value']= substr($detailStat,94,8);// hexdec(substr($detailStat,94,8));
	    $module['SequenceNum']['Color']="#0000ff";
	    $module['SequenceNum']['Display']="block";

	    //License date
	    $LicenseDate=substr($detailStat,102,6);
	    $LicenseDate=(hexdec(substr($LicenseDate,0,2))+2000).".".hexdec(substr($LicenseDate,2,2)).".".hexdec(substr($LicenseDate,4,2));
	    $module['LicenseDate']['Value']=$LicenseDate;
	    $module['LicenseDate']['Color']="#0000ff";
	    $module['LicenseDate']['Display']="block";
	    break;
	//SGPW
	case 362:
	    //SystemID
	    $module['SystemID']['Value']=substr($detailStat,0,2)+0;
	    $module['SystemID']['Color']="#0000ff";
	    $module['SystemID']['Display']="block";
	    
	    //SubsystemID
	    $module[SubsystemID][Value]=substr($detailStat,2,2)+0;
	    $module[SubsystemID][Color]="#0000ff";
	    $module[SubsystemID][Display]="block";
	    
	    //TimeStamp
	    $module[TimeStamp][Value]=$module[RefreshTime][Value];
	    $module[TimeStamp][Color]=$module[RefreshTime][Color];
	    $module[TimeStamp][Display]=$module[RefreshTime][Display];
	    
	    //Version
	    $version_string=substr($detailStat,36,6);
	    $version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	    $module[Version][Value]=$version_string;
	    $module[Version][Color]="#0000ff";
	    $module[Version][Display]="block";
	    
	    //S11ConnStatus          0->unconnected;1->connected
	    $Status=substr($detailStat,42,2)+0;
	    if($Status == 0)
	    {
	        $module[S11ConnStatus][Value]="N";
	        $module[S11ConnStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[S11ConnStatus][Value]="Y";
	        $module[S11ConnStatus][Color]="#0000ff";
	    }
	    $module[S11ConnStatus][Display]="block";
	    
	    //s1UConnStatus          0->unconnected;1->connected
	    $Status=substr($detailStat,44,2)+0;
	    if($Status == 0)
	    {
	        $module[s1UConnStatus][Value]="N";
	        $module[s1UConnStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[s1UConnStatus][Value]="Y";
	        $module[s1UConnStatus][Color]="#0000ff";
	    }
	    $module[s1UConnStatus][Display]="block";
	    
	    //SGIConnStatus          0->unconnected;1->connected
	    $Status=substr($detailStat,46,2)+0;
	    if($Status == 0)
	    {
	        $module[SGIConnStatus][Value]="N";
	        $module[SGIConnStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[SGIConnStatus][Value]="Y";
	        $module[SGIConnStatus][Color]="#0000ff";
	    }
	    $module[SGIConnStatus][Display]="block";
	    
	    //GxConnStatus           0->unconnected;1->connected
	    $Status=substr($detailStat,48,2)+0;
	    if($Status == 0)
	    {
	        $module[GxConnStatus][Value]="N";
	        $module[GxConnStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[GxConnStatus][Value]="Y";
	        $module[GxConnStatus][Color]="#0000ff";
	    }
	    $module[GxConnStatus][Display]="block";
	    
	    //GyConnStatus           0->unconnected;1->connected
	    $Status=substr($detailStat,50,2)+0;
	    if($Status == 0)
	    {
	        $module[GyConnStatus][Value]="N";
	        $module[GyConnStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[GyConnStatus][Value]="Y";
	        $module[GyConnStatus][Color]="#0000ff";
	    }
	    $module[GyConnStatus][Display]="block";
	    
	    //SystemCapability       12345
	    $module[SystemCapability][Value]=hexdec(substr($detailStat,52,8));
	    $module[SystemCapability][Color]="#0000ff";
	    $module[SystemCapability][Display]="block";
	    
	    //LicenseUser            12345
	    $module[LicenseUser][Value]=hexdec(substr($detailStat,60,8));
	    $module[LicenseUser][Color]="#0000ff";
	    $module[LicenseUser][Display]="block";
	    
	    //SequenceNum            12345
	    $module[SequenceNum][Value]= substr($detailStat,68, 8);// hexdec(substr($detailStat,94,8));
	    $module[SequenceNum][Color]="#0000ff";
	    $module[SequenceNum][Display]="block";
	    
	    //License date
	    $LicenseDate=substr($detailStat,76,6);
	    $LicenseDate=(hexdec(substr($LicenseDate,0,2))+2000).".".hexdec(substr($LicenseDate,2,2)).".".hexdec(substr($LicenseDate,4,2));
	    $module[LicenseDate][Value]=$LicenseDate;
	    $module[LicenseDate][Color]="#0000ff";
	    $module[LicenseDate][Display]="block";
	    break;
	//IMS
	case 363:
	    //SystemID
	    $module[SystemID][Value]=substr($detailStat,0,2)+0;
	    $module[SystemID][Color]="#0000ff";
	    $module[SystemID][Display]="block";
	    
	    //SubsystemID
	    $module[SubsystemID][Value]=substr($detailStat,2,2)+0;
	    $module[SubsystemID][Color]="#0000ff";
	    $module[SubsystemID][Display]="block";
	    
	    //TimeStamp
	    $module[TimeStamp][Value]=$module[RefreshTime][Value];
	    $module[TimeStamp][Color]=$module[RefreshTime][Color];
	    $module[TimeStamp][Display]=$module[RefreshTime][Display];
	    
	    //Version
	    $version_string=substr($detailStat,46,6);
	    $version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	    $module[Version][Value]=$version_string;
	    $module[Version][Color]="#0000ff";
	    $module[Version][Display]="block";
	    
	    //status
	    $Status=substr($detailStat,52,2)+0;
	    if($Status == 0)
	    {
	        $module[Status][Value]="N";
	        $module[Status][Color]="#ff0000";
	    }
	    else
	    {
	        $module[Status][Value]="Y";
	        $module[Status][Color]="#0000ff";
	    }
	    $module[Status][Display]="block";
	    
	    //checksum
	    $module[Checksum][Value]=hexdec(substr($detailStat,54,8));
	    $module[Checksum][Color]="#0000ff";
	    $module[Checksum][Display]="block";
	    
	    //license user
	    $module[LicenseUser][Value]=hexdec(substr($detailStat,62,8));
	    $module[LicenseUser][Color]="#0000ff";
	    $module[LicenseUser][Display]="block";
	    
	    //volte pcscf status
	    $VoltePCSCFStatus=substr($detailStat,70,2)+0;
	    if($VoltePCSCFStatus == 0)
	    {
	        $module[VoltePCSCFStatus][Value]="N";
	        $module[VoltePCSCFStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[VoltePCSCFStatus][Value]="Y";
	        $module[VoltePCSCFStatus][Color]="#0000ff";
	    }
	    $module[VoltePCSCFStatus][Display]="block";
	    
	    //voip pcscf status
	    $VoipPCSCFStatus=substr($detailStat,72,2)+0;
	    if($VoipPCSCFStatus == 0)
	    {
	        $module[VoipPCSCFStatus][Value]="N";
	        $module[VoipPCSCFStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[VoipPCSCFStatus][Value]="Y";
	        $module[VoipPCSCFStatus][Color]="#0000ff";
	    }
	    $module[VoipPCSCFStatus][Display]="block";
		
		//icscf status
	    $IcscfStatus=substr($detailStat,74,2)+0;
	    if($IcscfStatus == 0)
	    {
	        $module[IcscfStatus][Value]="N";
	        $module[IcscfStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[IcscfStatus][Value]="Y";
	        $module[IcscfStatus][Color]="#0000ff";
	    }
	    $module[IcscfStatus][Display]="block";
	    
		//scscf status
	    $ScscfStatus=substr($detailStat,76,2)+0;
	    if($ScscfStatus == 0)
	    {
	        $module[ScscfStatus][Value]="N";
	        $module[ScscfStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[ScscfStatus][Value]="Y";
	        $module[ScscfStatus][Color]="#0000ff";
	    }
	    $module[ScscfStatus][Display]="block";
		
		//mmtel status
	    $MMETelStatus=substr($detailStat,78,2)+0;
	    if($MMETelStatus == 0)
	    {
	        $module[MMETelStatus][Value]="N";
	        $module[MMETelStatus][Color]="#ff0000";
	    }
	    else
	    {
	        $module[MMETelStatus][Value]="Y";
	        $module[MMETelStatus][Color]="#0000ff";
	    }
	    $module[MMETelStatus][Display]="block";
	    
	    //SequenceNum            12345
	    $module[SequenceNum][Value]= substr($detailStat,94, 8);// hexdec(substr($detailStat,94,8));
	    $module[SequenceNum][Color]="#0000ff";
	    $module[SequenceNum][Display]="block";
	    
	    //License date
	    // $LicenseDate=substr($detailStat,76,6);
	    // $LicenseDate=(hexdec(substr($LicenseDate,0,2))+2000).".".hexdec(substr($LicenseDate,2,2)).".".hexdec(substr($LicenseDate,4,2));
	    // $module[LicenseDate][Value]=$LicenseDate;
	    // $module[LicenseDate][Color]="#0000ff";
	    // $module[LicenseDate][Display]="block";
	    break;
	//IMS
	case 364:
	    //SystemID
	    $module[SystemID][Value]=substr($detailStat,0,2)+0;
	    $module[SystemID][Color]="#0000ff";
	    $module[SystemID][Display]="block";
	    
	    //SubsystemID
	    $module[SubsystemID][Value]=substr($detailStat,2,2)+0;
	    $module[SubsystemID][Color]="#0000ff";
	    $module[SubsystemID][Display]="block";
	    
	    //TimeStamp
	    $module[TimeStamp][Value]=$module[RefreshTime][Value];
	    $module[TimeStamp][Color]=$module[RefreshTime][Color];
	    $module[TimeStamp][Display]=$module[RefreshTime][Display];
	    
	    //Version
	    $version_string=substr($detailStat,46,6);
	    $version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	    $module[Version][Value]=$version_string;
	    $module[Version][Color]="#0000ff";
	    $module[Version][Display]="block";
	    
	    //status
	    $Status=substr($detailStat,52,2)+0;
	    if($Status == 0)
	    {
	        $module[Status][Value]="N";
	        $module[Status][Color]="#ff0000";
	    }
	    else
	    {
	        $module[Status][Value]="Y";
	        $module[Status][Color]="#0000ff";
	    }
	    $module[Status][Display]="block";
	    
	    //checksum
	    $module[Checksum][Value]=hexdec(substr($detailStat,54,8));
	    $module[Checksum][Color]="#0000ff";
	    $module[Checksum][Display]="block";
	    
	    //license user
	    $module[LicenseUser][Value]=hexdec(substr($detailStat,62,8));
	    $module[LicenseUser][Color]="#0000ff";
	    $module[LicenseUser][Display]="block";
	    
	    //registeredUES
	    $module[registeredUES][Value]=hexdec(substr($detailStat,70,8));
	    $module[registeredUES][Color]="#0000ff";
	    $module[registeredUES][Display]="block";
 
	    //onlineHNBNum
	    $module[onlineHNBNum][Value]=hexdec(substr($detailStat,78,8));
	    $module[onlineHNBNum][Color]="#0000ff";
	    $module[onlineHNBNum][Display]="block";
	    
	    //SequenceNum            12345
	    $module[SequenceNum][Value]= substr($detailStat,94, 8);// hexdec(substr($detailStat,94,8));
	    $module[SequenceNum][Color]="#0000ff";
	    $module[SequenceNum][Display]="block";
	    
	    //expireDate
	    $expireDate=substr($detailStat,102,6);
	    $expireDate=(hexdec(substr($expireDate,0,2))+2000).".".hexdec(substr($expireDate,2,2)).".".hexdec(substr($expireDate,4,2));
	    $module[expireDate][Value]=$expireDate;
	    $module[expireDate][Color]="#0000ff";
	    $module[expireDate][Display]="block";
	    break;
	//UDM
	case 365:
	    //SystemID
	    $module[SystemID][Value]=substr($detailStat,0,2)+0;
	    $module[SystemID][Color]="#0000ff";
	    $module[SystemID][Display]="block";
	    
	    //SubsystemID
	    $module[SubsystemID][Value]=substr($detailStat,2,2)+0;
	    $module[SubsystemID][Color]="#0000ff";
	    $module[SubsystemID][Display]="block";
	    
	    //TimeStamp
	    $module[TimeStamp][Value]=$module[RefreshTime][Value];
	    $module[TimeStamp][Color]=$module[RefreshTime][Color];
	    $module[TimeStamp][Display]=$module[RefreshTime][Display];
	    
	    //Version
	    $version_string=substr($detailStat,46,6);
	    $version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	    $module[Version][Value]=$version_string;
	    $module[Version][Color]="#0000ff";
	    $module[Version][Display]="block";
	    
	    //status
	    $Status=substr($detailStat,52,2)+0;
	    if($Status == 0)
	    {
	        $module[Status][Value]="N";
	        $module[Status][Color]="#ff0000";
	    }
	    else
	    {
	        $module[Status][Value]="Y";
	        $module[Status][Color]="#0000ff";
	    }
	    $module[Status][Display]="block";
	    
	    //checksum
	    $module[Checksum][Value]=hexdec(substr($detailStat,54,8));
	    $module[Checksum][Color]="#0000ff";
	    $module[Checksum][Display]="block";
	    
	    //license user
	    $module[LicenseUser][Value]=hexdec(substr($detailStat,62,8));
	    $module[LicenseUser][Color]="#0000ff";
	    $module[LicenseUser][Display]="block";
	    
	    //SequenceNum            12345
	    $module[SequenceNum][Value]= substr($detailStat,94, 8);
	    $module[SequenceNum][Color]="#0000ff";
	    $module[SequenceNum][Display]="block";
	    break;		
        //AUSF
	case 366:
	    //SystemID
	    $module[SystemID][Value]=substr($detailStat,0,2)+0;
	    $module[SystemID][Color]="#0000ff";
	    $module[SystemID][Display]="block";
	    
	    //SubsystemID
	    $module[SubsystemID][Value]=substr($detailStat,2,2)+0;
	    $module[SubsystemID][Color]="#0000ff";
	    $module[SubsystemID][Display]="block";
	    
	    //TimeStamp
	    $module[TimeStamp][Value]=$module[RefreshTime][Value];
	    $module[TimeStamp][Color]=$module[RefreshTime][Color];
	    $module[TimeStamp][Display]=$module[RefreshTime][Display];
	    
	    //Version
	    $version_string=substr($detailStat,46,6);
	    $version_string=hexdec(substr($version_string,0,2)).".".hexdec(substr($version_string,2,2)).".".hexdec(substr($version_string,4,2));
	    $module[Version][Value]=$version_string;
	    $module[Version][Color]="#0000ff";
	    $module[Version][Display]="block";
	    
	    //status
	    $Status=substr($detailStat,52,2)+0;
	    if($Status == 0)
	    {
	        $module[Status][Value]="N";
	        $module[Status][Color]="#ff0000";
	    }
	    else
	    {
	        $module[Status][Value]="Y";
	        $module[Status][Color]="#0000ff";
	    }
	    $module[Status][Display]="block";
	    
	    //checksum
	    $module[Checksum][Value]=hexdec(substr($detailStat,54,8));
	    $module[Checksum][Color]="#0000ff";
	    $module[Checksum][Display]="block";
	    
	    //license user
	    $module[LicenseUser][Value]=hexdec(substr($detailStat,62,8));
	    $module[LicenseUser][Color]="#0000ff";
	    $module[LicenseUser][Display]="block";
	    
	    //SequenceNum            12345
	    $module[SequenceNum][Value]= substr($detailStat,94, 8);
	    $module[SequenceNum][Color]="#0000ff";
	    $module[SequenceNum][Display]="block";
	    break;	
	//OPPS
	case 375:
		//License
		$module[License][Value]=hexdec(substr($detailStat,62,8));
		$module[License][Color]="#0000ff";
		$module[License][Display]="block";
		
		//User
		$module[User][Value]=hexdec(substr($detailStat,70,8));
		$module[User][Color]="#0000ff";
		$module[User][Display]="block";
		
		//OPR Status
		$value=hexdec(substr($detailStat,86,1));
		if($value == 0)
		{
			$module[OPRStatus][Value]="Disabled";
			$module[OPRStatus][Color]="#000000";
		}
		else
		{
			$module[OPRStatus][Value]="Normal";
			$module[OPRStatus][Color]="#0000ff";
		}
		$module[OPRStatus][Display]="block";
		
		//IMDX Status
		$value=hexdec(substr($detailStat,87,1));
		if($value == 0)
		{
			$module[IMDXStatus][Value]="Disabled";
			$module[IMDXStatus][Color]="#000000";
		}
		else
		{
			$module[IMDXStatus][Value]="Normal";
			$module[IMDXStatus][Color]="#0000ff";
		}
		$module[IMDXStatus][Display]="block";
		
		//Serial Number
		$module[SerialNumber][Value]=substr($detailStat,78,8);
		$module[SerialNumber][Color]="#000000";
		$module[SerialNumber][Display]="block";
		
		break;
	//MHC
	case 386:
		//Serial Number
		$module[SerialNumber][Value]=substr($detailStat,86,8);
		$module[SerialNumber][Color]="#000000";
		$module[SerialNumber][Display]="block";
		break;
	//VSS
	case 390:		
		//Total Mailbox
		$module[TotalMailbox][Value]=hexdec(substr($detailStat,62,8));
		$module[TotalMailbox][Color]="#0000ff";
		$module[TotalMailbox][Display]="block";
		
		//Registered Mailbox
		$module[RegisteredMailbox][Value]=hexdec(substr($detailStat,70,8));
		$module[RegisteredMailbox][Color]="#0000ff";
		$module[RegisteredMailbox][Display]="block";
		
		//Active Mailbox
		$module[ActiveMailbox][Value]=hexdec(substr($detailStat,86,8));
		$module[ActiveMailbox][Color]="#0000ff";
		$module[ActiveMailbox][Display]="block";
		
		//Total Voicemail
		$module[TotalVoicemail][Value]=hexdec(substr($detailStat,94,8));
		$module[TotalVoicemail][Color]="#0000ff";
		$module[TotalVoicemail][Display]="block";

		//Total seconds of Voicemail
		$module[TotalSecondVoicemail][Value]=hexdec(substr($detailStat,102,8));
		$module[TotalSecondVoicemail][Color]="#0000ff";
		$module[TotalSecondVoicemail][Display]="block";
		
		//Average seconds of Voicemail
		$module[AverageSecondVoicemail][Value]=hexdec(substr($detailStat,110,8));
		$module[AverageSecondVoicemail][Color]="#0000ff";
		$module[AverageSecondVoicemail][Display]="block";
		
		//SMPP State
		$value=hexdec(substr($detailStat,118,2));
		if($value > 0)
		{
			$module[SMPPState][Value]="Established";
			$module[SMPPState][Color]="#0000ff";
		}
		else
		{
			$module[SMPPState][Value]="Not established";
			$module[SMPPState][Color]="#000000";
		}
		$module[AverageSecondVoicemail][Display]="block";
		
		break;
	//TMG
	case 391:
	//AMRMG
	case 392:
	//GbC
	case 393:
		//MaxE1Number
		$module[MaxE1Number][Value]=hexdec(substr($detailStat,62,8));
		$module[MaxE1Number][Color]="#0000ff";
		$module[MaxE1Number][Display]="block";
		
		//MaxE1Number
		$module[OnlineUser][Value]=hexdec(substr($detailStat,70,8));
		$module[OnlineUser][Color]="#0000ff";
		$module[OnlineUser][Display]="block";
		
		//Serial Number
		$module[SerialNumber][Value]=substr($detailStat,78,8);
		$module[SerialNumber][Color]="#000000";
		$module[SerialNumber][Display]="block";
				
		break;
	//MCA
	case 394:
		//Serial Number
		$module[SerialNumber][Value]=substr($detailStat,78,8);
		$module[SerialNumber][Color]="#000000";
		$module[SerialNumber][Display]="block";
		break;
	//SMSC
	case 350:
		//License
		$module[License][Value]=hexdec(substr($detailStat,62,8));
		$module[License][Color]="#0000ff";
		$module[License][Display]="block";
		
		//User
		$module[User][Value]=hexdec(substr($detailStat,70,8));
		$module[User][Color]="#0000ff";
		$module[User][Display]="block";
		
		//SMPP Link
		$smpp_link_status_color=array(0=>"#aeaeae",1=>"#000000",2=>"#00ff00",3=>"#0000ff",4=>"#ff00ff");
		$smpp_link_status_label=array(0=>"Not Init",1=>"Idle",2=>"Waiting",3=>"Established",4=>"Suspend");
		$smpp_link_status_pos=47;
		$smpp_link_status_len=32;
		$smpp_link_status_hex=substr($detailStat,$smpp_link_status_pos*2,$smpp_link_status_len*2);
		//smpp link alias
		$smpp_link_alias_oid="2.2.1.1.2";
		//oidwhere
		$levelArr=explode('.',$smpp_link_alias_oid);
		for($j=0;$j<sizeof($levelArr);$j++){
			$levelNo=$j+1;
			${"level_$levelNo"}=$levelArr[$j];

			if($j == 0){
				$levelWhere ="level_$levelNo='${"level_$levelNo"}'";
			}else{
				$levelWhere .=" AND level_$levelNo='${"level_$levelNo"}'";
			}
		}
		for($i=0;$i<$smpp_link_status_len;$i++)
		{
			$module[SMPPLink][$i][Name][Value]="&nbsp;";
		}
		
		$sql="select * from OBJ_260.param_9 where $levelWhere ";
		$res=@mysqli_query($pubConn,$sql);
		//echo "$sql<br>";
		while($row=@mysqli_fetch_array($res))
		{
			$instanceNo=$row[instanceNo]+0;
			$module[SMPPLink][$instanceNo][Name][Value]="[{$row[initValue]}]";
			//echo "$instanceNo-{$row[initValue]}<br>";
		}
		
		for($row=0;$row<4;$row++)
		{
			for($col=0;$col<8;$col++)
			{
				$no=$row*8+$col;
				$status=substr($smpp_link_status_hex,$no*2,2);
				$istatus=hexdec($status)+0;
				if($istatus>=0&&$istatus<5)
				{
					$module[SMPPLink][$no][Status][Value]=$smpp_link_status_label[$istatus];
					$module[SMPPLink][$no][Status][Color]=$smpp_link_status_color[$istatus];
				}
				else
				{
					$module[SMPPLink][$no][Status][Value]="--";
					$module[SMPPLink][$no][Status][Color]="#000000";
				}
			}
		}
		break;
	//IWF
	case 384:
		//License
		$module[License][Value]=hexdec(changeByteOrder(substr($detailStat,62,8)));
		$module[License][Color]="#0000ff";
		$module[License][Display]="block";
		
		//User
		$module[User][Value]=hexdec(changeByteOrder(substr($detailStat,70,8)));
		$module[User][Color]="#0000ff";
		$module[User][Display]="block";
		
		break;
	//VIM
	case 389:
		//Used Count
		$module[UsedCount][Value]=hexdec(substr($detailStat,86,4));
		$module[UsedCount][Color]="#0000ff";
		$module[UsedCount][Display]="block";
		break;
	default:
		break;
	}

	return $module;
}


function GetPlatInfo($conf,$sysNo)
{
	global $pubConn;
	$sql="select detailStat from OMC_PUB.sysStat where sysTypeNo=200 and sysNo={$conf[PlatNo]} and subSysNo=$sysNo ";
	//echo "$sql<br>";
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	if($num != 1)
	{
		return 0;
	}

	$row=@mysqli_fetch_array($res);
	$baseStat=$row[detailStat];
	$compStat=substr($baseStat,38);
	$compStatLen=strlen($compStat)-1;
	//echo "$compStat<br>";
	$index=0;
	$i=0;
	while($i<$compStatLen)
	{
		$tmp=substr($compStat,$i,4);
		$component[$index][ID]=$tmp+0;
		$i+=4;
		$tmp=substr($compStat,$i,4);
		$component[$index][Length]=hexdec($tmp);
		$i+=4;
		$component[$index][Content]=substr($compStat,$i,$component[$index][Length]*2);
		$i+=$component[$index][Length]*2;
		$index++;
	}
	
	//echo "<pre>";
	//print_r($component);
	//echo "</pre>";
	if($component[8][Length] > 0)
	{
		$snmp_hb=$component[8][Content];
		//echo "{$component[8][Length]}<br>$snmp_hb<br>";
		
		//Start Time
		$pos=0;
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		
		$plat[StartTime][Value]=date("Y-m-d H:i:s",$tmpValue);
		$plat[StartTime][Color]="#0000ff";
		$plat[StartTime][Display]="block";
		$pos+=8;
		
		//CPU Use Rate
		$tmpValue=100-hexdec(substr($snmp_hb,$pos,2));
		$plat[CPURate][Value]="{$tmpValue}%";
		$plat[CPURate][Color]="#000000";
		$plat[CPURate][Display]="block";
		
		
		
		//CPU Use Rate Process Num
		$plat[CPURatePN][Value]=floor($tmpValue/10);
		$plat[CPURatePN][Color]="#0000ff";
		$plat[CPURatePN][Display]="Rect";
		$pos+=2;
		
		//Physical Memory Used/Total
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue2=floor(($tmpValue/$tmpValue1)*100);

		$plat[PMTotalRate][Value]="{$tmpValue2}%";
		$plat[PMTotalRate][Color]="#000000";
		$plat[PMTotalRate][Display]="block";
		
		$plat[PMTotalRateV][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
		$plat[PMTotalRateV][Color]="#000000";
		$plat[PMTotalRateV][Display]="block";
		
		$plat[PMTotalRatePN][Value]=floor($tmpValue2/10);
		$plat[PMTotalRatePN][Color]="#0000ff";
		$plat[PMTotalRatePN][Display]="Rect";
		
		//Physical Memory Used/Swap
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$tmpValue2=floor(($tmpValue/$tmpValue1)*100);
		
		$plat[PMSwapRate][Value]="{$tmpValue2}%";
		$plat[PMSwapRate][Color]="#000000";
		$plat[PMSwapRate][Display]="block";
		
		$plat[PMSwapRateV][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
		$plat[PMSwapRateV][Color]="#000000";
		$plat[PMSwapRateV][Display]="block";
		
		$plat[PMSwapRatePN][Value]=floor($tmpValue2/10);
		$plat[PMSwapRatePN][Color]="#0000ff";
		$plat[PMSwapRatePN][Display]="Rect";
		
		//Physical Memory Buffers
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$plat[PMBuffers][Value]=(floor($tmpValue/1024))."M";
		$plat[PMBuffers][Color]="#000000";
		$plat[PMBuffers][Display]="block";
		
		//Physical Memory Cached
		$tmpValue=hexdec(substr($snmp_hb,$pos,8));
		$pos+=8;
		$plat[PMCached][Value]=(floor($tmpValue/1024))."M";
		$plat[PMCached][Color]="#000000";
		$plat[PMCached][Display]="block";
		
		//Harddisk
		$tmpValue=hexdec(substr($snmp_hb,$pos,2));
		$pos+=2;
		$plat[HDNum]=$tmpValue;
		for($i=0;$i<$plat[HDNum];$i++)
		{
			$tmpValue=hexdec(substr($snmp_hb,$pos,2));
			$pos+=2;
			$path_len=$tmpValue;
			$path="";
			for($j=0;$j<$path_len;$j++)
			{
				$path.=chr(hexdec(substr($snmp_hb,$pos,2)));
				$pos+=2;
			}
			$plat[HD][$i][Path][Value]="($path)";
			$plat[HD][$i][Path][Color]="#000000";
			$plat[HD][$i][Path][Display]="block";
			
			$tmpValue=hexdec(substr($snmp_hb,$pos,8));
			$pos+=8;
			$tmpValue1=hexdec(substr($snmp_hb,$pos,8));
			$pos+=8;
			
			$tmpValue2=floor(($tmpValue/$tmpValue1)*100);
			$plat[HD][$i][PN][Value]=floor($tmpValue2/10);
			$plat[HD][$i][PN][Color]="#0000ff";
			$plat[HD][$i][PN][Display]="Rect";
			
			$plat[HD][$i][V][Value]=(floor($tmpValue/1024))."M/".(floor($tmpValue1/1024))."M";
			$plat[HD][$i][V][Color]="#000000";
			$plat[HD][$i][V][Display]="block";
			
			$plat[HD][$i][Rate][Value]="{$tmpValue2}%";
			$plat[HD][$i][Rate][Color]="#000000";
			$plat[HD][$i][Rate][Display]="block";
		}
	}
	

	return $plat;
}

function GetProcessLabel($pn)
{
	$sign="��";
	$label="";
	for($i=0;$i<$pn;$i++)
		$label.=$sign;
	return $label;
}

function GetLevel($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 GetDetailPlatInfo($sysNo,$subSysNo,$component_show_id)
{
	$sql="select * from OMC_PUB.sysInfo where sysTypeNo=200 and sysNo={$sysNo} and subSysNo={$subSysNo} ";
	//echo "$sql<br>";
	
	$res=mysqli_query($pubConn,$sql);
	 
	//$res=mysql_query($sql,$link);
   
  $num=mysqli_num_rows($res);

	if($num != 1)
	{
		return 0;
	}
	
	$row=@mysqli_fetch_array($res);
	$refresh_time=$row[updateTime];
	$due_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-60,date("m"),date("d"),date("Y")));
	$ove_date=date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")+60,date("m"),date("d"),date("Y")));
	
	
	
	if($refresh_time < $due_date || $refresh_time > $ove_date)
	{
		$detailPlatInfo[RefreshTime][Value]="$refresh_time";
		$detailPlatInfo[RefreshTime][Color]="#ff0000";
		$valid_time=0;
	}
	else
	{
		$detailPlatInfo[RefreshTime][Value]="$refresh_time";
		$detailPlatInfo[RefreshTime][Color]="#0000ff";
		$valid_time=1;
	}
	
	$detailPlatInfo[IPAddress][Value]=$row[ip];
	$detailPlatInfo[IPAddress][Color]="#000000";


//����

$status=$row[baseStat];
if($valid_time && $status)
{
  $detailPlatInfo[Application][Status][Value]="Y";
	$detailPlatInfo[Application][Status][Color]="#0000FF";	
}	
else
{
  $detailPlatInfo[Application][Status][Value]="N";
	$detailPlatInfo[Application][Status][Color]="#000000";	
}	

//����	





	$sql="select * from OMC_PUB.sysStat where sysTypeNo=200 and sysNo={$sysNo} and subSysNo={$subSysNo} ";
	$res=mysqli_query($pubConn,$sql);
	$num=mysqli_num_rows($res);
	
	
	if($num < 1)
	{
		return 0;
	}
	$row=@mysqli_fetch_array($res);
	$baseStat=$row[detailStat];
	$compStat=substr($baseStat,38);
	$compStatLen=strlen($compStat)-1;
	//echo "$compStat<br>";
	$index=0;
	$i=0;
	
	
	
	//����
	$version_string=substr($row[detailStat],46,6);
	if(strlen($version_string) < 6)
	{
	  $detailPlatInfo[version][Status][Value]="--";
	}
	else
	{
		$detailPlatInfo[version][Status][Value]=(substr($version_string,0,2)+0).".".substr($version_string,2,2).".".substr($version_string,4,2);
	  $detailPlatInfo[version][Status][Color]="#0000FF";
	}
		
	//����
	
	
	
	
	
	while($i<$compStatLen)
	{
		$tmp=substr($compStat,$i,4);
		$component[$index][ID]=$tmp+0;
		$i+=4;
		$tmp=substr($compStat,$i,4);
		$component[$index][Length]=hexdec($tmp);
		$i+=4;
		$component[$index][Content]=substr($compStat,$i,$component[$index][Length]*2);
		$i+=$component[$index][Length]*2;
		$index++;
	}
	if(0)
	{
		echo "<pre>";
		print_r($component);
		echo "</pre>";
	}
	
	//IPTRANS
	$component_id=0;
	if($component[$component_id][Length] > 0)
	{
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[IPTRANS][Version][Value]=$newValue;
		$detailPlatInfo[IPTRANS][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 1)
		{
			$detailPlatInfo[IPTRANS][Status][Value]="Y";
			$detailPlatInfo[IPTRANS][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[IPTRANS][Status][Value]="N";
			$detailPlatInfo[IPTRANS][Status][Color]="#FF0000";
		}
		$detail_flag=0;
		if($component_show_id == $component_id)
		{
			$value=substr($component[$component_id][Content],8,8);
			$value=hexdec($value);
			$value=decbin($value);
			$value=omc_keep_length($value,"0",32);
			$test="";
			for($i=0;$i<32;$i++)
			{
				if($value[$i] == "1")
				{
					$detailPlatInfo[IPTRANS][Port][$i][Status][Value]="Y";
					$detailPlatInfo[IPTRANS][Port][$i][Status][Color]="#0000FF";
				}
				else
				{
					$detailPlatInfo[IPTRANS][Port][$i][Status][Value]="--";
					$detailPlatInfo[IPTRANS][Port][$i][Status][Color]="#000000";
				}
			}
		}
	}
	else
	{
		$detailPlatInfo[IPTRANS][Status][Value]="--";
		$detailPlatInfo[IPTRANS][Status][Color]="#000000";
	}
	
	//MTP3
	$component_id=1;
	if($component[$component_id][Length] > 0)
	{
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[MTP3][Version][Value]=$newValue;
		$detailPlatInfo[MTP3][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 1)
		{
			$detailPlatInfo[MTP3][Status][Value]="Y";
			$detailPlatInfo[MTP3][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[MTP3][Status][Value]="N";
			$detailPlatInfo[MTP3][Status][Color]="#FF0000";
		}
	}
	else
	{
		$detailPlatInfo[MTP3][Status][Value]="--";
		$detailPlatInfo[MTP3][Status][Color]="#000000";
	}
	
	//SCCP
	$component_id=2;
	if($component[$component_id][Length] > 0)
	{ 
		
		$detailPlatInfo[SCCP][Status][sum]=$component[$component_id][Length]-4;
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[SCCP][Version][Value]=$newValue;
		$detailPlatInfo[SCCP][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 2)
		{
			$detailPlatInfo[SCCP][Status][Value]="Y";
			$detailPlatInfo[SCCP][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[SCCP][Status][Value]="N";
			$detailPlatInfo[SCCP][Status][Color]="#FF0000";
		}
		if($component_show_id == $component_id)
		{
			for($i=8;$i<$component[$component_id][Length]*2;$i++)
			{
				if($i%2 == 0)
				{
					$value=hexdec(substr($component[$component_id][Content],$i,2));
					$detailPlatInfo[SCCP][LocalNode][$value][Flag]=1;
					$instanceNo=omc_keep_length($value,"0",4);
					$sql_find="select initValue from OBJ_223.param_{$sysNo} where level_1=2 and level_2=2 and level_3=1 and level_4=1 and level_5=2 and level_6=0 and instanceNo='$instanceNo' ";
					$res_find=mysqli_query($pubConn,$sql_find);
					$num_find=mysqli_num_rows($res_find);
					if($num_find < 1)
						continue;
					$row_find=@mysqli_fetch_array($res_find);
					$detailPlatInfo[SCCP][LocalNode][$value][Value]=trim($row_find[initValue])."&nbsp;";
					$detailPlatInfo[SCCP][LocalNode][$value][Value1]=trim($row_find[initValue]);
					$detailPlatInfo[SCCP][LocalNode][$value][Color]="#000000";
					
				}
			}
		}
	}
	else
	{
		$detailPlatInfo[SCCP][Status][Value]="--";
		$detailPlatInfo[SCCP][Status][Color]="#000000";
	}
	
	//TCAP
	$component_id=3;
	if($component[$component_id][Length] > 0)
	{
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[TCAP][Version][Value]=$newValue;
		$detailPlatInfo[TCAP][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 1)
		{
			$detailPlatInfo[TCAP][Status][Value]="Y";
			$detailPlatInfo[TCAP][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[TCAP][Status][Value]="N";
			$detailPlatInfo[TCAP][Status][Color]="#FF0000";
		}
		if($component_show_id == $component_id)
		{
			$detailPlatInfo[TCAP][CurrentUsedDialogueID][Value]=hexdec(substr($component[$component_id][Content],8,4));
			$detailPlatInfo[TCAP][CurrentUsedDialogueID][Color]="#000000";
			$detailPlatInfo[TCAP][MaxUsedDialogueID][Value]=hexdec(substr($component[$component_id][Content],12,4));
			$detailPlatInfo[TCAP][MaxUsedDialogueID][Color]="#000000";
		}
	}
	else
	{
		$detailPlatInfo[TCAP][Status][Value]="--";
		$detailPlatInfo[TCAP][Status][Color]="#000000";
	}
	
	//SNMP
	$component_id=4;
	if($component[$component_id][Length] > 0)
	{
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[SNMP][Version][Value]=$newValue;
		$detailPlatInfo[SNMP][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 1)
		{
			$detailPlatInfo[SNMP][Status][Value]="Y";
			$detailPlatInfo[SNMP][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[SNMP][Status][Value]="N";
			$detailPlatInfo[SNMP][Status][Color]="#FF0000";
		}
		if($component_show_id == $component_id)
		{
			$detailPlatInfo[SNMP][TrapFuncCount][Value]=hexdec(substr($component[$component_id][Content],8,2));
			$detailPlatInfo[SNMP][TrapFuncCount][Color]="#000000";
			$detailPlatInfo[SNMP][SetFuncCount][Value]=hexdec(substr($component[$component_id][Content],10,2));
			$detailPlatInfo[SNMP][SetFuncCount][Color]="#000000";
			
			$detailPlatInfo[SNMP][GetFuncCount][Value]=hexdec(substr($component[$component_id][Content],12,2));
			$detailPlatInfo[SNMP][GetFuncCount][Color]="#000000";
			$detailPlatInfo[SNMP][RspFuncCount][Value]=hexdec(substr($component[$component_id][Content],14,2));
			$detailPlatInfo[SNMP][RspFuncCount][Color]="#000000";
		}
	}
	else
	{
		$detailPlatInfo[SNMP][Status][Value]="--";
		$detailPlatInfo[SNMP][Status][Color]="#000000";
	}
	
	
	//DEBUG
	$component_id=5;
	if($component[$component_id][Length] > 0)
	{
		$value=substr($component[$component_id][Content],0,6);
		$newValue=(substr($value,0,2)-0).".".substr($value,2,2).".".substr($value,4,2);
		$detailPlatInfo[DEBUG][Version][Value]=$newValue;
		$detailPlatInfo[DEBUG][Version][Color]="#000000";
		
		$value=hexdec(substr($component[$component_id][Content],6,2));
		if($value == 1)
		{
			$detailPlatInfo[DEBUG][Status][Value]="Y";
			$detailPlatInfo[DEBUG][Status][Color]="#0000FF";
		}
		else
		{
			$detailPlatInfo[DEBUG][Status][Value]="N";
			$detailPlatInfo[DEBUG][Status][Color]="#FF0000";
		}
		if($component_show_id == $component_id)
		{
			$value=hexdec(substr($component[$component_id][Content],8,6));
			$value=decbin($value);
			$value=omc_keep_length($value,"0",24);
			for($i=0;$i<24;$i++)
			{
				if($value[$i] == "1")
				{
					$detailPlatInfo[DEBUG][Module][$i][Value]="Y";
					$detailPlatInfo[DEBUG][Module][$i][Color]="#0000FF";
				}
				else
				{
					$detailPlatInfo[DEBUG][Module][$i][Value]="--";
					$detailPlatInfo[DEBUG][Module][$i][Color]="#000000";
				}
			}
		}
	}
	else
	{
		$detailPlatInfo[DEBUG][Status][Value]="--";
		$detailPlatInfo[DEBUG][Status][Color]="#000000";
	}
	
	//SMPP
	$component_id=9;
	if($component[$component_id][Length] > 0)
	{
		$detailPlatInfo[SMPP][Status][Value]="Y";
		$detailPlatInfo[SMPP][Status][Color]="#0000FF";
		if($component_show_id == $component_id)
		{
			$binstr="";
			for($i=0;$i<8;$i++)
			{
				$value=hexdec(substr($component[$component_id][Content],$i*2,2));
				$value=decbin($value);
				$value=omc_keep_length($value,"0",8);
				$binstr.=$value;
			}
			
			for($i=0;$i<32;$i++)
			{
				$value=substr($binstr,$i*2,2);
				$value=bindec($value);
				$detailPlatInfo[SMPP][SMPPLink][$i][Value]=$value;
			}
		}
	}
	else
	{
		$detailPlatInfo[SMPP][Status][Value]="--";
		$detailPlatInfo[SMPP][Status][Color]="#000000";
	}
													 
	if(0)
	{
		echo "<pre>";
		print_r($detailPlatInfo);
		echo "</pre>";
	}
	return $detailPlatInfo;
}
?>

