📄 ks_webfilescls.asp
字号:
<td height="25" align="center">
<input type="checkbox" name="FolderId" value="<%=DirFolder.name%>"></td>
<td> <a href="?ChannelID=<%=ChannelID%>&topdir=<%=topdir%>&action=Main&OpTypeStr=<%=OpTypeStr%>&CurrentDir=<%=CurrentDir & DirFolder.name%>"><img src="<%=WebDir%>syscls/fileicon/folder.gif" border=0 width="16" height="16" align="absmiddle"></a> <a href="?ChannelID=<%=ChannelID%>&topdir=<%=topdir%>&action=Main&OpTypeStr=<%=OpTypeStr%>&CurrentDir=<%=CurrentDir & DirFolder.name%>"><%=DirFolder.name%></a></td>
<td width="197" align="center"><%=GetSize(DirFolder.size,"b")%></td>
<td align="center" nowrap> <%=DirFolder.DateLastModified%></td>
<td width="198" align="center"><a href="?ChannelID=<%=ChannelID%>&topdir=<%=topdir%>&action=Main&OpTypeStr=<%=OpTypeStr%>&CurrentDir=<%=CurrentDir & DirFolder.name%>">打开</a></td>
</tr>
<%
Next
For Each DirFiles in FsoFile.Files
k=k+1
if j>=MaxPerPage then
exit for
elseif k>MaxPerPage*(CurrentPage-1) then
%>
<tr bgcolor="#ffffff" onMouseOver="this.style.background='#F5f5f5'" onMouseOut="this.style.background='#FFFFFF'">
<td height="25" align="center">
<input type="checkbox" name="FileId" value="<%=DirFiles.name%>"></td>
<td>
<%if OpTypeStr="select" then%>
<a href="#" title="<table width=80 border=0 align=center><tr><td><img src='<%=TopDir & CurrentDir & DirFiles.name%>' border=0 width='130' height='80'></td></tr></table>" onClick="window.returnValue='<%=TopDir & CurrentDir & DirFiles.name%>';window.close();">
<%else%>
<a href="<%=TopDir & CurrentDir & DirFiles.name%>" target="_blank">
<%end if%>
<img src="<%=WebDir%>syscls/fileicon/<%=GetFileIcon(DirFiles.name)%>" border=0 width="16" height="16" align="absmiddle" alt="<%=DirFiles.type%>"> <%=DirFiles.name%></a></td>
<td width="197" align="center"><%=GetSize(DirFiles.size,"b")%></td>
<td align="center" nowrap><%=DirFiles.DateLastModified%></td>
<td width="198" align="center">
<%if OpTypeStr="select" then%>
<a href="#" onClick="window.returnValue='<%=TopDir & CurrentDir & DirFiles.name%>';window.close();">选择</a>
<%else%>
<a href="<%=TopDir & CurrentDir & DirFiles.name%>" target="_blank">浏览</a> | <a href="?ChannelID=<%=ChannelID%>&topdir=<%=topdir%>&action=Del&OpTypeStr=<%=OpTypeStr%>&CurrentDir=<%=CurrentDir%>&FileId=<%=DirFiles.name%>" onClick="return confirm('确定要删除选择的文件么?\n此操作不可以恢复!')">删除</a>
<%end if%>
</td>
</tr>
<%
j=j+1
end if
Next
if OpTypeStr<>"select" then
%>
<tr>
<td height="25" align="center" bgcolor="#FFFFFF">
<input type="checkbox" name="CheckAll" value="checkbox" onClick="CheckAll1()" title=全部选择 style="cursor:hand"></td>
<td height="30" colspan="5" bgcolor="#FFFFFF">
<input type="button" name="Submit" value="重命名" class=button onClick="Rname()" title=重命名>
<input type="button" name="Submit2" value="删 除" class=button onClick="DelAll()" title=删除>
<input type="hidden" name="CurrentDir" value="<%=CurrentDir%>"> </td>
</tr>
<%end if%>
</form>
<tr>
<td colspan="6" height="25" align="center" bgcolor="#FFFFFF">
<%
Call KSCMS.ShowPageParamter(totalPut, MaxPerPage, "", True, "个文件", CurrentPage, "action=Main&OpTypeStr="&OpTypeStr&"&CurrentDir="&CurrentDir)
%>
</td>
</tr>
</table>
<%
Set FsoFile = Nothing
End Sub
Public Function GetSize(size,unit)
if isEmpty(size) or Not Isnumeric(size) then Exit Function
size=CheckUnit(size,unit)
if size>1024 then
size=(size/1024)
getsize=formatnumber(size,2) & " MB"
else
getsize=size & " KB"
Exit Function
end if
if size>1024 then
size=(size/1024)
getsize=formatnumber(size,2) & " GB"
end if
End Function
Public Function CheckUnit(size,unit)
Select Case Lcase(Unit)
Case "b"
CheckUnit = formatnumber(size/1024,2)
Case "k"
CheckUnit = size
Case "m"
CheckUnit = (size*1024)
Case "g"
CheckUnit = (size*1024*1024)
Case Else
CheckUnit = size
End Select
End Function
Public Sub DelFiles(strFiles)
if strFiles="" then Exit Sub
dim fso,arrFiles,i
On Error Resume Next
Err=0
Set fso = CreateObject(Trim(KSCMS.GetConfig("FsoObjName")))
if fso.FileExists(server.MapPath(strFiles)) then
fso.DeleteFile(server.MapPath(strFiles))
if 0=Err then
Response.Write "<br>清除文件("&strFiles&")成功!"
else
Response.Write "<br>清除文件("&strFiles&")失败!"
end if
end if
Set fso = Nothing
Err=0
End Sub
Function GetUpDir()
Dim strDir,strDir2,i
strDir=""
If CurrentDir = "" then Exit Function
strDir2=CurrentDir
strDir2=Split(strDir2,"/")
for i=0 to Ubound(strDir2)-1
if i<Ubound(strDir2)-1 then strDir=strDir & strDir2(i) & "/"
next
GetUpDir=strDir
End Function
Sub DelAll()
Dim FolderId,FileId,FileNum,FolderNum,FilePath,FolderPath
Dim FsoFolder,sSize
FolderId = Split(Request.Form("FolderId"),",")
FileId = Trim(Request("FileId"))
FileNum=0
FolderNum=0
If instr(FileId,",")>0 then
FileId = Split(FileId,",")
If Ubound(FileId) > -1 then
For i = 0 to Ubound(FileId)
FilePath = Server.MapPath(TopDir & CurrentDir & Trim(FileId(i)))
If Fso.FileExists(FilePath) then
Fso.DeleteFile FilePath,true
FileNum = FileNum + 1
End If
Next
End If
else
FilePath = Server.MapPath(TopDir & CurrentDir & FileId)
If Fso.FileExists(FilePath) then
Fso.DeleteFile FilePath,true
FileNum = FileNum + 1
End If
end if
If Ubound(FolderId) > -1 then
For i = 0 to Ubound(FolderId)
FolderPath = Server.MapPath(TopDir & CurrentDir & Trim(FolderId(i)))
If Fso.FolderExists(FolderPath) then
Set FsoFolder = Fso.GetFolder(FolderPath)
if FsoFolder.size <=0 then
Fso.DeleteFolder FolderPath,true
FolderNum = FolderNum + 1
end if
End If
Next
End If
Response.Write("<script>alert('\n成功删除 "& FileNum &" 个文件\n成功删除 "& FolderNum &" 个文件夹');location.href='" & ComeUrl & "';</script>")
End Sub
Sub Rname()
Dim FolderName,FileName,NewName,OldName,strNewName
FolderName = Trim(Request("FolderId"))
FileName = Trim(Request("FileId"))
NewName = Trim(Request("NewName"))
if NewName="" then Call Response.Write("<script>alert('请输入新文件名!');location.href='" & ComeUrl & "';</script>")
If len(FolderName) <> 0 then
strNewName = Server.MapPath(TopDir & CurrentDir & NewName)
OldName = Server.MapPath(TopDir & CurrentDir & FolderName)
If not Fso.FolderExists(strNewName) then
Fso.MoveFolder OldName,strNewName
Response.Write("<script>alert('文件夹“"& FolderName &"”已经成功改名为“"& NewName &"”');location.href='" & ComeUrl & "';</script>")
Else
Response.Write("<script>alert('有同名文件夹,请换个文件夹名!');location.href='" & ComeUrl & "';</script>")
End If
End If
If len(FileName) <> 0 then
Dim FileExt,NewFileExt
'Response.Write FileName
FileExt=Split(FileName,".")
NewFileExt=Trim(FileExt(Ubound(FileExt)))
if Instr(NewName,".")>0 then
Response.Write("<script>alert('文件名中不能带“.”,换个文件名!');location.href='" & ComeUrl & "';</script>")
Response.End
end if
NewName=NewName & "." & NewFileExt
strNewName = Server.MapPath(TopDir & CurrentDir & NewName)
OldName = Server.MapPath(TopDir & CurrentDir & FileName)
If not Fso.FileExists(strNewName) then
Fso.MoveFile OldName,strNewName
Response.Write("<script>alert('文件“"& FileName &"”已经成功改名为“"& NewName &"”');location.href='" & ComeUrl & "';</script>")
Else
Response.Write("<script>alert('有同名文件,请换个文件名!');location.href='" & ComeUrl & "';</script>")
End If
End If
End Sub
End Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -