<?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 "<SCRIPT LANGUAGE='JavaScript'>";
echo "<!--
//-->";
echo "</SCRIPT>";



/* date */

$view_mode = enco($_GET["VIEW_MODE"]);
$view_name = enco($_GET["VIEW_NAME"]);
$view_free3 = enco($_GET["FREE3"]);

if(0 == strlen($view_free3)){
   $view_id = "";
   $mytitle = "最新エラー状況";
   }
else{ 
   $view_id = "and free3='$view_free3'";
   $mytitle = "監視番号 $view_free3 のエラー状況";
   }


if(0 == strlen($view_mode)){
   $view_mode = "MONITOR";
   }
if(0 == strlen($view_mode)){
   $view_mode = "";
   }


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

echo "<META http-equiv=refresh content='$interval; url=http://$my_web_ip/kanshi.php?VIEW_MODE=$view_mode&VIEW_NAME=$view_name&FREE3=$view_free3' >";
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>　情報 -> $mytitle</b></font></td></tr>";
echo "</table><br><br>";

print("<font size=1>");
print($version_name);
print("\n");
echo "エラー状況を $interval 秒おきに表示しています ";
print(date("Y m d g i s A"));
print("\n");

echo "このページの使い方は<a href='./kanshi_help.html' target=help>使い方</a> を見てください";

print("\n");

echo "<TABLE border=0  WIDTH=80% height=0% BGCOLOR=#e6e8fa>";

echo "<FORM METHOD=GET ACTION='kanshi.php'>";

echo "<tr><td>";
echo "<select size=1 name=VIEW_MODE>";
echo "<option value=$view_mode selected>$view_mode";
echo "<option value=MONITOR_3>MONITOR_3";
echo "<option value=MONITOR_2>MONITOR_2";
echo "<option value=MONITOR_1>MONITOR_1";
echo "<option value=MONITOR_12>MONITOR_12";
echo "<option value=MONITOR>MONITOR";
echo "<option value=TEST>TEST";
echo "<option value=TEST_ONLY>TEST_ONLY";
echo "<option value=LOG>LOG";
echo "<option value=LOG_ONLY>LOG_ONLY";
echo "<option value=ALL>ALL";
echo "</td>";

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

echo "<td>";
echo "<input type=submit value='表示モードの変更及び再読み込み'>";
echo "</td>";
echo "</form>";

echo "<FORM METHOD=GET ACTION='test_delete.php' target='test_delete' >";
echo "<td>";
echo "<input type=submit value='テスト監視削除'>";
echo "</td>";

echo "</tr>";
echo "</form><br>";

echo "</table>";


if(0 == strcmp($view_mode, "MONITOR")){
   $view_select = "prino < '4'";
   }
else if(0 == strcmp($view_mode, "MONITOR_1")){
   $view_select = "prino = '1'";
   }
else if(0 == strcmp($view_mode, "MONITOR_2")){
   $view_select = "prino = '2'";
   }
else if(0 == strcmp($view_mode, "MONITOR_3")){
   $view_select = "prino = '3'";
   }
else if(0 == strcmp($view_mode, "MONITOR_12")){
   $view_select = "prino < '3'";
   }
else if(0 == strcmp($view_mode, "TEST")){
   $view_select = "prino < '5'";
   }
else if(0 == strcmp($view_mode, "TEST_ONLY")){
   $view_select = "prino = '4'";
   }
else if(0 == strcmp($view_mode, "LOG")){
   $view_select = "prino < '6'";
   }
else if(0 == strcmp($view_mode, "LOG_ONLY")){
   $view_select = "prino = '5'";
   }
else if(0 == strcmp($view_mode, "ALL")){
   $view_select = "prino < '14'";
   }
else{
   $view_select = " ";
   }


if(0 == strlen($view_name)){
   $view_user = "";
   }
else{
   $view_user = "and cname='$view_name'";
   }

$view_sign = "and sign < '2'";

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

$result = db_query($conn, "select * from errlog where uct > $settime and $view_select $view_user $view_sign $view_id order by uct desc limit $leng");
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=1  WIDTH=80% height=1% BGCOLOR=#e6e8fa>";
echo "<TABLE border=0  WIDTH=80% height=1% BGCOLOR=$my_bocolor>";

echo "<tr>"; 
echo "<td $kcal1><font size=1>監視番号</font></td>";
echo "<td $kcal1><font size=1>観測時間</font></td>";
echo "<td $kcal1><font size=1>監視先のIP</font></td>";
echo "<td $kcal1><font size=1>監視属性</font></td>";
echo "<td $kcal1><font size=1>Info & command & Protocol</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>";
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>"; 


while($s < $num){
   $CIP = enco_rtrim(db_fetch_Result($result, $s, cip));
   $CNAME = enco_rtrim(db_fetch_Result($result, $s, cname));
   $MONITOR = enco_rtrim(db_fetch_Result($result, $s, monitor));
   $UCT = enco_rtrim(db_fetch_Result($result, $s, uct));
   $YE = enco_rtrim(db_fetch_Result($result, $s, ye));
   $MO = enco_rtrim(db_fetch_Result($result, $s, mo));
   $DA = enco_rtrim(db_fetch_Result($result, $s, da));
   $HA = enco_rtrim(db_fetch_Result($result, $s, ha));
   $MI = enco_rtrim(db_fetch_Result($result, $s, mi));
   $SE = enco_rtrim(db_fetch_Result($result, $s, se));
   $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));
   $CINFO = enco_rtrim(db_fetch_Result($result, $s, cinfo));
   $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));
   $ERRDATA = enco_rtrim(db_fetch_Result($result, $s, errdata));
   $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($PRINO <= 1){
      $pcol = "bgcolor=red";
      } 
   else if($PRINO == 2){
      $pcol = "bgcolor=magenta";
      } 
   else if($PRINO == 3){
      $pcol = "bgcolor=green";
      }
   else if($PRINO == 4){
      $pcol = "bgcolor=orengi";
      }
   else if($PRINO == 5){
      $pcol = "bgcolor='#ffff99'";
      }
   else if($PRINO == 6){
      $pcol = "bgcolor='#ffff99'";
      }
   else if($PRINO == 11){
      $pcol = "bgcolor='#cc0099'";
      }
   else if($PRINO == 12){
      $pcol = "bgcolor='#9900ff'";
      }
   else if($PRINO == 13){
      $pcol = "bgcolor='#99cc00'";
      }
   else{
      $pcol = "bgcolor=cyan";
      }

   if(0 == strcmp($MONITOR, "CONNECT")){
      echo "<td $acol1></td>";
      echo "<td $pcol>$MO/$DA $HA:$MI:$SE</td>";
      echo "<td $acol2>$PINFO</td>";
      echo "<td $acol1><a target=_self href=$detaile?KEY=$UNO>$MONITOR</a></td>";
      echo "<td $acol2>$ERRDATA</td>";
      echo "<td $ncol1><a target=_view href=$treewatch?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $acol2>$FREE4</td>";
      }

   elseif(0 == strcmp($MONITOR, "CLOSE")){
      echo "<td $bcol1></td>";
      echo "<td $pcol>$MO/$DA $HA:$MI:$SE</td>";
      echo "<td $bcol2>$PINFO</td>";
      echo "<td $bcol1><a target=edit href=$detaile?KEY=$UNO>$MONITOR</a></td>";
      echo "<td $bcol2>$ERRDATA</td>";
      echo "<td $ncol1><a target=_view href=$treewatch?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $bcol2>$FREE4</td>";
      }



   else{
      echo "<td $ncol2><a terget=top href='./kanshi.php?VIEW_MODE=$view_mode&VIEW_NAME=$view_name&FREE3=$FREE3'>$FREE3</a></td>";
      echo "<td $pcol><a target=edit href=$monitoredit?UNO=$FREE3&STATUS=UPDATE>$MO/$DA $HA:$MI:$SE</a></td>";
      echo "<td $ncol2><a target=edit href=$treewatch2?CIP=$CINFO&UNO=$FREE3#CENTER>$CINFO</a></td>";
      echo "<td $ncol1><a target=edit href=$detaile?KEY=$UNO>$MONITOR</a></td>";
      if(0 == strcmp($MONITOR, "PORT")){
         if(0 == strcmp($PROTO, "DHW")){
            echo "<td $ncol2><a terget=edit href=$menucnew?CNAME=$CNAME&BNAME=$FREE4>$PROTO($COM)</a></td>";
            }
         else{
            echo "<td $ncol2><a terget=edit href=$menucnew?CNAME=$CNAME&BNAME=$FREE4>$PROTO(Port $PORT)</a></td>";
            }
         echo "<td $ncol1><a target=_view href=$treewatch?CNAME=$CNAME&UNO=$FREE3#CENTER>$CNAME</a></td>";
         echo "<td $ncol2><a target=_view href=$treewatch?CNAME=$CNAME&BNAME=$FREE4&UNO=$FREE3#CENTER>$FREE4</a></td>";
         }
      elseif(0 == strcmp($MONITOR, "SNMP")){
         echo "<td $ncol2><a terget=edit href=$menucnew?CNAME=$CNAME&BNAME=$FREE4>$FREE1</a></td>";
//       echo "<td $ncol2>$FREE1</td>";
         echo "<td $ncol1><a target=_view href=$treewatch?CNAME=$CNAME&UNO=$FREE3#CENTER>$CNAME</a></td>";
         echo "<td $ncol2><a target=_view href=$treewatch?CNAME=$CNAME&BNAME=$FREE4&UNO=$FREE3#CENTER>$FREE4</a></td>";
         }
      else{
         echo "<td $ncol2><a terget=edit href=$menucnew?CNAME=$CNAME&BNAME=$FREE4>$COM</a></td>";
//       echo "<td $ncol2>$COM</td>";
         echo "<td $ncol1><a target=_view href=$treewatch?CNAME=$CNAME&UNO=$FREE3#CENTER>$CNAME</a></td>";
         echo "<td $ncol2><a target=_view href=$treewatch?CNAME=$CNAME&BNAME=$FREE4&UNO=$FREE3#CENTER>$FREE4</a></td>";
         }

      }


   echo "</tr>";

   $s++;
   }

echo"</table>";



print("</font>");

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

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


