www.gusucode.com > 维六酷博客管理系统 1.1源码程序 > master/file.asp
<!--#include file="check.asp"--> <!-- #include file="../inc/conn.asp" --> <!-- #include file="../inc/function.asp" --> <!--#include file="../inc/asppage.asp"--> <html> <head> <meta http-equiv="createtime-Type" createtime="text/html; charset=gb2312"> <title>file</title> <link href="css.css" rel="stylesheet" type="text/css"> <script type="text/javascript"> function del(id) { var ok; ok=confirm("删除后不可恢复!您确定要删除此文件吗?"); if (ok==true) { window.location="file.asp?action=del&id="+id; } else {} } function delfolder(id) { var ok; ok=confirm("删除此文件夹,此文件夹内的所有文件都将被删除!您确定要删除此文件吗?"); if (ok==true) { window.location="file.asp?action=delfolder&id="+id; } else {} } </script> </head> <body topmargin="10" background="images/bg1024.gif"> <% Sub Head() Response.Write "<table cellpadding=""5"" cellspacing=""1"" border=""0"" width=""98%"" class=""tableBorder"" align=center style='margin-bottom:5px;'><tr><th height=25>我的网络硬盘</th></tr><tr class=""tdbg"">"&_ "<td width=""66%"" class=Forumrow><a href='file.asp?action=upfile'>上传文件</a> <a href='file.asp?action=createfolder'>新建文件夹</a> <a href=file.asp>返回根目录</a>" Response.Write "</td></tr></table>" End Sub Call Head() action=RequestSafeStr("action") Select Case action Case "createfolder" Call CreateFolder() Case "savefolder" Call savefolder() Case "editfolder" Call editfolder() Case "editsavefolder" Call editsavefolder() Case "delfolder" Call delfolder() Case "upfile" Call add() Case "save" Call save() Case "edit" Call edit() Case "editsave" Call editSave() Case "del" Call del() Case "showfile" Call show() Case "top" Call top() Case else Call showFolders() End Select %> <% 'savefolder Sub savefolder() foldername=RequestFormStr("foldername") If foldername="" Then Call MessageBox("请输入文件夹名称!","") Response.End End If set rs=Server.CreateObject("ADODB.Recordset") sql="select * from filefolder" rs.open sql,conn,1,3 rs.addnew rs("foldername")=foldername rs.update rs.close Call MessageBox("新建文件夹成功!","file.asp") End Sub 'editsavefolder Sub editsavefolder() id=RequestFormStr("id") foldername=RequestFormStr("foldername") If foldername="" Then Call MessageBox("请输入文件夹名称!","") Response.End End If set rs=Server.CreateObject("ADODB.Recordset") sql="select * from filefolder Where id="&id rs.open sql,conn,2,3 rs("foldername")=foldername rs.update rs.close Call MessageBox("文件夹修改属性成功!","file.asp") End Sub 'delfolder 'del Sub delfolder() Dim path,id id=RequestQueryNum("id") If id<>0 Then Set rs=conn.Execute("Select path from file Where folderid="& id &"") Do While Not rs.eof Call delFile("../"& rs("path")) rs.MoveNext Loop Set rs=nothing conn.Execute("delete From file Where folderid="& id &"") conn.Execute("delete From filefolder Where id="& id &"") Call MessageBox("删除成功!","file.asp") End If End Sub 'savefile Sub save() filename=RequestFormStr("filename") folderid=RequestFormNum("folderid") path=RequestFormStr("path") isshow=RequestFormStr("isshow") password=RequestFormStr("password") If filename="" Then Call MessageBox("请输入文件名称!","") Response.End End If If path="" Then Call MessageBox("请上传文件!","") Response.End End If set rs=Server.CreateObject("ADODB.Recordset") sql="select * from file" rs.open sql,conn,1,3 rs.addnew rs("filename")=filename rs("folderid")=folderid rs("path")=path rs("isshow")=isshow rs("password")=password rs.update rs.close Call MessageBox("添加文件成功!","file.asp") End Sub 'edit file save Sub editSave() id=RequestFormNum("id") If id<>0 then filename=RequestFormStr("filename") folderid=RequestFormNum("folderid") isshow=RequestFormStr("isshow") password=RequestFormStr("password") If filename="" Then Call MessageBox("请输入文件名称!","") Response.End End If set rs=Server.CreateObject("ADODB.Recordset") sql="select * from file Where id="& id &"" rs.open sql,conn,2,3 If Not rs.eof then rs("filename")=filename rs("folderid")=folderid rs("isshow")=isshow rs("password")=password rs.update End If rs.close Set rs=nothing Call MessageBox("修改文件成功!","file.asp?action=showfile&folderid="&RequestQueryNum("fid")) End If End Sub 'del Sub del() Dim path,isshow id=RequestQueryNum("id") If id<>0 Then Set rs=conn.Execute("Select path from file Where id="& id &"") path="../"& rs("path") Call delFile(path) Set rs=nothing conn.Execute("delete From file Where id="& id &"") Call MessageBox("删除成功!","file.asp") End If End Sub 'top Sub top() id=RequestQueryNum("id") intTop=RequestQueryNum("top") If id<>0 Then conn.Execute("Update file set [top]="& intTop &",toptime=Now() Where id="& id &"") If intTop=1 Then strMsg="置顶成功!" Else strMsg="取消置顶成功!" End If Call MessageBox(strMsg,"file.asp") End If End Sub 'showFolders Sub showFolders() sql="Select * From filefolder Order by id asc" Set mypage=new xdownpage '创建对象 mypage.getconn=conn '得到数据库连接 mypage.getsql=sql mypage.pagesize=20 '设置每一页的记录条数据为5条 set rs=mypage.getrs() '返回Recordset %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <tr> <th height="25" colspan="5">文件管理</th> </tr> <tr> <td class=Forumrow>文件夹</td> <td class=Forumrow width="220">创建日间</td> <td class=Forumrow align="center" width="200">操作</td> </tr> <% for i=1 to mypage.pagesize If rs.eof Then Exit for End If %> <tr> <td class=Forumrow align="left"><a href="file.asp?action=showfile&folderid=<%=rs("id")%>"><%=rs("foldername")%></a></td> <td class=Forumrow width="150"><%=rs("createtime")%></td> <td class=Forumrow align="center" width="200"> <a href="?action=editfolder&id=<%=rs("id")%>">修改属性</a> <a href="javascript:delfolder(<%=rs("id")%>)">删除</a></td> </tr> <% rs.MoveNext Next %> <tr align="center"><td colspan="4" class=Forumrow><%mypage.showpage() %></td></tr> </table> <% End Sub 'createFolder Sub createFolder() %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <form name="add" method="post" action="?action=savefolder"> <tr> <th height="25" colspan="3">新建文件夹</th> </tr> <tr> <td width="35%" height="25" align="right" class=Forumrow>文件夹名称:</td> <td width="180" align="left" class=Forumrow> <input name="foldername" type="text" value="新建文件夹" size=20 style="width:150"></td> <td height="30" class=Forumrow> <input type="submit" name="Submit" value="创 建" class="input1"></td> </tr> </form> </table> <% End Sub 'editfolder Sub editfolder() id=RequestQueryNum("id") Set rs=conn.Execute("Select * From filefolder Where id="& id &"") If Not rs.eof Then %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <form name="add" method="post" action="?action=editsavefolder"> <input type="hidden" name="id" value="<%=id%>"> <tr> <th height="25" colspan="3">文件夹修改属性</th> </tr> <tr> <td width="35%" height="25" align="right" class=Forumrow>文件夹名称:</td> <td width="180" align="left" class=Forumrow> <input name="foldername" type="text" value="<%=rs("foldername")%>" size=20 style="width:150"></td> <td height="30" class=Forumrow> <input type="submit" name="Submit" value="文件夹修改属性" class="input1"></td> </tr> </form> </table> <% End If End Sub 'ShowFiles Sub show() cid=RequestQueryNum("folderid") If cid<>0 Then sql="Select * From file Where folderid="& cid &" Order by id desc" Else sql="Select * From file Order by id desc" End If Set mypage=new xdownpage '创建对象 mypage.getconn=conn '得到数据库连接 mypage.getsql=sql mypage.pagesize=20 '设置每一页的记录条数据为5条 set rs=mypage.getrs() '返回Recordset 'Set rs=conn.Execute("Select * From file Order by id desc") %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <tr> <th height="25" colspan="5">文件管理</th> </tr> <tr> <td class=Forumrow width="100">编号</td> <td class=Forumrow>文件名</td> <td class=Forumrow width="220">创建日期</td> <td class=Forumrow align="center" width="200">操作</td> </tr> <% for i=1 to mypage.pagesize If rs.eof Then Exit for End If %> <tr> <td class=Forumrow><%=rs("id")%></td> <td class=Forumrow align="left"><%=rs("filename")&"."&getExt(rs("path"))%></td> <td class=Forumrow width="150"><%=rs("createtime")%></td> <td class=Forumrow align="center" width="200"> <a href="?action=edit&id=<%=rs("id")%>">修改属性</a> <a href="javascript:del(<%=rs("id")%>)">删除</a></td> </tr> <% rs.MoveNext Next %> <tr align="center"><td colspan="4" class=Forumrow><%mypage.showpage() %></td></tr> </table> <% End Sub 'upfile Sub add() %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <form name="add" method="post" action="file.asp"> <input type="hidden" name="action" value="save"> <tr> <th height="25" colspan="2">上传文件</th> </tr> <tr> <td height="25" align="right" class=Forumrow>选择文件夹:</td> <td align="left" class=Forumrow> <Select name="folderid"> <% Set rs=conn.Execute("Select * From filefolder order by id asc") Do While Not rs.eof %> <option value="<%=rs("id")%>"><%=rs("foldername")%></option> <% rs.MoveNext Loop rs.close Set rs=nothing %> </select> <a href='file.asp?action=createfolder'>新建文件夹</a></td> </tr> <tr> <td height="25" align="right" class=Forumrow>上传:</td> <td align="left" class=Forumrow style="padding-left:15px;"> <input name="path" type="hidden" size="30" style="width:300"> <iframe border=0 frameborder=0 framespacing=0 height=22 width="310" marginheight=0 marginwidth=0 name=new_date noresize scrolling=no src="uploadForm3.asp?upFolder=files&inputName=path" vspale="0"></iframe>(最大上传:<%=mediaSize%>KB) </td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>文件名:</td> <td align="left" class=Forumrow> <input name="filename" type="text" value="" size="25" style="width:300"> </td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>前台是否显示:</td> <td align="left" class=Forumrow> <input name="isshow" type="radio" value="1" size="25" >是 <input name="isshow" type="radio" value="0" size="25" checked="true">否 </td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>文件下载密码:</td> <td align="left" class=Forumrow> <input name="password" type="text" value="" size="25" style="width:100"> (允许网友下载,不用设置密码)</td> </tr> <tr> <td class=Forumrow></td> <td height="30" class=Forumrow> <input type="submit" name="Submit" value="添加文件" class="input1"> <input type="reset" name="Submit" class="input1"></td> </tr> </form> </table> <% End Sub Sub edit() id=RequestQueryNum("id") Set rs=conn.Execute("Select * From file Where id="& id &"") If Not rs.eof Then %> <table width="98%" border="0" class="tableBorder" align=center cellpadding="2" cellspacing="1" bgcolor="#FFFFFF"> <form name="add" method="post" action="file.asp"> <input type="hidden" name="action" value="editsave"> <input type="hidden" name="id" value="<%=id%>"> <input type="hidden" name="fid" value="<%=rs("folderid")%>"> <tr> <th height="25" colspan="2">文件修改属性</th> </tr> <tr> <td height="25" align="right" class=Forumrow>选择文件夹:</td> <td align="left" class=Forumrow> <Select name="folderid"> <% Set rsC=conn.Execute("Select * From filefolder order by id asc") Do While Not rsC.eof %> <option value="<%=rsC("id")%>" <%If rs("folderid")=rsC("id") Then Response.Write "selected=""true""" End If %>><%=rsC("foldername")%></option> <% rsC.MoveNext Loop rsC.close Set rsC=nothing %> </select></td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>文件名:</td> <td align="left" class=Forumrow> <input name="filename" type="text" value="<%=rs("filename")%>" size="25" style="width:300"> </td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>前台是否显示:</td> <td align="left" class=Forumrow> <input name="isshow" type="radio" value="1" size="25" <%If rs("isshow")=1 Then Response.Write "checked='true'" End If%>>是 <input name="isshow" type="radio" value="0" size="25" <%If rs("isshow")=0 Then Response.Write "checked='true'" End If%>>否 </td> </tr> <tr> <td width="15%" height="25" align="right" class=Forumrow>文件下载密码:</td> <td align="left" class=Forumrow> <input name="password" type="text" value="<%=rs("password")%>" size="25" style="width:100"> (允许网友下载,不用设置密码)</td> </tr> <tr> <td class=Forumrow></td> <td height="30" class=Forumrow> <input type="submit" name="Submit" value="修改" class="input1"> <input type="reset" name="reset" class="input1"></td> </tr> </form> </table> <% End If End Sub %> </body> </html>