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

View File

@@ -0,0 +1,329 @@
<?php
require("../../inc/lib.inc");
?>
<?php
$maxRowPerPage=16;
$mtp3_systypeno=222;
$plat_systypeno=200;
$mss_platno=9;
$mtp3_modid=1;
$linkset_index_name="lsIndex";
$linkset_title_name="lsTitle";
$linkset_status_name="lsStatus";
$link_index_name="lkIndex";
$link_title_name="lkTitle";
$link_status_name="lkLinkStatus";
$link_lsID_name="lkLinkSetID";
$field_sep=",";
$line_sep=";";
global $OMC_server;
$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "OBJ_".$mtp3_systypeno);
$current_page_no=$_REQUEST['current_page_no'];
function GetOIDByName($sysTypeNo,$name)
{
global $mss_platno,$plat_systypeno,$OMC_server;
$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "OBJ_".$sysTypeNo);
$database="OBJ_".$sysTypeNo.".paramConf";
$sql="select * from $database where name_2 like '%$name%' ";
$res=@mysqli_query($objDbConn,$sql);
$row=@mysqli_fetch_array($res);
$oids="";
for($i=1;$i<=10;$i++)
{
$tmpN="level_".$i;
$tmpV=$row[$tmpN]+0;
if($tmpV == 0)
break;
$oids.=$tmpV.".";
}
if($i>1)
$oids=substr($oids,0,strlen($oids)-1);
return $oids;
}
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"}'";
}
}
$levelNo+=1;
if($levelNo<=10)
$levelWhere.=" AND level_$levelNo=0 ";
return($levelWhere);
}
function getLinkInfo($table,$titleoid,$statusoid,$instance)
{
global $OMC_server,$mtp3_systypeno;
$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "OBJ_".$mtp3_systypeno);
$instanceNo=omc_keep_length($instance,"0",4);
$tmpwhere=getLevel($titleoid);
$sql="select * from $table where $tmpwhere and instanceNo = '$instanceNo' ";
//echo "sql=$sql<br>";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
if($num == 0)
$linkInfo[Title]="";
else
{
$row=@mysqli_fetch_array($res);
$linkInfo[Title]=$row[initValue];
}
$tmpwhere=getLevel($statusoid);
$sql="select * from $table where $tmpwhere and instanceNo = '$instanceNo' ";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
if($num == 0)
$linkInfo[Status]=0;
else
{
$row=@mysqli_fetch_array($res);
$linkInfo[Status]=$row[initValue]+0;
}
return $linkInfo;
}
function getStatusByHeartbeat()
{
global $mss_platno,$plat_systypeno,$OMC_server;
$pubConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'], "OMC_PUB");
$sql="select * from OMC_PUB.sysStat where sysTypeNo=$plat_systypeno and sysNo=$mss_platno order by updateTime desc ";
$res=@mysqli_query($pubConn,$sql);
$num=mysqli_num_rows($res);
if($num == 0)
return $StatusSet;
$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++;
}
if($component[1][Length] == 0)
return $StatusSet;
$mtp3_hb=$component[1][Content];
$pos=0;
$link_hb=substr($mtp3_hb,8,256*2);
$linkset_hb=substr($mtp3_hb,520,128*2);
for($i=0;$i<256;$i++)
{
$tmpi=hexdec(substr($link_hb,$i*2,2));
$tmpb=omc_keep_length(decbin($tmpi),"0",8);
$tmpb=strrev($tmpb);
for($j=0;$j<4;$j++)
{
$tmp2bit=strrev(substr($tmpb,$j*2,2));
$StatusSet[LinkStatus][$i*4+$j]=bindec($tmp2bit);
}
}
for($i=0;$i<128;$i++)
{
$tmpi=hexdec(substr($linkset_hb,$i*2,2));
$tmpb=omc_keep_length(decbin($tmpi),"0",8);
$tmpb=strrev($tmpb);
for($j=0;$j<4;$j++)
{
$tmp2bit=strrev(substr($tmpb,$j*2,2));
$tt=$i*4+$j;
$yy=bindec($tmp2bit);
$StatusSet[LinkSetStatus][$i*4+$j]=bindec($tmp2bit);
}
}
return $StatusSet;
}
?>
<?php
$mtp3_param_table="OBJ_".$mtp3_systypeno.".param_".$mss_platno;
$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'],"OBJ_".$mtp3_systypeno);
$linkset_index_oid=GetOIDByName($mtp3_systypeno,$linkset_index_name);
$linkset_title_oid=GetOIDByName($mtp3_systypeno,$linkset_title_name);
$linkset_status_oid=GetOIDByName($mtp3_systypeno,$linkset_status_name);
$link_index_oid=GetOIDByName($mtp3_systypeno,$link_index_name);
$link_title_oid=GetOIDByName($mtp3_systypeno,$link_title_name);
$link_status_oid=GetOIDByName($mtp3_systypeno,$link_status_name);
$link_lsID_oid=GetOIDByName($mtp3_systypeno,$link_lsID_name);
$response="";
//get the page list
$tmpwhere=getLevel($linkset_index_oid);
$sql="select * from $mtp3_param_table where $tmpwhere ";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
$page_count=ceil($num/$maxRowPerPage);
$response.="page_count".$field_sep.$page_count.$line_sep;
//get the linkset index
$tmpwhere=getLevel($linkset_index_oid);
$from=$current_page_no * $maxRowPerPage;
$sql="select * from $mtp3_param_table where $tmpwhere order by instanceNo LIMIT $from, $maxRowPerPage ";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
$linksetCount=$num;
//system("echo '$sql' >> /tmp/test.txt");
if($num > 0)
$response.="layer".$field_sep."blank_row_id".$field_sep."hide".$line_sep;
else
$response.="layer".$field_sep."blank_row_id".$field_sep."show".$line_sep;
for($index=0;$index<$maxRowPerPage;$index++)
{
//system("echo 'linksetCount=$linksetCount' >> /tmp/test.txt");
if($index < $linksetCount)
$response.="layer".$field_sep."row_id_{$index}".$field_sep."show".$line_sep;
else
$response.="layer".$field_sep."row_id_{$index}".$field_sep."hide".$line_sep;
}
$linkset_id_cond=" and (";
for($index=0;$index < $num;$index++)
{
$row=@mysqli_fetch_array($res);
$linkset[$index][Instance]=$row[instanceNo]+0;
$linkset_id_cond.=" initValue={$linkset[$index][Instance]} ";
if($index != ($num-1))
$linkset_id_cond.=" or ";
$linkset[$index][LinkIndex]=0;
$index_mirror[$linkset[$index][Instance]][Index]=$index;
}
$linkset_id_cond.=") ";
if($num == 0)
$linkset_id_cond="";
$statusSet=getStatusByHeartbeat();
//get linkset status and title
$tmpwhere=getLevel($linkset_title_oid);
$from=$current_page_no * $maxRowPerPage;
$sql="select * from $mtp3_param_table where $tmpwhere order by instanceNo LIMIT $from, $maxRowPerPage ";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
for($index=0;$index < $num;$index++)
{
$row=@mysqli_fetch_array($res);
$instance=$row[instanceNo]+0;
$pos=$index_mirror[$instance][Index];
$linkset[$index][Title]=$row[initValue];
}
$tmpwhere=getLevel($linkset_status_oid);
$from=$current_page_no * $maxRowPerPage;
$sql="select * from $mtp3_param_table where $tmpwhere order by instanceNo LIMIT $from, $maxRowPerPage ";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
for($index=0;$index < $num;$index++)
{
$row=@mysqli_fetch_array($res);
$instance=$row[instanceNo]+0;
$pos=$index_mirror[$instance][Index];
//$linkset[$index][Status]=$row[initValue]+0;
$linkset[$index][Status]=$statusSet[LinkSetStatus][$instance]+0;
}
$status_value=array(0=>"N",1=>"Y",2=>"I",3=>"--");
$status_color=array(0=>"#ff0000",1=>"#0000ff",2=>"#cecece",3=>"#000000");
for($index=0;$index<$linksetCount;$index++)
{
if(strlen($linkset[$index][Title])>0)
$value=$linkset[$index][Instance]."[".$linkset[$index][Title]."]";
else
$value=$linkset[$index][Instance];
$response.="obj".$field_sep."ls_title_id_{$index}".$field_sep.$value.$field_sep."#000000".$line_sep;
$value=$linkset[$index][Status]+0;
$response.="obj".$field_sep."ls_status_id_{$index}".$field_sep.$status_value[$value].$field_sep.$status_color[$value].$line_sep;
}
//get link status
//echo "AAA=$link_lsID_oid<br>";
$tmpwhere=getLevel($link_lsID_oid);
$from=$current_page_no * $maxRowPerPage;
$sql="select * from $mtp3_param_table where $tmpwhere $linkset_id_cond order by instanceNo asc ";
//echo "SSSSS=$sql<br>";
$res=@mysqli_query($objDbConn,$sql);
$num=mysqli_num_rows($res);
for($index=0;$index<$num;$index++)
{
$row=@mysqli_fetch_array($res);
$ls_instance=$row[initValue]+0;
$lk_instance=$row[instanceNo]+0;
$ls_index=$index_mirror[$ls_instance][Index];
$lk_index=$linkset[$ls_index][LinkIndex];
$lkInfo=getLinkInfo($mtp3_param_table,$link_title_oid,$link_status_oid,$lk_instance);
$value=$lk_instance;
//$color=$status_color[$lkInfo[Status]];
$color=$status_color[$statusSet[LinkStatus][$lk_instance]];
$response.="obj".$field_sep."lk_status_id_{$ls_index}_{$lk_index}".$field_sep."{$value}".$field_sep."{$color}".$line_sep;
//$response.="title".$field_sep."lk_title_id_{$ls_index}_{$lk_index}".$field_sep."{$lkInfo[Title]}".$line_sep;
$linkset[$ls_index][LinkIndex]++;
}
for($index=0;$index<$num;$index++)
{
for($j=$linkset[$index][LinkIndex];$j<$maxRowPerPage;$j++)
{
$response.="obj".$field_sep."lk_status_id_{$index}_{$j}".$field_sep."--".$field_sep."#000000".$line_sep;
//$response.="obj".$field_sep."lk_status_id_{$index}_{$j}".$field_sep."--".$line_sep;
}
}
$response=substr($response,0,strlen($response)-1);
//system("date >> /tmp/test.txt");
echo $response;
?>

View File

@@ -0,0 +1,195 @@
<?php
//Include the head file
require("../../inc/header.inc");
?>
<script language="JavaScript">
function updateStatus(flag)
{
var current_page_no=document.getElementById('current_page_no').value;
var fixurl="./linksetStatus_deal.php?current_page_no="+current_page_no;
var browserr = navigator.appName;
if(browserr == "Microsoft Internet Explorer")
request_oo = new ActiveXObject("Microsoft.XMLHTTP");
else
request_oo = new XMLHttpRequest();
request_oo.open("GET",fixurl,"false");
request_oo.onreadystatechange=function()
{
getRes();
}
request_oo.send(null);
if(flag == 1)
setTimeout("updateStatus("+flag+")", 10000);
}
function getRes()
{
//not
if(request_oo.readyState == 3)
{
//alert("not finish");
}
if(request_oo.readyState == 4)
{
var response = request_oo.responseText;
//return;
var module=response.split(';');
//alert(document.getElementById('prev_page_count').value)
// var items=module[0].split(',');
// alert(items[1]);
for(pos=0;pos<module.length;pos++)
{
var items=module[pos].split(',');
var types=items[0].replace(/(^\s*)|(\s*$)/g, "");
//alert(types);
if(types == 'obj')
{
var item_id=items[1].replace(/(^\s*)|(\s*$)/g, "");
var item_val=items[2].replace(/(^\s*)|(\s*$)/g, "");
var item_col=items[3].replace(/(^\s*)|(\s*$)/g, "");
if(document.getElementById(item_id) == null)
continue;
document.getElementById(item_id).style.color=item_col;
document.getElementById(item_id).innerHTML=item_val;
}
else if(types == 'title')
{
var item_id=items[1].replace(/(^\s*)|(\s*$)/g, "");
var item_val=items[2].replace(/(^\s*)|(\s*$)/g, "");
document.getElementById(item_id).title=item_val;
}
else if(types == 'page_count')
{
var prev_page_count=document.getElementById('prev_page_count').value;
if(prev_page_count != items[1])
{
var sel_obj=document.getElementById('page_select');
for(i=sel_obj.length-1;i>=0;i--)
{
sel_obj[i]=null;
}
var opt_len=0;
for(i=0;i<items[1];i++)
{
var nam="Linkset "+(i*16)+" - "+(i*16+15);
sel_obj[opt_len]=new Option(nam,i);
opt_len++;
}
document.getElementById('prev_page_count').value=items[1];
}
}
else if(types == 'layer')
{
//alert('layer');
var item_id=items[1].replace(/(^\s*)|(\s*$)/g, "");
var item_val=items[2].replace(/(^\s*)|(\s*$)/g, "");
if(item_val == 'hide')
document.getElementById(item_id).style.display='none';
else
document.getElementById(item_id).style.display='';
}
}
}
}
function changepage()
{
document.getElementById('current_page_no').value=document.getElementById('page_select').value;
updateStatus(0);
}
</script>
<body leftmargin="15" rightmargin="10" onload="javascript:adjust();" onresize="javascript:adjust();" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php
$maxRowPerPage=16;
adjust_head();
adjust_title_head();
echo "<form name=\"statusForm\" method=\"post\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
echo "Status > NSS > LinkSet";
echo "</td>";
echo "<td width=\"50%\" align=\"right\">";
$helpId="1.2.4";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"50%\">";
echo "<select id=\"page_select\" onchange=\"javascript:changepage();\">";
echo "</select>";
echo "</td>";
echo "<td width=\"50%\" align=right>";
echo "<a href=\"$PHP_SELF?clear=1\" target=\"_self\"><img style=\"vertical-align:middle;\" border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";
echo "</td>";
echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();
//echo "<center><font color=blue size=2>Linkset Status</font></center><p>";
echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#FFFFFF\">";
echo "<caption><center><font color=blue size=2>Linkset Status</font></center></caption>";
echo "<tr bgcolor=\"#E6E6E6\">";
echo "<td width=\"10%\" align=\"center\">Name</td>";
echo "<td width=\"6%\" align=\"center\">Status</td>";
echo "<td width=\"84%\" align=\"center\" colspan=\"16\">Links Status</td>";
echo "</tr>";
echo "<tr id=\"blank_row_id\"><td>--</td><td>--</td><td colspan=16>--</td></tr>";
for($i=0;$i<$maxRowPerPage;$i++)
{
echo "<tr id=\"row_id_{$i}\">";
echo "<td>";
echo "<span id=\"ls_title_id_{$i}\">--</span>";
echo "</td>";
echo "<td align=\"center\">";
echo "<span id=\"ls_status_id_{$i}\">--</span>";
echo "</td>";
for($j=0;$j<16;$j++)
{
echo "<td width=\"5%\" id=\"lk_title_id_{$i}_{$j}\">";
echo "<span id=\"lk_status_id_{$i}_{$j}\">--</span>";
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
echo "Remarks: <font color=blue>Y</font> = Available, <font color=red>N</font> = Unavailable, <font color=#CCCCCC>I</font> = Inhibited.";
echo "<input type=hidden value=\"0\" id=\"prev_page_count\">";
echo "<input type=hidden value=\"0\" id=\"current_page_no\">";
echo "</form>";
adjust_content_tail();
?>
<script language="JavaScript">
updateStatus(1);
</script>