OSDN Git Service

new rule
[squarantine/squarantine.git] / package / var / squarantine / www / regist.php
index b3fde2e..beedfb4 100644 (file)
@@ -8,15 +8,29 @@
 <?php 
 require_once('spyc.php');
 $conf = Spyc::YAMLLoad('/etc/squarantine/squarantine.conf');
-
 $SAMBAPATH = "//192.168.0.51/usb/";
 if (isset( $_POST["id"      ] )) { $_var[      "id"]=$_POST["id"] ;      }
 if (isset( $_POST["nickname"] )) { $_var["nickname"]=$_POST["nickname"]; }
-if (isset( $_POST["flags"   ] )) { $_var[   "flags"]=$_POST["flags"];    }
 if (isset( $_POST["distpath"] )) { $_var["distpath"]=$_POST["distpath"]; }
+if (isset( $_POST["distaccount"] )) { $_var["distaccount"]=$_POST["distaccount"]; }
 if (isset( $_POST["memo"    ] )) { $_var[    "memo"]=$_POST["memo"];     }
 if (isset( $_POST["mode"    ] )) { $_var[    "mode"]=$_POST["mode"];     } else {  $_var["mode"]=0; }
 if (isset( $_POST["devname" ] )) { $_var[ "devname"]=$_POST["devname"];  }
+if (isset( $_POST["flags1"   ] )) { $_var["flags1"   ]=$_POST["flags1"   ];     } else {  $_var["flags1"   ]=0; }
+if (isset( $_POST["flags2"   ] )) { $_var["flags2"   ]=$_POST["flags2"   ];     } else {  $_var["flags2"   ]=0; }
+if (isset( $_POST["flags4"   ] )) { $_var["flags4"   ]=$_POST["flags4"   ];     } else {  $_var["flags4"   ]=0; }
+if (isset( $_POST["flags8"   ] )) { $_var["flags8"   ]=$_POST["flags8"   ];     } else {  $_var["flags8"   ]=0; }
+if (isset( $_POST["flags16"  ] )) { $_var["flags16"  ]=$_POST["flags16"  ];     } else {  $_var["flags16"   ]=0; }
+if (isset( $_POST["flags32"  ] )) { $_var["flags32"  ]=$_POST["flags32"  ];     } else {  $_var["flags32"   ]=0; }
+if (isset( $_POST["flags64"  ] )) { $_var["flags64"  ]=$_POST["flags64"  ];     } else {  $_var["flags64"   ]=0; }
+if (isset( $_POST["flags128" ] )) { $_var["flags128" ]=$_POST["flags128" ];     } else {  $_var["flags128"   ]=0; }
+if (isset( $_POST["flags256" ] )) { $_var["flags256" ]=$_POST["flags256" ];     } else {  $_var["flags256"   ]=0; }
+if (isset( $_POST["flags512" ] )) { $_var["flags512" ]=$_POST["flags512" ];     } else {  $_var["flags512"   ]=0; }
+if (isset( $_POST["flags1024"] )) { $_var["flags1024"]=$_POST["flags1024"];     } else {  $_var["flags1024"   ]=0; }
+ $_var["flags"]= $_var["flags1" ]+ $_var["flags2" ]+ $_var["flags4" ]+ $_var["flags8" ]+ $_var["flags16" ]+ $_var["flags32"   ]+ $_var["flags64"   ]+ $_var["flags128"   ]+ $_var["flags256"   ]+ $_var["flags512"   ]+ $_var["flags1024"   ]; 
+
+
+
 if (isset( $_POST["adminid" ] ) && isset( $_POST["adminpass"] ) &&  0 == strcmp( "admin",$_POST["adminid"] )  &&  0 == strcmp( $conf["WEB_ADMINPASS"],$_POST["adminpass"] )) {
    $_var["adminmode"] = 1;
 } else {
@@ -38,31 +52,13 @@ $db = 'squarantine';
 
 ?>
 <?php
-<table style="border:0" width="100%">
-<tbody><tr>
-<td style="border:0"><img src="image/addr.png" alt="address"></td>
-<td style="border:0"><img src="image/logo.png" alt="Logo" align="right"></td>
-<td style="border:1"><form action=regist.php method=POST>
-  <table border=1><tr><td><input type=text name=adminid>:ID</td></tr><tr><td><input type=password name=adminpass>:PASS</td></tr></table>
-<input type="hidden" name="mode" value="change">
-<input type="submit" value="login">
-<?php
-if ( 1 == isset( $_var["id"] )) {
-?>
-<input type="hidden" name="id" value="<?php echo $_var[      "id"];  ?>">
-<?php } ?>
-</form>
-</td>
-</tr></tbody>
-</table>
-<?php
 
-if ( 0 == isset( $_var["id"] )){
+if ( 0 == isset( $_var["id"] )){ 
 // ----------------------------------------------- list mode start-----------------------
- print("<h1>登録済みUSBデバイス一覧</h1>");
+// print("<h1>登録済みUSBデバイス一覧</h1>");
 
 
-        $sql = "select id,id_serial,nickname,memo,flags from media";
+        $sql = "select id,id_serial,nickname,memo,flags,distpath,distaccount from media";
         $results = mysql_db_query($db,$sql);
         if (!$results)
         {
@@ -72,9 +68,243 @@ if ( 0 == isset( $_var["id"] )){
         $num = mysql_num_fields($results);
 ?>
 
-<table border=1><tr><th></th><th>ID</th><th>名前</th><th>説明</th><th>動作</th><th></th></tr>
+<table>
+<tbody>
+<tr>
+<td colspan="4" rowspan="11" style="vertical-align: top;"><br>
+<table style="border: 0pt none ;" width="100%">
+<tbody>
+<tr>
+<td style="border: 0pt none ;"><img src="image/addr.png"
+alt="address"></td>
+<td style="border: 0pt none ;"><img src="image/logo.png"
+alt="Logo" align="right"></td>
+<td style="">
+<form action="regist.php" method="post">
+<table border="1">
+<tbody>
+<tr>
+<td><input name="adminid" type="text">:ID</td>
+</tr>
+<tr>
+<td><input name="adminpass" type="password">:PASS</td>
+</tr>
+</tbody>
+</table>
+<input name="mode" value="change" type="hidden">
+<input value="login" type="submit">
+<?php 
+if ( 1 == isset( $_var["id"] )) {
+?>
+<input type="hidden" name="id" value="<?php echo $_var[      "id"];  ?>">
+<?php } ?>
+</form> 
+</td>
+</tr>
+</tbody>
+</table>
 
 
+<h1>登録済みUSBデバイス一覧</h1>
+</td>
+<th style="vertical-align: top;">┏<br>
+</th>
+<td colspan="11" rowspan="1" style="vertical-align: top;">*未登録<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="10" rowspan="1" style="vertical-align: top;">*使用禁止<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="9" rowspan="1" style="vertical-align: top;">*信頼済(管理者
+のみ利用)<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="8" rowspan="1" style="vertical-align: top;">(操作前確認<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="7" rowspan="1" style="vertical-align: top;">(削除ファイルを
+バックアップ<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="6" rowspan="1" style="vertical-align: top;">実行ファイル削除<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="5" rowspan="1" style="vertical-align: top;">検疫済ファイルを外
+部にコピー
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="4" rowspan="1" style="vertical-align: top;">フォーマット<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="3" rowspan="1" style="vertical-align: top;">*使用停止<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="2" rowspan="1" style="vertical-align: top;">検疫後共有公開<br>
+</td>
+</tr>
+<tr>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">|<br>
+</th>
+<th style="vertical-align: top;">┏
+</th>
+<td colspan="1" rowspan="1" style="vertical-align: top;">持出可(書込OK)</td>
+</tr>
+
+<tr>
+<th style="vertical-align: top;"></th>
+<th style="vertical-align: top;">USB ID</th>
+<th style="vertical-align: top;">名前</th>
+<th style="vertical-align: top;">説明</th>
+</th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th style="vertical-align: top;">|<br> </th>
+<th>外部コピー先</th>
+</tr>
+
 <?php
         while($row=mysql_fetch_array($results))
         {
@@ -84,15 +314,15 @@ if ( 0 == isset( $_var["id"] )){
                         print("<td>".$row[$j]."</td>");
                 }
                 if ( 0 == $row[4] ) {
-                  print ("<td>@</td>");
+                  print ("<td></td>");
                } else {
-                  print ("<td></td>");
+                  print ("<td></td>");
                 }
                 for ( $i=1 ; $i<=512 ; $i = $i * 2 ) {
                  if ( 0 == ( $i & $row[4]) ){
-                   $check="";
+                   $check="";
                  } else {
-                   $check="@";
+                   $check="";
                  }
                   print("<td>$check</td>");
                }
@@ -100,6 +330,9 @@ if ( 0 == isset( $_var["id"] )){
 //              print ($row[4]); // flags
 //               print("</td>");
                 print("<td>");
+               print ($row[5]);  // distpath
+                print("</td>");
+                print("<td>");
                if (1 == $_var["adminmode"]){
 ?>
                <form action="regist.php" method="post">
@@ -132,7 +365,7 @@ exit(0);
 }
 // ----------------------------------------------- list mode end-----------------------
 
-$sql = "select id_serial,nickname,flags,memo,distpath from media where id=\"".$_var["id"]."\"";
+$sql = "select id_serial,nickname,flags,memo,distpath,distaccount from media where id=\"".$_var["id"]."\"";
 // echo $sql;
 $results = mysql_db_query($db,$sql);
 if (!$results)
@@ -143,20 +376,22 @@ if (!$results)
 $num = mysql_num_fields($results);
 while($row=mysql_fetch_array($results))
 {
-       $org["id_serial"] =($row[0]);
-       $org["nickname" ] =($row[1]);
-       $org["flags"    ] =($row[2]);
-       $org["memo"     ] =($row[3]);
-       $org["distpath" ] =($row[4]);
+       $org["id_serial"  ] =($row[0]);
+       $org["nickname"   ] =($row[1]);
+       $org["flags"      ] =($row[2]);
+       $org["memo"       ] =($row[3]);
+       $org["distpath"   ] =($row[4]);
+       $org["distaccount"] =($row[5]);
  }
 mysql_free_result($results);
 if ( 0 == strcmp("regist", $_var["mode"])){
 // ----------------------------------------------- new regist mode start-----------------------
         $sql = "update media set
-                nickname=\"".$_var["nickname"]."\",
-               flags   =\"".$_var["flags"]."\", 
-               memo    =\"".$_var["memo"]."\", 
-               distpath=\"".$_var["distpath"]."\" 
+                nickname   =\"".$_var["nickname"]."\",
+               flags      =\"".$_var["flags"]."\", 
+               memo       =\"".$_var["memo"]."\", 
+               distpath   =\"".$_var["distpath"]."\",
+               distaccount=\"".$_var["distaccount"]."\" 
         where id=\"".$_var["id"]."\"";
         
         $results = mysql_db_query($db,$sql);
@@ -190,40 +425,6 @@ print "$sql";
 <b>一旦抜いて、もう一度差し直してください</b>
 <?php
 //----------------------------new regist mode end -------------------
-} else if ( 0 == strcmp("format", $_var["mode"])){
-//----------------------------format mode start --------------------
-print "<h1>format中...</h1>";
-print "<pre>";
-passthru("sudo mkfs.vfat   ".$_var["devname"]);
-passthru("sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
-passthru("echo sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
-#passthru("find /etc -name a*");
-print "</pre>";
-print "<h2>終了しました</h2>";
-print "<a href=\"file:".$conf["SAMBAPATH"]."\">こちらからアクセスしてください</a>";
-
-
-//----------------------------format mode end   --------------------
-} else if ( 0 == strcmp("delete", $_var["mode"])){
-//----------------------------delete mode start --------------------
-print "<h1>消毒中...</h1>";
-print "<pre>";
-print $_var["devname"]."\n";
-passthru("sudo mount ".$_var["devname"]." /mnt".$_var["devname"]);
-//passthru("sudo mount");
-//print "-------------\n";
-passthru("sudo usbsearchdelete /mnt".$_var["devname"]);
-passthru("sudo umount ".$_var["devname"]);
-passthru("sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
-//passthru("sudo mount");
-//passthru("sudo echo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
-//passthru("echo 123");
-//passthru("find /etc -name a*");
-print "</pre>";
-print "<h2>終了しました</h2>";
-
-
-//----------------------------delete mode end   --------------------
 } else if ( 0 == strcmp("change",$_var["mode"] )) {
 //----------------------------device edit mdde start -----------------
 print("<h1>登録情報変更</h1>");
@@ -237,105 +438,126 @@ print("<h1>登録情報変更</h1>");
 <br>
 <input type="text" name=memo     value="<?php echo $org["memo"    ]; ?>">メモ(備忘録)
 <br>
-<input type="text" name=flags    value="<?php echo $org["flags"   ]; ?>">動作指定
+動作指定
 <br>
+<input type="checkbox" name=flags1    value="1"   <?php if ( 0 != (   1 &$org["flags"]) ) { print "checked"; } ?>>*使用禁止
+<br>
+<input type="checkbox" name=flags2    value="2"   <?php if ( 0 != (   2 &$org["flags"]) ) { print "checked"; } ?>>*信頼済(管理者のみ利用)
+<br>
+<input type="checkbox" name=flags4    value="4"   <?php if ( 0 != (   4 &$org["flags"]) ) { print "checked"; } ?>>操作前確認
+<br>
+<input type="checkbox" name=flags8    value="8"   <?php if ( 0 != (   8 &$org["flags"]) ) { print "checked"; } ?>>#削除ファイルをバックアップ
+<br>
+<input type="checkbox" name=flags16   value="16"  <?php if ( 0 != (  16 &$org["flags"]) ) { print "checked"; } ?>>実行ファイル削除
+<br>
+<input type="checkbox" name=flags32   value="32"  <?php if ( 0 != (  32 &$org["flags"]) ) { print "checked"; } ?>>検疫済ファイルを外部にコピー
+<br>
+<input type="checkbox" name=flags64   value="64"  <?php if ( 0 != (  64 &$org["flags"]) ) { print "checked"; } ?>>フォーマット
+<br>
+<input type="checkbox" name=flags128  value="128" <?php if ( 0 != ( 128 &$org["flags"]) ) { print "checked"; } ?>>*使用停止
+<br>
+<input type="checkbox" name=flags256  value="256" <?php if ( 0 != ( 256 &$org["flags"]) ) { print "checked"; } ?>>検疫後共有公開
+<br>
+<input type="checkbox" name=flags512  value="512" <?php if ( 0 != ( 512 &$org["flags"]) ) { print "checked"; } ?>>持出可(書込OK) 
 
+<br>
+ルールは上から順番に適用されます。*印のついているものは、そこでストップします。#印のついているものは現在使用できません
+<br>
+<input type="text" name=distpath value="<?php echo $org["distpath"]; ?>">コピー先PATH //SERVERNAME/DIR/PATH のように入力してください
+<br>
+<input type="text" name=distaccount value="<?php echo $org["distaccount"]; ?>">コピー先PATHへのユーザ名、パスワード USERNAME%PASSWORDと入力してください。必要ない場合も%のみ入力してください
+<br>
 <input type="submit">
 <input type="hidden" name="id" value="<?php echo $_var["id"]; ?>">
 <input type="hidden" name="mode" value="regist">
 </form>
 <?php
 //----------------------------device edit mode end-------------
-} else if ( 0 == $_var["mode"] ) {  
+} else if ( 0 == strcmp( "0",  $_var["mode"] ) ) {  
 //----------------------------new device found mode -----------------
 print("<h1>このUSBデバイス(".$org["nickname"].")は未登録です</h1>");
 
-
 ?>
 
 <b>以下のボタンから登録してください</b>
 <form action="regist.php" method="POST">
 <input type="text" name=nickname value="<?php echo $org["nickname"]; ?>">ニックネームを登録してください
+<br>
 <input type="text" name=memo     value="<?php echo $org["memo"    ]; ?>">メモ(備忘録)
-<input type="text" name=flags    value="<?php echo $org["flags"   ]; ?>">動作指定
-
+<br>
+動作指定
+<br>
+<input type="checkbox" name=flags1    value="1"   <?php if ( 0 != (   1 &$org["flags"]) ) { print "checked"; } ?>>*使用禁止
+<br>
+<input type="checkbox" name=flags2    value="2"   <?php if ( 0 != (   2 &$org["flags"]) ) { print "checked"; } ?>>*信頼済(管理者のみ利用)
+<br>
+<input type="checkbox" name=flags4    value="4"   <?php if ( 0 != (   4 &$org["flags"]) ) { print "checked"; } ?>>操作前確認
+<br>
+<input type="checkbox" name=flags8    value="8"   <?php if ( 0 != (   8 &$org["flags"]) ) { print "checked"; } ?>>#削除ファイルをバックアップ
+<br>
+<input type="checkbox" name=flags16   value="16"  <?php if ( 0 != (  16 &$org["flags"]) ) { print "checked"; } ?>>実行ファイル削除
+<br>
+<input type="checkbox" name=flags32   value="32"  <?php if ( 0 != (  32 &$org["flags"]) ) { print "checked"; } ?>>検疫済ファイルを外部にコピー
+<br>
+<input type="checkbox" name=flags64   value="64"  <?php if ( 0 != (  64 &$org["flags"]) ) { print "checked"; } ?>>フォーマット
+<br>
+<input type="checkbox" name=flags128  value="128" <?php if ( 0 != ( 128 &$org["flags"]) ) { print "checked"; } ?>>*使用停止
+<br>
+<input type="checkbox" name=flags256  value="256" <?php if ( 0 != ( 256 &$org["flags"]) ) { print "checked"; } ?>>検疫後共有公開
+<br>
+<input type="checkbox" name=flags512  value="512" <?php if ( 0 != ( 512 &$org["flags"]) ) { print "checked"; } ?>>持出可(書込OK) 
+<br>
 
+ルールは上から順番に適用されます。*印のついているものは、そこでストップします。#印のついているものは現在使用できません
+<br>
+<input type="text" name=distpath value="<?php echo $org["distpath"]; ?>">コピー先PATH //SERVERNAME/DIR/PATH のように入力してください
+<br>
+<input type="text" name=distaccount value="<?php echo $org["distaccount"]; ?>">コピー先PATHへのユーザ名、パスワード USERNAME%PASSWORDと入力してください。必要ない場合も%のみ入力してください
+<br>
 <input type="submit">
 <input type="hidden" name="id" value="<?php echo $_var["id"]; ?>">
 <input type="hidden" name="mode" value="regist">
 </form>
 <?php
 //----------------------------new device found mode end-------------
-} else if ( 1 == $_var["mode"] ) {
-//----------------------------forbidden mode start-------------
- print("<h1>このUSBデバイスは使用禁止です</h1>");
-
-
-        $sql = "select * from media where id=\"".$_var["id"]."\"";
-        $results = mysql_db_query($db,$sql);
-        if (!$results)
-        {
-                print("SQL execution error");
-                exit;
-        }
-        $num = mysql_num_fields($results);
+} else if ( 0 == strcmp("ACTION",$_var["mode"]) ) {
+//----------------------------ACTION mode start-------------
+  
+$flags = $org["flags"];
+// print_r ($org);
+  $actions="";
+  if (   1 == (    1 & $flags )) { $actions = $actions."「使用禁止」"; }
+  if (   2 == (    2 & $flags )) { $actions = $actions."「信頼済」"; }
+  if (   4 == (    4 & $flags )) { $actions = $actions."「操作前確認」"; }
+  if (   8 == (    8 & $flags )) { $actions = $actions."「削除ファイルをバックアップ」"; }
+  if (  16 == (   16 & $flags )) { $actions = $actions."「実行ファイル削除」"; }
+  if (  32 == (   32 & $flags )) { $actions = $actions."「検疫済ファイルを外部にコピー」"; }
+  if (  64 == (   64 & $flags )) { $actions = $actions."「フォーマット」"; }
+  if ( 128 == (  128 & $flags )) { $actions = $actions."「使用停止」"; }
+  if ( 256 == (  256 & $flags )) { $actions = $actions."「検疫後共有公開」"; }
+  if ( 512 == (  512 & $flags )) { $actions = $actions."「持出可」"; }
+
+  if (   4 == (    4 & $flags )) {
+//----------------------------actionconfirm mode start-------------
+
+    print("<h1>このUSBデバイスは".$actions."として設定されています</h1>");
 ?>
-
-<table border=1><tr><th></th><th>ID</th><th>名前</th><th>説明</th><th></th></tr><tr>
+ <b>以下のボタンを押して開始してください</b>
+ <form action="regist.php" method="POST">
+ <input type="submit">
+ <input type="hidden" name="devname" value="<?php echo $_var["devname"]; ?>">
+ <input type="hidden" name="id"      value="<?php echo $_var["id"]; ?>">
+ <input type="hidden" name="mode"    value="DOACTION">
+ <input type="hidden" name="flags"   value="<?php echo $_var["flags"]; ?>">
+ </form>
 <?php
-        while($row=mysql_fetch_array($results))
-        {
-                for($j=0;$j<$num;$j++)
-                {
-                        print("<td>".$row[$j]."</td>");
-                }
-        }
-        mysql_free_result($results);
-        mysql_close($dbh);
 
+//----------------------------actionconfirm mode end-------------
 
-?>
+  } else if (  0 !=  $flags ) { 
+//----------------------------actiondisplay mode start-------------
 
-</tr></table>
-状態の変更は管理としてログインしてください
-<?php
-//----------------------------forbidden mode end-------------
-} else if ( 2 == $_var["mode"] ) {
-//----------------------------stop mode start-------------
- print("<h1>このUSBデバイスは使用停止中です</h1>");
-
-
-        $sql = "select * from media where id=\"".$_var["id"]."\"";
-        $results = mysql_db_query($db,$sql);
-        if (!$results)
-        {
-                print("SQL execution error");
-                exit;
-        }
-        $num = mysql_num_fields($results);
-?>
-
-<table border=1><tr><th></th><th>ID</th><th>名前</th><th>説明</th><th></th></tr><tr>
-<?php
-        while($row=mysql_fetch_array($results))
-        {
-                for($j=0;$j<$num;$j++)
-                {
-                        print("<td>".$row[$j]."</td>");
-                }
-        }
-        mysql_free_result($results);
-        mysql_close($dbh);
-
-
-?>
-</tr></table>
-状態の変更は管理としてログインしてください
-<?php
-//----------------------------stop mode end-------------
-} else if ( 4 == $_var["mode"] ) {
-//----------------------------hold mode start-------------
- print("<h1>このUSBデバイスの使用は保留中です</h1>");
+    print("<h1>このUSBデバイスは".$actions."として設定されています</h1>");
 
 
         $sql = "select * from media where id=\"".$_var["id"]."\"";
@@ -364,43 +586,97 @@ print("<h1>このUSBデバイス(".$org["nickname"].")は未登録です</h1>");
 ?>
 
 </tr></table>
-状態の変更は管理としてログインしてください
-<?php
-//----------------------------hold mode end-------------
-} else if ( 16 == $_var["mode"] ) {  
-//----------------------------manual   format  mode start-------------
- print("<h1>このUSBデバイスのフォーマットを開始します</h1>");
-
-?>
-
-<b>以下のボタンを押して開始してください</b>
-<form action="regist.php" method="POST">
-<input type="submit">
-<input type="hidden" name="devname" value="<?php echo $_var["devname"]; ?>">
-<input type="hidden" name="id"      value="<?php echo $_var["id"]; ?>">
-<input type="hidden" name="mode"    value="format">
-</form>
+状態の変更は管理者としてログインしてください
 <?php
-//----------------------------manual   format  mode end-------------
-} else if ( 64 == $_var["mode"] ) {
-//----------------------------manual   delete  mode start-------------
- print("<h1>このUSBデバイスの消毒を開始します</h1>");
-
-echo $_var["devname"];
-?>
+//----------------------------actiondisplay mode end-------------
+  }
+} else if ( 0 == strcmp("DOACTION", $_var["mode"])){
+//----------------------------manual action mode start --------------------
+       
+ob_end_flush();
+
+$flags = $org["flags"];
+  $actions="";
+  if (   1 == (    1 & $flags )) { $actions = $actions."「使用禁止」"; }
+  if (   2 == (    2 & $flags )) { $actions = $actions."「信頼済」"; }
+  if (   4 == (    4 & $flags )) { $actions = $actions."「操作前確認」"; }
+  if (   8 == (    8 & $flags )) { $actions = $actions."「削除ファイルをバックアップ」"; }
+  if (  16 == (   16 & $flags )) { $actions = $actions."「実行ファイル削除」"; }
+  if (  32 == (   32 & $flags )) { $actions = $actions."「検疫済ファイルを外部にコピー」"; }
+  if (  64 == (   64 & $flags )) { $actions = $actions."「フォーマット」"; }
+  if ( 128 == (  128 & $flags )) { $actions = $actions."「使用停止」"; }
+  if ( 256 == (  256 & $flags )) { $actions = $actions."「検疫後共有公開」"; }
+  if ( 512 == (  512 & $flags )) { $actions = $actions."「持出可」"; }
+
+  if (   4 == (    4 & $flags )) {
+//----------------------------actionconfirm mode start-------------
+
+    print("<h1>このUSBデバイスは".$actions."として設定されています</h1>");
+  if (        1 == (    1 & $flags )) {
+     $action = "「使用禁止」"; 
+     print $action;
+} else {
+  if (  16 == (   16 & $flags )) {
+      $action = "「実行ファイル削除」";
+      print $action;
+      print "<h1>消毒中...</h1>";
+      print "<pre>";
+      print $_var["devname"]."\n";
+      passthru("sudo mount ".$_var["devname"]." /mnt".$_var["devname"]);
+      //passthru("sudo mount");
+      //print "-------------\n";
+      passthru("sudo usbsearchdelete /mnt".$_var["devname"]);
+      passthru("sudo umount ".$_var["devname"]);
+      print "</pre>";
+  }
+  if (  32 == (   32 & $flags )) {
+      $action = "「検疫済ファイルを外部にコピー」";
+      print $action;
+      print "<h1>外部にコピー中...</h1>";
+      print "<pre>";
+      passthru("sudo mkdir -p /mnt".$_var["devname"]);
+      passthru("sudo mount ".$_var["devname"]." /mnt".$_var["devname"]);
+      passthru("sudo smbmount ".$_var["distpath"]." /mnt/$id -o username=".$_var["distaccount"]);
+      passthru("sudo cp -a /mnt".$_var["devname"]."/ /mnt/".$_var["id"]);
+      passthru("sudo umount ".$_var["devname"]);
+      print "</pre>";
+  }
+  if (  64 == (   64 & $flags )) {
+      $action = "「フォーマット」";
+      print $action;
+      print "<h1>format中...</h1>";
+      print "<pre>";
+      passthru("sudo mkfs.vfat   ".$_var["devname"]);
+      passthru("sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
+      passthru("echo sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
+      #passthru("find /etc -name a*");
+      print "</pre>";
+  }
+  if ( 128 == (  128 & $flags )) {
+      $action = "「使用停止」";
+      print $action;
+  } else {
+    if ( 256 == (  256 & $flags )) {
+       $action = "「検疫後共有公開」";
+       print $action;
+       if ( 512 == (  512 & $flags )) {
+          $action = "「持出可」";
+          print $action;
+          passthru("sudo mount ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
+       } else {
+          passthru("sudo mount -r ".$_var["devname"]." /var/squarantine/usbstorages/".$org["nickname"]);
+       }
+       print "<h2>終了しました</h2>";
+       print "<a href=\"file:".$conf["SAMBAPATH"]."\">こちらからアクセスしてください</a>";
+
+    }
+  }
+}
+}
+}
 
-<b>以下のボタンを押して開始してください</b>
-<form action="regist.php" method="POST">
-<input type="submit">
-<input type="hidden" name="devname" value="<?php echo $_var["devname"]; ?>">
-<input type="hidden" name="id"      value="<?php echo $_var["id"]; ?>">
-<input type="hidden" name="mode"    value="delete">
-</form>
-<?php
 
-//----------------------------manual   delete  mode end-------------
-}
+//----------------------------DOACTION mode end   --------------------
 
 ?>
 </body>