<?php
require("./total.inc");

session_start();
require("./ninsyou.inc");
if(0 > ninsyou_check(5)){
   exit;
   }


echo "<!DOCTYP:pserver:cvs@dhcvs.ms-n.com:/usr/home/cvsE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
echo "<HTML>";
echo "<HEAD>";
echo "<META name='GENERATOR' content='AmBuilder'>";
echo "<META http-equiv='Content-Type' content='text/html; charset=euc-jp'>";



$myutime = date("U");
$settime = $myutime - 86400;
$ncol1 = "bgcolor=#f0f0d2";
$ncol2 = "bgcolor=#d2f0f0";
$acol1 = "bgcolor=#e0e0a0";
$acol2 = "bgcolor=#a0e0e0";
$bcol1 = "bgcolor=#f0c0c0";
$bcol2 = "bgcolor=#c0c0f0";
$kcal1 = "bgcolor=#6de051";
$kcal2 = "bgcolor=#d9c37a";

$cip   = enco($_GET["CIP"]);
$uno   = enco($_GET["UNO"]);


echo "<title>zither monitorring save info</title>";
echo "</head>";
echo "<body alink='#ff0000' bgcolor='$my_bgcolor' link='#0000ff' text='#000000' vlink='#000080'>";

echo "<pre>";

echo "<TABLE border=0 bgcolor=FFA500 cellspacing=3 cellpadding=0 width=100%>";
echo "<tr><td align=left><font color=ffffff><b>  情報ー＞監視先ツリー （監視元） </b></font></td></tr>";
echo "</table><br>";

print("<font size=1>");
print($version_name);
print("\n");
print(date("Y m d g i s A"));
print("\n");
echo "このページの使い方は<a href='./connect_help.html' target=help>使い方</a> を見てください";
print("\n");
print("\n");


$conn = db_connect();
if(!$conn){
   echo "not connection!<br>";
   exit;
   }

// echo "<TABLE border=0  BGCOLOR=$my_bocolor>";
echo "<TABLE border=0  $acol2>";

echo "<tr>"; 
echo "<td $kcal1><font size=1>監視属性</font></td>";
echo "<td $kcal1><font size=1>プライオリティ</font></td>";
echo "<td $kcal1><font size=1>プロトコル</font></td>";
echo "<td $kcal1><font size=1>コマンド</font></td>";
echo "<td $kcal1><font size=1>ポート</font></td>";
echo "<td $kcal1><font size=1>管理番号</font></td>";
echo "<td $kcal1><font size=1>監視ブロック</font></td>";
echo "<td $kcal1><font size=1>Sitar クライアント</font></td>";
echo "</tr>"; 
echo "<tr>"; 

echo "<td $kcal2><font size=1>編集</font></td>";
echo "<td $kcal2><font size=1>複製</font></td>";
echo "<td $kcal2><font size=1>一括編集</font></td>";
echo "<td $kcal2><font size=1></font></td>";
echo "<td $kcal2><font size=1></font></td>";
echo "<td $kcal2><font size=1></font></td>";

echo "<td $kcal2><font size=1>設定</font></td>";
echo "<td $kcal2><font size=1>設定</font></td>";
echo "</tr>"; 

echo "<tr>"; 
echo "<td $acol2>$cip(監視先IP)</td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "<td $acol2></td>";
echo "</tr>";




$s1 = 0;
$s2 = 0;
$s3 = 0;
$s4 = 0;
$s5 = 0;
$bplus = "|";
$plus  = "|";
$plus1 = "|";
$plus2 = "|";
$plus3 = "|";
$line = "+------------+";





$result1 = db_query($conn, "select distinct(cname) from monitor where cip='$cip';");

if(!$result1){
   print("bud query\n");
   exit;
   }
$num1 = db_num_rows($result1);
if($num1 <= 0){
   print("(1)no data\n");
// exit;
   }

$s1 = 0;
while($s1 < $num1){
   $CNAME = enco_rtrim(db_fetch_Result($result1, $s1, cname));




   $result2 = db_query($conn, "select distinct(free4) from monitor where cip='$cip' and cname='$CNAME';");

   if(!$result2){
      print("bud query\n");
      exit;
      }
   $num2 = db_num_rows($result2);
   if($num2 <= 0){
      print("(1)no data\n");
//    exit;
      }

   $s2 = 0;
   while($s2 < $num2){
      $FREE4 = enco_rtrim(db_fetch_Result($result2, $s2, free4));






      if($num2 > 1){
//       print("$s1 $s2 $num2 A\n");
         if($s2 == 0 && $s1 == 0){
            $plus3 = " ";
//          print("   $plus3 A0\n");
            }
         else if($s2 < ($num2 - 1) && $s1 > 0){
            $plus3 = " ";
//          print("   $plus3 A1\n");
            }
         else{
            $plus3 = "|";
//          print("   $plus3 A2\n");
            }
         }
      else{
//       print("$s1 $s2 $num2 B\n");
         if($s2 < $num2){
            $plus3 = " ";
//          print("   $plus3 B1\n");
            }
         else{
            $plus3 = "|";
//          print("   $plus3 B2\n");
            }
         }





      echo "<tr>"; 
      echo "<td $acol2>*</td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2>$plus3</td>";
      echo "</tr>";




      $result3 = db_query($conn,
        "select come,monitor,proto,prino,com,port,uno from monitor where cip='$cip' and free4='$FREE4';");

      if(!$result3){
         print("bud query\n");
         exit;
         }
      $num3 = db_num_rows($result3);
 //   print("$num3 .");
      if($num3 <= 0){
         print("(1)no data\n");
      // exit;
         }
      $s3 = 0;
      while($s3 < $num3){

         $COME = enco_rtrim(db_fetch_Result($result3, $s3, come));
         $MONITOR = enco_rtrim(db_fetch_Result($result3, $s3, monitor));
         $PROTO = enco_rtrim(db_fetch_Result($result3, $s3, proto));
         $COM = enco_rtrim(db_fetch_Result($result3, $s3, com));
         $PORT = enco_rtrim(db_fetch_Result($result3, $s3, port));
         $PRINO = enco_rtrim(db_fetch_Result($result3, $s3, prino));
         $UNO = enco_rtrim(db_fetch_Result($result3, $s3, uno));

         if($PRINO <= 1){
            $pcol = "bgcolor=red";
            $prcol = "bgcolor=red";
            }
         if($PRINO == 2){
            $pcol = "bgcolor=magenta";
            $prcol = "bgcolor=magenta";
            }
         if($PRINO == 3){
            $pcol = "bgcolor=green";
            $prcol = "bgcolor=green";
            }
         if($PRINO == 4){
            $pcol = "bgcolor=orengi";
            $prcol = "bgcolor=orengi";
            }
         if($PRINO > 4){
            $pcol = "bgcolor=white";
            $prcol = "bgcolor=white";
            }


         if(0 == strcmp($uno, $UNO)){
            echo "<td bgcolor='red'><blink><a name='CENTER'><a target=insert href=$monitoredit?UNO=$UNO&STATUS=UPDATE>$MONITOR</a></a></blink></td>";
            }
         else{
            if(0 == strcmp($COME, "ON")){
               echo "<td bgcolor='yellow'><a target=insert href=$monitoredit?UNO=$UNO&STATUS=UPDATE>$MONITOR</a></td>";
               }
            if(0 != strcmp($COME, "ON")){
               echo "<td bgcolor='gray'><a target=insert href=$monitoredit?UNO=$UNO&STATUS=UPDATE>$MONITOR</a></td>";
               }
            }

         echo "<td $pcol><a target=insert href=$monitoredit?UNO=$UNO>$PRINO</a></td>";
         echo "<td $ncol1><a target=insert href=$monitorwatch?FREE4=$FREE4&CIP=$cip>$PROTO</td>";
         echo "<td $ncol1>$COM</td>";
         echo "<td $ncol1>$PORT</td>";
         echo "<td $ncol1>+$UNO</td>";
         echo "<td $acol2></td>";
         echo "<td $acol2>$plus3</td>";
         echo "</tr>";


         $s3++;
         }

      db_free_result($result3);



      echo "<tr>"; 
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2>$plus2</td>";
      echo "<td $acol2></td>";
      echo "<td $acol2>$plus3</td>";
      echo "</tr>";


      echo "<tr>"; 
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2>$line</td>";
      echo "<td $acol2><a target=insert href=$blocknewedit?BNAME=$FREE4>$FREE4</a></td>";
      echo "<td $acol2>+</td>";
      echo "</tr>";


      $s2++;
      }
   db_free_result($result2);





   echo "<tr>"; 
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2>+ <a target=insert href=$configedit?CNAME=$CNAME>$CNAME</a></td>";
   echo "</tr>";





   $s1++;
   }
db_free_result($result1);








db_Close($conn);



echo"</table>";


echo "\n";



?>

</pre>
<br>
<br>
</body>
</html>


