972 lines
29 KiB
PHP
Executable File
972 lines
29 KiB
PHP
Executable File
<?php
|
||
function getNameByOID($sysTypeNo,$oidwhere)
|
||
{
|
||
global $objDbConn;
|
||
$tb="OBJ_".$sysTypeNo.".paramConf";
|
||
$sqlstr="select name_2 from $tb where $oidwhere";
|
||
$res = @mysqli_query($objDbConn,$sqlstr);
|
||
$row = @mysqli_fetch_array($res);
|
||
return $row[name_2];
|
||
}
|
||
|
||
function adjustShowName($name)
|
||
{
|
||
$len=strlen($name);
|
||
$result="";
|
||
|
||
if($name[0]>='a' && $name[0]<='z')
|
||
$result.=chr(ord($name[0])-32);
|
||
for($i=1;$i<$len;$i++)
|
||
{
|
||
if($i != 1)
|
||
if($name[$i]>='A' && $name[$i]<='Z' && $name[$i-1]>='a' && $name[$i-1]<='z')
|
||
$result.=" ";
|
||
|
||
if($name[$i]>='A' && $name[$i]<='Z' && $name[$i+1]>='a' && $name[$i+1]<='z' && $name[$i-1]>='A' && $name[$i-1]<='Z')
|
||
$result.=" ";
|
||
|
||
$result.=$name[$i];
|
||
|
||
if(($name[$i]<'0' || $name[$i]>'9')&& ($name[$i+1]>='0' && $name[$i+1]<='9'))
|
||
$result.=" ";
|
||
if(($name[$i]>='0' && $name[$i]<='9')&& ($name[$i+1]<'0' || $name[$i+1]>'9'))
|
||
$result.=" ";
|
||
}
|
||
|
||
$result=str_replace("Table","",$result);
|
||
$result=str_replace("Entry","",$result);
|
||
|
||
return $result;
|
||
}
|
||
|
||
//<2F>û<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
if($language == 'eng'){
|
||
require("../sub_inc/sub_english.inc");
|
||
}else{
|
||
require("../sub_inc/sub_chinese_gb.inc");
|
||
}
|
||
|
||
$buttonStyle = "cursor:pointer; left: 1; top: 2; height: 22; position: relative";
|
||
$nGetComm = 0;
|
||
$nSetComm = 3;
|
||
$nGetBulkComm = 5;
|
||
$nNewEntryComm = 9;
|
||
|
||
$nProcFail = 0;
|
||
$nWaitProc = 1;
|
||
$nInProc = 2;
|
||
$nOutProc = 3;
|
||
|
||
/*************************************************
|
||
Function: // getLevelWhere
|
||
Description: //
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: // oid
|
||
Output: //level where
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function getLevelWhere($objIdStr)
|
||
{
|
||
//echo $objIdStr;
|
||
$levelArr=explode('.',$objIdStr);
|
||
// print_r($levelArr);
|
||
//$test=sizeof($levelArr);
|
||
//echo "test=$test";
|
||
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"}'";
|
||
// echo $levelWhere;
|
||
|
||
}else{
|
||
$levelWhere .=" AND level_$levelNo='${"level_$levelNo"}'";
|
||
}
|
||
}
|
||
//echo $levelWhere;
|
||
return($levelWhere);
|
||
}
|
||
|
||
|
||
/*************************************************
|
||
Function: // ip2byte
|
||
Description: // Transfer ip format to 4bytes HEX string
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: //
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
|
||
function ip2byte($ipStr){
|
||
$DEBUG=0;
|
||
$byteDec = explode('.',$ipStr);
|
||
for($i=0;$i<sizeof($byteDec);$i++){
|
||
if($byteDec[$i]<16)
|
||
$tmpStr="0".dechex($byteDec[$i]);
|
||
else{
|
||
if($byteDec[$i]>255)
|
||
echo "<br>input ip error";
|
||
else
|
||
$tmpStr=dechex($byteDec[$i]);
|
||
}
|
||
$byteStr=$byteStr.$tmpStr;
|
||
}
|
||
|
||
if($DEBUG) echo "<br>byteStr=$byteStr";
|
||
return ($byteStr);
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // translate
|
||
Description: // Transfer the value to string
|
||
// e.g. AdminState=2 --> AdminState=Unlocked
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: //
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function translate($input,$data)
|
||
{
|
||
$found=-1;
|
||
if ($data)
|
||
{
|
||
$items=split("[;=]",$data);
|
||
$no_of_items=count($items);
|
||
|
||
for ($i=0;$i<$no_of_items;$i+=2) {
|
||
if ( $input == $items[$i+1] ) {
|
||
$found=$i;
|
||
break;
|
||
}
|
||
}
|
||
if ($found != -1)
|
||
return($items[$found]);
|
||
else
|
||
//return('Undefined Value ('.$input.')');
|
||
return('--');
|
||
}
|
||
return($input);
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // reCombName
|
||
Description: // Transfer the coding string to normal string
|
||
// e.g. trunkGroup -> Trunk Group;MSRNRange->MSRN Range
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: //
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function reCombName($name){
|
||
$displayFlag=0;
|
||
//$displayName="";
|
||
for($i=0;$i<strlen($name);$i++){
|
||
if($name[$i]>='A'&&$name[$i]<='Z'){
|
||
$displayFlag=1;
|
||
}
|
||
if($displayFlag==1){
|
||
if($name[$i]>='A'&&$name[$i]<='Z'){
|
||
if($i>1){
|
||
if($name[$i-1]>='a'&&$name[$i-1]<='z'){
|
||
if(isset($displayName))
|
||
$displayName=$displayName.' '.$name[$i];
|
||
else
|
||
$displayName=$displayName.$name[$i];
|
||
}else{
|
||
if($name[$i+1]>='a'&&$name[$i+1]<='z')
|
||
$displayName=$displayName.' '.$name[$i];
|
||
else
|
||
$displayName=$displayName.$name[$i];
|
||
}
|
||
}else{
|
||
$displayName=$displayName.$name[$i];
|
||
}
|
||
}else{
|
||
$displayName=$displayName.$name[$i];
|
||
}
|
||
}
|
||
}
|
||
return $displayName;
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // oidSysCommSend
|
||
Description: // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: //
|
||
Output: //
|
||
Return: //<2F>ɹ<EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||
//ʧ<><CAA7>: -1
|
||
Others: //
|
||
*************************************************/
|
||
function oidSysCommSend($sysId,$commType,$objIdStr,$selectedSysId=-1,$instanceNo='')
|
||
{
|
||
//echo "AAA";
|
||
//global $pubDb,$commTable;
|
||
global $STR_CONF_COMMAND_ERR_0000;
|
||
global $STR_CONF_PROMPT_01,$STR_CONF_COMMAND_ERR_0101,$STR_CONF_COMMAND_ERR_0102;
|
||
global $STR_CONF_PROMPT_02,$STR_CONF_COMMAND_ERR_0201,$STR_CONF_COMMAND_ERR_0202;
|
||
global $STR_CONF_PROMPT_03,$STR_CONF_COMMAND_ERR_0301,$STR_CONF_COMMAND_ERR_0302,$STR_CONF_COMMAND_ERR_0303;
|
||
global $STR_CONF_PROMPT_04,$STR_CONF_COMMAND_ERR_0401,$STR_CONF_COMMAND_ERR_0402,$STR_CONF_COMMAND_ERR_0403;
|
||
global $STR_CONF_COMMAND_ERR_9999;
|
||
global $pubConn;
|
||
global $strBack;
|
||
//fj
|
||
$DEBUG = 0;
|
||
//echo "oidSysCommSend($sysId,$commType,$objIdStr,$selectedSysId=-1,$instanceNo='')";
|
||
$info="oidSysCommSend($sysId, $commType, $objIdStr, $selectedSysId, $instanceNo);";
|
||
system("echo '$info' >> /tmp/sysCommand.txt");
|
||
|
||
|
||
//===get the sysTypeNo=====
|
||
$sysIdArr = explode('_',$sysId);
|
||
$sysTypeNo = $sysIdArr[0];
|
||
$sysNo = $sysIdArr[1];
|
||
$subSysNo = $sysIdArr[2];
|
||
|
||
|
||
//========================start insert log===============
|
||
//===get the operate type set or get==
|
||
//opt_type: 0-get object, 1-set, 2-create, 3-delete, 4-get table
|
||
$tmpWhere=getLevelWhere($objIdStr);
|
||
$fieldName=getNameByOID($sysTypeNo,$tmpWhere);
|
||
$showname=trim(adjustShowName($fieldName));
|
||
//echo "showname=$showname<br>";
|
||
$sysName=getSystemNameBySysTypeNo($sysTypeNo);
|
||
if($commType == 0)
|
||
{
|
||
$opt_type=0;
|
||
}
|
||
else if($commType == 5)
|
||
{
|
||
$opt_type=4;
|
||
}
|
||
if($commType == 3)
|
||
{
|
||
if(strstr($fieldName,"RowStatus"))
|
||
$opt_type=3;
|
||
else
|
||
$opt_type=1;
|
||
}
|
||
else if($commType == 9)
|
||
{
|
||
$opt_type=2;
|
||
}
|
||
switch($opt_type)
|
||
{
|
||
//get object
|
||
case 0:
|
||
$logstr="Get $sysName: $showname ".trim($instanceNo);
|
||
break;
|
||
//set object
|
||
case 1:
|
||
$logstr="Set $sysName: $showname ".trim($instanceNo);
|
||
//echo "Set $sysName: $showname ".trim($instanceNo);
|
||
break;
|
||
//create
|
||
case 2:
|
||
$oidwhere=getLevelWhere(substr($objIdStr,0,strlen($objIdStr)-2));
|
||
$tableName=getNameByOID($sysTypeNo,$oidwhere);
|
||
$tableName=str_replace("Entry","",$tableName);
|
||
$showname=trim(adjustShowName($tableName));
|
||
$logstr="Create $sysName: $showname ".trim($instanceNo);
|
||
break;
|
||
//delete
|
||
case 3:
|
||
$oidwhere=getLevelWhere(substr($objIdStr,0,strlen($objIdStr)-2));
|
||
$tableName=getNameByOID($sysTypeNo,$oidwhere);
|
||
$tableName=str_replace("Entry","",$tableName);
|
||
$showname=trim(adjustShowName($tableName));
|
||
$logstr="Delete $sysName: $showname ".trim($instanceNo);
|
||
break;
|
||
case 4:
|
||
$logstr="Get $sysName: $showname";
|
||
break;
|
||
}
|
||
|
||
insertLog($logstr);
|
||
|
||
//$handle=fopen("/tmp/test.txt","a");
|
||
//fwrite($handle,$logstr);
|
||
//fwrite($handle,"\n");
|
||
//fclose($handle);
|
||
//========================end insert log===============
|
||
|
||
$pubDb = 'OMC_PUB';
|
||
$commTable = 'parameterComm';
|
||
$nGetComm = 0;
|
||
$nSetComm = 3;
|
||
$nGetBulkComm = 5;
|
||
$nNewEntryComm = 9;
|
||
$nSubSysParam = 0;
|
||
$nGlobalSubSysParam = 1;
|
||
$nGlobalSysParam = 2;
|
||
|
||
if(checkIndependSystem($sysTypeNo))//Plat
|
||
$paramType = $nGlobalSubSysParam;
|
||
else
|
||
$paramType = $nGlobalSysParam;
|
||
|
||
if($selectedSysId != -1){
|
||
$selectedSysIdArr = explode('_',$selectedSysId);
|
||
$selectedSysTypeNo = $selectedSysIdArr[0];
|
||
$selectedSysNo = $selectedSysIdArr[1];
|
||
$selectedSubSysNo = $selectedSysIdArr[2];
|
||
}
|
||
if($DEBUG) echo"<br>selectedSysId=$selectedSysId";
|
||
if($DEBUG) echo"<br>selectedSysNo=$selectedSysNo";
|
||
if($DEBUG) echo"<br>selectedSubSysNo=$selectedSubSysNo";
|
||
|
||
//step 1: delete overtime and imcompetent command , check the exist command num
|
||
$overTime = date("Y-m-d H:i:s", mktime(date("H"),date("i")-1,date("s"),date("m"),date("d"),date("Y")));
|
||
$delSql = "DELETE FROM $commTable WHERE (commState ='0' OR commState ='3') AND sendTime < '$overTime'
|
||
";
|
||
if($DEBUG) echo"<br>delete command sql = $delSql";
|
||
mysqli_query($pubConn,$delSql);
|
||
echo mysqli_error($pubConn);
|
||
|
||
$overTime = date("Y-m-d H:i:s", mktime(date("H"),date("i")-30,date("s"),date("m"),date("d"),date("Y")));
|
||
$delSql = "DELETE FROM $commTable WHERE sendTime < '$overTime'
|
||
";
|
||
if($DEBUG) echo"<br>delete command sql = $delSql";
|
||
mysqli_query($pubConn,$delSql);
|
||
echo mysqli_error($pubConn);
|
||
|
||
//check the exist command num
|
||
$chkSql = "SELECT commId FROM $commTable";
|
||
if($DEBUG) echo"<br>check exist commands sql = $chkSql";
|
||
$chkResult = mysqli_query($pubConn,$chkSql);
|
||
echo mysqli_error($pubConn);
|
||
$existNum = @mysqli_num_rows($chkResult);
|
||
|
||
//step 2:insert commands into command table
|
||
if($commType == $nSetComm||$commType == $nNewEntryComm)//д<><D0B4><EFBFBD><EFBFBD>
|
||
{
|
||
if($selectedSysId == -1)
|
||
{
|
||
if($sysNo=='99')
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo'
|
||
ORDER BY sysNo,subSysNo,baseStat DESC
|
||
";
|
||
}
|
||
else if($subSysNo=='99')
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo'
|
||
AND sysNo='$sysNo'
|
||
ORDER BY sysNo,subSysNo,baseStat DESC
|
||
";
|
||
}else
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo'
|
||
AND sysNo='$sysNo' AND subSysNo='$subSysNo'
|
||
ORDER BY sysNo,subSysNo,baseStat DESC
|
||
";
|
||
}
|
||
}
|
||
else//ѡ<><D1A1>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ϵͳ
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$selectedSysTypeNo'
|
||
AND sysNo ='$selectedSysNo'
|
||
AND subSysNo='$selectedSubSysNo'
|
||
ORDER BY baseStat DESC
|
||
";
|
||
}
|
||
// fj
|
||
if($DEBUG)
|
||
{
|
||
echo"<br>selSql=$selSql";
|
||
//exit();
|
||
}
|
||
$selResult = mysqli_query($pubConn,$selSql);
|
||
$selRowsNum = mysqli_num_rows($selResult);
|
||
|
||
// fj
|
||
if(0)
|
||
{
|
||
echo "selRowsNum:$selRowsNum existNum:$existNum<br>";
|
||
}
|
||
if($selRowsNum+$existNum>256)
|
||
{
|
||
echo "<br><br><b>Error:$STR_CONF_COMMAND_ERR_0302<br>";
|
||
echo "<b>Prompt:$STR_CONF_PROMPT_03<br>";
|
||
echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
exit();
|
||
}
|
||
|
||
if($selRowsNum > 0)
|
||
{
|
||
while($selRows = mysqli_fetch_array($selResult))
|
||
{
|
||
$sysNo = $selRows[sysNo];
|
||
$subSysNo = $selRows[subSysNo];
|
||
$sendSql="INSERT INTO $commTable
|
||
(commType,sysTypeNo,sysNo,subSysNo,paramType,objId,InstanceNo,commState,sendTime)
|
||
VALUES
|
||
('$commType','$sysTypeNo','$sysNo','$subSysNo','$paramType','$objIdStr','$instanceNo','1',CURRENT_TIMESTAMP)
|
||
";
|
||
// fj
|
||
if($DEBUG)echo"<br>send command sql = $sendSql";
|
||
$sendResult=mysqli_query($pubConn,$sendSql);
|
||
echo mysqli_error($pubConn);
|
||
|
||
$tmpSql = "SELECT commId FROM $commTable
|
||
WHERE sysTypeNo='$sysTypeNo'
|
||
AND sysNo='$sysNo'
|
||
AND subSysNo='$subSysNo'
|
||
AND objId='$objIdStr'
|
||
AND instanceNo='$instanceNo'"
|
||
;
|
||
$tmpResult=mysqli_query($pubConn,$tmpSql);
|
||
echo mysqli_error($pubConn);
|
||
$tmpRows = mysqli_fetch_array($tmpResult);
|
||
$commIdStr .= $tmpRows[commId].'-';
|
||
}
|
||
}
|
||
else
|
||
{
|
||
echo "<br><br><b>Error:$STR_CONF_COMMAND_ERR_0101<br>";
|
||
echo "<b>Prompt:$STR_CONF_PROMPT_01<br>";
|
||
echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
exit();
|
||
}
|
||
|
||
}
|
||
else//<2F><>ϵͳ
|
||
{
|
||
if($paramType != $nSubSysParam)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
{
|
||
if($selectedSysId == -1)
|
||
{
|
||
//get baseStat 0=uninstalled, 1=nomal, 2=warning, 3=error
|
||
//<2F>Ȱ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>ٰ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>,<2C><>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>״̬<D7B4><CCAC><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>С<EFBFBD><D0A1>
|
||
if($sysNo == '99')
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo'
|
||
ORDER BY baseStat DESC,updateTime DESC,sysNo,subSysNo
|
||
";
|
||
}
|
||
else if($subSysNo == '99')
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo' AND sysNo='$sysNo'
|
||
ORDER BY baseStat DESC,updateTime DESC,sysNo,subSysNo
|
||
";
|
||
}
|
||
else
|
||
{
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo'
|
||
AND sysNo='$sysNo' AND subSysNo='$subSysNo'
|
||
ORDER BY baseStat DESC,updateTime DESC,sysNo,subSysNo
|
||
";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//ѡ<><D1A1>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ϵͳ
|
||
$selSql="SELECT sysNo,subSysNo FROM sysInfo
|
||
WHERE sysTypeNo = '$sysTypeNo' AND sysNo='$selectedSysNo' AND subSysNo='$selectedSubSysNo'
|
||
ORDER BY baseStat DESC,updateTime DESC
|
||
";
|
||
}
|
||
|
||
$selResult=mysqli_query($pubConn,$selSql);
|
||
if($DEBUG)
|
||
{
|
||
echo"<br>get system info sql = $selSql";
|
||
|
||
}
|
||
echo mysqli_error($pubConn);
|
||
if(@mysqli_num_rows($selResult) > 0)
|
||
{
|
||
$selRows = @mysqli_fetch_array($selResult);
|
||
$sysNo = $selRows[sysNo];
|
||
$subSysNo = $selRows[subSysNo];
|
||
}
|
||
else
|
||
{
|
||
echo "<br><br><b>Error:$STR_CONF_COMMAND_ERR_0101<br>";
|
||
echo "<b>Prompt:$STR_CONF_PROMPT_01<br>";
|
||
echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
exit();
|
||
}
|
||
}
|
||
|
||
if(1+$existNum>256)
|
||
{
|
||
echo "<br><br><b>Error:$STR_CONF_COMMAND_ERR_0302<br>";
|
||
echo "<b>Prompt:$STR_CONF_PROMPT_03<br>";
|
||
echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
exit();
|
||
}
|
||
|
||
$sendSql="INSERT INTO $commTable
|
||
(commType,sysTypeNo,sysNo,subSysNo,paramType,objId,instanceNo,commState,sendTime)
|
||
VALUES
|
||
('$commType','$sysTypeNo','$sysNo','$subSysNo','$paramType','$objIdStr','$instanceNo','1',CURRENT_TIMESTAMP)
|
||
";
|
||
if($DEBUG)
|
||
echo"<br>send command sql = $sendSql";
|
||
$sendResult=mysqli_query($pubConn,$sendSql);
|
||
echo mysqli_error($pubConn);
|
||
|
||
$tmpSql = "SELECT commId FROM $commTable
|
||
WHERE sysTypeNo='$sysTypeNo'
|
||
AND sysNo='$sysNo'
|
||
AND subSysNo='$subSysNo'
|
||
AND objId='$objIdStr'
|
||
AND instanceNo='$instanceNo'"
|
||
;
|
||
$tmpResult=mysqli_query($pubConn,$tmpSql);
|
||
echo mysqli_error($pubConn);
|
||
$tmpRows = mysqli_fetch_array($tmpResult);
|
||
$commIdStr .= $tmpRows[commId].'-';
|
||
}
|
||
|
||
//step 3:Return commIdStr
|
||
// fj
|
||
if(0)
|
||
{
|
||
$array =debug_backtrace();
|
||
print_r($array);//<2F><><EFBFBD><EFBFBD><EFBFBD>
|
||
}
|
||
if($DEBUG) echo "<br>commIdStr = $commIdStr";
|
||
if($DEBUG) exit();
|
||
return($commIdStr);
|
||
}//end of function oidSysSendComm()
|
||
|
||
|
||
/*************************************************
|
||
Function: // getParam
|
||
Description: // <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>get<65><74>get Bulk<6C><6B><EFBFBD><EFBFBD>
|
||
Calls: // oidSysCommSend,CheckState
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: // $commInfoArr<72><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>͵<EFBFBD>sysId,oid,selectSysId,instanceNo
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
$getParam_showFinishResultFlag=1;
|
||
|
||
function getParam($commInfoArr,$sleep=0){
|
||
global $objDbConn,$pubDb,$nGetComm,$nGetBulkComm,$nGetBulkComm,$DEBUG;
|
||
#fj
|
||
$DEBUG=0;
|
||
if(strlen(trim($pubDb)) == 0)
|
||
$pubDb="OMC_PUB";
|
||
|
||
|
||
for($i =0;$i< sizeof($commInfoArr);$i++){
|
||
$sysIdArr = explode('_',$commInfoArr[$i][sysId]);
|
||
$sysTypeNo = $sysIdArr[0];
|
||
$sysNo = $sysIdArr[1];
|
||
$subSysNo = $sysIdArr[2];
|
||
$tmpWhere=getLevelWhere($commInfoArr[$i][oid]);
|
||
$selSql="SELECT * FROM OBJ_$sysTypeNo.paramConf WHERE $tmpWhere";
|
||
if($DEBUG)
|
||
echo "<br>selSql=$selSql";
|
||
$selResult=mysqli_query($objDbConn,$selSql);
|
||
echo mysqli_error($objDbConn);
|
||
$selRows=mysqli_fetch_array($selResult);
|
||
if(strstr($selRows[desc_2],"Table Parameter")){
|
||
$tmpWhere=getLevelWhere($commInfoArr[$i][oid]);
|
||
if(checkIndependSystem($sysTypeNo))//Plat
|
||
$paraTable="OBJ_".$sysTypeNo.".param_".$sysNo;
|
||
else
|
||
$paraTable="OBJ_".$sysTypeNo.".param_99";
|
||
$delSql="DELETE FROM $paraTable WHERE $tmpWhere AND instanceNo LIKE '{$commInfoArr[$i][instanceNo]}%'";
|
||
//ISSUE-3
|
||
if(checkPlatWhoHaveSubSysNo($sysTypeNo,$sysNo))
|
||
{
|
||
$delSql.=" AND subSysNo='$subSysNo' ";
|
||
}
|
||
if($DEBUG)
|
||
echo "<br>delSql=$delSql";
|
||
mysqli_query($objDbConn,$delSql);
|
||
if($DEBUG)
|
||
echo "<br>table oidSysCommSend({$commInfoArr[$i][sysId]},$nGetBulkComm,{$commInfoArr[$i][oid]},{$commInfoArr[$i][selectSysId]},{$commInfoArr[$i][instanceNo]})<br>";
|
||
$tmpCommIdStr = oidSysCommSend($commInfoArr[$i][sysId],$nGetBulkComm,$commInfoArr[$i][oid],'-1',$commInfoArr[$i][instanceNo]);
|
||
}else{
|
||
if($DEBUG)
|
||
echo "<br>oidSysCommSend({$commInfoArr[$i][sysId]},$nGetComm,{$commInfoArr[$i][oid]},{$commInfoArr[$j][selectSysId]},{$commInfoArr[$j][instanceNo]});";
|
||
$tmpCommIdStr = oidSysCommSend($commInfoArr[$i][sysId],$nGetComm,$commInfoArr[$i][oid],'-1',$commInfoArr[$i][instanceNo]);
|
||
}
|
||
$commIdStr=$commIdStr.$tmpCommIdStr;
|
||
|
||
|
||
|
||
|
||
|
||
flush();
|
||
echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
|
||
ob_flush();
|
||
flush();
|
||
|
||
if($sleep)
|
||
usleep(200000);
|
||
flush();
|
||
|
||
|
||
}
|
||
if($DEBUG) echo "$commIdStr<br>";
|
||
|
||
checkState($commIdStr);
|
||
|
||
for($i =0;$i< sizeof($commInfoArr);$i++){
|
||
$sysIdArr = explode('_',$commInfoArr[$i][sysId]);
|
||
$sysTypeNo = $sysIdArr[0];
|
||
if(checkIndependSystem($sysTypeNo))//Plat
|
||
$paraTable="OBJ_".$sysTypeNo.".param_".$sysNo;
|
||
else
|
||
$paraTable="OBJ_".$sysTypeNo.".param_99";
|
||
$tmpWhere=getLevelWhere($commInfoArr[$i][sysId]);
|
||
$selSql="UPDATE $paraTable SET initValue=readValue WHERE WHERE $tmpWhere";
|
||
$selResult=mysqli_query($objDbConn,$selSql);
|
||
}
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // setParam
|
||
Description: // <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>set<65><74><EFBFBD><EFBFBD>
|
||
Calls: // oidSysCommSend,CheckState
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: // $commInfoArr<72><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>͵<EFBFBD>sysId,oid,selectSysId,instanceNo
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function setParam($commInfoArr){
|
||
global $nSetComm;
|
||
|
||
for($i =0;$i< sizeof($commInfoArr);$i++){
|
||
$sysIdArr = explode('_',$commInfoArr[$i][sysId]);
|
||
$sysTypeNo = $sysIdArr[0];
|
||
$sysNo = $sysIdArr[1];
|
||
$subSysNo = $sysIdArr[2];
|
||
|
||
if($DEBUG) echo "<br>oidSysCommSend({$commInfoArr[$i][sysid]},$nSetComm,{$commInfoArr[$i][oid]},-1,{$commInfoArr[$i][instanceNo]})<br>";
|
||
$tmpCommIdStr = oidSysCommSend($commInfoArr[$i][sysId],$nSetComm,$commInfoArr[$i][oid],'-1',$commInfoArr[$i][instanceNo]);
|
||
$commIdStr=$commIdStr.$tmpCommIdStr;
|
||
}
|
||
if($DEBUG)echo "$commIdStr<br>";
|
||
checkState($commIdStr);
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // checkState
|
||
Description: // <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>ⷢ<EFBFBD><E2B7A2>get/set<65><74><EFBFBD><EFBFBD><EFBFBD>response<73><65>״̬
|
||
Calls: // outPutChkMsg
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: // $commIdStr
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function checkState($commIdStr,$backsrc=''){
|
||
global $pubDb;
|
||
global $pubConn;
|
||
global $maxNum,$remark,$nProcFail,$nWaitProc,$nInProc,$nOutProc;
|
||
global $getParam_showFinishResultFlag;
|
||
//fj
|
||
$DEBUG=0;
|
||
|
||
if(strlen(trim($pubDb)) == 0)
|
||
$pubDb="OMC_PUB";
|
||
$commIdStrArr=explode("-",$commIdStr);
|
||
for($i=0;$i<sizeof($commIdStrArr)-1;$i++){
|
||
if($i==0)
|
||
$tmpWhere="(commId='$commIdStrArr[$i]'";
|
||
else
|
||
$tmpWhere=$tmpWhere." OR commId='$commIdStrArr[$i]'";
|
||
}
|
||
$tmpWhere=$tmpWhere.")";
|
||
|
||
$descArr=getCommdDesc($commIdStr);
|
||
|
||
$i = 0;
|
||
$commTable = "parameterComm";
|
||
while(1){
|
||
if($i > 120){
|
||
$tmpRemark='Timeout';
|
||
$delComm = " DELETE FROM $commTable WHERE $tmpWhere ";
|
||
|
||
// fj
|
||
//echo "delComm:$delComm<br>";
|
||
|
||
mysqli_query($pubConn,$delComm);
|
||
outPutChkMsg($tmpSysTypeNo,$tmpSysNo,'0303','Network is busy or managed object response is too slow',$backsrc,$descArr);
|
||
break;
|
||
}
|
||
|
||
flush();
|
||
echo "<img border=\"0\" src=\"../../images/arrow.gif\" width=\"10\" height=\"10\">";
|
||
ob_flush();
|
||
flush();
|
||
usleep(200000);
|
||
|
||
|
||
$selComm = "SELECT commState,remark,objId,sysTypeNo,sysNo,subSysNo FROM $commTable WHERE $tmpWhere AND commState='$nProcFail'";
|
||
if($DEBUG)
|
||
echo "<br>selComm=$selComm,pubDb=$pubDb";
|
||
|
||
$selRes = mysqli_query($pubConn,$selComm);
|
||
|
||
if(mysqli_num_rows($selRes) > 0){
|
||
$selRow = mysqli_fetch_array($selRes);
|
||
$tmpRemark=$selRow[remark];
|
||
$tmpSysTypeNo=$selRow[sysTypeNo];
|
||
$tmpSysNo=$selRow[sysNo];
|
||
$delComm = " DELETE FROM $commTable WHERE $tmpWhere ";
|
||
// fj
|
||
// echo "<br> delComm:$delComm backsrc:$backsrc mpRemark:$tmpRemark<br>";
|
||
mysqli_query($pubConn,$delComm);
|
||
$tmpRemarkArr=explode(":",$tmpRemark);
|
||
$des="";
|
||
for($ttt=1;$ttt<count($tmpRemarkArr);$ttt++)
|
||
{
|
||
$des.=$tmpRemarkArr[$ttt].",";
|
||
}
|
||
$des=substr($des,0,strlen($des)-1);
|
||
|
||
// fj
|
||
outPutChkMsg($tmpSysTypeNo,$tmpSysNo,$tmpRemarkArr[0],$des,$backsrc,$descArr);
|
||
}
|
||
|
||
$selComm = "SELECT commState,remark FROM $commTable WHERE $tmpWhere AND (commState='$nWaitProc' OR commState='$nInProc')";
|
||
|
||
if($DEBUG)
|
||
echo "<br>selComm=$selComm";
|
||
|
||
$selRes = mysqli_query($pubConn,$selComm);
|
||
if($DEBUG) $tmpNum=mysqli_num_rows($selRes);
|
||
if($DEBUG) echo "<br>tmpNum=$tmpNum";
|
||
|
||
if(mysqli_num_rows($selRes)>0){
|
||
sleep(1);
|
||
$i++;
|
||
continue;
|
||
}
|
||
$delComm = " DELETE FROM $commTable WHERE $tmpWhere ";
|
||
mysqli_query($pubConn,$delComm);
|
||
break;
|
||
}
|
||
if($getParam_showFinishResultFlag)
|
||
echo "<br><font size=4 color=blue>Finished</font><br>";
|
||
for($index=0;$index<$descArr[Count];$index++)
|
||
{
|
||
if(strlen(trim($descArr[$index][SysTypeName])) > 0 && strlen(trim($descArr[$index][TableName])) > 0)
|
||
{
|
||
$log="{$descArr[$index][CommdType]} {$descArr[$index][SysTypeName]}: {$descArr[$index][TableName]} {$descArr[$index][InstanceNo]} successfully";
|
||
insertLog($log);
|
||
}
|
||
}
|
||
}
|
||
|
||
function getNameByOID_sub_config($sysTypeNo,$oidwhere)
|
||
{
|
||
$tb="OBJ_".$sysTypeNo.".paramConf";
|
||
$sqlstr="select name_2 from $tb where $oidwhere";
|
||
$res = @mysqli_query($pubConn,$sqlstr);
|
||
$row = @mysqli_fetch_array($res);
|
||
return $row[name_2];
|
||
}
|
||
|
||
function adjustShowName_sub_config($name)
|
||
{
|
||
$len=strlen($name);
|
||
$result="";
|
||
|
||
if($name[0]>='a' && $name[0]<='z')
|
||
$result.=chr(ord($name[0])-32);
|
||
for($i=1;$i<$len;$i++)
|
||
{
|
||
if($i != 1)
|
||
if($name[$i]>='A' && $name[$i]<='Z' && $name[$i-1]>='a' && $name[$i-1]<='z')
|
||
$result.=" ";
|
||
|
||
if($name[$i]>='A' && $name[$i]<='Z' && $name[$i+1]>='a' && $name[$i+1]<='z' && $name[$i-1]>='A' && $name[$i-1]<='Z')
|
||
$result.=" ";
|
||
|
||
$result.=$name[$i];
|
||
|
||
if(($name[$i]<'0' || $name[$i]>'9')&& ($name[$i+1]>='0' && $name[$i+1]<='9'))
|
||
$result.=" ";
|
||
if(($name[$i]>='0' && $name[$i]<='9')&& ($name[$i+1]<'0' || $name[$i+1]>'9'))
|
||
$result.=" ";
|
||
}
|
||
|
||
$result=str_replace("Table","",$result);
|
||
$result=str_replace("Entry","",$result);
|
||
|
||
return $result;
|
||
}
|
||
|
||
function getCommdDesc($commIdStr)
|
||
{
|
||
$comm=explode("-",$commIdStr);
|
||
$len=count($comm);
|
||
$desc[Count]=$len;
|
||
for($index=0;$index<$len;$index++)
|
||
{
|
||
$sqlstr="select * from OMC_PUB.parameterComm where commId={$comm[$index]} ";
|
||
$res = @mysqli_query($pubConn,$sqlstr);
|
||
$row = @mysqli_fetch_array($res);
|
||
$desc[$index][SysTypeName]=getSystemNameBySysTypeNo($row[sysTypeNo]);
|
||
|
||
$desc[$index][TableName]=getNameByOID_sub_config($row[sysTypeNo],getLevelWhere($row[objId]));
|
||
$desc[$index][TableName]=adjustShowName_sub_config(str_replace("Entry","",$desc[$index][TableName]));
|
||
$desc[$index][InstanceNo]=$row[instanceNo];
|
||
if($row[commType] == 0)
|
||
$desc[$index][CommdType]="Get";
|
||
else if($row[commType] == 3)
|
||
$desc[$index][CommdType]="Set";
|
||
else if($row[commType] == 5)
|
||
$desc[$index][CommdType]="Get";
|
||
else if($row[commType] == 9)
|
||
{
|
||
$oidwhere=getLevelWhere(substr($row[objId],0,strlen($row[objId])-2));
|
||
$tableName=getNameByOID($row[sysTypeNo],$oidwhere);
|
||
$tableName=str_replace("Entry","",$tableName);
|
||
$desc[$index][TableName]=adjustShowName_sub_config($tableName);
|
||
$desc[$index][CommdType]="Create";
|
||
}
|
||
}
|
||
return $desc;
|
||
}
|
||
|
||
/*************************************************
|
||
Function: // outPutChkMsg
|
||
Description: // <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Calls: //
|
||
Called By: //
|
||
Table Accessed: //
|
||
Table Updated: //
|
||
Input: // $sysTypeNo,$sysNo,$Reason=''
|
||
Output: //
|
||
Return: //
|
||
Others: //
|
||
*************************************************/
|
||
function outPutChkMsg($sysTypeNo,$sysNo,$Reason='',$des='',$backsrc='',$descArr)
|
||
{
|
||
global $STR_CONF_COMMAND_ERR_0000;
|
||
global $STR_CONF_PROMPT_01,$STR_CONF_COMMAND_ERR_0101,$STR_CONF_COMMAND_ERR_0102;
|
||
global $STR_CONF_PROMPT_02,$STR_CONF_COMMAND_ERR_0201,$STR_CONF_COMMAND_ERR_0202;
|
||
global $STR_CONF_PROMPT_03,$STR_CONF_COMMAND_ERR_0301,$STR_CONF_COMMAND_ERR_0302,$STR_CONF_COMMAND_ERR_0303;
|
||
global $STR_CONF_PROMPT_04,$STR_CONF_COMMAND_ERR_0401,$STR_CONF_COMMAND_ERR_0402,$STR_CONF_COMMAND_ERR_0403;
|
||
global $STR_CONF_PROMPT_05,$STR_CONF_COMMAND_ERR_0501,$STR_CONF_COMMAND_ERR_0502,$STR_CONF_COMMAND_ERR_0503;
|
||
global $STR_CONF_COMMAND_ERR_0504,$STR_CONF_COMMAND_ERR_0505,$STR_CONF_COMMAND_ERR_0506;
|
||
global $STR_CONF_COMMAND_ERR_0507,$STR_CONF_COMMAND_ERR_0508,$STR_CONF_COMMAND_ERR_0509;
|
||
global $STR_CONF_COMMAND_ERR_0510,$STR_CONF_COMMAND_ERR_0511,$STR_CONF_COMMAND_ERR_0512;
|
||
global $STR_CONF_COMMAND_ERR_0513,$STR_CONF_COMMAND_ERR_0514,$STR_CONF_COMMAND_ERR_0515;
|
||
global $STR_CONF_COMMAND_ERR_0516,$STR_CONF_COMMAND_ERR_0517,$STR_CONF_COMMAND_ERR_0518;
|
||
global $STR_CONF_COMMAND_ERR_9999;
|
||
global $pubConn;
|
||
global $strBack,$strError,$strPrompt;
|
||
//echo "Reason=$Reason";
|
||
global $PlatTypeDefArr;
|
||
$pubdb = "OMC_PUB";
|
||
$selSql = "SELECT sysTypeName FROM sysConf WHERE sysTypeNo='$sysTypeNo'";
|
||
$selRes = mysqli_query($pubConn, $selSql);
|
||
$selRow = mysqli_fetch_array($selRes);
|
||
if($sysTypeNo[0] == '2'){//Plat
|
||
$sysName = $selRow[sysTypeName]. "-" .$PlatTypeDefArr[$sysNo][remark];
|
||
}else{
|
||
$sysName = $selRow[sysTypeName]."-".$sysNo;
|
||
}
|
||
$tmpErrCode="STR_CONF_COMMAND_ERR_".$Reason;
|
||
$tmpPromptCode="STR_CONF_PROMPT_".$Reason[0].$Reason[1];
|
||
|
||
// fj
|
||
if(0)
|
||
{
|
||
echo "<br><br><b><font color=red>$sysName Error:${$tmpErrCode} ,$des</font><br>";
|
||
echo "Reason: $Reason<hr>";
|
||
}
|
||
|
||
for($index=0;$index<$descArr[Count];$index++)
|
||
{
|
||
if(strlen(trim($descArr[$index][SysTypeName])) > 0 && strlen(trim($descArr[$index][TableName])) > 0)
|
||
{
|
||
$log="{$descArr[$index][CommdType]} {$descArr[$index][SysTypeName]}: {$descArr[$index][TableName]} {$descArr[$index][InstanceNo]} fail";
|
||
insertLog($log);
|
||
}
|
||
}
|
||
|
||
|
||
echo "<br><br><b><font color=red>$sysName Error: $des.<br>";
|
||
echo "<b>Prompt: ${$tmpPromptCode} </font>";
|
||
if($backsrc == '' || strlen($backsrc)==0)
|
||
echo "<p align=\"left\"><a href=\"JavaScript:history.go(-1)\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
else
|
||
{
|
||
//echo "backsrc=$backsrc<br>";
|
||
//because the operation error, then get the table again
|
||
if(strstr($backsrc,"param_edit.php") || strstr($backsrc,"param_show_table.php") || strstr($backsrc,"param_show_down.php"))
|
||
{
|
||
$tmp=explode("sysId=",$backsrc);
|
||
$tmp2=explode("&",$tmp[1]);
|
||
$get_sysId=$tmp2[0];
|
||
|
||
$tmp=explode("tableOid=",$backsrc);
|
||
$tmp2=explode("&",$tmp[1]);
|
||
$get_tableOid=$tmp2[0];
|
||
|
||
$tmp=explode("table_type=",$backsrc);
|
||
$tmp2=explode("&",$tmp[1]);
|
||
$get_table_type=$tmp2[0];
|
||
|
||
$tmp=explode("instanceNo=",$backsrc);
|
||
$tmp2=explode("&",$tmp[1]);
|
||
$get_instanceNo=$tmp2[0];
|
||
|
||
if(strlen($get_instanceNo) == 0)
|
||
{
|
||
$backsrc="./param_show_table.php?sysId=$get_sysId&tableOid=$get_tableOid&table_type=$get_table_type&instanceNo=0000";
|
||
}
|
||
|
||
if(strlen($get_sysId)>0 && strlen($get_tableOid)>0)
|
||
{
|
||
|
||
$commIdStr=oidSysCommSend($get_sysId,5,$get_tableOid,-1,"");
|
||
}
|
||
|
||
}
|
||
echo "<p align=\"left\"><a href=\"$backsrc\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">Back</a>";
|
||
}
|
||
exit();
|
||
}
|
||
?>
|