<!--#include file="../Include/Conn.asp" -->
<!--#include file="../Include/const.asp" -->
<!--#include file="../Include/char.asp" -->
<!--#include file="IsLogin.asp" -->
<%
dim idarr,i
user_flag=0
f_id=clng(request("id"))
 if f_id="" then
 Call Msgbox("对不起，ID号错误！",1)
 Response.end
 end if
 m_ID = Session("CurUserID")
 m_username= Session("CurUserName")
set rs_a=server.createobject("adodb.recordset")
sql_a="select f_id,f_manage_username from t_club where F_id="&f_id
rs_a.open sql_a,conn,1,3

if rs_a.eof then
 Call Msgbox("对不起，该俱乐部已经不存在！",1)
 Response.end
end if
'判别身份，是否有权限上传照片
set rs_user=server.createobject("adodb.recordset")
sql_user="select f_ischeck,f_identity from t_club_member where F_club_id="&f_id&" and f_username='"&m_username&"'"
rs_user.open sql_user,conn
if rs_user.eof and rs_user.bof then
 Call Msgbox("对不起,您还未加入本俱乐部！",1)
 Response.end
 else
 if rs_user("f_ischeck")=false then
 Call Msgbox("对不起,您还未通过审核加入本俱乐部，请耐心等待！",1)
 Response.end
 end if
end if
if rs_user("f_identity")="初级会员" then    '初级会员无权上传照片
 Call Msgbox("对不起,您是本俱乐部[初级会员]暂无上传照片权限！",1)
 Response.end
end if
rs_user.close
set rs_user=nothing
'/////////////////////////////////////////////////////
if rs_a("f_manage_username")=m_username then
user_flag=1
end if
rs_a.close
set rs_a=nothing
%>
<%
sub CloseConn()
	conn.close
	set conn=nothing
end sub
ArticleID=trim(request("ArticleID"))
'Action=Trim(Request("Action"))
'response.Write(articleid)
FoundErr=False

if ArticleId="" then
	FoundErr=True
   Call Msgbox("对不起,请选择删除照片！",1)
    Response.end
end if
  
  if FoundErr=False then
	if instr(ArticleID,",")>0 then
	'	dim idarr,i
		idArr=split(ArticleID)
		for i = 0 to ubound(idArr)
			call DelArticle(clng(idarr(i)),user_flag)
		next
	else
		call DelArticle(clng(ArticleID),user_flag)
	end if
end if
if FoundErr=False then
	call CloseConn()
	response.Redirect "club_photomanage.asp?id="&f_id
else
	call CloseConn()
	call WriteErrMsg()
end if
  
  


sub DelArticle(ID,flag)
	'PurviewChecked=False
	if flag=1 then
	sqlDel1="select f_id,f_photo from t_club_photo where f_ID=" & CLng(ID)
	else
	sqlDel1="select f_id,f_photo from t_club_photo where f_username='"&m_username&"' and f_ID=" & CLng(ID)
	end if
	Set rsDel1= Server.CreateObject("ADODB.Recordset")
	rsDel1.open sqlDel1,conn,1,3
	if not rsdel1.eof then
	     '文件删除
	     strUploadFiles=rsdel1("f_photo")
	     if strUploadFiles<>"" then
				Set fso = CreateObject("Scripting.FileSystemObject")				
					if fso.FileExists(server.MapPath("" & strUploadfiles)) then
						fso.DeleteFile(server.MapPath("" & strUploadfiles))
					end if				
				Set fso = nothing
			end if
			
     conn.execute "update T_club set F_clubphoto=f_clubphoto-1 where F_ID=" &f_id
    mSql = "DELETE FROM t_club_photobook WHERE F_photo_ID=" &rsdel1("f_id") '删除俱乐部下照片评论
    conn.execute mSql
  	 rsdel1.delete
	 rsdel1.update
	 end if

	 rsdel1.close
	set rsDel1=nothing
		'conn.execute "delete from Comment where ArticleID=" & CLng(ID)	
end sub
%>