<!--#include file="conn.asp"-->
<!--#include file="inc/cook1.asp"-->
<!--#include file="inc/dimflag.asp" -->
<!--#include file="file_err.asp"-->
<!--#include file="top.asp"-->
<div id="container">
<%
filepath=request("filepath")
SaveUpFilesPath=filepath '存放上传文件的目录
Const MaxPerPage=30
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim UploadDir,TruePath,fso,theFolder,theFile,whichfile,thisfile,FileCount,TotleSize
strFileName="file_upload.asp"

if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if

if right(SaveUpFilesPath,1)<>"/" then
	UploadDir="" & SaveUpFilesPath & "/"
else
	UploadDir="" & SaveUpFilesPath
end if
TruePath=Server.MapPath(UploadDir)
If not IsObjInstalled("Scripting.FileSystemObject") Then
	Response.Write "<b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能</font></b>"
Else
set fso=CreateObject("Scripting.FileSystemObject")

if request("Action")="Del" then
whichfile=server.mappath(Request("FileName")) 
Set thisfile = fso.GetFile(whichfile) 
thisfile.Delete True
end if
%>

<%
  if fso.FolderExists(TruePath)then
	FileCount=0
	TotleSize=0
	Set theFolder=fso.GetFolder(TruePath)
	For Each theFile In theFolder.Files
		FileCount=FileCount+1
		TotleSize=TotleSize+theFile.Size
	next
    totalPut=FileCount
	if currentpage<1 then
   		currentpage=1
   	end if
   	if (currentpage-1)*MaxPerPage>totalput then
		if (totalPut mod MaxPerPage)=0 then
	  		currentpage= totalPut \ MaxPerPage
	  	else
	      	currentpage= totalPut \ MaxPerPage + 1
		end if
    end if
%>
<div class="top_but">
 <li class="left">&nbsp;</li>
 <li><img src="images/but_3.gif" alt="删除"  onclick="form1.action='file_delfile.asp'; ConfirmDel() "></li>
 <li><img src="images/but_8.gif" alt="刷新" onClick="window.location.reload(true);"></li>
 <li><img src="images/but_9.gif" alt="打印" onClick="window.print() "/></li>
</div>
<form name="form1" id="form1" action="file_delfile.asp" >
<% showContent %>
<div id="divStayTop" class="bottom titlebgcolor" >
<li style="width:30px;">&nbsp;</li>
<li><%showpage2 strFileName,filepath,totalput,MaxPerPage%></li>
</div>
<%
else
response.write "<br>找不到文件夹！可能是配置有误！"
end if
end if
%>
</form>
</div>
<%
sub showContent()
dim c
FileCount=0
TotleSize=0
%>
<input name="filepath" type="hidden" id="filepath" value="<%=filepath%>" >
<div class="tableAll titlebgcolor">
 <li style="width:30px"><input name="chkall" type="checkbox" id="chkall" value="select" onClick="CheckAll(this.form)" ></li>
 <li style="width:50px">操作</li>
 <li style="width:250px">文件名(点击可查看文件)</li>
 <li style="width:150px">文件大小</li>
 <li style="width:150px">文件类型</li>
 <li style="width:200px">最后修改时间</li>
</div>
<%
For Each theFile In theFolder.Files
c=c+1
if FileCount>=MaxPerPage then
exit for
elseif c>MaxPerPage*(CurrentPage-1) then
%>
<div class="tableAll trbgcolor">
 <li style="width:80px"><%
dim aa,bb,cc,dd
set rs=server.CreateObject("adodb.recordset") 
    
rs.open "select bookpicm,bookpic,textcn,texten,textutf from com_books where bookpicm like'%"&theFile.Name&"%' or bookpic like'%"&theFile.Name&"%' or InStr(1,LCase(textcn),LCase('"&theFile.Name&"'),0)<>0 or InStr(1,LCase(texten),LCase('"&theFile.Name&"'),0)<>0 or InStr(1,LCase(textutf),LCase('"&theFile.Name&"'),0)<>0",conn,1,1    

'rs.open "select bookpicm,bookpic,textcn,texten,textutf from com_books where bookpicm like'%"&theFile.Name&"%' or bookpic like'%"&theFile.Name&"%' or textcn like'%"&theFile.Name&"%' or texten like'%"&theFile.Name&"%' or textutf like'%"&theFile.Name&"%'",conn,1,1              
if rs.eof and rs.bof then                   
aa=1
else
aa=0
end if
rs.close

rs.open "select textcn,texten,textutf from com_news where InStr(1,LCase(textcn),LCase('"&theFile.Name&"'),0)<>0 or InStr(1,LCase(texten),LCase('"&theFile.Name&"'),0)<>0 or InStr(1,LCase(textutf),LCase('"&theFile.Name&"'),0)<>0 ",conn,1,1
'rs.open "select textcn,texten,textutf from com_news where textcn like'%"&theFile.Name&"%' or texten like'%"&theFile.Name&"%' or textutf like'%"&theFile.Name&"%'",conn,1,1
'Sql = "select * from [tbname] where InStr(1,LCase(Title),LCase('"&keyword&"'),0)<>0 order by id desc"

if rs.eof and rs.bof then                   
bb=1
else
bb=0
end if
rs.close

rs.open "select bookpicm,bookpic from com_class where bookpicm like'%"&theFile.Name&"%' or bookpic like'%"&theFile.Name&"%'",conn,1,1               
if rs.eof and rs.bof then                   
cc=1
else
cc=0
end if
rs.close

rs.open "select bookpicm from com_down where bookpicm like'%"&theFile.Name&"%'",conn,1,1               
if rs.eof and rs.bof then                   
dd=1
else
dd=0
end if
rs.close

set rs=nothing
if aa=1 and bb=1 and cc=1 and dd=1 then
Response.Write "<input type=checkbox name=delfilename value="&UploadDir&theFile.Name&">&nbsp;&nbsp;<a href=?Action=Del&FileName="&UploadDir&theFile.Name&"&filepath="&filepath&" onclick='return ConfirmDel()'>删除</a>" 
else
Response.Write "<span style='padding-left:28px; color=#ccc;'>使用中</span>"
end if
%></li>
 <li style="width:250px"><a href="<%=(UploadDir & theFile.Name)%>" target="_blank"><%=theFile.Name%></a></li>
 <li style="width:150px"><%=theFile.size\1024%>kb</li>
 <li style="width:150px"><%=theFile.type%></li>
 <li style="width:200px"><%=theFile.DateLastModified%></li>
</div>
<%
FileCount=FileCount+1
TotleSize=TotleSize+theFile.Size
end if
Next
end sub
%>
<%
sub showpage2(sfilename,filepath,totalnumber,maxperpage)
dim n, i,strTemp
	if totalnumber mod maxperpage=0 then
    	n= totalnumber \ maxperpage
  	else
    	n= totalnumber \ maxperpage+1
  	end if

  	'strTemp= "<form name='showpages' method='Post' action='" & sfilename & "'>"
	strTemp=strTemp & "<div>总共搜索到<b> <font color=ff0000>"&FileCount&"</font> </b>个上传文件，占用 <b><font color=ff0000>"&TotleSize\1024&"</font></b> Kb&nbsp;&nbsp; "
	sfilename=JoinChar(sfilename)
  	if CurrentPage<2 then
    		strTemp=strTemp & "首页&nbsp;上一页&nbsp;"
  	else
    		strTemp=strTemp & "<a href='" & sfilename & "filepath="&filepath&"&page=1'>首页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & sfilename & "filepath="&filepath&"&page=" & (CurrentPage-1) & "'>上一页</a>&nbsp;"
  	end if

  	if n-currentpage<1 then
    		strTemp=strTemp & "下一页&nbsp;尾页"
  	else
    		strTemp=strTemp & "<a href='" & sfilename & "filepath="&filepath&"&page=" & (CurrentPage+1) & "'>下一页</a>&nbsp;"
    		strTemp=strTemp & "<a href='" & sfilename & "filepath="&filepath&"&page=" & n & "'>尾页</a>"
  	end if
   	strTemp=strTemp & "&nbsp;页次：<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & "个文件/页"
	strTemp=strTemp & "&nbsp;转到：<select name='page' size='1' onChange=""MM_jumpMenu('this',this,0)"">" 
	'strTemp=strTemp & "&nbsp;转到：<select name='page' size='1' onchange='javascript:submit()'>"   
    for i = 1 to n   
   		strTemp=strTemp & "<option value='?filepath="&filepath&"&page=" & i & "'"
		if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
		strTemp=strTemp & ">第" & i & "页</option>"   
	next
	strTemp=strTemp & "</select>"
	response.write strTemp
end sub
%>
<!--#include file="footer.asp"-->