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

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


echo "<HTML>";
echo "<HEAD>";
echo "<meta http-equiv='Content-Type' content='text/html; charset=EUC-JP'>";
echo "<TITLE>Zither server Administration tool 'Apollon'</TITLE>";

echo "<style type='text/css'>";
echo "<!--
a { text-decoration:none; }
a:hover { text-decoration:underline; }
a:hover { color:red; }

.example {
width: 100%;
max-width: 80px;
min-width: 60px;
}

-->";
echo "</style>";

echo "</HEAD>";







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

//  監視ブロック名リスト作成
$bname_count = 0;
$result = db_query($conn, "select distinct(bname) from userblock;");
if(!$result){
   print("banem select , bud query\n");
   exit;
   }
$num = db_num_rows($result);
if($num > 0){
   while($bname_count < $num){
      $bname_data[$bname_count] = enco_rtrim(db_fetch_Result($result, $bname_count, bname));
      $result1=db_query($conn,"select distinct(cname) from userblock where bname='$bname_data[$bname_count]';");
      if(!$result1){
         print("bname , canem select , bud query\n");
         exit;
         }
      $num1 = db_num_rows($result1);
      if($num1 > 0){
         $cname_data[$bname_count] = enco_rtrim(db_fetch_Result($result1, 0, cname));
         }
      $bname_count++;
      }
   }
else{
   print("NG 監視ブロックが無いです \n");
   }
db_free_result($result);
db_free_result($result1);


$cname_count = 0;
$result=db_query($conn,"select distinct(cname) from connection;");
if(!$result){
   print("canem select , bud query\n");
   exit;
   }
$num = db_num_rows($result);
if($num > 0){
   while($cname_count < $num){
      $xcname_data[$cname_count] = enco_rtrim(db_fetch_Result($result, $cname_count, cname));
      $cname_count++;
      }
   }
db_free_result($result);


$ip_count = 0;
$result=db_query($conn,"select distinct(cip) from monitor;");
if(!$result){
   print("ip select , bud query\n");
   exit;
   }
$num = db_num_rows($result);
if($num > 0){
   while($ip_count < $num){
      $ip_data[$ip_count] = enco_rtrim(db_fetch_Result($result, $ip_count, cip));
      $ip_count++;
      }
   }
db_free_result($result);


db_Close($conn);
// Cname Bname List 










echo "<center>";
echo "<BODY Link='#FF8C00' Vlink='#FF8C00' Alink='#FF8C00'  bgcolor='$my_bgcolor' >";

// 監視設定検索

echo "<h2 id='kanshi'></h2>";
echo "<TABLE border='0' bgcolor='FFA500' cellspacing='3' cellpadding='0' width=125>";
echo "<tr>";
echo "<td align=center>";
echo "<font color='ffffff' size=2>";
echo "<b>";
echo "監視設定詮索";
echo "</b>";
echo "</font>";
echo "</td>";
echo "</tr>";
echo "</table>";

echo "<FORM METHOD=GET ACTION='tree.php' target='top'>";
echo "<TABLE border='0' bgcolor='FFEBCD' cellspacing='8' cellpadding='0' width=125>";


echo "<tr>";
echo "<td align=center>";
echo "<font color='FF8C00' size=2>";
echo "監視クライアント名";
// echo "<INPUT type='text' NAME=CNAME size='18' value=''>";
echo "<select size=1 name=CNAME class='example'>";
echo "<option value=''>なし";
for($select_count = 0; $select_count < $cname_count; $select_count++){
   echo "<option value=$xcname_data[$select_count]>$xcname_data[$select_count]";
   }
echo "</select>";
echo "</font>";
echo "</td>";
echo "</tr>";


echo "<tr>";
echo "<td align=center>";
echo "<font color='FF8C00' size=2>";
echo "監視ブロック名";
// echo "<INPUT type='text' NAME=BNAME size='18' value=''>";
echo "<select size=1 name=BNAME class='example'>";
echo "<option value=''>なし";
for($select_count = 0; $select_count < $bname_count; $select_count++){
   echo "<option value=$bname_data[$select_count]>$bname_data[$select_count] ($cname_data[$select_count])";
   }
echo "</select>";
echo "</font>";
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td align=center>";
echo "<font color='FF8C00' size=2>";
echo "<input type=submit value='検索'>";
echo "</font>";
echo "</td>";
echo "</tr>";


echo "</table>";
echo "</form>";
echo "</center>";

?>

</BODY>
</HTML>
