<?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 "<style type='text/css'>";
echo "<!--
.example {
width: 100%;
max-width: 80px;
min-width: 60px;
}
-->";
echo "</style>";

echo "</head>";



print("<body alink='#ff0000' bgcolor='$my_monitorcolor' link='#0000ff' text='#000000' vlink='#000080'>\n");

print("<TABLE border=0 bgcolor=FFA500 cellspacing=3 cellpadding=0 width=100%>\n");
print("<tr><td align=left><font color=ffffff><b>　監視項目表示</b></font></td></tr>\n");
print("</table>\n");

$ncol1 = "bgcolor=#f0f0d2";
$ncol2 = "bgcolor=#d2f0f0";
$kcal1 = "bgcolor=#6de051";
$kcal2 = "bgcolor=#d9c37a";

$cname = enco($_GET["CNAME"]);
$monitor = enco($_GET["MONITOR"]);
$cinfo = enco($_GET["CINFO"]);
$pinfo = enco($_GET["PINFO"]);
$prino = enco($_GET["PRINO"]);
$proto = enco($_GET["PROTO"]);
$cip = enco($_GET["CIP"]);
$cip2 = enco($_GET["CIP2"]);
$uno = enco($_GET["UNO"]);
$come = enco($_GET["COME"]);
$block = enco($_GET["FREE4"]);
$block2 = enco($_GET["FREE42"]);
$com = enco($_GET["COM"]);
$port = enco($_GET["PORT"]);
$sign = enco($_GET["SIGN"]);


$cname_ch = enco($_GET["CNAME_CH"]);
$monitor_ch = enco($_GET["MONITOR_CH"]);
$cinfo_ch = enco($_GET["CINFO_CH"]);
$pinfo_ch = enco($_GET["PINFO_CH"]);
$prino_ch = enco($_GET["PRINO_CH"]);
$proto_ch = enco($_GET["PROTO_CH"]);
$cip_ch = enco($_GET["CIP_CH"]);
$cip2_ch = enco($_GET["CIP2_CH"]);
$uno_ch = enco($_GET["UNO_CH"]);
$come_ch = enco($_GET["COME_CH"]);
$block_ch = enco($_GET["FREE4_CH"]);
$block2_ch = enco($_GET["FREE42_CH"]);
$com_ch = enco($_GET["COM_CH"]);
$port_ch = enco($_GET["PORT_CH"]);
$sign_ch = enco($_GET["SIGN_CH"]);

$csv_ch = enco($_GET["CSV_CH"]);

$dekinai="不可";

$SE="LIKE";
$EE="=";


if(2 < strlen($block2)){
   if(0 == strcmp("on", $block2_ch)){
      $select_data = "select * from monitor where " . "free4 NOT LIKE '$block2'";
      $select_data2 = " where " . "free4 NOT LIKE '$block2'";
      }
   else{
      $select_data = "select * from monitor where " . "free4 LIKE '$block2'";
      $select_data2 = " where " . "free4 LIKE '$block2'";
      }
   }
else{
   if(0 != strlen($block)){
      if(0 == strcmp("on", $block_ch)){
         $select_data = "select * from monitor where " . "free4!='$block'";
         $select_data2 = " where " . "free4!='$block'";
         }
      else{
         $select_data = "select * from monitor where " . "free4='$block'";
         $select_data2 = " where " . "free4='$block'";
         }
      }


   else{
      if(0 != strlen($uno)){
         if(0 == strcmp("on", $uno_ch)){
            $select_data = "select * from monitor where " . "uno!='$uno'";
            $select_data2 = " where " . "uno!='$uno'";
            }
         else{
            $select_data = "select * from monitor where " . "uno='$uno'";
            $select_data2 = " where " . "uno='$uno'";
            }
         }
      else{


         if(1 < strlen($cname)){
            if(0 == strcmp("on", $cname_ch)){
               $select_data = "select * from monitor where " . "cname!='$cname'";
               $select_data2 = " where " . "cname!='$cname'";
               }
            else{
               $select_data = "select * from monitor where " . "cname='$cname'";
               $select_data2 = " where " . "cname='$cname'";
               }
            }
         else{
            print("not host name err\n");
            if(0 == strcmp("on", $cname_ch)){
               $select_data = "select * from monitor where " . "cname NOT LIKE '%'";
               $select_data2 = " where " . "cname NOT LIKE '%'";
               }
            else{
               $select_data = "select * from monitor where " . "cname LIKE '%'";
               $select_data2 = " where " . "cname LIKE '%'";
               }
            }



         }
      }
   }

if(0 == strlen($uno)){

   if(0 != strlen($monitor)){
      if(0 == strcmp("on", $monitor_ch)){
         $select_data = $select_data . " and monitor!='$monitor'";
         $select_data2 = $select_data2 . " and monitor!='$monitor'";
         }
      else{
         $select_data = $select_data . " and monitor='$monitor'";
         $select_data2 = $select_data2 . " and monitor='$monitor'";
         }
      }
   if(0 != strlen($prino)){
      if(0 == strcmp("on", $prino_ch)){
         $select_data = $select_data . " and prino!='$prino'";
         $select_data2 = $select_data2 . " and prino!='$prino'";
         }
      else{
         $select_data = $select_data . " and prino='$prino'";
         $select_data2 = $select_data2 . " and prino='$prino'";
         }
      }

   if(0 != strlen($pinfo)){
      if(0 == strcmp("on", $pinfo_ch)){
         $select_data = $select_data . "and pinfo!='$pinfo'";
         $select_data2 = $select_data2 . "and pinfo!='$pinfo'";
         }
      else{
         $select_data = $select_data . "and pinfo='$pinfo'";
         $select_data2 = $select_data2 . "and pinfo='$pinfo'";
         }
      }

   if(0 != strlen($proto)){
      if(0 == strcmp("on", $proto_ch)){
         $select_data = $select_data . "and proto!='$proto'";
         $select_data2 = $select_data2 . "and proto!='$proto'";
         }
      else{
         $select_data = $select_data . "and proto='$proto'";
         $select_data2 = $select_data2 . "and proto='$proto'";
         }
      }


   if(2 < strlen($cip2)){
      if(0 == strcmp("on", $cip2_ch)){
         $select_data = $select_data . "and cip NOT LIKE '$cip2'";
         $select_data2 = $select_data2 . "and cip NOT LIKE '$cip2'";
         }
      else{
         $select_data = $select_data . "and cip LIKE '$cip2'";
         $select_data2 = $select_data2 . "and cip LIKE '$cip2'";
         }
      }
   else {
      if(0 != strlen($cip)){
         if(0 == strcmp("on", $cip_ch)){
            $select_data = $select_data . "and cip!='$cip'";
            $select_data2 = $select_data2 . "and cip!='$cip'";
            }
         else{
            $select_data = $select_data . "and cip='$cip'";
            $select_data2 = $select_data2 . "and cip='$cip'";
            }
         }
      }


   if(0 != strlen($come)){
      if(0 == strcmp("on", $come_ch)){
         $select_data = $select_data . "and come!='$come'";
         $select_data2 = $select_data2 . "and come!='$come'";
         }
      else{
         $select_data = $select_data . "and come='$come'";
         $select_data2 = $select_data2 . "and come='$come'";
         }
      }
   if(0 != strlen($com)){
      if(0 == strcmp("on", $com_ch)){
         $select_data = $select_data . "and com NOT LIKE '$com'";
         $select_data2 = $select_data2 . "and com NOT LIKE '$com'";
         }
      else{
         $select_data = $select_data . "and com LIKE '$com'";
         $select_data2 = $select_data2 . "and com LIKE '$com'";
         }
      }
   if(0 != strlen($port)){
      if(0 == strcmp("on", $port_ch)){
         $select_data = $select_data . "and port NOT LIKE '$port'";
         $select_data2 = $select_data2 . "and port NOT LIKE '$port'";
         }
      else{
         $select_data = $select_data . "and port LIKE '$port'";
         $select_data2 = $select_data2 . "and port LIKE '$port'";
         }
      }
   if(0 != strlen($cinfo)){
      if(0 == strcmp("on", $cinfo_ch)){
         $select_data = $select_data . "and pinfo NOT LIKE '$cinfo'";
         $select_data2 = $select_data2 . "and pinfo NOT LIKE '$cinfo'";
         } 
      else{
         $select_data = $select_data . "and pinfo LIKE '$cinfo'";
         $select_data2 = $select_data2 . "and pinfo LIKE '$cinfo'";
         } 
      }
   if(0 != strlen($sign)){
      if(0 == strcmp("on", $sign_ch)){
         $select_data = $select_data . "and sign NOT LIKE '$sign'";
         $select_data2 = $select_data2 . "and sign NOT LIKE '$sign'";
         }
      else{
         $select_data = $select_data . "and sign LIKE '$sign'";
         $select_data2 = $select_data2 . "and sign LIKE '$sign'";
         }
      }
   }


echo "<pre>";
print($font_size);
print($version_name);
print(date("Y m d g i s A"));
print("\n");
if(0 == strcmp("on", $csv_ch)){
   print("\n");
   }
else{
   print("２カラム目をクリックすることで、各行を編集、削除が出来ます \n");
   print("１カラム目が黄色は監視がアクティブ、灰色は監視停止状態です\n");
   print("<font color=red>");
   print("（取扱い注意！！）最後の行の内容を変更すると該当するカラムの内容を統一することが出来ます。 \n");
   print("</font>");

   echo "このページの使い方は<a href='./monitor_help.html' target=help>使い方</a> を見てください \n";
   }
$conn = db_connect();
if(!$conn){
   echo "not connection!<br>";
   exit;
   }
//  print("$select_data\n");
//  print("update monitor set ???='???', ???='???' $select_data2\n");
// $result = db_query($conn, "select * from monitor where cname='$cname'");



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





$result = db_query($conn, $select_data);
if(!$result){
   print("bud query\n");
   exit;
   }

$num = db_num_rows($result);
if($num > 0){

   if(0 == strcmp("on", $csv_ch)){
      print("リストファイルのフォーマットで出力しています\n");
      print("\n");
      }
   else{
      print("\n\n");

      echo "<TABLE border=0  WIDTH=50% height=10% BGCOLOR=$my_bocolor>";

      echo "<tr>";
      echo "<td $kcal1><font size=1>STAT</font></td>";
      echo "<td $kcal1><font size=1>Client Name</font></td>";
      echo "<td $kcal1><font size=1>属性</font></td>";
      echo "<td $kcal1><font size=1>正逆</font></td>";
      echo "<td $kcal1><font size=1>Plotcol or 閾値</font></td>";
      echo "<td $kcal1><font size=1>MIB or Command or resolvd name</font></td>";
      echo "<td $kcal1><font size=1>監視先IP</font></td>";
      echo "<td $kcal1><font size=1>sec.name or port</font></td>";
      echo "<td $kcal1><font size=1>Time out</font></td>";
      echo "<td $kcal1><font size=1>監視先情報</font></td>";
      echo "<td $kcal1><font size=1>Prioriti</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 "</tr>";

      echo "<tr>";
      echo "<td $kcal2><font size=1>TEST</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 "<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>BLOCK編集</font></td>";
      echo "<td $kcal2><font size=1>操作</font></td>";
      echo "<td $kcal2><font size=1>*</font></td>";
      echo "</tr>";
      }

   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 = enco_rtrim(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 = enco_rtrim(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));


      if(0 == strcmp($COME, "ON")){
         $cpcol = "bgcolor=yellow";
         }
      else{
         $cpcol = "bgcolor=gray";
         }


      if($PRINO <= 1){
         $pcol = "bgcolor=red";
         $prcol = "bgcolor=red";
         } 
      else if($PRINO == 2){
         $pcol = "bgcolor=magenta";
         $prcol = "bgcolor=magenta";
         } 
      else if($PRINO == 3){
         $pcol = "bgcolor=green";
         $prcol = "bgcolor=green";
         }
      else if($PRINO == 4){
         $pcol = "bgcolor=orengi";
         $prcol = "bgcolor=orengi";
         }
      else if($PRINO == 5){
         $pcol = "bgcolor='#ffff99'";
         $prcol = "bgcolor='#ffff99'";
         }
      else if($PRINO == 6){
         $pcol = "bgcolor='#ffff99'";
         $prcol = "bgcolor='#ffff99'";
         }
      else if($PRINO == 11){
         $pcol = "bgcolor='#cc0099'";
         $prcol = "bgcolor='#cc0099'";
         }
      else if($PRINO == 12){
         $pcol = "bgcolor='#9900ff'";
         $prcol = "bgcolor='#9900ff'";
         }
      else if($PRINO == 13){
         $pcol = "bgcolor='#99cc00'";
         $prcol = "bgcolor='#99cc00'";
         }
      else{
         $pcol = "bgcolor=cyan";
         $prcol = "bgcolor=cyan";
         }





 
      if(0 == strcmp("on", $csv_ch)){
         print("$MONITOR,$SIGN,$PROTO,$COM,$CIP,$PORT,$WTIME,$PINFO,$PRINO,$FREE1,$FREE2,$UNO,$FREE4,\n");

         }
      else{

         $kazu = $s + 1;

         echo "<tr>"; 

         echo "<td $cpcol><a target=check href=$monitorcheck?UNO=$UNO&STATUS+UPDATE>$COME</a></td>";
         echo "<td $pcol><a target=edit href=$monitoredit?UNO=$UNO&STATUS=UPDATE>$CNAME</a></td>";
         echo "<td $ncol1><a target=edit href=$monitoredit?UNO=$UNO>$MONITOR</a></td>";
         echo "<td $ncol2>$SIGN</td>";
         echo "<td $ncol1>$PROTO</td>";
         echo "<td $ncol2>$COM</td>";
         echo "<td $ncol1><a target=edit href='tree2.php?CIP=$CIP'>$CIP</a></td>";
         echo "<td $ncol2>$PORT</td>";
         echo "<td $ncol1>$WTIME</td>";
         echo "<td $ncol2>$PINFO</td>";
         echo "<td $prcol>$PRINO</td>";
         echo "<td $ncol2>$FREE1</td>";
         echo "<td $ncol1>$FREE2</td>";
         echo "<td $ncol2>$FREE3</td>";
         echo "<td $ncol1><a target=edit href='./block.php?BNAME=$FREE4'>$FREE4</a></td>";
         echo "<td $ncol2><a target=edit href=$menucnew?BNAME=$FREE4>$UNO</a></td>";
         echo "<td $ncol1>$kazu</td>";

         echo "</tr>";
         }

      $s++;
      }

   $kazu = 0;

   if(0 != strcmp("on", $csv_ch)){

      echo "<FORM METHOD=GET ACTION='monitor_cut_edit.php' target='insert'>";

      echo "<tr>"; 

      echo "<td $cpcol>";
        echo "<select size=1 name=COME>";
        echo "<option value=>編集しない";
        echo "<option value=ON>監視中";
        echo "<option value=OFF>監視停止";
        echo "</select>";
      echo "</td>";

      echo "<td $pcol>$dekinai</td>";
      echo "<td $ncol1>$dekinai</td>";

      echo "<td $ncol2>";
        echo "<select size=1 name=SIGN>";
        echo "<option value=>編集しない";
        echo "<option value=0>正";
        echo "<option value=1>逆";
        echo "</select>";
      echo "</td>";

      echo "<td $ncol1><INPUT type='text' NAME=PROTO value=''></td>";
      echo "<td $ncol2><INPUT type='text' NAME=COM value=''></td>";
      echo "<td $ncol1><INPUT type='text' NAME=CIP value=''></td>";
      echo "<td $ncol2><INPUT type='text' NAME=PORT value=''></td>";
      echo "<td $ncol1><INPUT type='text' NAME=WTIME value=''></td>";
      echo "<td $ncol2><INPUT type='text' NAME=PINFO value=''></td>";

      echo "<td $ncol2>";
        echo "<select size=1 name=PRINO>";
        echo "<option value=>編集しない";
        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=11>監視ログモード(11)";
        echo "<option value=12>監視ログモード(12)";
        echo "<option value=13>監視ログモード(13)";
        echo "</select>";
      echo "</td>";

      echo "<td $ncol2><INPUT type='text' NAME=FREE1 value=''></td>";
      echo "<td $ncol1>$dekinai</td>";
      echo "<td $ncol2>$dekinai</td>";
   // echo "<td $ncol1><INPUT type='text' NAME=FREE4 value=''></td>";



      echo "<td $ncol1>";
        echo "<select size=1 name=FREE4 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 "</td>";



      echo "<td $ncol2>$dekinai</td>";
      echo "<td $ncol1>$dekinai</td>";

      echo "</tr>";

      echo"</table>";

      echo "<TABLE border=0  BGCOLOR=$my_bocolor>";
      echo "<tr>"; 
      echo "<td>"; 
      $select_data_put = urlencode($select_data2);
      echo "<INPUT type='checkbox' NAME=DEL_CHECK>";
      echo "<font color='red'>\n";
      echo "削除\n";
      echo "<INPUT type='hidden' NAME=SELECT size='0' value='$select_data_put'>";
      echo "<INPUT type='hidden' NAME=GEN value='taro'>";
      echo "<input type=submit value='検索内容の一括編集OR削除!(注！要確認)'>";
      echo "ブロックを選択すると、修正を加えて選択先にコピーします\n";
      echo "<select size=1 name=BLOCK_NEW 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 "</font>";
      echo "</select>";
      echo "</td>"; 
      echo "</tr>";
      echo "</FORM>";

      echo"</table>";



      print("\n\n");


      echo "<TABLE border=0  WIDTH=80% height=0% BGCOLOR='$my_bocolor'>";
      echo "<FORM METHOD=GET ACTION='monitor_newedit.php' target='insert'>";
      echo "<tr><td>";
      echo "プロトコルと監視ブロックを指定して、監視設定を追加出来ます \n";
      echo "</td></tr>";
      echo "<tr><td>";
      echo "<select size=1 name=MONITOR>";
      echo "<option value=PORT>PORT";
      echo "<option value=COMAND selected>COMAND";
      echo "<option value=SNMP selected>SNMP";
      echo "</select>";
      echo "</td>";

      echo "<td>";
      echo "<INPUT type='text' NAME=FREE4 size='24' value='$FREE4'>";
      echo "</td>";

      echo "<td>";
      echo "<input type=submit value=' 新規作成  '>";
      echo "</td>";
      echo "</form>";

      echo "</table>";

      }
   else{
      }  
   }

else{
   echo "not data!!\n";
   $FREE4 = $block;
   }

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

?>

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


