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

session_start();
require("./ninsyou.inc");
if(0 > ninsyou_check(2)){
   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 "<SCRIPT LANGUAGE='JavaScript'>";
echo "<!--
function WinCls(){
        window.close()
                       }
// window.onload=WinCls();
//-->";
echo "</SCRIPT>";

echo "</head>";
echo "<body alink='#ff0000' bgcolor='#ffffff' link='#0000ff' text='#000000' vlink='#000080'>";

echo "<pre>";


$CNAME = enco($_GET["CNAME"]);
$STAT = enco($_GET["STAT"]);
$GEN = enco($_GET["GEN"]);

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


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

print($CNAME);
print("\n");
print($STAT);
print("\n");


if(0 < strlen($GEN)){

   $result = db_query($conn, "update connection set mode='$STAT' where cname='$CNAME'");

   if(!$result){
      print("bud query set\n");
      exit;
      }

   echo "OK update data\n";

   }

$stat_file = "/usr/local/zither/conf/" . $CNAME . ".stat";

if(($fp = fopen($stat_file, "w+"))==NULL){
   print("file not open\n");
   exit;
   }

fwrite($fp, "$STAT\n");
fclose($fp);

echo "stat file=$stat_file update ok\n";
echo "À®¸ù \n";


if(0 < strlen($GEN)){
   $s = 0;
   $result = db_query($conn, "select distinct(server) from connection;");
   if(!$result){
      print("bud query\n");
      exit;
      }
   $num = db_num_rows($result);
   if($num <= 0){
      print("no data\n");
      exit;
      }
   else{
      while($s < $num){
         $SERVER = enco_rtrim(db_fetch_Result($result, $s, server));
         print("$SERVER $my_web_ip ");
         if(0 != strcmp($SERVER, $my_web_ip)){
            $T_1 = "/statset_ok.php" . "?";
            $T_2 = "CNAME=" . urlencode($CNAME) . "&";
            $T_3 = "STAT=" . urlencode($STAT);
            $T_ALL = $T_1 . $T_2 . $T_3;
            print("<br>");
            print("$T_ALL");
            http_open($SERVER, $T_ALL, $my_web_ip);
            }
         $s++;
         }
      }
   }

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

?>


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

