<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../css/main.css">
</HEAD>
<%
LoginID=Session("LoginID")
if LoginID="" then response.end
set rs=server.createobject("adodb.recordset")
sql="select LookOtherIDs from tblUser where ID="& LoginID

rs.open sql,oConn
if not rs.eof then
	strLookOtherIDs=trim(rs("LookOtherIDs"))
end if
rs.close
set rs=nothing


FromID=trim(request("FromID"))
if FromID="" then FromID=0
Title=replace(trim(request("Title")),"'","''")
StartTime=replace(trim(request("StartTime")),"'","''")
EndTime=replace(trim(request("EndTime")),"'","''")
if StartTime<>"" and not isdate(StartTime) then
	response.write "<font color=#ff0000>输入的不是日期格式！</font>"
	response.write "<a href=# onclick=""javascript:history.back(-1);"">[返回]</a>"
	oconn.close
	response.end
end if
if EndTime<>"" and not isdate(EndTime) then
	response.write "<font color=#ff0000>输入的不是日期格式！</font>"
	response.write "<a href=# onclick=""javascript:history.back(-1);"">[返回]</a>"
	oconn.close
	response.end
end if
if StartTime<>"" then
if cdate(StartTime)>date() then StartTime=date()
end if
if endTime<>"" and EndTime<StartTime then EndTime=StartTime

maxmessage=15
currentpage=request("page")
if currentpage="" then 
currentpage=1
end if

set rs=Server.CreateObject("ADODB.RecordSet")
sql="select ID,FromID,Title,FilePath,Times from tblFile where id>0 "
if FromID<>"0" then
sql=sql& " and FromID="& FromID
end if
if Title<>"" then
sql=sql& " and Title like '%"& Title &"%'"
end if
if StartTime<>"" then
sql=sql& " and Times >='"& StartTime &"'"
end if
if EndTime<>"" then
sql=sql& " and Times <='"& EndTime &"'"
end if

rs.pagesize=maxmessage
rs.open sql,oConn,1,1
totalpage=rs.pagecount
totalmessage=rs.recordcount
if totalmessage<>0 then
	rs.AbsolutePage=currentpage
	msgArr=rs.getrows(maxmessage)
end if

rs.close
%>
<BODY BGCOLOR="#FFFFFF">
<fieldset title="文件检索">
<legend align=center><font color=red class="pt11"><b>文件检索</b></font></legend> 
<div style="word-break:break-all;font-size:12px;line-height:16px;padding:10px;">

我们将采用组合条件检索的方式搜寻您要找的文件，但必须保证您已被授权查看该文件。
<form name="SearchForm" method="Post" action="">
<div align=center>
<table width="75%" border=0>
<tr>
	<td>文件主题：<input type="text" name="Title" value="<%=Title%>" class="input" size=20 maxlength=50></td>
	<td>创建人：<%options "FromID","tblUser","Name",FromID%></td>
</tr>
<tr>
<td>创建时间：
从：<input type="text" name="StartTime" value="<%=StartTime%>" class="input" size=10 maxlength=20>(yyyy-mm-dd)
</td>
<td>到：<input type="text" name="EndTime" value="<%=EndTime%>" class="input" size=10 maxlength=20>(yyyy-mm-dd)
<INPUT TYPE="submit" name="cmdSearch" value="搜  索" class="font9boldwhite">

</td>
</tr>
</table>
</div>
</form>

</div></fieldset> 
<BR>
<fieldset title="检索到的文件">
<legend align=left>
<%response.write "检索到的文件 共" & totalmessage & "条/" & totalpage & "页，每页"& maxmessage &"条"%>

<%
if totalpage>0 then
	response.write "，第" & currentpage & "页　"
end if

if totalpage>1 then
	if currentpage>1 then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?page=<%=currentpage-1%>">上页</a>　　
		<%
	end if

	if currentpage+1<=totalpage then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?page=<%=currentpage+1%>">下页</a>
		<%
	end if
end if
%>
</font></legend> 
<div>
<table border=0 width="100%" bgcolor=#FFFFFF cellpadding=3>
<tr bgcolor=#eeeddb>
<td>文件</td>
<td>主题</td>
<td>创建人</td>
<td>创建时间</td>
</tr>
<%
if isempty(msgArr) then
	response.write "<tr><td colspan=7>没有搜索到您指定的文件。</td></tr>"
else
for i = 0 to UBound(msgArr,2)
%>
	<tr>
		<td width="20%">
		<%
		strFile=trim(msgArr(3,i))
		arrFile=split(strFile,"/")
		theFile = arrFile(ubound(arrFile))
		if right(strFile,"1")="/" or right(strFile,"1")="\"  then strFile=left(strFile,(len(strFile)-1))
		'response.write strFile
		if instr(strLookOtherIDs,trim(msgArr(1,i)))>0 or LoginID=trim(msgArr(1,i)) or instr(strFile,"_Share/")>0 or instr(strFile,"FileDir/Public")>0 then
		%>
		<a target="_blank" href="http://<%=Request.ServerVariables("SERVER_NAME")&"/"&server.URLencode(strFile)%>" alt="<%=strFile%>"><%=theFile%></a>
		<%else%>
		<%=theFile%>
		<%end if%>
		</td>
		<td><%=trim(msgArr(2,i))%></td>
		<td width="15%"><%=GetTableValue("tblUser","Name","ID",trim(msgArr(1,i)))%></td>
		<td width="20%"><%=trim(msgArr(4,i))%></td>
	
	</tr>
<%
next
end if
%>

</table>

</div></fieldset> 
<BR><BR>
</BODY>
</HTML>
<!--#include file="../inc/conn_close.htm"-->
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		'set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function

%>
