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

session_start();
require("./ninsyou.inc");
if(0 > ninsyou_check(3)){
   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>";



$EDIT = enco($_GET["EDIT"]);
$GEN = enco($_GET["GEN"]);

$YOUNAME = enco($_GET["YOUNAME"]); 
$BNAME = enco($_GET["BNAME"]); 
$CNAME = enco($_GET["CNAME"]); 
$MAILTO = enco($_GET["MAILTO"]);
$MAILCC = enco($_GET["MAILCC"]);
$PLUSTIME = enco($_GET["PLUSTIME"]);
$MAILSEND = enco($_GET["MAILSEND"]);
$STAT = enco($_GET["STAT"]);

$STARTTIME = enco($_GET["STARTTIME"]);

$STARTTIME_YEAR = enco($_GET["STARTTIME_YEAR"]);
$STARTTIME_MONTH = enco($_GET["STARTTIME_MONTH"]);
$STARTTIME_DAY = enco($_GET["STARTTIME_DAY"]);
$STARTTIME_HOUR = enco($_GET["STARTTIME_HOUR"]);
$STARTTIME_MIN = enco($_GET["STARTTIME_MIN"]);

$STOPSETTIME = enco($_GET["STOPSETTIME"]);

$STOPSETTIME_YEAR = enco($_GET["STOPSETTIME_YEAR"]);
$STOPSETTIME_MONTH = enco($_GET["STOPSETTIME_MONTH"]);
$STOPSETTIME_DAY = enco($_GET["STOPSETTIME_DAY"]);
$STOPSETTIME_HOUR = enco($_GET["STOPSETTIME_HOUR"]);
$STOPSETTIME_MIN = enco($_GET["STOPSETTIME_MIN"]);


$FREE1 = enco($_GET["FREE1"]);
$FREE2 = enco($_GET["FREE2"]);

$UP_TIME = date("Y m d g i s A");   

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


if(0 == strlen($BNAME)){
   print("NG NOT block name");
   exit;
   }
if(0 == strlen($CNAME)){
   print("NG NOT sitar client name");
   exit;
   }
if(0 == strlen($YOUNAME)){
   $YOUNAME = "test";
   }


if(0 != strlen($STARTTIME)){
   if(4 == substr_count($STARTTIME, ":")){
      $STARTTIME_YEAR = strtok($STARTTIME, ":");
      $STARTTIME_MONTH = strtok(":");
      $STARTTIME_DAY = strtok(":");
      $STARTTIME_HOUR = strtok(":");
      $STARTTIME_MIN = strtok(":");
      }
   }
if(0 != strlen($STOPSETTIME)){
   if(4 == substr_count($STOPSETTIME, ":")){
      $STOPSETTIME_YEAR = strtok($STOPSETTIME, ":");
      $STOPSETTIME_MONTH = strtok(":");
      $STOPSETTIME_DAY = strtok(":");
      $STOPSETTIME_HOUR = strtok(":");
      $STOPSETTIME_MIN = strtok(":");
      }
   }

if(0 == strlen($STARTTIME_YEAR)){ $STARTTIME_YEAR = "100"; }
if(0 == strlen($STARTTIME_MONTH)){ $STARTTIME_MONTH = "100"; }
if(0 == strlen($STARTTIME_DAY)){ $STARTTIME_DAY = "100"; }
if(0 == strlen($STARTTIME_HOUR)){ $STARTTIME_HOUR = "100"; }
if(0 == strlen($STARTTIME_MIN)){ $STARTTIME_MIN = "00"; }

if(0 == strlen($STOPSETTIME_YEAR)){ $STOPSETTIME_YEAR = "100"; }
if(0 == strlen($STOPSETTIME_MONTH)){ $STOPSETTIME_MONTH = "100"; }
if(0 == strlen($STOPSETTIME_DAY)){ $STOPSETTIME_DAY = "100"; }
if(0 == strlen($STOPSETTIME_HOUR)){ $STOPSETTIME_HOUR = "100"; }
if(0 == strlen($STOPSETTIME_MIN)){ $STOPSETTIME_MIN = "00"; }

$STARTTIME = $STARTTIME_YEAR . ":" . $STARTTIME_MONTH . ":" . $STARTTIME_DAY . ":" . $STARTTIME_HOUR . ":" . $STARTTIME_MIN;
$STOPSETTIME = $STOPSETTIME_YEAR . ":" . $STOPSETTIME_MONTH . ":" . $STOPSETTIME_DAY . ":" . $STOPSETTIME_HOUR . ":" . $STOPSETTIME_MIN;


echo " start = $STARTTIME \n";
echo " stop = $STOPSETTIME \n";


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


$result = db_query($conn, "select * from connection where cname='$CNAME';");
if(!$result){
   print("bud query set(select)\n");
   exit;
   }
$num = db_num_rows($result);
if($num > 0){
   print("OK 棘骰弁仿奶失件玄反繡箕仄引允鈾n");
   }
else{
   print("NG 棘骰弁仿奶失件玄反繡箕仄引六氏\n");
   exit;
   }
db_free_result($result);


$result = db_query($conn, "select * from userblock where bname='$BNAME';");
if(!$result){
   print("bud update query set\n");
   exit;
   }
$num = db_num_rows($result);

if($num > 0){
   print("OK 棘骰皮伕永弁反允匹卞繡箕仄引允\n");

   if("ON" == $EDIT){
      print("OK 彸螂乒□玉卅及匹曉踏五仄引允\n");

      $result=db_query($conn, "select * from userblock where bname='$BNAME'");
      if(!$result){
         print("bud query set\n");
         exit;
         }
      $num2 = db_num_rows($result);
      if($num2 > 0){
         $CNAME_OLD = enco_rtrim(db_fetch_Result($result, $s, cname));
         $BNAME_OLD = enco_rtrim(db_fetch_Result($result, $s, bname));
         }

      if("ON" == $KANSHI){
         $result = db_query($conn, "update userblock set
           youname='$BNAME',
           bname='$BNAME', 
           cname='$CNAME',
           mailsend='$MAILSEND',
           stat='$STAT',
           plustime=$PLUSTIME,
           starttime='$STARTTIME',
           stopsettime='$STOPSETTIME',
           mailto='$MAILTO',
           mailcc='$MAILCC',
           free1='$FREE1',
           free2='$FREE2',
           free3='NOT'
           where bname='$BNAME'");
          }

      else{
         $result = db_query($conn, "update userblock set
           youname='$YOUNAME',
           bname='$BNAME', 
           cname='$CNAME',
           mailsend='$MAILSEND',
           stat='$STAT',
           plustime=$PLUSTIME,
           starttime='$STARTTIME',
           stopsettime='$STOPSETTIME',
           mailto='$MAILTO',
           mailcc='$MAILCC',
           free1='$FREE1',
           free2='$FREE2',
           free3='NOT'
           where bname='$BNAME'");
          }

      print("OK 棘骰嫩杴毛譆五晶尹化中五引允\n");
      $result =db_query($conn,
        "update monitor set free4='$BNAME',
                            cname='$CNAME'
                      where free4='$BNAME_OLD' and cname='$CNAME_OLD'");
      if(!$result){
         print("bud query set\n");
         exit;
         }

      list_file_upload($CNAME, $GEN);
      list_file_upload($CNAME_OLD, $GEN);

      }
   else{
      print("OK 彸螂乒□玉匹卅中及匹﹜曉踏五仄引六氏\n");
      }
   if(!$result){
      print("bud update query set\n");
      exit;
      }
   }

if($num <= 0){
   if("ON" != $EDIT){
      print("OK 彸螂乒□玉匹拑中及匹﹜棘骰皮伕永弁毛綜嶽仄引允鈾n");
      $result = db_query($conn, "insert into userblock values (
       '$YOUNAME',
       '$BNAME', 
       '$CNAME',
       '$MAILSEND',
       '$STAT',
       $PLUSTIME,
       '$STARTTIME',
       '$STOPSETTIME',
       '$MAILTO',
       '$MAILCC',
       '$FREE1',
       '$FREE2',
       'NOT'
        )");
      if(!$result){
         print("bud update query set\n");
         exit;
         }
      }
   }



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

print("</font>");

?>

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


