<!--#include file="../login/0.asp"-->
<!--#include file="../../mycartconn/conn.asp" -->
<!--#INCLUDE FILE="HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<!--#INCLUDE FILE="HXINCLUDE/HX_SYSTEM.ASP"-->
<!--#INCLUDE FILE="HXINCLUDE/HX_FILEICON.ASP"-->
<%
LOGINUSERNAME="mofahe"   '设置默认登陆用户

ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
if ComeUrl<>"" then ComeUrl=PathFileReplace(ComeUrl)
FilePath=PathReplace(UrlDecoded(request("Path")))
if FilePath="" or isnull(FilePath) then FilePath="/"
FolderId = Split(Request.Form("FolderId"),",")
FileId = Split(Request.Form("FileId"),",")
action=request("action")
FileDir=""
  orderby=" where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"'"
if ubound(FolderId)>=0 then
  for i=0 to ubound(FolderId)
   FileDir=FileDir&FolderId(i)&"<br>"
  next 
end if
if ubound(FileId)>=0 then
  for i=0 to ubound(FileId)
   FileDir=FileDir&FileId(i)&"<br>"
  next 
end if
if FileDir="" or isnull(FileDir) then
  FileDir=FilePath
end if
if ubound(FolderId)>=0 then
   orderby=orderby&" and DirName='"&trim(FolderId(0))&"'"
elseif ubound(FileId)>=0 then
   orderby=orderby&" and FileName='"&trim(FileId(0))&"'"
end if
if action="update" then
  Share=request.Form("Share")
  FilePath=PathReplace(FilePath)
select case Share
case 0
       if ubound(FolderId)>=0 then
           for i=0 to ubound(FolderId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and DirName='"&trim(FolderId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=0
			 rs("OpenPass")=empty
			 rs("ShareType")=0
			 rs("AddFile")=0
			 rs("EditFile")=0
			 rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
       if ubound(FileId)>=0 then
           for i=0 to ubound(FileId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and FileName='"&trim(FileId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=0
			 rs("OpenPass")=empty
			 rs("ShareType")=0
			 rs("AddFile")=0
			 rs("EditFile")=0
			 rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
	 if ubound(FolderId)<0 and ubound(FileId)<0 then
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"'")
     	    if rs.recordcount>0 then
		     rs("Share")=0
			 rs("OpenPass")=empty
			 rs("ShareType")=0
			 rs("AddFile")=0
			 rs("EditFile")=0
			 rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if 
		   HX_RSClose rs            
	 end if
case 1
    AddFile=request("AddFile")
    EditFile=request("EditFile")
    DelFile=request("DelFile")
    OpenPass=request("OpenPass")
	SET URS=HX_SetRSD("","HX_CompanyUser"," where WS_Uid<>"&loginuid&" and WS_department="&LOGdepartment)
	UserArr="|"
	if URS.recordcount>0 then
	  do until URS.eof
	    UserArr=UserArr&URS("WS_Uid")&"|"
	  URS.movenext
	  loop
	end if
	HX_RSClose Urs
       if ubound(FolderId)>=0 then
           for i=0 to ubound(FolderId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and DirName='"&trim(FolderId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=UserArr
			 rs("ShareAdd")=UserArr
			 rs("ShareEdit")=UserArr
			 rs("ShareDel")=UserArr
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
       if ubound(FileId)>=0 then
           for i=0 to ubound(FileId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and FileName='"&trim(FileId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=UserArr
			 rs("ShareAdd")=UserArr
			 rs("ShareEdit")=UserArr
			 rs("ShareDel")=UserArr
			 rs.update		   
		   end if            
          next 
		   HX_RSClose rs            
        end if
 
	 if ubound(FolderId)<0 and ubound(FileId)<0 then
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"'")
     	    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=UserArr
			 rs("ShareAdd")=UserArr
			 rs("ShareEdit")=UserArr
			 rs("ShareDel")=UserArr
			 rs.update		   
		   end if
		   HX_RSClose rs            
	 end if	 
case 2
    AddFile=request("AddFile1")
    EditFile=request("EditFile1")
    DelFile=request("DelFile1")
    OpenPass=request("OpenPass1")
       if ubound(FolderId)>=0 then
           for i=0 to ubound(FolderId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and DirName='"&trim(FolderId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
       if ubound(FileId)>=0 then
           for i=0 to ubound(FileId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and FileName='"&trim(FileId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
	 if ubound(FolderId)<0 and ubound(FileId)<0 then
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"'")
     	    if rs.recordcount>0 then
		     rs("Share")=Share
			 rs("OpenPass")=OpenPass
			 rs("ShareType")=1
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=empty
			 rs("ShareAdd")=empty
			 rs("ShareEdit")=empty
			 rs("ShareDel")=empty
			 rs.update		   
		   end if 
		   HX_RSClose rs            
	 end if	 
case 3
	   ShareType=request("WS_ShareTypeUid")
	   AddFile=request("WS_AddFileUid")
	   EditFile=request("WS_EditFileUid")
	   DelFile=request("WS_DelFileUid")
	   FilePath=replace(FilePath,"/","\")
       if ubound(FolderId)>=0 then
           for i=0 to ubound(FolderId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and DirName='"&trim(FolderId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 if ShareType<>"" then rs("ShareType")=1 else rs("ShareType")=0
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=ShareType
			 rs("ShareAdd")=AddFile
			 rs("ShareEdit")=EditFile
			 rs("ShareDel")=DelFile
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
       if ubound(FileId)>=0 then
           for i=0 to ubound(FileId)
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"' and FileName='"&trim(FileId(i))&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 if ShareType<>"" then rs("ShareType")=1 else rs("ShareType")=0
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=ShareType
			 rs("ShareAdd")=AddFile
			 rs("ShareEdit")=EditFile
			 rs("ShareDel")=DelFile
			 rs.update		   
		   end if            
          next
		   HX_RSClose rs            
        end if
 
	 if ubound(FolderId)<0 and ubound(FileId)<0 then
	       SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile"," where UserName='"&LOGINUSERNAME&"' and Postion='"&FilePath&"'")
		    if rs.recordcount>0 then
		     rs("Share")=Share
			 if ShareType<>"" then rs("ShareType")=1 else rs("ShareType")=0
			 if AddFile<>"" then rs("AddFile")=1 else rs("AddFile")=0
			 if EditFile<>"" then rs("EditFile")=1 else rs("EditFile")=0
			 if DelFile<>"" then rs("DelFile")=1 else rs("DelFile")=0
			 rs("ShareSee")=ShareType
			 rs("ShareAdd")=AddFile
			 rs("ShareEdit")=EditFile
			 rs("ShareDel")=DelFile
			 rs.update		   
		   end if 
		   HX_RSClose rs            
	 end if	 
end select
response.redirect "netdisk.asp?ThisDir="&FilePath
response.end
end if
     SET RS=HX_SetRSD("","HX_NetDiskFolderOrFile",orderby)
     if rs.recordcount>0 then
             Share=trim(rs("Share"))
			 ShareType=trim(rs("ShareType"))
			 AddFile=trim(rs("AddFile"))
			 EditFile=trim(rs("EditFile"))
			 DelFile=trim(rs("DelFile"))
			 ShareSee=trim(rs("ShareSee"))
			 ShareAdd=trim(rs("ShareAdd"))
			 ShareEdit=trim(rs("ShareEdit"))
			 ShareDel=trim(rs("ShareDel"))
			 OpenPass=trim(rs("OpenPass"))
       if Share="" or isnull(Share) then Share=0
     end if
%>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<title>网络硬盘－目录和文件共享</title>
<script>OnloadPage();</script></head>
<body>
<table cellpadding='2' cellspacing='1' border='0' class='border' align=center>
<form name="form1" method="post" action="" id="form">
<input type="hidden" name="action" value="update">
<input type="hidden" name="Path" value="<%=UrlEncoded(FilePath)%>">
<input type="hidden" name="FolderId" value="<%=Request.Form("FolderId")%>">
<input type="hidden" name="FileId" value="<%=Request.Form("FileId")%>">
<tr class="title"> 
  <td>目录和文件共享</td>
</tr>
<tr align="left" valign="middle"> 
  <td class="titletdbg" height="25">
	  <table width="100%" border="0">
<tr>
	<td>以下是您共享的目录和文件：</td>
</tr>
<tr>
	<td><font color=red><%=FileDir%></font></td>
</tr></table><table width="100%" border="0">
<tr>
	<td width="100%">请指定共享权限：</td>
</tr>
<tr>
	<td><table border="0" style="width:400px;">
	<tr>
		<td><input id="Share1" type="radio" name="Share" value="0" onClick="ShareDisplay('Panel');" class=radio <%if Share=0 then response.Write "checked"%> /><label for="Share1">不共享</label></td>
		<td><input id="Share2" type="radio" name="Share" value="1" onClick="ShareDisplay('Panel1');" class=radio <%if Share=1 then response.Write "checked"%> /><label for="Share2">共享给本部门</label></td>
		<td><input id="Share3" type="radio" name="Share" value="2" onClick="ShareDisplay('Panel2');" class=radio <%if Share=2 then response.Write "checked"%> /><label for="Share3">所有人可见</label></td>
		<td><input id="Share4" type="radio" name="Share" value="3" onClick="ShareDisplay('Panel3');" class=radio <%if Share=3 then response.Write "checked"%> /><label for="Share4">指定人可见</label></td>
	</tr>
</table></td></tr></table>
<div id="Panel" style="display:<%if Share=0 then response.Write "" else response.Write "none;"%>"></div>
<div id="Panel1" style="display:<%if Share=1 then response.Write "" else response.Write "none;"%>">
<TABLE width="100%" border="0">
<TR><TD width="100%">可设定文件夹查看密码(对文件无效)： <input name="OpenPass" type="text" autocomplete=off id="OpenPass" value="<%=OpenPass%>"></TD></TR>
<TR><TD width="49%">指定特殊权限：</TD></TR>
<TR><TD vAlign="top">
<input id="AddFile" type="checkbox" name="AddFile" class=radio <%if AddFile=1 then response.write "checked"%>><label for="AddFile">可添加</label>
<input id="EditFile" type="checkbox" name="EditFile" class=radio <%if EditFile=1 then response.write "checked"%>><label for="EditFile">可修改（覆盖）</label>
<input id="DelFile" type="checkbox" name="DelFile" class=radio <%if DelFile=1 then response.write "checked"%>><label for="DelFile">可删除</label></TD>
</TR></TABLE></div>
<div id="Panel2" style="display:<%if Share=2 then response.Write "" else response.Write "none;"%>">
<TABLE width="100%" border="0">
<TR><TD width="100%">可设定文件夹查看密码(对文件无效)： <input name="OpenPass1" type="text" autocomplete=off id="OpenPass1" value="<%=OpenPass%>"></TD></TR>
<TR><TD width="49%">指定特殊权限：</TD></TR>
<TR><TD vAlign="top">
<input id="AddFile1" type="checkbox" name="AddFile1" class=radio <%if AddFile=1 then response.write "checked"%>><label for="AddFile1">可添加</label>
<input id="EditFile1" type="checkbox" name="EditFile1" class=radio <%if EditFile=1 then response.write "checked"%>><label for="EditFile1">可修改（覆盖）</label>
<input id="DelFile1" type="checkbox" name="DelFile1" class=radio <%if DelFile=1 then response.write "checked"%>><label for="DelFile1">可删除</label></TD>
</TR></TABLE>
</div>
<div id="Panel3" style="display:<%if Share=3 then response.Write "" else response.Write "none;"%>">
<TABLE width="100%" border="0">
	<TR>
		<TD width="51%">以下是有读取权限的用户：</TD>
		<TD width="49%">以下是有添加权限的用户：</TD>
	</TR>
	<TR>
		<TD>
<input type="hidden" name="WS_ShareTypeUid" value="<%=ShareSee%>">
<textarea name="WS_ShareTypeName" cols="40" rows="5" readonly><%=ShowUserName(ShareSee)%></textarea>
	<br />
<input type="button" class="button" name="Button1" value="选择" onClick="openwin(510,500,'../HXinclude/HX_Selectuser.asp?checkuser=ShareType')" id="Button1" /></TD>
		<TD vAlign="top">
<input type="hidden" name="WS_AddFileUid" value="<%=ShareAdd%>">			
<textarea name="WS_AddFileName" cols="40" rows="5" readonly><%=ShowUserName(ShareAdd)%></textarea><br />
	<input type="button" class="button" name="Button2" value="选择" onClick="openwin(510,500,'../HXinclude/HX_Selectuser.asp?checkuser=AddFile')" id="Button2" /></TD>
	</TR>
</TABLE>
<TABLE id="Table3" width="100%" border="0">
	<TR>
		<TD width="51%">以下是有修改权限的用户：</TD>
		<TD width="49%">以下是有删除权限的用户：</TD>
	</TR>
	<TR>
		<TD>
			<P>
<input type="hidden" name="WS_EditFileUid" value="<%=ShareEdit%>">				
<textarea name="WS_EditFileName" cols="40" rows="5" readonly><%=ShowUserName(ShareEdit)%></textarea><br />
	<input type="button" class="button" name="Button3" value="选择" onClick="openwin(510,500,'../HXinclude/HX_Selectuser.asp?checkuser=EditFile')" id="Button3" />
			</TD>
		<TD vAlign="top">
<input type="hidden" name="WS_DelFileUid" value="<%=ShareDel%>">	
<textarea name="WS_DelFileName" cols="40" rows="5" readonly><%=ShowUserName(ShareDel)%></textarea><br />
 <input type="button" class="button" name="Button4" value="选择" onClick="openwin(510,500,'../HXinclude/HX_Selectuser.asp?checkuser=DelFile')" id="Button4" /></TD>
	</TR>
</TABLE></div><br>
<input type="submit" class="button" name="Button5" value="完成设置" id="Button5" />　
<input onClick="javascript:window.location='<%=ComeUrl%>';" type="button" class="button" value="返回前页"
		name="Submit"><input name="Hidden1" type="hidden" id="Hidden1" style="WIDTH: 23px; HEIGHT: 22px" size="1" /> <input name="type" type="hidden" id="type" style="WIDTH: 24px; HEIGHT: 22px" size="1" /></td>
</tr></form></table></td>
</tr>
  </table>
