<?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'>";
	echo "<title>zither monitorring save info</title>";
echo "</head>";
echo "<body alink='#ff0000' bgcolor='#ffffff' link='#0000ff' text='#000000' vlink='#000080'>";

echo "<pre>";

$ncol1 = "bgcolor=#f0f0d2";
$ncol2 = "bgcolor=#d2f0f0";
$uno = enco($_GET["UNO"]);
$STATUS = enco($_GET["STATUS"]);


if(0 == strcmp($uno, "NON")){
   $uno = 0;
   }

print($font_size);
print($version_name);
print(date("Y m d g i s A"));
print("\n");

if($STATUS == "UPDATE"){
   print("この行の監視項目を編集または削除できます \n");
   }
else{
   print("この行の監視項目を複製します\n");
   }

print("編集方法は<a target=edit_help href='./setupmonitor.html'>ここ</a>を確認してください。\n");


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

$result = db_query($conn, "select * from monitor where uno='$uno'");
if(!$result){
   print("bud query\n");
   exit;
   }

$num = db_num_rows($result);
if($num <= 0){
   print("no data\n");
   exit;
   }

print("\n\n");

echo "<TABLE border=3  WIDTH=50% height=10% BGCOLOR=#e6e8fa>";

while($s < $num){
   $COME = enco_rtrim(db_fetch_Result($result, $s, come));
   $CNAME = enco_rtrim(db_fetch_Result($result, $s, cname));
   $MONITOR = enco_rtrim(db_fetch_Result($result, $s, monitor));
   $SIGN = enco_rtrim(db_fetch_Result($result, $s, sign));
   $PROTO = enco_rtrim(db_fetch_Result($result, $s, proto));
   $COM = db_fetch_Result($result, $s, com);
   $CIP = enco_rtrim(db_fetch_Result($result, $s, cip));
   $PORT = enco_rtrim(db_fetch_Result($result, $s, port));
   $WTIME = enco_rtrim(db_fetch_Result($result, $s, wtime));
   $PINFO = db_fetch_Result($result, $s, pinfo);
   $PRINO = enco_rtrim(db_fetch_Result($result, $s, prino));
   $FREE1 = enco_rtrim(db_fetch_Result($result, $s, free1));
   $FREE2 = enco_rtrim(db_fetch_Result($result, $s, free2));
   $FREE3 = enco_rtrim(db_fetch_Result($result, $s, free3));
   $FREE4 = enco_rtrim(db_fetch_Result($result, $s, free4));
   $UNO = enco_rtrim(db_fetch_Result($result, $s, uno));

   $s++;
   }
db_free_result($result);



//  監視ブロック名リスト作成
$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 = cname_return($FREE4);


echo"</table>";

echo "\n";
echo "<FORM METHOD=GET ACTION='monitor_up.php' target=monitor_up>";

// echo "<TABLE cellspacing=0 nowrap border=0 WIDTH='90%' height='8%'BGCOLOR='#e6e8fa'>";
echo "<TABLE cellspacing=0 cellpadding=3 nowrap border=1 Bordercolor='$my_bocolor' nowrap border=0 WIDTH='790' height='8%'BGCOLOR='#e6e8fa'>";



echo "<tr><td>";
echo "監視をオン、オフ \n";
echo "</td><td>";
echo "<select size=1 name=COME>";
echo "<option value=$COME selected>$COME";
echo "<option value=ON>ON";
echo "<option value=OFF>OFF";
echo "</select>";
echo "</td></tr>";

echo "<tr bgcolor='#D9DBED'><td>";
echo "監視クライアントのホスト名 \n";
echo "</td><td>";
echo "<INPUT type='hidden' NAME=CNAME size='24' value='$CNAME'>";
echo "$CNAME";
echo "</td></tr>";

echo "<tr><td>";
echo "監視形態の属性、コマンド、ポート\n";
echo "</td><td>";
echo "<select size=1 name=MONITOR>";
echo "<option value=$MONITOR selected>$MONITOR";
echo "<option value=SNMP>SNMP";
echo "<option value=PORT>PORT";
echo "<option value=COMAND>COMAND";
echo "</select>";
echo "</td></tr>";

echo "<tr bgcolor='#D9DBED'><td>";
echo "監視正逆の設定\n";
echo "</td><td>";
echo "<select size=1 name=SIGN>";
echo "<option value=$SIGN selected>$SIGN";
echo "<option value=0>0";
echo "<option value=1>1";
echo "</select>";
echo "</td></tr>";

if(0 == strcmp($MONITOR, "PORT")){
   echo "<tr><td>";
   echo "監視プロトコル、ポート DHWの場合のみ\n";
   echo "</td><td>";
   echo "<select size=1 name=PROTO>";
   echo "<option value=$PROTO selected>$PROTO";
   echo "<option value=ICMP>ICMP";
   echo "<option value=UDP>UDP";
   echo "<option value=TCP>TCP";
   echo "<option value=URL>URL";
   echo "<option value=GET>GET";
   echo "<option value=SSL>SSL";
   echo "<option value=SMTP>SMTP";
   echo "<option value=FTP>FTP";
   echo "<option value=POP>POP";
   echo "<option value=SSH>SSH";
   echo "<option value=DHW>DHW";
   echo "<option value=MYSQL>MYSQL";
   echo "<option value=PGSQL>PGSQL";
   echo "<option value=SNTP>SNTP";
   echo "<option value=HOST>HOST";
   echo "<option value=NOT>NOT";
   echo "</select>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "SNMP")){
   echo "<tr><td>";
   echo "SNMP 監視閾値設定\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=PROTO size='70' value='$PROTO'>";
   echo "</td></tr>";
   }
else{
   echo "<INPUT type='hidden' NAME=PROTO size='70' value='NOT'>";
   }


if(0 == strcmp($MONITOR, "COMAND")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "実行コマンド\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "PORT") && 0 == strcmp($PROTO, "DHW")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "DHWでの実行コマンド\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "PORT") && 0 == strcmp($PROTO, "MYSQL")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "MYSQLでのクエリー\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "PORT") && 0 == strcmp($PROTO, "PGSQL")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "PGSQLでのクエリー\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }

elseif(0 == strcmp($MONITOR, "PORT") && 0 == strcmp($PROTO, "SSL")){
   if(0 == strcmp($COM, "NOT")){
      $COM = "14";
      }

   echo "<tr bgcolor='#D9DBED'><td>";
   echo "CERT有効期限通知日数（0で無効）\n";
   echo "</td><td>";
   echo "<select size=1 NAME=COM>";
   echo "<option value=$COM selected>$COM";
   echo "<option value=0>無効";
   echo "<option value=1>1日";
   echo "<option value=2>2日";
   echo "<option value=3>3日";
   echo "<option value=4>4日";
   echo "<option value=5>5日";
   echo "<option value=6>6日";
   echo "<option value=7>7日";
   echo "<option value=8>8日";
   echo "<option value=9>9日";
   echo "<option value=10>10日";
   echo "<option value=11>11日";
   echo "<option value=12>12日";
   echo "<option value=13>13日";
   echo "<option value=14>14日";
   echo "</select>";
   echo "</td></tr>";
   }

elseif(0 == strcmp($MONITOR, "PORT") && 0 == strcmp($PROTO, "HOST")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "名前解決後の比較IP\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "SNMP")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "SNMP OID\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=COM size='70' value='$COM'>";
   echo "</td></tr>";
   }
else{
   echo "<INPUT type='hidden' NAME=COM size='70' value='NOT'>";
   }

echo "<tr><td>";
echo "監視先のIPアドレス\n";
echo "</td><td>";
echo "<INPUT type='text' NAME=CIP size='70' value='$CIP'>";
echo "</td></tr>";

if(0 == strcmp($MONITOR, "PORT")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "監視先のポート\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=PORT size='12' value='$PORT'>";
   echo "</td></tr>";
   }
elseif(0 == strcmp($MONITOR, "SNMP")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "SNMP 接続先のsec.name\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=PORT size='12' value='$PORT'>";
   echo "</td></tr>";
   }
else{
   echo "<INPUT type='hidden' NAME=PORT size='12' value='0'>";
   }

if(0 != strcmp($MONITOR, "SNMP")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "ステータスの待ち時間秒\n";
   echo "</td><td>";
   echo "<select size=1 name=WTIME>";
   echo "<option value=$WTIME selected>$WTIME";
   echo "<option value=0>0";
   echo "<option value=1>1";
   echo "<option value=2>2";
   echo "<option value=3>3";
   echo "<option value=4>4";
   echo "<option value=5>5";
   echo "<option value=6>6";
   echo "<option value=7>7";
   echo "<option value=8>8";
   echo "<option value=9>9";
   echo "<option value=10>10";
   echo "<option value=11>11";
   echo "<option value=12>12";
   echo "<option value=13>13";
   echo "<option value=14>14";
   echo "<option value=15>15";
   echo "<option value=16>16";
   echo "<option value=17>17";
   echo "<option value=18>18";
   echo "<option value=19>19";
   echo "<option value=20>20";
   echo "<option value=21>21";
   echo "<option value=22>22";
   echo "<option value=23>23";
   echo "<option value=24>24";
   echo "<option value=25>25";
   echo "<option value=26>26";
   echo "<option value=27>27";
   echo "<option value=28>28";
   echo "<option value=29>29";
   echo "<option value=30>30";
   echo "</select>";
   echo "</td></tr>";
   }
else{
   echo "<INPUT type='hidden' NAME=WTIME size='12' value=4>";
   }


echo "<tr><td>";
echo "監視先の情報\n";
echo "</td><td>";
echo "<INPUT type='text' NAME=PINFO size='70' value='$PINFO'>";
echo "</td></tr>";

echo "<tr><td>";
echo "この監視のプライオリティー\n";
echo "</td><td>";
echo "<select size=1 name=PRINO>";
echo "<option value=$PRINO selected>$PRINO";
echo "<option value=1>1最強";
echo "<option value=2>2そこそこ";
echo "<option value=3>3まあこんあもん";
echo "<option value=4>4 TEST MODE";
echo "<option value=5>5 LOGING MODE";
echo "<option value=11>監視ログ(11)";
echo "<option value=12>監視ログ(12)";
echo "<option value=13>監視ログ(13)";
echo "</select>";
echo "</td></tr>";


if(0 == strcmp($MONITOR, "SNMP")){
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "OID の説明など、、、\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=FREE1 size='70' value='$FREE1'>";
   echo "</td></tr>";
   }
else{
   echo "<tr bgcolor='#D9DBED'><td>";
   echo "コメント 1\n";
   echo "</td><td>";
   echo "<INPUT type='text' NAME=FREE1 size='70' value='$FREE1'>";
   echo "</td></tr>";
   }

// echo "<tr><td>";
// echo "コメント 2\n";
// echo "</td><td>";
// echo "<INPUT type='text' NAME=FREE2 size='70' value='$FREE2'>";
// echo "</td></tr>";

// echo "<tr bgcolor='#D9DBED'><td>";
// echo "コメント 3\n";
// echo "</td><td>";
// echo "<INPUT type='text' NAME=FREE3 size='70' value='$FREE3'>";
// echo "</td></tr>";

//echo "<tr><td>";
//echo "監視ブロック名\n";
//echo "</td><td>";
//echo "<INPUT type='text' NAME=FREE4 size='70' value='$FREE4'>";
//echo "</td></tr>";



echo "<tr><td>";
echo "監視ブロック名\n";
echo "</td><td>";
echo "<select size=1 name=FREE4>";
echo "<option value='$FREE4'>$FREE4";
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 "</td></tr>";





echo "<INPUT type='hidden' NAME=GEN value='taro'>";
echo "<INPUT type='hidden' NAME=UNO value=$UNO>";
echo "<INPUT type='hidden' NAME=STATUS value=$STATUS>";

echo"</table>";


if($STATUS == "UPDATE"){
   echo "\n";
   echo "<font color=red>";
   print("監視内容を変更します,内容を再度確認してください\n");
   echo "<input type=submit value='監視内容を変更！！'>";
   echo "</form>";

   print("\n");

   echo "<FORM METHOD=GET ACTION='monitor_data_delete.php'>";
   print("<font color=red>");
   print("この監視項目を削除します\n");
   print("戻すことが出来ませんので、注意して押してください\n");
   print("</font>");
   echo "<INPUT type='hidden' NAME=GEN value='taro'>";
   echo "<INPUT type='hidden' NAME=UNO value=$UNO>";
   echo "<INPUT type='hidden' NAME=CNAME value=$CNAME>";
   echo "<input type=submit value='注意！！この設定を削除'>";
   echo "</form>";
   }
else{
   echo "\n";
   echo "<font color=red>";
   print("監視内容の複製を作成します,内容を再度確認してください\n");
   echo "<input type=submit value='複製を作成'>";
   echo "</form>";
   print("\n");
   }


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

print("</font>");

?>

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


