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

function WinCls(){
        window.close()
                       }
// window.onload=WinCls();
//-->";
echo "</SCRIPT>";

print("</head>\n");
print("<body alink='#ff0000' bgcolor='$my_bgcolor' 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");
echo "<pre>";
print($font_size);
print($version_name);
print(date("Y m d g i s A"));
print("\n");
print("新規で監視ブロックを作成します。\n");
print("各ブロック単位で実行時間を指定することが可能です。\n");
echo "詳しいことは";
echo "<a target=help href='./block_help.html'> ここ </a>";
echo "を確認してください。";

echo "\n";
echo "<FORM METHOD=GET ACTION='block_upnew.php' target=block_upnew>";

echo "<TABLE cellspacing=0 cellpadding=3 nowrap border=1 Bordercolor='$my_bocolor' nowrap border=0 WIDTH='790' height='8%'BGCOLOR='#e6e8fa'>";



// echo "<TABLE  cellspacing=0 cellpadding=3 nowrap border=0 Bordercolor='$my_bocolor' nowrap border=0  WIDTH='90%' height='8%'BGCOLOR='#e6e8fa'>";


$BNAME = enco($_GET["BNAME"]);
$CNAME = enco($_GET["CNAME"]);
$MAILTO = enco($_GET["MAILTO"]);
$MAILCC = enco($_GET["MAILCC"]);
$MAILSEND = enco($_GET["MAILSEND"]);
$PLUSTIME = enco($_GET["PLUSTIME"]);
$STAT = enco($_GET["STAT"]);
$STARTTIME = enco($_GET["STARTTIME"]);
$STOPSETTIME = enco($_GET["STOPSETTIME"]);
$FREE1 = enco($_GET["FREE1"]);
$FREE2 = enco($_GET["FREE2"]);
$UNO = enco($_GET["UNO"]);


if(0 >= strlen($STAT)){
   $STAT = "NOT";
   }


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


if(0 != strlen($BNAME)){
   $select_data = "select * from userblock where bname='$BNAME'";
   $result = db_query($conn, $select_data);
   if($result){
      $num = db_num_rows($result);
      if($num == 1){
         while($s < $num){
          echo "ブロックが存在したので反映しています。\n";
//          echo "$select_data\n";

            $YOUNAME = enco_rtrim(db_fetch_Result($result, $s, youname));
            $CNAME = enco_rtrim(db_fetch_Result($result, $s, cname));
            $BNAME = enco_rtrim(db_fetch_Result($result, $s, bname));
            $MAILSEND = enco_rtrim(db_fetch_Result($result, $s, mailsend));
            $STAT = enco_rtrim(db_fetch_Result($result, $s, stat));
            $PLUSTIME = enco_rtrim(db_fetch_Result($result, $s, plustime));
            $STARTTIME = enco_rtrim(db_fetch_Result($result, $s, starttime));
            $STOPSETTIME = enco_rtrim(db_fetch_Result($result, $s, stopsettime));
            $MAILTO = enco_rtrim(db_fetch_Result($result, $s, mailto));
            $MAILCC = enco_rtrim(db_fetch_Result($result, $s, mailcc));
            $FREE1 = enco_rtrim(db_fetch_Result($result, $s, free1));
            $FREE2 = enco_rtrim(db_fetch_Result($result, $s, free2));
            $UNO = enco_rtrim(db_fetch_Result($result, $s, uno));



            $s++;
            }
         }
      }
   }


if(0 == strlen($BNAME)){
   $BNAME = "";
   }
if(0 == strlen($CNAME)){
   $CNAME = "";
   }
if(0 == strlen($MAILTO)){
   $MAILTO = "test@localhost";
   }
if(0 == strlen($MAILCC)){
   $MAILCC = "";
   }
if(0 == strlen($PLUSTIME)){
   $PLUSTIME = "60";
   }
if(1 == strlen($STAT)){
   $STAT = "NOT";
   }
if(0 == strlen($MAILSEND)){
   $MAILSEND = "OFF";
   }
if(0 == strlen($STARTTIME)){
   $STARTTIME = "100:100:100:100:00";
   }
if(0 == strlen($STOPSETTIME)){
   $STOPSETTIME = "100:100:100:100:00";
   }
if(0 == strlen($FREE1)){
   $FREE1 = "block infolmation";
   }
if(0 == strlen($FREE2)){
   $FREE2 = "mail priority";
   }


// 監視クライアントリストの作成
$cname_count = 0;
$result=db_query($conn,"select distinct(cname) from connection;");
if(!$result){
   print("canem select , bud query\n");
   exit;
   }
$num = db_num_rows($result);
if($num > 0){
   while($cname_count < $num){
      $xcname_data[$cname_count] = enco_rtrim(db_fetch_Result($result, $cname_count, cname));
      $cname_count++;
      }
   }
db_free_result($result);





// echo "1 $STARTTIME\n";
// echo "2 $STOPSETTIME\n";

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








echo "<tr><td>";
echo "監視ブロック名\n";
echo "</td><td>";
echo "<INPUT type='text' NAME=BNAME size='48' value='$BNAME'>";
echo "</td></tr>";

echo "<tr bgcolor='#D9DBED'><td>";
echo "このブロックを登録する監視クライアント名\n";
echo "</td><td>";
// echo "<INPUT type='text' NAME=CNAME size='48' value='$CNAME'>";
echo "<select size=1 name=CNAME>";
echo "<option value='$CNAME'>$CNAME";
for($select_count = 0; $select_count < $cname_count; $select_count++){
   echo "<option value=$xcname_data[$select_count]>$xcname_data[$select_count]";
   }
echo "</select>";

echo "</td></tr>";

echo "<tr><td>";
echo "メイルのTo:\n";
echo "</td><td>";
echo "<INPUT type='text' NAME=MAILTO size='48' value='$MAILTO'>";
echo "</td></tr>";

echo "<tr><td>";
echo "メイルのCc:\n";
echo "</td><td>";
echo "<INPUT type='text' NAME=MAILCC size='48' value='$MAILCC'>";
echo "</td></tr>";


echo "<tr><td>";
echo "監視インターバル(加算秒)\n";
echo "</td><td>";
echo "<select size=1 name=PLUSTIME>";
echo "<option value=$PLUSTIME selected>$PLUSTIME";
echo "<option value=0>0";
echo "<option value=60>1分";
echo "<option value=120>2分";
echo "<option value=180>3分";
echo "<option value=240>4分";
echo "<option value=300>5分";
echo "<option value=360>6分";
echo "<option value=420>7分";
echo "<option value=480>8分";
echo "<option value=540>9分";
echo "<option value=600>10分";
echo "<option value=900>15分";
echo "<option value=1200>20分";
echo "<option value=1500>25分";
echo "<option value=1800>30分";
echo "<option value=2100>35分";
echo "<option value=2400>40分";
echo "<option value=2700>45分";
echo "<option value=3000>50分";
echo "<option value=3300>55分";
echo "<option value=3600>1時間";
echo "</select>";
echo "</td></tr>";


echo "<tr><td>";
echo "監視モード選択";
echo "</td><td>";
echo "<select size=1 name=STAT>";
echo "<option value=$STAT selected>$STAT";
echo "<option value=NOT>NOT";
echo "<option value=JUST>JUST";
echo "<option value=FOR>FOR";
echo "<option value=RES>RES";
echo "</select><br>";
echo "JUSTで指定時刻実行、FORは指定時刻内(例 1時から12時)に実行<br>";
echo "RESは指定時刻内(例 1時から12時)に停止<br>";
echo "JUSTは指定時刻(時間)内に一回だけ実行されます。監視停止時刻だけ設定してください";
echo "</td></tr>";




echo "<tr bgcolor='#D9DBED'><td>";
echo "監視開始時刻(年:月:日:時:分)";
echo "</td><td>";

echo "<select size=1 name=STARTTIME_YEAR>";
echo "<option value=$STARTTIME_YEAR selected>$STARTTIME_YEAR";
echo "<option value=100>100無効";
echo "<option value=2008>2008";
echo "<option value=2009>2009";
echo "<option value=2010>2010";
echo "<option value=2011>2011";
echo "<option value=2012>2012";
echo "<option value=2013>2013";
echo "<option value=2014>2014";
echo "<option value=2015>2015";
echo "<option value=2016>2016";
echo "<option value=2017>2017";
echo "<option value=2018>2018";
echo "<option value=2019>2019";
echo "<option value=2020>2020";
echo "</select>";
echo " : ";
echo "<select size=1 name=STARTTIME_MONTH>";
echo "<option value=$STARTTIME_MONTH selected>$STARTTIME_MONTH";
echo "<option value=100>100無効";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "</select>";
echo " : ";
echo "<select size=1 name=STARTTIME_DAY>";
echo "<option value=$STARTTIME_DAY selected>$STARTTIME_DAY";
echo "<option value=100>100無効";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "<option value=13>13";
echo "<option value=14>14";
echo "<option value=15>15";
echo "<option value=16>16";
echo "<option value=17>17";
echo "<option value=18>18";
echo "<option value=19>19";
echo "<option value=20>20";
echo "<option value=21>21";
echo "<option value=22>22";
echo "<option value=23>23";
echo "<option value=24>24";
echo "<option value=25>25";
echo "<option value=26>26";
echo "<option value=27>27";
echo "<option value=28>28";
echo "<option value=29>29";
echo "<option value=30>30";
echo "<option value=31>31";
echo "</select>";
echo " : ";
echo "<select size=1 name=STARTTIME_HOUR>";
echo "<option value=$STARTTIME_HOUR selected>$STARTTIME_HOUR";
echo "<option value=100>100無効";
echo "<option value=0>0";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "<option value=13>13";
echo "<option value=14>14";
echo "<option value=15>15";
echo "<option value=16>16";
echo "<option value=17>17";
echo "<option value=18>18";
echo "<option value=19>19";
echo "<option value=20>20";
echo "<option value=21>21";
echo "<option value=22>22";
echo "<option value=23>23";
echo "<option value=24>24";
echo "</select>";
echo " : ";
echo "<select size=1 name=STARTTIME_MIN>";
echo "<option value=$STARTTIME_MIN selected>$STARTTIME_MIN";
echo "<option value=0>0";
echo "<option value=5>5";
echo "<option value=10>10";
echo "<option value=15>15";
echo "<option value=20>20";
echo "<option value=25>25";
echo "<option value=30>30";
echo "<option value=35>35";
echo "<option value=40>40";
echo "<option value=45>45";
echo "<option value=50>50";
echo "<option value=55>55";
echo "<option value=60>60";
echo "</select>";

echo "<br>100の場合は無効設定です<br>";
echo "</td></tr>";




echo "<tr bgcolor='#D9DBED'><td>";
echo "監視停止時刻(年:月:日:時:分)";
echo "</td><td>";

echo "<select size=1 name=STOPSETTIME_YEAR>";
echo "<option value=$STOPSETTIME_YEAR selected>$STOPSETTIME_YEAR";
echo "<option value=100>100無効";
echo "<option value=2008>2008";
echo "<option value=2009>2009";
echo "<option value=2010>2010";
echo "<option value=2011>2011";
echo "<option value=2012>2012";
echo "<option value=2013>2013";
echo "<option value=2014>2014";
echo "<option value=2015>2015";
echo "<option value=2016>2016";
echo "<option value=2017>2017";
echo "<option value=2018>2018";
echo "<option value=2019>2019";
echo "<option value=2020>2020";
echo "</select>";
echo " : ";
echo "<select size=1 name=STOPSETTIME_MONTH>";
echo "<option value=$STOPSETTIME_MONTH selected>$STOPSETTIME_MONTH";
echo "<option value=100>100無効";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "</select>";
echo " : ";
echo "<select size=1 name=STOPSETTIME_DAY>";
echo "<option value=$STOPSETTIME_DAY selected>$STOPSETTIME_DAY";
echo "<option value=100>100無効";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "<option value=13>13";
echo "<option value=14>14";
echo "<option value=15>15";
echo "<option value=16>16";
echo "<option value=17>17";
echo "<option value=18>18";
echo "<option value=19>19";
echo "<option value=20>20";
echo "<option value=21>21";
echo "<option value=22>22";
echo "<option value=23>23";
echo "<option value=24>24";
echo "<option value=25>25";
echo "<option value=26>26";
echo "<option value=27>27";
echo "<option value=28>28";
echo "<option value=29>29";
echo "<option value=30>30";
echo "<option value=31>31";
echo "<option value=200>200日曜日";
echo "<option value=201>201月曜日";
echo "<option value=202>202火曜日";
echo "<option value=203>203水曜日";
echo "<option value=204>204木曜日";
echo "<option value=205>205金曜日";
echo "<option value=206>206土曜日";
echo "</select>";
echo " : ";
echo "<select size=1 name=STOPSETTIME_HOUR>";
echo "<option value=$STOPSETTIME_HOUR selected>$STOPSETTIME_HOUR";
echo "<option value=100>100無効";
echo "<option value=0>0";
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=6>6";
echo "<option value=7>7";
echo "<option value=8>8";
echo "<option value=9>9";
echo "<option value=10>10";
echo "<option value=11>11";
echo "<option value=12>12";
echo "<option value=13>13";
echo "<option value=14>14";
echo "<option value=15>15";
echo "<option value=16>16";
echo "<option value=17>17";
echo "<option value=18>18";
echo "<option value=19>19";
echo "<option value=20>20";
echo "<option value=21>21";
echo "<option value=22>22";
echo "<option value=23>23";
echo "<option value=24>24";
echo "</select>";
echo " : ";
echo "<select size=1 name=STOPSETTIME_MIN>";
echo "<option value=$STOPSETTIME_MIN selected>$STOPSETTIME_MIN";
echo "<option value=0>0";
echo "<option value=5>5";
echo "<option value=10>10";
echo "<option value=15>15";
echo "<option value=20>20";
echo "<option value=25>25";
echo "<option value=30>30";
echo "<option value=35>35";
echo "<option value=40>40";
echo "<option value=45>45";
echo "<option value=50>50";
echo "<option value=55>55";
echo "<option value=60>60";
echo "</select>";

echo "<br> JUSTの場合はこちらが有効となります、曜日の選択はJUSTしか行えません </br>";
echo "</td></tr>";



echo "<tr bgcolor='#D9DBED'><td>";
echo "この監視ブロックの情報";
echo "</td><td>";
echo "<INPUT type='text' NAME=FREE1 size='100' value='$FREE1'>";
echo "</td></tr>";


echo "<tr bgcolor='#D9DBED'><td>";
echo "エラーメールのプライオリティー";
echo "</td><td>";
echo "<select size=1 name=FREE2>";
echo "<option value=$FREE2 selected>$FREE2";
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 "</select>";
echo "</td></tr>";



echo "<tr><td>";
echo "メールの送信方法";
echo "</td><td>";
echo "<select size=1 name=MAILSEND>";
echo "<option value=$MAILSEND selected>$MAILSEND";
echo "<option value=OFF>(OFF)送信停止";
echo "<option value=ON>(ON)送信";
echo "<option value=MID>(MID)自動間欠モード１";
echo "<option value=MIX>(MIX)自動間欠モード２";
echo "</select><br>";
echo "メールを送信、停止出来ます。 <br>";
echo "自動間欠モードとは、連続したエラーを3回までメール送信しますが、以後は停止します。 <br>";
echo "1の場合は再度正常な監視が3回連続して行われた場合リセットされます。<br>";
echo "2の場合は再度正常な監視が行われた場合は自動でリセットされます。<br>";


echo"</table>";


echo "\n";
echo "<font color=red>";
echo "チェックすることで上書き(編集)になります。<br>";
echo "</font>";
echo "<input type=submit value='監視ブロックの新規作成'>";
echo "<INPUT type='checkbox' value='ON' NAME=EDIT>";
echo "</form>";


print("</font>");

?>

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



