📄 files.asp
字号:
<%@ LANGUAGE = VBScript %><!--#include file="utils.asp" -->
<%check_security(2)%>
<%
dim fileext
fileext="ace,app,arj,asp,av,avi,bmp,cab,cad,chm,com,dll,down,doc,exe,dtp,gif,htm,html,img,jpeg"&_
",jpg,m3a,mid,mov,move,mp3,mpeg,mpg,ppt,ra,rar,real,rm,sql,swf,tar,txt,url,mav,wave,xls,zip"
Function sql_GetFoldersCount()
dim sql
' if DB_BOOLACCESS or DB_BOOLPOSTGRES or DB_BOOLMYSQL then
sql = "SELECT folders.folder_id, " & _
"(Count(folders_1.sub_to) + Count(files.folder)) as rec_count " & _
"FROM files RIGHT JOIN " & _
"(folders AS folders_1 RIGHT JOIN " & _
"folders ON folders_1.sub_to = folders.folder_id) " & _
"ON files.folder = folders.folder_id " & _
"GROUP BY folders.folder_id"
' else
' sql = "SELECT folders.folder_id, " & _
' "(Count(folders.sub_to) + Count(files.folder)) as rec_count " & _
' "FROM folders " & _
' "LEFT JOIN folders as folders on folders.folder_id = folders.sub_to " & _
' "LEFT JOIN files on folders.folder_id = files.folder " & _
' "WHERE " & _
' "folders.folder_id = files.folder " & _
' "or folders.folder_id = folders.sub_to " & _
' "GROUP BY folders.folder_id"
' end if
sql_GetFoldersCount = sql
End Function
Function sql_GetFolderByID(id)
dim sql
sql = "SELECT * FROM folders WHERE folder_id = " & id & ""
sql_GetFolderByID = sql
End Function
Function sql_GetSubFoldersByFolderID(id)
dim sql
sql = "SELECT * FROM folders WHERE sub_to = " & id & " ORDER BY folder"
sql_GetSubFoldersByFolderID = sql
End Function
Function sql_GetDocumentByDocumentID(id)
dim sql
sql = "SELECT * FROM files " & _
"WHERE id = " & id & ""
sql_GetDocumentByDocumentID = sql
End Function
Function sql_UpdateDocument(id, submitby,description,folder)
dim sql
sql = "UPDATE files set submitby = " & submitby & ", " & _
"description = '" & description & "', " & _
"folder = " & folder & " " & _
"WHERE id = " & id & ""
sql_UpdateDocument = sql
End Function
Function sql_UpdateFolder(id, folder,sub_to)
dim sql
sql = "UPDATE folders set folder = '" & folder & "', " & _
"sub_to = " & sub_to & " " & _
"WHERE folder_id = " & id & ""
'Response.Write sql
sql_UpdateFolder = sql
End Function
Function sql_DeleteFolder(id)
dim sql
sql = "DELETE FROM folders WHERE (folder_id = " & id & ") OR (sub_to = " & id & ") "
sql_DeleteFolder = sql
End Function
Function sql_GetDocumentsByFolderID(id)
dim sql
sql = "SELECT * FROM files " & _
"WHERE folder = " & id & " " & _
"ORDER BY submitDate DESC, filename"
sql_GetDocumentsByFolderID = sql
End Function
Function sql_GetAllFolders()
dim sql
sql = "SELECT * FROM folders ORDER BY folder"
sql_GetAllFolders = sql
End Function
Function sql_GetMainFolders()
dim sql
sql = "SELECT * FROM folders where sub_to=0 ORDER BY folder"
sql_GetMainFolders = sql
End Function
Function sql_DeleteDocument(id)
dim sql
sql = "DELETE FROM files WHERE id = " & id & ""
sql_DeleteDocument = sql
End Function
Function sql_InsertDocument(fileNameShow,fileSize,Folder, URL, Description, user_name, eDate)
dim sql
sql = "INSERT INTO files (filename, filesize,folder, url, description, submitby, submitdate) " & _
"values (" & _
"'" & fileNameShow & "', " & _
filesize & ", " & _
Folder & ", " & _
"'" & URL & "', " & _
"'" & Description & "', " & _
user_name & ", " & _
"'" & MediumDate(eDate) & "')"
sql_InsertDocument = sql
End Function
Function sql_InsertFolder(folderName, subTo)
dim sql
sql = "INSERT INTO folders (folder, sub_to) VALUES ('" & folderName & "', " & subTo & ")"
sql_InsertFolder = sql
End Function
Function sql_GetMyLatestFolder(folderName, subTo)
dim sql
sql = "SELECT folder_id FROM folders WHERE folder = '" & folderName & "' and sub_to = " & subTo & ""
sql_GetMyLatestFolder = sql
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function SpaceEncode(strText)
if strText <> "" and isNull(strText) = False then
strText = replace(strText," ","%20")
end if
SpaceEncode = strText
end function
function SpaceDecode(strText)
if strText <> "" and isNull(strText) = False then
strText = replace(strText,"%20"," ")
end if
SpaceDecode = strText
end function
Private sub DisplayFolderInfo(fid, strLevel, boolFatherIsKing, boolBrotherIsKing, boolNewphewIsKing)
folder_count = dCount.Item(trim(fid))
if folder_count ="" then
folder_count = 0
end if
sql = sql_GetFolderByID(fid)
Call RunSQL(sql, rsF)
if not rsF.eof then
folder_name = rsF("folder")
folder_subto = rsF("sub_to")
end if
rsF.close
set rsF = nothing
if trim(fid) = trim(folder) then
'Display my two kids but no grandkids
sql = sql_GetSubFoldersByFolderID(fid)
Call RunSQL(sql, rsSubFolders)
while not rsSubFolders.eof
Call DisplayFolderInfo(rsSubFolders("folder_id"), strLevel + 1, 1, 0, 0)
rsSubFolders.movenext
wend
rsSubFolders.close
set rsSubFolders = nothing
'I am the King, print me open
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, TRUE)
elseif boolFatherIsKing then
'print me closed
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, FALSE)
elseif boolBrotherIsKing then
'display me closed, no children
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, FALSE)
else
'if I have children, check to see if one of them is the king, if they are then print me open
boolLocalOpen = AreMyDescendantsKing(fid, folder, FALSE)
sql = sql_GetSubFoldersByFolderID(fid)
Call RunSQL(sql, rsSubFolders)
boolLocalBrother = FALSE
while not rsSubFolders.eof
if trim(rsSubFolders("folder_id")) = trim(folder) then
boolLocalBrother = TRUE
end if
rsSubFolders.movenext
wend
if not rsSubFolders.bof then
rsSubFolders.movefirst
end if
while not rsSubFolders.eof
if boolLocalOpen then
Call DisplayFolderInfo(rsSubFolders("folder_id"), strLevel + 1, 0, boolLocalBrother, 1)
else
Call DisplayFolderInfo(rsSubFolders("folder_id"), strLevel + 1, 0, boolLocalBrother, 0)
end if
rsSubFolders.movenext
wend
rsSubFolders.close
set rsSubFolders = nothing
'if one of them is open then show me open
if boolLocalOpen then
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, TRUE)
elseif boolNewphewIsKing then
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, FALSE)
elseif folder_subto = 0 then
Call DisplayFolderLine(fid, folder_name, strLevel, folder_count, FALSE)
end if
end if
end sub
Sub DisplayFolderLine(fid, fName, intLevel, intCount, boolOpen)
strSubFolders = ""
for i = 1 to intLevel
strSubFolders = strSubFolders & "<img src='" & "images/dot_clear.gif' width='10' height='1' border='0'>"
next
if boolOpen then
strSubFolders = strSubFolders & "<img src='" & "images/open.gif' WIDTH='15' HEIGHT='13' border='0'>"
else
strSubFolders = strSubFolders & "<img src='" & "images/folder.png' WIDTH='15' HEIGHT='13' border='0'>"
end if
strSubFolders = strSubFolders & "<a href='" & thispage & "?folder=" & fid & "' class='smallhome'>" & fName & "</a> <font class='smallhome'>(" & intCount & ")</font><br>"
strFolders = strSubFolders & strFolders
end sub
Function AreMyDescendantsKing(fid, kingID, boolCheck)
if not boolCheck then
sql = sql_GetSubFoldersByFolderID(fid)
Call RunSQL(sql, rsWhatzit)
while not rsWhatzit.eof and not boolCheck
if trim(rsWhatzit("folder_id")) = trim(kingID) then
boolCheck = TRUE
else
boolCheck = AreMyDescendantsKing(rsWhatzit("folder_id"), kingID, boolCheck)
end if
rsWhatzit.movenext
wend
rsWhatzit.close
set rsWhatzit = nothing
end if
AreMyDescendantsKing = boolCheck
End Function
Function sql_GetUsernameByID(id)
dim sql
sql = "Select * from users where user_id = " & id & ""
sql_GetUsernameByID = sql
End Function
%>
<link rel="stylesheet" href="vos.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<table border"0" cellpadding="2" cellspacing="2" width="100%">
<tr bgcolor="<%=gsColorHighlight%>">
<td align="center" class="HeaderTD" height="22">网络硬盘</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="HeaderTable" bgcolor="f1f1f1">
<tr>
<td class="FieldTD" height="22">文件夹</td>
</tr>
<tr>
<td class="homecontent" nowrap>
<%
'*****Record count per folder
if request("folder") <> "" then
folder = request("folder")
else
folder = 5
end if
thispage="files.asp"
sql = sql_GetFoldersCount()
Call RunSQL(sql, rsSearch)
' Create a dictionary object to hold counts
set dCount = Server.CreateObject("Scripting.Dictionary")
do while not rsSearch.EOF
if rsSearch(0) <> "" then
dCount.add cstr(rsSearch(0)), trim(rsSearch(1))
end if
rsSearch.movenext
loop
rsSearch.close
set rsSearch=nothing
sql = sql_GetMainFolders()
Call RunSQL(sql, rsFolders2)
do while not rsFolders2.eof
folder_id = trim(rsFolders2("folder_id"))
fcount = dCount.Item(trim(folder_id))
if fcount = "" then
fcount = 0
end if
strFolders = ""
if folder_id = trim(folder) then
boolCheck = TRUE
else
boolCheck = AreMyDescendantsKing(folder_id, folder, FALSE)
end if
if boolCheck then
Call DisplayFolderInfo(folder_id, 0, 0, 0, 0)
else
Call DisplayFolderLine(folder_id, trim(rsFolders2("folder")), 0, fcount, FALSE)
end if
Response.Write strFolders
rsFolders2.movenext
loop
rsFolders2.Close
set rsFolders2 = nothing
%>
</td>
</tr>
</table>
</td>
<td rowspan="2" valign="top" >
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="HeaderTable">
<tr>
<td height="20" colspan="5"class="FieldTD"> 点击图标<a href="files_upload.asp" class="home"><img src="images/upload.png" width="19" height="16" alt="文件上载" border="0" align="absmiddle"></a>上载文件</td>
</tr>
<tr>
<td nowrap class="FieldTD" >文件名称</td>
<td nowrap class="FieldTD" >文件大小</td>
<td nowrap class="FieldTD" >提交日期</td>
<td nowrap class="FieldTD" >提交人</td>
<td class="FieldTD"><img src="images/file.png" WIDTH="11" HEIGHT="14"></td>
</tr>
<%
sql = sql_GetSubFoldersByFolderID(folder)
Call RunSQL(sql, rsSubs)
sql = sql_GetDocumentsByFolderID(folder)
Call RunSQL(sql, rsSearch)
if (not rsSubs.eof) or (not rsSearch.eof) then%>
<% do while not rsSubs.eof
intRowcounter = intRowcounter + 1
If intRowcounter MOD 2 = 1 then
colour = "bgcolor=#F0F8FF"
Else
colour = "bgcolor=#ffffff"
End If
Response.Write "<tr " & bgcolor & ">"
strFolderID = rsSubs("folder_id")
strFolderName = trim(rsSubs("folder"))
strFolderImage = "<img src='" & gsSiteRoot & "images/close_folder.gif' WIDTH='19' HEIGHT='19'>" %>
<tr>
<td nowrap class="DataTD"> <%=strFolderImage%> <a href="files.asp?folder=<%=strFolderID%>" class="small" title="<%=strFolderName%>"><%=strFolderName%></a>
</td>
<td nowrap class="DataTD"> </td>
<td nowrap class="DataTD"> </td>
<td nowrap class="DataTD"> </td>
<td></td>
</tr>
<%
rsSubs.movenext
loop
do while not rsSearch.eof
sql = sql_GetUsernameByID(rsSearch("submitBy"))
Call RunSQL(sql, rsContact)
intRowcounter = intRowcounter + 1
If intRowcounter MOD 2 = 1 then
colour = "bgcolor=#F0F8FF"
Else
colour = "bgcolor=#ffffff"
End If
Response.Write "<tr " & bgcolor & ">"
strFileName = rsSearch("fileName")
if strFileName<>"" then
boolURL = FALSE
if right(lcase(strFileName),3) = "doc" or right(lcase(strFileName),3) = "txt" or right(lcase(strFileName),3) = "htm" or right(lcase(strFileName),3) = "rtf" or right(lcase(strFileName),3) = "xls" or right(lcase(strFileName),3) = "pdf" or right(lcase(strFileName),3) = "ppt" then
file_image = right(lcase(strFileName),3) & ".gif"
elseif right(lcase(strFileName),4) = "html" then
file_image = "htm.gif"
else
file_image = "document.gif"
end if
else
boolURL=TRUE
strFileName = rsSearch("url")
file_image = "htm.gif"
end if %>
<td nowrap class="DataTD"> <img src="images/file.png" align="baseline" WIDTH="11" HEIGHT="14">
<a href="file/<%=SpaceEncode(strFileName)%>" title="<%=rsSearch("description")%>" class="small" target="_blank"><%=SpaceDecode(strFileName)%></a>
</td>
<td nowrap class="DataTD"> <img src="images/file.png" align="baseline" WIDTH="11" HEIGHT="14">
<%=rsSearch("FileSize")%>K </td>
<td nowrap align="center" class="DataTD"><%=rsSearch("submitDate")%></td>
<td nowrap class="DataTD"><a href="<%=gsSiteRoot%>/user_public.asp?user_id=<%=rsSearch("submitBy")%>" class="small"><%=rsContact("user_name")%></a></td>
<td align="left" class="DataTD">
<% if trim(rsSearch("submitBy")) = trim(session("user_id")) then%>
<a href="files_delete.asp?file=<%=rsSearch("ID")%>&filename=<%=rsSearch("fileName")%>" class="small" onClick="return confirm('确认要删除文件?');"><img src="images/delete.png" WIDTH="14" HEIGHT="14" border="0" alt="删除"></a>
<%end if%>
</td>
</tr>
<%rsSearch.MoveNext
loop
else %>
<tr>
<td colspan="4" height="20"align="center" class="DataTD">文件夹为空</td>
<td></td>
</tr>
<%end if%>
</table>
</td>
</tr>
</table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -