<!--#include file=conn.asp-->
<!--#include file="inc/const.asp" -->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="Dv_Plus/Avatar/Plus_Avatar_Const.asp"-->
<%
Dv_Plus.Name = "Plus_Avatar"
Dv_Plus.CheckLogin
Dvbbs.LoadTemplates "Avatar"
Dvbbs.Stats = Template.Strings(28)
Dvbbs.ActiveOnline()
v_FoundErr = False
If Dvbbs.Forum_Setting(82) <> "0" Then
	v_ErrCodes = "<li>该论坛尚未开启虚拟形象功能，不能保存形象！"
	v_FoundErr = True
ElseIf Dvbbs.UserID = 0 Then
	v_ErrCodes = "<li>您不是会员，无法保存形象！"
	v_FoundErr = True
Else
	Select Case Request("action")
	Case "SaveRequest"
		Call SaveRequest
	Case "PhotoMyself"
		Call PhotoMyself
	Case "ConfirmRequest"
		Call ConfirmRequest
	Case "SaveDesign"
		Call SaveDesign
	Case "AcceptDesign"
		Call AcceptDesign
	Case "DeletePhoto"
		Call DeletePhoto
	Case "RebuildPhoto"
		Call RebuildPhoto
	Case "SecretPhoto"
		Call SecretPhoto
	Case "PublicPhoto"
		Call PublicPhoto
	Case Else
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
	End Select
End If
If v_FoundErr Then
	Call ShowErr(True)
End If
If Request("action") <> "RebuildPhoto" And Request("action") <> "SecretPhoto" And Request("action") <> "PublicPhoto" Then
	If v_FoundErr Then
		Response.Write "<script>parent.document.getElementById('PhotoFrame').height=" & (130 + CalcLineCount(v_ErrCodes, "<br>") * 15) & ";</script>"
	End If
Else
	Dvbbs.Footer
End If
Set Dv_Plus = Nothing

Sub SaveRequest()
	Dim isUpload, PhotoUserCount, PhotoFee, PhotoID, UserAvatar(), i, SQL
	Dim CurAvatar, CurAvatarSplit, BgWidth, BgHeight
	Dim PhotoName, PhotoExplain, PhotoUser, PhotoStatus, PhotoBg, PhotoBodyBack, PhotoBodyFore, PhotoFg
	
	If Request.form("fromAvatar") = "" Then
		CurAvatar = v_MyAvatar
	Else
		CurAvatar = Trim(Request.form("fromAvatar"))
	End If
	Call UndressPeriod(CurAvatar, v_MySex, False)
	CurAvatar = FilterAvatarLayer(CurAvatar)
	If Not isAllowShow(CurAvatar) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>形象不雅，不能参加照相！"
		v_FoundErr = True
		Exit Sub
	End If
	If IsNull(Request.form("BgWidth")) Or Request.form("BgWidth") = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		BgWidth = Request.form("BgWidth")
		If Not IsInteger(BgWidth) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		BgWidth = CLng(BgWidth)
	End If
	If IsNull(Request.form("BgHeight")) Or Request.form("BgHeight") = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		BgHeight = Request.form("BgHeight")
		If Not IsInteger(BgHeight) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		BgHeight = CLng(BgHeight)
	End If
	If IsNull(Request.form("photoname")) Or Request.form("photoname") = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>合影的名称不能为空！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoName = Dvbbs.CheckStr(Trim(Request.form("photoname")))
		If Dvbbs.strLength(PhotoName) > 50 Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>合影的名称限定最多50个字符！"
			v_FoundErr = True
			Exit Sub
		End If
	End If
	If IsNull(Request.form("photostatus")) Or Request.form("photostatus") = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoStatus = Trim(Request.form("photostatus"))
		If Not IsInteger(PhotoStatus) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoStatus = CLng(PhotoStatus)
		If PhotoStatus <> 0 Then PhotoStatus = 1
	End If
	PhotoBg = Dvbbs.CheckStr(Trim(Request.form("photobg")))
	If PhotoBg = "0" Then
		PhotoBg = Split(CurAvatar, "|")(1)
		If PhotoBg <> "" Then PhotoBg = Split(PhotoBg, ".")(0)
	ElseIf PhotoBg = "-1" Then
		PhotoBg = Dvbbs.CheckStr(Trim(Request.form("bgfname")))
		If PhotoBg = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			isUpload = True
		End If
	Else
		isUpload = False
		If PhotoBg <> "" Then PhotoBg = Split(PhotoBg, ".")(0)
	End If
	PhotoBodyBack = Dvbbs.CheckStr(Trim(Request.form("photobodyback")))
	If PhotoBodyBack <> "" Then PhotoBodyBack = Split(PhotoBodyBack, ".")(0)
	PhotoBodyFore = Dvbbs.Checkstr(Trim(Request.form("photobodyfore")))
	If PhotoBodyFore <> "" Then PhotoBodyFore = Split(PhotoBodyFore, ".")(0)
	PhotoFg = Dvbbs.CheckStr(Trim(Request.form("photofg")))
	If PhotoFg <> "" Then PhotoFg = Split(PhotoFg, ".")(0)
	If Request.form("photomyself") <> "1" Then
		If IsNull(Request.form("photomsg")) Or Request.form("photomsg") = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>请求的内容不能为空！"
			v_FoundErr = True
			Exit Sub
		Else
			PhotoExplain = Dvbbs.CheckStr(Trim(Request.form("photomsg")))
			If Dvbbs.strLength(PhotoExplain) > CInt(Dvbbs.GroupSetting(34)) Then
				If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
				v_ErrCodes = v_ErrCodes & "<li>请求的内容限定最多" & Dvbbs.GroupSetting(34) & "个字符！"
				v_FoundErr = True
				Exit Sub
			End If
		End If
	Else
		PhotoExplain = ""
	End If
	If Request.form("photomyself") <> "1" Then
		If IsNull(Request.form("photouser")) Or Request.form("photouser") = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>参与者不能为空！"
			v_FoundErr = True
			Exit Sub
		Else
			PhotoUser = Dvbbs.CheckStr(Trim(Request.form("photouser")))
			If InStr("," & PhotoUser & ",", "," & Dvbbs.MemberName & ",") > 0 Then
				If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
				v_ErrCodes = v_ErrCodes & "<li>不能与自己合影！"
				v_FoundErr = True
				Exit Sub
			End If
			PhotoUser = Split(PhotoUser, ",")
			PhotoUserCount = UBound(PhotoUser) + 1
			If PhotoUserCount > CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("MaxPhotoUserCount").Text) Then
				If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
				v_ErrCodes = v_ErrCodes & "<li>最多只能允许" & AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("MaxPhotoUserCount").Text & "个用户合影！"
				v_FoundErr = True
				Exit Sub
			End If
			ReDim Preserve PhotoUser(PhotoUserCount)
			ReDim Preserve UserAvatar(PhotoUserCount)
			For i = PhotoUserCount - 1 To 0 Step -1
				PhotoUser(i + 1) = PhotoUser(i)
				Set AvatarRs = Dvbbs.Execute("Select Top 1 UserAvaSetting,UserSex From [Dv_User] Where UserName='" & PhotoUser(i) & "'")
				If AvatarRs.Eof Then
					If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
					v_ErrCodes = v_ErrCodes & "<li>用户【" & PhotoUser(i) & "】不存在，无法与之合影！"
					v_FoundErr = True
				ElseIf Not Dvbbs.Execute("Select Top 1 F_ID From [Dv_Friend] Where F_UserName='" & PhotoUser(i) & "' And F_Friend='" & Dvbbs.MemberName & "' And F_Mod=2").Eof Then
					If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
					v_ErrCodes = v_ErrCodes & "<li>用户【" & PhotoUser(i) & "】已经将您屏蔽，无法与之合影！"
					v_FoundErr = True
				ElseIf Dvbbs.Master And Request.form("forcephoto") = "1" Then
					UserAvatar(i + 1) = AvatarRs(0)
					Call UndressPeriod(UserAvatar(i + 1), AvatarRs(1), False)
					UserAvatar(i + 1) = FilterAvatarLayer(UserAvatar(i + 1))
					If Not isAllowShow(UserAvatar(i + 1)) Then
						If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
						v_ErrCodes = v_ErrCodes & "<li>用户【" & PhotoUser(i) & "】的形象不雅，无法强制与之合影！"
						v_FoundErr = True
					End If
				End If
				AvatarRs.Close
			Next
			If v_FoundErr Then Exit Sub
			PhotoUserCount = PhotoUserCount + 1
		End If
	Else
		ReDim PhotoUser(0)
		ReDim UserAvatar(0)
		PhotoUserCount = 1
	End If
	PhotoUser(0) = Dvbbs.MemberName
	UserAvatar(0) = CurAvatar
	If v_MyVip <> 1 Then
		PhotoFee = PhotoUserCount * CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("NormalPhotoPrice").Text)
	Else
		PhotoFee = PhotoUserCount * CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("VIPPhotoPrice").Text)
	End If
	If v_MyMoney < PhotoFee Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>本次照相共需现金" & PhotoFee & "元，您的现金(" & v_MyMoney & ")不足，无法发出邀请！"
		v_FoundErr = True
		Exit Sub
	End If
	SQL = "Insert Into Dv_Plus_Avatar_Photo (Name,Content,FromUser,Status"
	If IsUpload Then
		SQL = SQL & ",UploadFile"
	Else
		If PhotoBg <> "" Then SQL = SQL & ",Background"
	End If
	If PhotoBodyBack <> "" Then SQL = SQL & ",BackBody"
	If PhotoBodyFore <> "" Then SQL = SQL & ",ForeBody"
	If PhotoFg <> "" Then SQL = SQL & ",Foreground"
	SQL = SQL & ",Width,Height,Child,AddDate,EndDate"
	If (Dvbbs.Master And Request.form("forcephoto") = "1") Or Request.form("photomyself") = "1" Then
		SQL = SQL & ",Confirmed"
	End If
	SQL = SQL & ") Values ('" & PhotoName & "','" & PhotoExplain & "','" & Dvbbs.MemberName & "'," & PhotoStatus
	If IsUpload Then
		SQL = SQL & ",'" & PhotoBg & "'"
	Else
		If PhotoBg <> "" Then SQL = SQL & "," & PhotoBg
	End If
	If PhotoBodyBack <> "" Then SQL = SQL & "," & PhotoBodyBack
	If PhotoBodyFore <> "" Then SQL = SQL & "," & PhotoBodyFore
	If PhotoFg <> "" Then SQL = SQL & "," & PhotoFg
	SQL = SQL & "," & BgWidth & "," & BgHeight & "," & PhotoUserCount & "," & SqlNowString & "," & SqlDateAddString(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPeriod").Text,SqlNowString)
	If (Dvbbs.Master And Request.form("forcephoto") = "1") Or Request.form("photomyself") = "1" Then
		SQL = SQL & ",1"
	End If
	SQL = SQL & ")"
	Dvbbs.Plus_Execute(SQL)
	PhotoID = Dvbbs.Plus_Execute("Select Max(ID) From Dv_Plus_Avatar_Photo")(0)
	For i = 0 To PhotoUserCount - 1
		SQL = "Insert Into Dv_Plus_Avatar_PhotoUser (PhotoID,UserName"
		If i = 0 Or (Dvbbs.Master And Request.form("forcephoto") = "1") Then
			SQL = SQL & ",UserAvaSetting,Confirmed,ConfirmTime"
		End If
		SQL = SQL & ") Values (" & PhotoID & ",'" & PhotoUser(i) & "'"
		If i = 0 Or (Dvbbs.Master And Request.form("forcephoto") = "1") Then
			SQL = SQL & ",'" & UserAvatar(i) & "',1," & SqlNowString
		End If
		SQL = SQL & ")"
		Dvbbs.Plus_Execute(SQL)
		If i > 0 And (Not Dvbbs.Master Or Request.form("forcephoto") <> "1") Then Call Dv_SendMsg(PhotoUser(i), Dvbbs.MemberName, Replace(Template.Strings(29),"{$PhotoName}",Server.HTMLEncode(PhotoName)), Replace(Replace(Replace(Replace(Template.Strings(30),"\n",vbCrLf), "{$PhotoID}", PhotoID),"{$PhotoExplain}", Server.HTMLEncode(PhotoExplain)), "'", "''"))
	Next
	Call UpdateUserWealth(Dvbbs.MemberName, -PhotoFee)
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	SucMsg = SucMsg + "<li>恭喜您，已经成功地保存了照片《" & Server.HTMLEncode(PhotoName) & "》。"
	If Request.form("photomyself") = "1" Or (Dvbbs.Master And Request.form("forcephoto") = "1") Then
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=497&photoid=" & PhotoID, "开始进行照片设计")
	Else
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=297", "查看已发出请求列表")
	End If
	Response.Write "<script>parent.document.getElementById('PhotoFrame').height=145;</script>"
End Sub

Sub PhotoMyself()
	Dim isUpload, PhotoUserCount, PhotoFee, PhotoID, UserAvatar, i, SQL
	Dim CurAvatar, CurAvatarSplit, BgWidth, BgHeight
	Dim PhotoName, PhotoExplain, PhotoUser, PhotoStatus, PhotoBg
	
	If Request("fromAvatar") = "" Then
		CurAvatar = v_MyAvatar
	Else
		CurAvatar = Trim(Request("fromAvatar"))
	End If
	Call UndressPeriod(CurAvatar, v_MySex, False)
	CurAvatar = FilterAvatarLayer(CurAvatar)
	If Not isAllowShow(CurAvatar) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>形象不雅，不能进行个人写真！"
		v_FoundErr = True
		Exit Sub
	End If
	BgWidth = CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("AvatarWidth").Text)
	BgHeight = CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("AvatarHeight").Text)
	PhotoName = Dvbbs.MemberName & "的个人写真"
	PhotoExplain = ""
	PhotoStatus = CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("DefPhotoStatus").Text)
	PhotoBg = Split(CurAvatar, "|")(1)
	If PhotoBg <> "" Then PhotoBg = Split(PhotoBg, ".")(0)
	PhotoUserCount = 1
	PhotoUser = Dvbbs.MemberName
	UserAvatar = CurAvatar
	If v_MyVip <> 1 Then
		PhotoFee = CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("NormalPhotoPrice").Text)
	Else
		PhotoFee = CLng(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("VIPPhotoPrice").Text)
	End If
	If v_MyMoney < PhotoFee Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>本次照相共需现金" & PhotoFee & "元，您的现金(" & v_MyMoney & ")不足，无法完成本次个人写真！"
		v_FoundErr = True
		Exit Sub
	End If
	SQL = "Insert Into Dv_Plus_Avatar_Photo (Name,Content,FromUser,Status"
	If PhotoBg <> "" Then SQL = SQL & ",Background"
	SQL = SQL & ",Width,Height,Child,AddDate,EndDate,Confirmed) Values ('" & PhotoName & "','" & PhotoExplain & "','" & Dvbbs.MemberName & "'," & PhotoStatus
	If PhotoBg <> "" Then SQL = SQL & "," & PhotoBg
	SQL = SQL & "," & BgWidth & "," & BgHeight & "," & PhotoUserCount & "," & SqlNowString & "," & SqlDateAddString(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPeriod").Text,SqlNowString) & ",1)"
	Dvbbs.Plus_Execute(SQL)
	PhotoID = Dvbbs.Plus_Execute("Select Max(ID) From Dv_Plus_Avatar_Photo")(0)
	SQL = "Insert Into Dv_Plus_Avatar_PhotoUser (PhotoID,UserName,UserAvaSetting,Confirmed,ConfirmTime) Values (" & PhotoID & ",'" & PhotoUser & "','" & UserAvatar & "',1," & SqlNowString & ")"
	Dvbbs.Plus_Execute(SQL)
	Call UpdateUserWealth(Dvbbs.MemberName, -PhotoFee)
	Dvbbs.Nav()
	Dvbbs.Head_Var 2, 0, "", ""
	Call ShowSuc("<li>您已经成功地提交了一份个人写真，请到如下地址进行设计：【<a href=""Plus_Avatar_Photo.asp?shopid=497&photoid=" & PhotoID & """><b>设计照片</b></a>】", True)
	Dvbbs.Footer
End Sub

Sub ConfirmRequest()
	Dim CurAvatar, PhotoID, Rs, PhotoName, RetFlag
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And u.UserName='" & Dvbbs.MemberName & "' And p.Confirmed=0")
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Server.HTMLEncode(Rs(0))
		Rs.Close
	End If
	If Request.form("userAvatar") = "" Then
		CurAvatar = v_MyAvatar
	Else
		CurAvatar = Trim(Request.form("userAvatar"))
	End If
	Call UndressPeriod(CurAvatar, v_MySex, False)
	CurAvatar = FilterAvatarLayer(CurAvatar)
	If Not isAllowShow(CurAvatar) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>形象不雅，不能参加合影！"
		v_FoundErr = True
		Exit Sub
	End If
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_PhotoUser Set UserAvaSetting='" & CurAvatar & "',Confirmed=1,ConfirmTime=" & SqlNowString & " Where PhotoID=" & PhotoID & " And UserName='" & Dvbbs.MemberName & "'")
	If Dvbbs.Plus_Execute("Select Top 1 PhotoID From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Confirmed=0").Eof Then
		Set Rs = Server.CreateObject("ADODB.Recordset")
		If Cint(Dvbbs.Forum_Setting(92))=1 Then
			If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
			Rs.Open "Select FromUser,Confirmed,AddDate From Dv_Plus_Avatar_Photo Where ID=" & PhotoID,Plus_Conn,1,3
		Else
			If Not IsObject(Conn) Then ConnectionDatabase
			Rs.Open "Select FromUser,Confirmed,AddDate From Dv_Plus_Avatar_Photo Where ID=" & PhotoID,Conn,1,3
		End If
		Rs(1) = 1
		Rs.Update
		Call Dv_SendMsg(Rs(0), Dvbbs.Forum_Info(0) & "照相馆", Replace(Template.Strings(31),"{$PhotoName}",PhotoName), Replace(Replace(Replace(Replace(Template.Strings(32),"\n",vbCrLf), "{$PhotoID}", PhotoID),"{$AddDate}", FormatDateTime(Rs(2),2)), "'", "''"))
		Rs.Close
		Set Rs = Nothing
		RetFlag = True
	Else
		RetFlag = False
	End If
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	SucMsg = SucMsg + "<li>恭喜您，已经成功地确认了照片《" & PhotoName & "》。"
	If RetFlag Then
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=497", "查看已确认照片列表")
	Else
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=397", "查看已收到照片请求列表")
	End If
	Response.Write "<script>parent.document.getElementById('PhotoFrame').height=145;</script>"
End Sub

Sub SaveDesign()
	Dim PhotoID, UserCount, i, Rs1, Rs2, PhotoName
	Dim PhotoNameLeft, PhotoNameTop, PhotoNameFont, PhotoNameSize, PhotoNameBold, PhotoNameItalic, PhotoNameColor, PhotoNameDirection
	Dim PhotoDateLeft, PhotoDateTop, PhotoDateFont, PhotoDateSize, PhotoDateBold, PhotoDateItalic, PhotoDateColor, PhotoDateDirection
	Dim UserNameLeft(), UserNameTop(), UserNameFont(), UserNameSize(), UserNameBold(), UserNameItalic(), UserNameColor(), UserNameDirection()
	Dim OuterLeft(), OuterTop(), OuterWidth(), OuterHeight()
	Dim InnerLeft(), InnerTop(), InnerWidth(), InnerHeight()
	Dim LayerNo(), Direction()
	Dim AccoutermentItemID(5), AccoutermentDirection(5)
	Dim AccoutermentOuterLeft(5), AccoutermentOuterTop(5), AccoutermentOuterWidth(5), AccoutermentOuterHeight(5)
	Dim AccoutermentInnerLeft(5), AccoutermentInnerTop(5), AccoutermentInnerWidth(5), AccoutermentInnerHeight(5)
	Dim hasModified1, hasModified2, hasDesigned, PhotoURL

	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		Set Rs1 = Dvbbs.Plus_Execute("Select Top 1 p.Name,p.Child From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And u.UserName='" & Dvbbs.MemberName & "' And p.Confirmed<>0 And p.Finished=0")
		If Rs1.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Server.HTMLEncode(Rs1(0))
		UserCount = Rs1(1)
		Rs1.Close
	End If
	PhotoNameLeft = Request.form("PhotoNameLeft")
	If PhotoNameLeft = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsNumeric(PhotoNameLeft) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameLeft = CInt(PhotoNameLeft)
	End If
	PhotoNameTop = Request.form("PhotoNameTop")
	If PhotoNameTop = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsNumeric(PhotoNameTop) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameTop = CInt(PhotoNameTop)
	End If
	PhotoNameFont = Dvbbs.CheckStr(Trim(Request.form("PhotoNameFont")))
	If PhotoNameFont = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	End If
	PhotoNameSize = Request.form("PhotoNameSize")
	If PhotoNameSize = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoNameSize) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameSize = CInt(PhotoNameSize)
	End If
	PhotoNameBold = Request.form("PhotoNameBold")
	If PhotoNameBold = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoNameBold) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameBold = CInt(PhotoNameBold)
		If PhotoNameBold <> 0 Then PhotoNameBold = 1
	End If
	PhotoNameItalic = Request.form("PhotoNameItalic")
	If PhotoNameItalic = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoNameItalic) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameItalic = CInt(PhotoNameItalic)
		If PhotoNameItalic <> 0 Then PhotoNameItalic = 1
	End If
	PhotoNameColor = Dvbbs.CheckStr(Request.form("PhotoNameColor"))
	PhotoNameDirection = Request.form("PhotoNameDirection")
	If PhotoNameDirection = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoNameDirection) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoNameDirection = CInt(PhotoNameDirection)
	End If
	PhotoDateLeft = Request.form("PhotoDateLeft")
	If PhotoDateLeft = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsNumeric(PhotoDateLeft) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateLeft = CInt(PhotoDateLeft)
	End If
	PhotoDateTop = Request.form("PhotoDateTop")
	If PhotoDateTop = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsNumeric(PhotoDateTop) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateTop = CInt(PhotoDateTop)
	End If
	PhotoDateFont = Dvbbs.CheckStr(Trim(Request.form("PhotoDateFont")))
	If PhotoDateFont = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	End If
	PhotoDateSize = Request.form("PhotoDateSize")
	If PhotoDateSize = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoDateSize) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateSize = CInt(PhotoDateSize)
	End If
	PhotoDateBold = Request.form("PhotoDateBold")
	If PhotoDateBold = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoDateBold) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateBold = CInt(PhotoDateBold)
		If PhotoDateBold <> 0 Then PhotoDateBold = 1
	End If
	PhotoDateItalic = Request.form("PhotoDateItalic")
	If PhotoDateItalic = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoDateItalic) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateItalic = CInt(PhotoDateItalic)
		If PhotoDateItalic <> 0 Then PhotoDateItalic = 1
	End If
	PhotoDateColor = Dvbbs.CheckStr(Request.form("PhotoDateColor"))
	PhotoDateDirection = Request.form("PhotoDateDirection")
	If PhotoDateDirection = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not IsInteger(PhotoDateDirection) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoDateDirection = CInt(PhotoDateDirection)
	End If
	ReDim UserNameLeft(UserCount - 1), UserNameTop(UserCount - 1), UserNameFont(UserCount - 1), UserNameSize(UserCount - 1), UserNameBold(UserCount - 1), UserNameItalic(UserCount - 1), UserNameColor(UserCount - 1), UserNameDirection(UserCount - 1)
	ReDim OuterLeft(UserCount - 1), OuterTop(UserCount - 1), OuterWidth(UserCount - 1), OuterHeight(UserCount - 1)
	ReDim InnerLeft(UserCount - 1), InnerTop(UserCount - 1), InnerWidth(UserCount - 1), InnerHeight(UserCount - 1)
	ReDim LayerNo(UserCount - 1), Direction(UserCount - 1)
	For i = 1 To UserCount
		LayerNo(i - 1) = Request.form("LayerNo_" & i)
		If LayerNo(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(LayerNo(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			LayerNo(i - 1) = CInt(LayerNo(i - 1))
		End If
		OuterLeft(i - 1) = Request.form("AvatarOuterLeft_" & i)
		If OuterLeft(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(OuterLeft(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			OuterLeft(i - 1) = CInt(OuterLeft(i - 1))
		End If
		OuterTop(i - 1) = Request.form("AvatarOuterTop_" & i)
		If OuterTop(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(OuterTop(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			OuterTop(i - 1) = CInt(OuterTop(i - 1))
		End If
		OuterWidth(i - 1) = Request.form("AvatarOuterWidth_" & i)
		If OuterWidth(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(OuterWidth(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			OuterWidth(i - 1) = CInt(OuterWidth(i - 1))
		End If
		OuterHeight(i - 1) = Request.form("AvatarOuterHeight_" & i)
		If OuterHeight(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(OuterHeight(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			OuterHeight(i - 1) = CInt(OuterHeight(i - 1))
		End If
		InnerLeft(i - 1) = Request.form("AvatarInnerLeft_" & i)
		If InnerLeft(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(InnerLeft(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			InnerLeft(i - 1) = CInt(InnerLeft(i - 1))
		End If
		InnerTop(i - 1) = Request.form("AvatarInnerTop_" & i)
		If InnerTop(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(InnerTop(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			InnerTop(i - 1) = CInt(InnerTop(i - 1))
		End If
		InnerWidth(i - 1) = Request.form("AvatarInnerWidth_" & i)
		If InnerWidth(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(InnerWidth(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			InnerWidth(i - 1) = CInt(InnerWidth(i - 1))
		End If
		InnerHeight(i - 1) = Request.form("AvatarInnerHeight_" & i)
		If InnerHeight(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(InnerHeight(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			InnerHeight(i - 1) = CInt(InnerHeight(i - 1))
		End If
		Direction(i - 1) = Request.form("AvatarDirection_" & i)
		If Direction(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not isInteger(Direction(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			Direction(i - 1) = CInt(Direction(i - 1))
		End If
		UserNameLeft(i - 1) = Request.form("UserNameLeft_" & i)
		If UserNameLeft(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(UserNameLeft(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameLeft(i - 1) = CInt(UserNameLeft(i - 1))
		End If
		UserNameTop(i - 1) = Request.form("UserNameTop_" & i)
		If UserNameTop(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(UserNameTop(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameTop(i - 1) = CInt(UserNameTop(i - 1))
		End If
		UserNameFont(i - 1) = Dvbbs.CheckStr(Trim(Request.form("UserNameFont_" & i)))
		If UserNameFont(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		UserNameSize(i - 1) = Request.form("UserNameSize_" & i)
		If UserNameSize(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(UserNameSize(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameSize(i - 1) = CInt(UserNameSize(i - 1))
		End If
		UserNameBold(i - 1) = Request.form("UserNameBold_" & i)
		If UserNameBold(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(UserNameBold(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameBold(i - 1) = CInt(UserNameBold(i - 1))
			If UserNameBold(i - 1) <> 0 Then UserNameBold(i - 1) = 1
		End If
		UserNameItalic(i - 1) = Request.form("UserNameItalic_" & i)
		If UserNameItalic(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(UserNameItalic(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameItalic(i - 1) = CInt(UserNameItalic(i - 1))
			If UserNameItalic(i - 1) <> 0 Then UserNameItalic(i - 1) = 1
		End If
		UserNameColor(i - 1) = Dvbbs.CheckStr(Request.form("UserNameColor_" & i))
		UserNameDirection(i - 1) = Request.form("UserNameDirection_" & i)
		If UserNameDirection(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(UserNameDirection(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		Else
			UserNameDirection(i - 1) = CInt(UserNameDirection(i - 1))
		End If
	Next
	For i = 1 To 6
		AccoutermentItemID(i - 1) = Request.form("AccoutermentItemID_" & i)
		If AccoutermentItemID(i - 1) <> "" Then
			AccoutermentItemID(i - 1) = Split(AccoutermentItemID(i - 1), ".")(0)
			If Not IsInteger(AccoutermentItemID(i - 1)) Then
				If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
				v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误1！"
				v_FoundErr = True
				Exit Sub
			Else
				AccoutermentItemID(i - 1) = CLng(AccoutermentItemID(i - 1))
			End If
		Else
			AccoutermentItemID(i - 1) = 0
		End If
		AccoutermentOuterLeft(i - 1) = Request.form("AccoutermentOuterLeft_" & i)
		If AccoutermentOuterLeft(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误2！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(AccoutermentOuterLeft(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误3！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentOuterLeft(i - 1) = CInt(AccoutermentOuterLeft(i - 1))
		End If
		AccoutermentOuterTop(i - 1) = Request.form("AccoutermentOuterTop_" & i)
		If AccoutermentOuterTop(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误4！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(AccoutermentOuterTop(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误5！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentOuterTop(i - 1) = CInt(AccoutermentOuterTop(i - 1))
		End If
		AccoutermentOuterWidth(i - 1) = Request.form("AccoutermentOuterWidth_" & i)
		If AccoutermentOuterWidth(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误6！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(AccoutermentOuterWidth(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误7！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentOuterWidth(i - 1) = CInt(AccoutermentOuterWidth(i - 1))
		End If
		AccoutermentOuterHeight(i - 1) = Request.form("AccoutermentOuterHeight_" & i)
		If AccoutermentOuterHeight(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误8！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(AccoutermentOuterHeight(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误9！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentOuterHeight(i - 1) = CInt(AccoutermentOuterHeight(i - 1))
		End If
		AccoutermentInnerLeft(i - 1) = Request.form("AccoutermentInnerLeft_" & i)
		If AccoutermentInnerLeft(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误10！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(AccoutermentInnerLeft(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误11！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentInnerLeft(i - 1) = CInt(AccoutermentInnerLeft(i - 1))
		End If
		AccoutermentInnerTop(i - 1) = Request.form("AccoutermentInnerTop_" & i)
		If AccoutermentInnerTop(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误12！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsNumeric(AccoutermentInnerTop(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误13！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentInnerTop(i - 1) = CInt(AccoutermentInnerTop(i - 1))
		End If
		AccoutermentInnerWidth(i - 1) = Request.form("AccoutermentInnerWidth_" & i)
		If AccoutermentInnerWidth(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误14！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(AccoutermentInnerWidth(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误15！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentInnerWidth(i - 1) = CInt(AccoutermentInnerWidth(i - 1))
		End If
		AccoutermentInnerHeight(i - 1) = Request.form("AccoutermentInnerHeight_" & i)
		If AccoutermentInnerHeight(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误16！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not IsInteger(AccoutermentInnerHeight(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误17！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentInnerHeight(i - 1) = CInt(AccoutermentInnerHeight(i - 1))
		End If
		AccoutermentDirection(i - 1) = Request.form("AccoutermentDirection_" & i)
		If AccoutermentDirection(i - 1) = "" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误18！"
			v_FoundErr = True
			Exit Sub
		ElseIf Not isInteger(AccoutermentDirection(i - 1)) Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误19！"
			v_FoundErr = True
			Exit Sub
		Else
			AccoutermentDirection(i - 1) = CInt(AccoutermentDirection(i - 1))
		End If
	Next
	Set Rs1 = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs1.Open "Select Top 1 * From Dv_Plus_Avatar_Photo Where ID=" & PhotoID,Plus_Conn,1,3
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs1.Open "Select Top 1 * From Dv_Plus_Avatar_Photo Where ID=" & PhotoID,Conn,1,3
	End If
	hasModified1 = False
	hasDesigned = (Not IsNull(Rs1("FinishDate")))
	If hasDesigned Then
		If ((IsNull(Rs1("PhotoNameColor")) And PhotoNameColor <> "") Or (Not IsNull(Rs1("PhotoNameColor")) And PhotoNameColor = "")) Then
			hasModified1 = True
		ElseIf Rs1("PhotoNameLeft") <> PhotoNameLeft Or Rs1("PhotoNameTop") <> PhotoNameTop Or Rs1("PhotoNameFont") <> PhotoNameFont Or Rs1("PhotoNameSize") <> PhotoNameSize Or Rs1("PhotoNameBold") <> PhotoNameBold Or Rs1("PhotoNameItalic") <> PhotoNameItalic Or Rs1("PhotoNameColor") <> PhotoNameColor Or Rs1("PhotoNameDirection") <> PhotoNameDirection Then
			hasModified1 = True
		ElseIf ((IsNull(Rs1("DateColor")) And PhotoDateColor <> "") Or (Not IsNull(Rs1("DateColor")) And PhotoDateColor = "")) Then
			hasModified1 = True
		ElseIf Rs1("DateLeft") <> PhotoDateLeft Or Rs1("DateTop") <> PhotoDateTop Or Rs1("DateFont") <> PhotoDateFont Or Rs1("DateSize") <> PhotoDateSize Or Rs1("DateBold") <> PhotoDateBold Or Rs1("DateItalic") <> PhotoDateItalic Or Rs1("DateColor") <> PhotoDateColor Or Rs1("DateDirection") <> PhotoDateDirection Then
			hasModified1 = True
		End If
	Else
		hasModified1 = True
	End If
	If hasModified1 Then
		Rs1("PhotoNameLeft") = PhotoNameLeft
		Rs1("PhotoNameTop") = PhotoNameTop
		Rs1("PhotoNameFont") = PhotoNameFont
		Rs1("PhotoNameSize") = PhotoNameSize
		Rs1("PhotoNameBold") = PhotoNameBold
		Rs1("PhotoNameItalic") = PhotoNameItalic
		Rs1("PhotoNameColor") = PhotoNameColor
		Rs1("PhotoNameDirection") = PhotoNameDirection
		Rs1("DateLeft") = PhotoDateLeft
		Rs1("DateTop") = PhotoDateTop
		Rs1("DateFont") = PhotoDateFont
		Rs1("DateSize") = PhotoDateSize
		Rs1("DateBold") = PhotoDateBold
		Rs1("DateItalic") = PhotoDateItalic
		Rs1("DateColor") = PhotoDateColor
		Rs1("DateDirection") = PhotoDateDirection
	End If
	Set Rs2 = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs2.Open "Select * From Dv_Plus_Avatar_Accouterment Where PhotoID= " & PhotoID,Plus_Conn,1,3
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs2.Open "Select * From Dv_Plus_Avatar_Accouterment Where PhotoID= " & PhotoID,Conn,1,3
	End If
	For i = 0 To 5
		If AccoutermentItemID(i) <> 0 Then
			If Not Rs2.EOF Then
				hasModified2 = False
			Else
				Rs2.Addnew
				Rs2("PhotoID") = PhotoID
				hasModified2 = True
			End If
			If hasDesigned Then
				If Rs2("SeqNo") <> i + 1 Or Rs2("ItemID") <> AccoutermentItemID(i) Or Rs2("OuterLeft") <> AccoutermentOuterLeft(i) Or Rs2("OuterTop") <> AccoutermentOuterTop(i) Or Rs2("OuterWidth") <> AccoutermentOuterWidth(i) Or Rs2("OuterHeight") <> AccoutermentOuterHeight(i) Or Rs2("InnerLeft") <> AccoutermentInnerLeft(i) Or Rs2("InnerTop") <> AccoutermentInnerTop(i) Or Rs2("InnerWidth") <> AccoutermentInnerWidth(i) Or Rs2("InnerHeight") <> AccoutermentInnerHeight(i) Or Rs2("Direction") <> AccoutermentDirection(i) Then hasModified2 = True
			Else
				hasModified2 = True
			End If
			If hasModified2 Then
				Rs2("SeqNo") = i + 1
				Rs2("ItemID") = AccoutermentItemID(i)
				Rs2("OuterLeft") = AccoutermentOuterLeft(i)
				Rs2("OuterTop") = AccoutermentOuterTop(i)
				Rs2("OuterWidth") = AccoutermentOuterWidth(i)
				Rs2("OuterHeight") = AccoutermentOuterHeight(i)
				Rs2("InnerLeft") = AccoutermentInnerLeft(i)
				Rs2("InnerTop") = AccoutermentInnerTop(i)
				Rs2("InnerWidth") = AccoutermentInnerWidth(i)
				Rs2("InnerHeight") = AccoutermentInnerHeight(i)
				Rs2("Direction") = AccoutermentDirection(i)
				Rs2.Update
				hasModified1 = True
			End If
			Rs2.Update
			Rs2.MoveNext
		End If
	Next
	Do While Not Rs2.EOF
		Rs2.Delete
		Rs2.MoveNext
		hasModified1 = True
	Loop
	Rs2.Close
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		Rs2.Open "Select * From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID,Plus_Conn,1,3
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		Rs2.Open "Select * From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID,Conn,1,3
	End If
	i = 0
	Do While Not Rs2.EOF And i < UserCount
		hasModified2 = False
		If hasDesigned Then
			If Rs2("LayerNo") <> LayerNo(i) Or Rs2("OuterLeft") <> OuterLeft(i) Or Rs2("OuterTop") <> OuterTop(i) Or Rs2("OuterWidth") <> OuterWidth(i) Or Rs2("OuterHeight") <> OuterHeight(i) Or Rs2("InnerLeft") <> InnerLeft(i) Or Rs2("InnerTop") <> InnerTop(i) Or Rs2("InnerWidth") <> InnerWidth(i) Or Rs2("InnerHeight") <> InnerHeight(i) Or Rs2("Direction") <> Direction(i) Then
				hasModified2 = True
			ElseIf (IsNull(Rs2("NameColor")) And UserNameColor(i) <> "") Or (Not IsNull(Rs2("NameColor")) And UserNameColor(i) = "") Then
				hasModified2 = True
			ElseIf Rs2("NameLeft") <> UserNameLeft(i) Or Rs2("NameTop") <> UserNameTop(i) Or Rs2("NameFont") <> UserNameFont(i) Or Rs2("NameSize") <> UserNameSize(i) Or Rs2("NameBold") <> UserNameBold(i) Or Rs2("NameItalic") <> UserNameItalic(i) Or Rs2("NameColor") <> UserNameColor(i) Or Rs2("NameDirection") <> UserNameDirection(i) Then
				hasModified2 = True
			End If
		Else
			hasModified2 = True
		End If
		If hasModified2 Then
			Rs2("LayerNo") = LayerNo(i)
			Rs2("OuterLeft") = OuterLeft(i)
			Rs2("OuterTop") = OuterTop(i)
			Rs2("OuterWidth") = OuterWidth(i)
			Rs2("OuterHeight") = OuterHeight(i)
			Rs2("InnerLeft") = InnerLeft(i)
			Rs2("InnerTop") = InnerTop(i)
			Rs2("InnerWidth") = InnerWidth(i)
			Rs2("InnerHeight") = InnerHeight(i)
			Rs2("Direction") = Direction(i)
			Rs2("NameLeft") = UserNameLeft(i)
			Rs2("NameTop") = UserNameTop(i)
			Rs2("NameFont") = UserNameFont(i)
			Rs2("NameSize") = UserNameSize(i)
			Rs2("NameBold") = UserNameBold(i)
			Rs2("NameItalic") = UserNameItalic(i)
			Rs2("NameColor") = UserNameColor(i)
			Rs2("NameDirection") = UserNameDirection(i)
			Rs2.Update
			hasModified1 = True
		End If
		If ((Rs2("Finished") = 0 Or hasModified1) And LCase(Trim(Rs2("UserName"))) = LCase(Trim(Dvbbs.MemberName))) Or (Dvbbs.Master And Request.form("forceagree") = "1") Then
			Rs2("Finished") = 1
			Rs2.Update
		End If
		Rs2.MoveNext
		i = i + 1
	Loop
	Rs2.Close
	Set Rs2 = Nothing
	If hasModified1 Or (((Dvbbs.Master And Request.form("forceagree") = "1") Or UserCount = 1) And Rs1("Finished") <> 1) Then
		Rs1("FinishDate") = Now()
		If (Dvbbs.Master And Request.form("forceagree") = "1") Or UserCount = 1 Then
			Rs1("Finished") = 1
		End If
		Rs1.Update
	End If
	Rs1.Close
	Set Rs1 = Nothing
	If (Dvbbs.Master And Request.form("forceagree") = "1") Or UserCount = 1 Then
		PhotoURL = CreateAvatarPhoto(PhotoID)
		If PhotoURL <> "" Then
			Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set URL='" & PhotoURL & "' Where ID=" & PhotoID)
		End If
		If UserCount = 1 Then
			SucMsg = SucMsg + "<li>恭喜您，已经成功地完成了照片《" & PhotoName & "》的设计，请到您的虚拟相簿中欣赏这张照片。"
		Else
			SucMsg = SucMsg + "<li>恭喜您，已经强制完成了照片《" & PhotoName & "》的设计，请到您的虚拟相簿中欣赏这张照片。"
		End If
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=597", "查看我的虚拟相簿")
	Else
		If hasModified1 Then
			Set Rs2 = Dvbbs.Plus_Execute("Select UserName, Finished From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID)
			Do While Not Rs2.Eof
				If LCase(Trim(Rs2(0))) <> LCase(Trim(Dvbbs.MemberName)) Then
					If Rs2("Finished") = 1 And hasDesigned Then
						Call Dv_SendMsg(Rs2(0), Dvbbs.MemberName, Replace(Template.Strings(35),"{$PhotoName}",Server.HTMLEncode(PhotoName)), Replace(Replace(Replace(Template.Strings(36),"\n",vbCrLf), "{$PhotoID}", PhotoID), "'", "''"))
					ElseIf Not hasDesigned Then
						Call Dv_SendMsg(Rs2(0), Dvbbs.MemberName, Replace(Template.Strings(37),"{$PhotoName}",Server.HTMLEncode(PhotoName)), Replace(Replace(Replace(Template.Strings(38),"\n",vbCrLf), "{$PhotoID}", PhotoID), "'", "''"))
					End If
				End If
				Rs2.MoveNext
			Loop
			Rs2.Close
			Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_PhotoUser Set Finished=0 Where PhotoID=" & PhotoID & " And UserName<>'" & Dvbbs.MemberName & "'")
		End If
		SucMsg = SucMsg + "<li>恭喜您，已经成功地保存了照片《" & PhotoName & "》的设计。"
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=497", "查看已确认照片列表")
	End If
	Response.Write "<script>parent.document.getElementById('PhotoFrame').height=145;</script>"
End Sub

Sub AcceptDesign()
	Dim PhotoID, Rs, PhotoName, RetFlag, PhotoURL
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name From (Dv_Plus_Avatar_PhotoUser u1 Inner Join Dv_Plus_Avatar_Photo p On u1.PhotoID=p.ID) Inner Join Dv_Plus_Avatar_PhotoUser u2 On u2.PhotoID=p.ID Where u2.UserName=p.FromUser And p.ID=" & PhotoID & " And u1.UserName='" & Dvbbs.MemberName & "' And p.Confirmed<>0 And p.Finished=0 And u1.Finished=0 And u2.Finished<>0")
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Server.HTMLEncode(Rs(0))
		Rs.Close
	End If
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_PhotoUser Set Finished=1 Where PhotoID=" & PhotoID & " And UserName='" & Dvbbs.MemberName & "'")
	If Dvbbs.Plus_Execute("Select Top 1 PhotoID From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Finished=0").Eof Then
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set Finished=1 Where ID=" & PhotoID)
		Set Rs = Dvbbs.Plus_Execute("Select UserName,ConfirmTime From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And UserName<>'" & Dvbbs.MemberName & "'")
		Do While Not Rs.Eof
			Call Dv_SendMsg(Rs(0), Dvbbs.Forum_Info(0) & "照相馆", Replace(Template.Strings(33),"{$PhotoName}",PhotoName), Replace(Replace(Replace(Template.Strings(34),"\n",vbCrLf),"{$PhotoDate}", FormatDateTime(Rs(1),2)), "'", "''"))
			Rs.MoveNext
		Loop
		Rs.Close
		PhotoURL = CreateAvatarPhoto(PhotoID)
		If PhotoURL <> "" Then
			Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set URL='" & PhotoURL & "' Where ID=" & PhotoID)
		End If
		RetFlag = True
	Else
		RetFlag = False
	End If
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	If RetFlag Then
		SucMsg = SucMsg + "<li>恭喜您，已经成功地同意了照片《" & PhotoName & "》的设计，请到您的虚拟相簿中欣赏这张照片。"
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=597", "查看我的虚拟相簿")
	Else
		SucMsg = SucMsg + "<li>恭喜您，已经成功地同意了照片《" & PhotoName & "》的设计。"
		Call ShowSucWithURL(SucMsg , "Plus_Avatar_PhotoDetail.asp?shopid=497", "查看已确认照片列表")
	End If
	Response.Write "<script>parent.document.getElementById('PhotoFrame').height=145;</script>"
End Sub

Sub RebuildPhoto()
	Dim PhotoID, Rs, objFSO, PhotoFile, UploadFile, PhotoName, PhotoURL
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		If Not Dvbbs.Master Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And u.UserName='" & Dvbbs.MemberName & "' And p.Finished<>0")
		Else
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And p.Finished<>0")
		End If
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Rs(0)
		Rs.Close
	End If
	PhotoURL = CreateAvatarPhoto(PhotoID)
	If PhotoURL <> "" Then
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set URL='" & PhotoURL & "' Where ID=" & PhotoID)
		If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
		SucMsg = SucMsg + "<li>恭喜您，已经成功地重印了照片《" & PhotoName & "》，照片文件名为 <b>" & PhotoURL & "</b>。"
		Call ShowSuc(SucMsg, False)
		Response.write "<script>if(window.opener) window.opener.document.execCommand('Refresh');</script>"
	Else
		v_FoundErr = True
	End If
End Sub

Sub DeletePhoto()
	Dim PhotoID, Rs, objFSO, PhotoFile, UploadFile, PhotoName
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		If Not Dvbbs.Master Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name,p.URL,p.UploadFile From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And u.UserName='" & Dvbbs.MemberName & "' And p.Finished<>0")
		Else
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 p.Name,p.URL,p.UploadFile From Dv_Plus_Avatar_PhotoUser u Inner Join Dv_Plus_Avatar_Photo p On u.PhotoID=p.ID Where u.PhotoID=" & PhotoID & " And p.Finished<>0")
		End If
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Rs(0)
		PhotoFile = Rs(1)
		UploadFile = Rs(2)
		Rs.Close
	End If
	If Dvbbs.Master Then
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_PhotoUser Set Deleted=1 Where PhotoID=" & PhotoID)
	Else
		Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_PhotoUser Set Deleted=1 Where PhotoID=" & PhotoID & " And UserName='" & Dvbbs.MemberName & "'")
	End If
	If Dvbbs.Plus_Execute("Select Top 1 PhotoID From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Deleted=0").Eof Then
		If Not IsNull(PhotoFile) And PhotoFile <> "" Then
			On Error Resume Next
			Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
			If Err = 0 Then
				If objFSO.fileExists(Server.MapPath(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPath").text & PhotoFile)) Then
					objFSO.DeleteFile (Server.MapPath(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPath").text & PhotoFile))
					If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
					SucMsg = SucMsg + "<li>照片文件 " & PhotoFile & " 已经删除。"
				Else
					If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
					SucMsg = SucMsg + "<li>照片文件 " & PhotoFile & " 不存在。"
				End If
			Else
				Err.Clear
				If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
				SucMsg = SucMsg + "<li>照片文件 " & PhotoFile & " 无法删除。"
			End If
			Set objFSO = Nothing
			On Error GoTo 0
		End If
		If Not IsNull(UploadFile) And UploadFile <> "" Then
			On Error Resume Next
			Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
			If Err = 0 Then
				If objFSO.fileExists(Server.MapPath(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPath").text & UploadFile)) Then
					objFSO.DeleteFile (Server.MapPath(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("PhotoPath").text & UploadFile))
					If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
					SucMsg = SucMsg + "<li>上传的背景文件 " & UploadFile & " 已经删除。"
				Else
					If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
					SucMsg = SucMsg + "<li>上传的背景文件 " & UploadFile & " 不存在。"
				End If
			Else
				Err.Clear
				If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
				SucMsg = SucMsg + "<li>上传的背景文件 " & UploadFile & " 无法删除。"
			End If
			Set objFSO = Nothing
			On Error GoTo 0
		End If
		Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_Photo Where ID=" & PhotoID)
		Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID)
		Dvbbs.Plus_Execute("Delete From Dv_Plus_Avatar_Accouterment Where PhotoID=" & PhotoID)
	End If
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	SucMsg = SucMsg + "<li>恭喜您，已经成功地删除了照片《" & PhotoName & "》。"
	Call ShowSucWithURL(SucMsg, "Plus_Avatar_PhotoDetail.asp?shopid=" & Request("shopid"), "返回上一页")
	Response.Write "<script>parent.document.getElementById('PhotoFrame').height=145;</script>"
End Sub

Sub SecretPhoto()
	Dim PhotoID, Rs, PhotoName
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		If Not Dvbbs.Master Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Name From Dv_Plus_Avatar_Photo Where ID=" & PhotoID & " And FromUser='" & Dvbbs.MemberName & "' And Finished<>0")
		Else
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Name From Dv_Plus_Avatar_Photo Where ID=" & PhotoID & " And Finished<>0")
		End If
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Rs(0)
		Rs.Close
	End If
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set Status=0 Where ID=" & PhotoID)
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	SucMsg = SucMsg + "<li>恭喜您，已经成功地隐藏了照片《" & PhotoName & "》。"
	Call ShowSuc(SucMsg, False)
	Response.write "<script>if(window.opener) window.opener.document.execCommand('Refresh');</script>"
End Sub

Sub PublicPhoto()
	Dim PhotoID, Rs, PhotoName
	
	PhotoID = Request("photoid")
	If PhotoID = "" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	ElseIf Not isInteger(PhotoID) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
		v_FoundErr = True
		Exit Sub
	Else
		PhotoID = CLng(PhotoID)
		If Not Dvbbs.Master Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Name From Dv_Plus_Avatar_Photo Where ID=" & PhotoID & " And FromUser='" & Dvbbs.MemberName & "' And Finished<>0")
		Else
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Name From Dv_Plus_Avatar_Photo Where ID=" & PhotoID & " And Finished<>0")
		End If
		If Rs.Eof Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>提交的数据有错误！"
			v_FoundErr = True
			Exit Sub
		End If
		PhotoName = Rs(0)
		Rs.Close
	End If
	Dvbbs.Plus_Execute("Update Dv_Plus_Avatar_Photo Set Status=1 Where ID=" & PhotoID)
	If SucMsg <> "" Then SucMsg = SucMsg & "<br>"
	SucMsg = SucMsg + "<li>恭喜您，已经成功地公开了照片《" & PhotoName & "》。"
	Call ShowSuc(SucMsg, False)
	Response.write "<script>if(window.opener) window.opener.document.execCommand('Refresh');</script>"
End Sub
%>