<?php

require("./total.inc");
require("./count.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'>";

/* date */

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


$Cname = enco($_GET["CNAME"]);
$Cname_2 = enco($_GET["CNAME_2"]);
$Cip = enco($_GET["CIP"]);
$Server = enco($_GET["SERVER"]);
$Mode = enco($_GET["MODE"]);
$Stat = enco($_GET["STAT"]);
$Ver = enco($_GET["VER"]);
$Uno = enco($_GET["UNO"]);

$Cname_ch = enco($_GET["CNAME_CH"]);
$Cname_2_ch = enco($_GET["CNAME_2_CH"]);
$Cip_ch = enco($_GET["CIP_CH"]);
$Server_ch = enco($_GET["SERVER_CH"]);
$Mode_ch = enco($_GET["MODE_CH"]);
$Stat_ch = enco($_GET["STAT_CH"]);
$Ver_ch = enco($_GET["VER_CH"]);
$Uno_ch = enco($_GET["UNO_CH"]);


if(0 != strlen($Cname)){
   if(0 == strcmp("on", $Cname_ch)){
      $select_data = "select * from connection where " . "cname != '$Cname'";
      }
   else{
      $select_data = "select * from connection where " . "cname = '$Cname'";
      }
   }
else{
   if(0 == strcmp("on", $Cname_ch)){
      $select_data = "select * from connection where " . "cname NOT LIKE '%'";
      }
   else{
      $select_data = "select * from connection where " . "cname LIKE '%'";
      }
   }


if(1 < strlen($Cname_2)){
   if(0 == strcmp("on", $Cname_2_ch)){
      $select_data = "select * from connection where " . "cname NOT LIKE '$Cname_2'";
      }
   else{
      $select_data = "select * from connection where " . "cname LIKE '$Cname_2'";
      }
   }



if(0 != strlen($Cip)){
   if(0 == strcmp("on", $Cip_ch)){
      $select_data = $select_data . " and cip NOT LIKE '$Cip'";
      }
   else{
      $select_data = $select_data . " and cip LIKE '$Cip'";
      }
   }

if(0 != strlen($Server)){
   if(0 == strcmp("on", $Server_ch)){
      $select_data = $select_data . " and server NOT LIKE '$Server'";
      }
   else{
      $select_data = $select_data . " and server LIKE '$Server'";
      }
   }

if(0 != strlen($Mode)){
   if(0 == strcmp("on", $Mode_ch)){
      $select_data = $select_data . " and mode !='$Mode'";
      }
   else{
      $select_data = $select_data . " and mode ='$Mode'";
      }
   }

if(0 != strlen($Stat)){
   if(0 == strcmp("on", $Stat_ch)){
      $select_data = $select_data . " and stat !='$Stat'";
      }
   else{
      $select_data = $select_data . " and stat='$Stat'";
      }
   }

if(0 != strlen($Ver)){
   if(0 == strcmp("on", $Ver_ch)){
      $select_data = $select_data . " and ver NOT LIKE '$Ver'";
      }
   else{
      if(0 != strcmp($Ver, "%")){
         $select_data = $select_data . " and ver LIKE '$Ver'";
         }
      }
   }

if(0 != strlen($Uno)){
   if(0 == strcmp("on", $Uno_ch)){
      $select_data = "select * from connection where " . "uno != $Uno";
      }
   else{
      $select_data = "select * from connection where " . "uno=$Uno";
      }
   }

if(0 == strcmp($select_data, "select * from connection where " . "cname LIKE '%'")){
   print($meta_loop2);
   }

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");
echo "接続状況を$interval2 秒おきに表示しています ";
print(date("Y m d g i s A"));
print("\n");
echo "このページの使い方は<a href='./connect_help.html' target=help>使い方</a> を見てください";
print("\n");
print("\n");
print($select_data);
print("\n");
print("\n");

if(0 == strcmp($select_data, "select * from connection where " . "cname LIKE '%'")){
   echo "<FORM METHOD=GET ACTION='connect.php'>";
   echo "<TABLE border=0 cellspacing=0 cellpadding=3 WIDTH=80% BGCOLOR=#e6e8fa>";
   }

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

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

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

print("\n\n");

echo "<TABLE border=0  WIDTH=80% height=2% 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>接続時間</font></td>";
echo "<td $kcal1><font size=1>状態</font></td>";
echo "<td $kcal1><font size=1>Client名</font></td>";
echo "<td $kcal1><font size=1>Client IP</font></td>";
echo "<td $kcal1><font size=1>Zither IP</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>";
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){
   $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));
   $CNAME = enco_rtrim(db_fetch_Result($result, $s, cname));
   $CIP = enco_rtrim(db_fetch_Result($result, $s, cip));
   $SERVER = enco_rtrim(db_fetch_Result($result, $s, server));
   $MODE = enco_rtrim(db_fetch_Result($result, $s, mode));
   $STAT = enco_rtrim(db_fetch_Result($result, $s, stat));
   $VER = enco_rtrim(db_fetch_Result($result, $s, ver));
   $UNO = enco_rtrim(db_fetch_Result($result, $s, uno));

   $blo = block_count($CNAME);
   $clo = monitor_count_client($CNAME);

   $pmode = $acol1;
   if(0 == strcmp($MODE, "STOP")){
      $pmode = "bgcolor=red";
      }

   if(0 == strcmp($STAT, "OFF")){
      $pcol = "bgcolor=red";
      echo "<td $acol1>$clo</td>";
      echo "<td $acol2>$blo</td>";
      echo "<td $pcol><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=EDIT>$MO/$DA $HA:$MI:$SE</a></td>";
      echo "<td $acol1><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=UPNEW>$STAT</a></td>";
      echo "<td $acol2><a target=oedit href=$treewatch?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $acol1><a target=_self href=$negdelete?CNAME=$CNAME>$CIP</a></td>";
      echo "<td $acol2><a terget=oedit href=$treewatch?CNAME=$CNAME>$SERVER</a></td>";
      echo "<td $pmode>$MODE</td>";
      echo "<td $acol1>$VER</td>";
      echo "<td $acol2><a target=oedit href='./config_newedit.php?CNAME=$CNAME&CIP=$CIP'>$UNO</a></td>";
      $no = $s + 1; 
      echo "<td $acol1>$no</td>";
      }

   elseif(0 == strcmp($STAT, "ON")){
      $pcol = "bgcolor=cyan";
      echo "<td $acol1>$clo</td>";
      echo "<td $acol2>$blo</td>";
      echo "<td $pcol><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=EDIT>$MO/$DA $HA:$MI:$SE</a></td>";
      echo "<td $acol1><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=UPNEW>$STAT</a></td>";
      echo "<td $acol2><a target=oedit href=$treewatch?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $acol1>$CIP</td>";
      echo "<td $acol2><a terget=oedit href=$treewatch?CNAME=$CNAME>$SERVER</a></td>";
      echo "<td $pmode><a target=_self href=$statset?KEY=$CNAME>$MODE</a></td>";
      echo "<td $acol1>$VER</td>";
      echo "<td $acol2><a target=oedit href='./config_newedit.php?CNAME=$CNAME&CIP=$CIP'>$UNO</a></td>";
      $no = $s + 1; 
      echo "<td $acol1>$no</td>";
      }

   else{
      $pcol = "bgcolor=#c3c3c3";
      echo "<td $acol1>$clo</td>";
      echo "<td $acol2>$blo</td>";
      echo "<td $pcol><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=EDIT>$MO/$DA $HA:$MI:$SE</a></td>";
      echo "<td $acol1><a target=oedit href=$configedit?CNAME=$CNAME&CIP=$CIP&EDIT=UPNEW>$STAT</a></td>";
      echo "<td $acol2><a target=oedit href=$treewatch?CNAME=$CNAME>$CNAME</a></td>";
      echo "<td $acol1><a target=_self href=$negdelete?CNAME=$CNAME>$CIP</a></td>";
      echo "<td $acol2><a terget=oedit href=$treewatch?CNAME=$CNAME>$SERVER</a></td>";
      echo "<td $pmode>$MODE</td>";
      echo "<td $acol1>$VER</td>";
      echo "<td $acol2><a target=oedit href='./config_newedit.php?CNAME=$CNAME&CIP=$CIP'>$UNO</a></td>";
      $no = $s + 1; 
      echo "<td $acol1>$no</td>";
      }

   echo "</tr>";

   $s++;
   }


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





echo"</table>";
echo "\n";



?>

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


