<?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";

$uno = enco($_GET["UNO"]);
$cname = enco($_GET["CNAME"]);
$bname = enco($_GET["BNAME"]);




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


if(0 < strlen($cname)){
   $cno = 1;
   if(0 < strlen($bname)){
      $cno = 2;
      }
   }
else {
   if(0 < strlen($bname)){
      $cno = 2;
      $s = 0;
      $result = db_query($conn, "select distinct(cname) from userblock where bname='$bname';");
      if(!$result){
         print("bud query\n");
         exit;
         }
      $num = db_num_rows($result);
      while($s < $num){
         $cname = enco_rtrim(db_fetch_Result($result, $s, cname));
         $s++;
         }
      db_free_result($result);
      }
   else{
      $cno = 0;
      }
   }
$s = 0;


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");



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

echo "<tr>"; 
echo "<td $kcal1><font size=1>Zither サーバー</font></td>";
echo "<td $kcal1><font size=1>Sitar クライアント</font></td>";
echo "<td $kcal1><font size=1>監視ブロック</font></td>";
echo "<td $kcal1><font size=1>監視先</font></td>";
if($cno != 0){
   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 "</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>";
if($cno != 0){
   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>"; 

if($cno == 1 || $cno == 2){
   $result = db_query($conn, "select distinct(server) from connection where cname='$cname';");
   }
else{
   $result = db_query($conn, "select distinct(server) from connection;");
   }
if(!$result){
   print("bud query\n");
   exit;
   }
$num = db_num_rows($result);
if($num <= 0){
   print("(1)no data\n");
// exit;
   }

$s1 = 0;
$s2 = 0;
$s3 = 0;
$s4 = 0;
$s5 = 0;
$bplus = "|";
$plus  = "|";
$plus1 = "|";
$plus2 = "|";
$line = "+-----------------------+";
$bline = "+--------!!ERR!!------->>";

while($s < $num){
   $SERVER = enco_rtrim(db_fetch_Result($result, $s, server));
   echo "<tr>"; 
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   if($cno != 0){
      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>";
   echo "<tr>"; 
   echo "<td $acol1>$SERVER</td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   echo "<td $acol2></td>";
   if($cno != 0){
      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>";

   if($cno == 1 || $cno == 2){
      $result2 = db_query($conn, "select distinct(cname) from connection where server='$SERVER' and cname='$cname';");
      }
   else{
      $result2 = db_query($conn, "select distinct(cname) from connection where server='$SERVER';");
      }

   if(!$result2){
      print("bud query\n");
      exit;
      }
   $num2 = db_num_rows($result2);
   if($num2 <= 0){
      print("(2)no data\n");
//    exit;
      }
   $s2 = 0;
   while($s2 < $num2){
      $CNAME = enco_rtrim(db_fetch_Result($result2, $s2, cname));
      echo "<tr>"; 
      echo "<td $acol2>$bplus</td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      if($cno != 0){
         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>";
      echo "<tr>"; 
      echo "<td $acol2>$line</td>";
      echo "<td $bcol1><a target=insert href=$configedit?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $acol2></td>";
      echo "<td $acol2></td>";
      if($cno != 0){
         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>";

      if($s2 == ($num2 -1)){
         $plus = " ";
         }
 
      if($cno == 1){
         $result3 = db_query($conn, "select distinct(bname) from userblock where cname='$cname';");
         }
      if($cno == 2){
         $result3 = db_query($conn, "select distinct(bname) from userblock where cname='$cname' and bname='$bname';");
         }
      else{
         $result3 = db_query($conn, "select distinct(bname) from userblock where cname='$CNAME';");
         }
      if(!$result3){
         print("bud query\n");
         exit;
         }
      $num3 = db_num_rows($result3);


      if($num3 > 0){
         $s3 =0;
         while($s3 < $num3){
            $BNAME = enco_rtrim(db_fetch_Result($result3, $s3, bname));
            echo "<tr>"; 
            echo "<td $acol2>$plus</td>";
            echo "<td $acol2>$bplus</td>";
            echo "<td $acol2></td>";
            echo "<td $acol2></td>";
            if($cno != 0){
               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>";
            echo "<tr>"; 
            echo "<td $acol2>$plus</td>";
            echo "<td $acol2>$line</td>";
            echo "<td $bcol2><a target=insert href=$blocknewedit?BNAME=$BNAME>$BNAME</a></td>";
            echo "<td $acol2></td>";
            if($cno != 0){
               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>";

            if($s3 == ($num3 -1)){
               $plus1 = " ";
               } 

            if($cno == 1){
               $result4 = db_query($conn, "select distinct(cip) from monitor where free4='$BNAME' and cname='$cname';");
               }
            if($cno == 2){
               $result4 = db_query($conn, "select distinct(cip) from monitor where free4='$bname' and cname='$cname';");
               }
            else{
               $result4 = db_query($conn, "select distinct(cip) from monitor where free4='$BNAME';");
               }

            if(!$result4){
               print("bud query\n");
               exit;
               }
            $num4 = db_num_rows($result4);

            if($num4 > 0){
               $s4 =0;
               while($s4 < $num4){
                  $CIP = enco_rtrim(db_fetch_Result($result4, $s4, cip));
                  echo "<tr>"; 
                  echo "<td $acol2>$plus</td>";
                  echo "<td $acol2>$plus1</td>";
                  echo "<td $acol2>$bplus</td>";
                  echo "<td $acol2></td>";
                  if($cno != 0){ 
                     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>";
                  echo "<tr>"; 
                  echo "<td $acol2>$plus</td>";
                  echo "<td $acol2>$plus1</td>";
                  echo "<td $acol2>$line</td>";
                  echo "<td $ncol2><a target=edit href=$monitorwatch?CIP=$CIP>$CIP</a></td>";
                  if($cno != 0){ 
                     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>";


// cno != 0

                  if($cno != 0){

                     if($s4 == ($num4 -1)){
                        $plus2 = " ";
                        } 

                     if($cno == 1){
                        $result5 = db_query($conn,
                        "select come,monitor,proto,prino,com,port,uno from monitor where cname='$cname' and free4='$BNAME' and cip='$CIP';");
                        }
                     if($cno == 2){
                        $result5 = db_query($conn,
                        "select come,monitor,proto,prino,com,port,uno from monitor where cname='$cname' and free4='$bname' and cip='$CIP';");
                        }
                     else{
                        $result5 = db_query($conn,
                        "select come,monitor,proto,prino,com,port,uno from monitor where cname='$CNAME' and free4='$BNAME' and cip='$CIP';");
                        }

                     if(!$result5){
                        print("bud query\n");
                        exit;
                        }
                     $num5 = db_num_rows($result5);
                     if($num5 > 0){
                        $s5 =0;
                        while($s5 < $num5){
                           $COME = enco_rtrim(db_fetch_Result($result5, $s5, come));
                           $MONITOR = enco_rtrim(db_fetch_Result($result5, $s5, monitor));
                           $PROTO = enco_rtrim(db_fetch_Result($result5, $s5, proto));
                           $COM = enco_rtrim(db_fetch_Result($result5, $s5, com));
                           $PORT = enco_rtrim(db_fetch_Result($result5, $s5, port));
                           $PRINO = enco_rtrim(db_fetch_Result($result5, $s5, prino));
                           $UNO = enco_rtrim(db_fetch_Result($result5, $s5, 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";
                              }

                           echo "<tr>"; 
                           echo "<td $acol2>$plus</td>";
                           echo "<td $acol2>$plus1</td>";
                           echo "<td $acol2>$plus2</td>";
                           echo "<td $acol2>$bplus</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>";
                           echo "<tr>"; 
                           echo "<td $acol2>$plus</td>";
                           echo "<td $acol2>$plus1</td>";
                           echo "<td $acol2>$plus2</td>";
                           if(0 == strcmp($uno, $UNO)){
                              echo "<td $acol2><blink><a name='CENTER'>$bline</a></vlink></td>";
                              echo "<td bgcolor='red'><blink><a target=insert href=$monitoredit?UNO=$UNO&STATUS=UPDATE>$MONITOR</a></blink></td>";
                              }
                           else{
                              echo "<td $acol2>$line</td>";
                              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=$BNAME&CIP=$CIP>$PROTO</a></td>";
                           echo "<td $ncol1>$COM</td>";
                           echo "<td $ncol1>$PORT</td>";
                           echo "<td $ncol1>$UNO</td>";
                           echo "</tr>";

                           $s5++;
                           }
                        }
                     else{
                        print("No data(5)");
                        }

                     db_free_result($result5);
                     }

// cno != 0


                  $plus2 = $bplus;
                  $s4++;
                  }
               }
            else{
               print("No data(4)");
               }
            db_free_result($result4);
            $plus1 = $bplus;
            $s3++;
            }
         }
      else{
         print("No data(3)");
         }
      db_free_result($result3);
      $plus = $bplus; 
      $s2++;
      }
   db_free_result($result2);
   $s++;
   }

db_free_result($result);
db_Close($conn);

echo"</table>";


echo "\n";



?>

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


