⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photoclass.asp

📁 一个网络相册
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<% option explicit %>
<!--#include file="../function1/DBOpen.asp"-->
<!--#include file="../function/md5.asp"-->
<%
  if session("name")="" then
      response.write "错误!!您没有权限或者连接超时,请重新登陆." %>
<a href="../login.asp?id=0" target="_top">登陆</a> 
<% response.end 

function delit(fileType,path)
	'remove a file
	dim fso
        set fso=server.CreateObject("scripting.filesystemobject")    

        IF UCase(fileType) = "SINGLE" THEN
		    if fso.FileExists(path) then 
        	fso.DeleteFile(path)
			end if 
        END IF
        IF UCase(fileType) = "MULTI" THEN
        	fso.DeleteFolder(path)

        END IF

    end function

  end if  
  dim isedit  '是否在修改状态
  dim color  '表格颜色
  dim sql,rs,rsc,i,curpage,rs2,sql2
  dim ownername,ownername1,ownername2
  ownername=trim(session("name"))
  color=1
  isedit=false
  
  ownername1=request("owner")
  sql="SELECT * FROM users where name='" & trim(ownername1) & "'"
  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.OPEN sql,Conn,1,1
  if not rs.eof and not rs.bof then
  ownername2=rs("turename")
  end if
  rs.close
  set rs=nothing
  if request("action")="edit" then
      isedit=true
  end if
  if request("action")="modify" then   '**************************修改相册*********************
    if trim(request("name"))="" then
	    response.write "错误!名称不能为空! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
        response.end
    end if
    if request("lock")=1 then
	    if trim(request("psw"))="" then
	    response.write "错误!锁定的相册必须设密码! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
        response.end
		end if
    end if
	set rs=server.createobject("adodb.recordset")   '检查相册是否重名
    rs.open "select * from class where name='" & trim(request("name")) & "' and id<>" & cstr(request("id")),conn,1,1
    if err.number <> 0 then
	          response.write "数据库出错"
    else  if not rs.bof and not rs.eof then
	          response.write "错误!该相册已存在! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
              response.end
          end if
    end if
	rs.close
	set rs=nothing
	sql="update class set name='" & trim(request("name")) & "',content='"&trim(request("content")) & "',psw='"&trim(request("psw"))&"',lock='"&request("lock")&"',hide='"& request("hide")&"',owner='"&request("owner")&"',ownername='"&trim(ownername2)&"' where id="&cstr(request("id"))
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
	else %>
<script language=vbscript>
			msgbox "操作成功!相册 <%=trim(request("name"))%> 的信息已经更新!"
		</script>
<%end if
  end if
  if request("action")="add" then   '******************************添加新相册************************
       if trim(request("name"))=""  or trim(request("content"))="" then
	    response.write "错误!名称和说明不能为空! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
        response.end
        end if
    if request("lock")=1 then
	    if trim(request("psw"))="" then
	    response.write "错误!锁定的相册必须设密码! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
        response.end
		end if
    end if
	set rs=server.createobject("adodb.recordset")   '检查相册是否重名
    rs.open "select * from class where name='" & trim(request("name")) & "'",conn,1,1
        if err.number <> 0 then
	          response.write "数据库出错"
              else  if not rs.bof and not rs.eof then
	          response.write "错误!该相册已存在! <a href=# onclick='javascript:window.history.go(-1)'>返回</a>"
              response.end
                       end if
           end if
	rs.close
	set rs=nothing
	'sql="insert into class(name,content,password,lock,hide,owner,time1,ownername) values('"&trim(request("name"))&"','"&trim(request("content"))&"','"&trim(request("password"))&"','"&cstr(request("lock"))&"','"&cstr(request("hide"))&"','"&cstr(request("owner"))&"','"&cstr(request("time1"))&"','"&trim(ownername2)&"')"
	sql="insert into class(name,content,lock,hide,owner,time1,ownername,psw) values('"&trim(request("name"))&"','"&trim(request("content"))&"','"&request("lock")&"','"&request("hide")&"','"&request("owner")&"','"&request("time1")&"','"&trim(ownername2)&"','"&trim(request("psw"))&"')"
	conn.execute sql
	if err.number <> 0 then
	    response.write "数据库操作出错:" + err.description
     end if%>
        <script language=vbscript>
			msgbox "操作成功!新相册 <%=trim(request("name"))%> 的信息添加成功!"
		</script>
<%
  end if
if request("action")="del" then   '**********************删除相册**********************
'============== 删除所有相片 =====================
dim rootpath,path,classid,pic,small,filepath,filepath1,fileType
rootPath = request.queryString("rootPath")
if rootPath = "" then rootPath = "."
path = server.mapPath(rootPath)
classid=Request.QueryString("id")
sql = "SELECT * FROM photo where classid="&classid
set rs=server.createobject("adodb.recordset") 
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
pic=rs("big")
small=rs("small")
classid=rs("classid")
filepath=path+ "\" +pic
filepath1=path+ "\" +small
fileType="SINGLE"
Call delit(fileType,filePath)
Call delit(fileType,filePath1)
rs.movenext
	loop
end if
rs.close
set rs=nothing
conn.execute "delete from photo where classid="&classid
'=====================================================================================
  		set rs=server.createobject("adodb.recordset") 
		sql="select * from photo where classid=" & cstr(request("id")) 
		rs.open sql,conn,1,1
		if rs.eof and rs.bof then
		sql="delete from class where   id=" & cstr(request("id")) 
	    conn.execute sql
	   if err.number <> 0 then
		response.write "数据库操作错误:" + err.description
		err.clear
	     else 
	           sql="delete from photo where classid=" & cstr(request("id")) 
	           conn.execute sql
		end if%>
       <script language=vbscript>
		msgbox "操作成功!该相册的所有相关信息已删除!"
		</script>
       <% else %>
		<script language=vbscript>
		msgbox "请先删除该相册的相片再删除相册!"
		</script>
		<%
		end if
		rs.close
		set rs=nothing
  end if
        %>
<html>
<head> 
<title>相册管理</title>
<meta http-equiv="Content-link" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.style2 {color: #FF0000}
.style3 {color: #CC0033}
-->
</style>

  <STYLE>
  TABLE {FONT-SIZE: 12px;COLOR: #000000; FONT-FAMILY: 宋体;LINE-HEIGHT: 180%}
.Shadow_white {FONT-SIZE: 14pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
.Shadow_white2 {FONT-SIZE: 10pt; FILTER: dropshadow(color:black, offx=1, offy=1, positive=1); WIDTH: 70%; COLOR: #000000; FONT-FAMILY: 宋体; POSITION: relative}
A:link {COLOR: #000000; TEXT-DECORATION: none}
A:active {COLOR: #000000; TEXT-DECORATION: none}
A:visited {COLOR: #000000; TEXT-DECORATION: none}
A:hover {COLOR: #ff0000; TEXT-DECORATION: underline}
  .style4 {font-size: 12px; color: #000000;}
  .style5 {
	font-size: 14;
	color: #000000;
}
  </STYLE></head>
  <body> 
  <script language=JavaScript>
function SureDel(id)
{ 
    if ( confirm("确定删除这个相册及所有相片文件吗?"))
        {
          window.location.href = "photoclass.asp?action=del&id=" + id
        }		
}
</script>
  <table border="0" width="80%" bgcolor="#000000" cellpadding="0" cellspacing="1" align="center">
    <tr valign="middle" background="images/topBar_bg.gif"> 
      <td height="20" background="images/topBar_bg.gif" colspan="7"> 
        <div align="center"></div> <div align="center"></div> 
        <div align="center" class="style4">相 册 管 理</div>
      </td>
    </tr>
		   

    <tr bgcolor="#FFFFFF"> 
      <td width="4%" height="23"> 
        <div align="center">ID</div>
      </td>
      <td width="24%"> 
        <div align="center" class="style2">相册名称</div>
      </td>
      <td width="24%"><div align="center" class="style2">所有者</div></td>
      <td width="11%"><div align="center" class="style2">访问密码</div></td>
      <td width="11%"><div align="center" class="style2">相册状态</div></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -