<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp" -->
<!--#include file="inc/plus_check.asp"-->
<!--#include file="Dv_Plus/Avatar/Plus_Avatar_Const.asp"-->
<%
Dim ShopID, PhotoID, CurPage, CurType, PhotoPageSize, CurTypeName, CurSubTypeName
Dim XMLDOM, URL, RemoteData

If Dvbbs.Forum_Setting(82) <> "0" Then
	Response.Redirect "showerr.asp?ErrCodes=<li>该论坛尚未开启虚拟形象功能，不能进行形象照相！&action=plus"
ElseIf Dvbbs.UserID = 0 And Request("action") <> "xml" Then
	Response.Redirect "showerr.asp?ErrCodes=<li>您不是会员，不能进行形象照相！&action=plus"
Else
	ShopID = Request("ShopID")
	If Not IsNumeric(ShopID) Or IsNull(ShopID) Or ShopID = "" Then
		ShopID = 197
	End If
	CurType = (Abs(ShopID) Mod 100)
	If CurType = 97 Then
		If ShopID <> 197 And ShopID <> 297 And ShopID <> 397 And ShopID <> 497 And ShopID <> 597 And ShopID <> 697 Then
			ShopID = 197
		End If
		CurTypeName = GetTypeName(ShopID)
		CurSubTypeName = GetSubTypeName(ShopID)
	End If
	PhotoID = Trim(Request("PhotoID"))
	If Not IsNumeric(PhotoID) Or IsNull(PhotoID) Or PhotoID = "" Then
		PhotoID = ""
	Else
		PhotoID = CLng(PhotoID)
	End If
	CurPage = Request("page")
	If CurPage = "" Or Not isInteger(CurPage) Then
		CurPage = 1
	Else
		CurPage = CLng(CurPage)
	End If
	PhotoPageSize = 10
	Dv_Plus.Name = "Plus_Avatar"
	Dvbbs.LoadTemplates ("Avatar")
	If Request("action") = "xml" And Request("testurl") = "" Then
		Set XMLDOM = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
		Call GetPhotoXML(XMLDOM, PhotoID)
		Response.Clear
		Response.Charset = "gb2312"
		Response.ContentType = "text/xml"
		Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
		Response.Write XMLDOM.documentElement.XML
		Set XMLDOM = Nothing
	ElseIf Request("action") = "xml" And Request("testurl") <> "" Then
		Set XMLDOM = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
		URL = Trim(Request("testurl"))
		If Right(URL, 1) <> "/" Then URL = URL & "/"
		If LCase(Left(URL, 7)) <> "http://" Then URL = "http://" & URL
		URL = URL & "Plus_Avatar_Photo.asp?action=xml"
		XMLDOM.Async = False
		XMLDOM.ValidateOnParse = False
		RemoteData = GetRemoteText(URL)
		Response.Clear
		Response.Charset = "gb2312"
		Response.ContentType = "text/xml"
		Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
		If Not XMLDOM.LoadXML(RemoteData) Then
			Response.Write "<Plus_Avatar>" & vbNewLine
			Response.Write "<AvatarInfo AllowRemoteCreatePhoto=""-1""/>" & vbNewLine
			Response.Write "</Plus_Avatar>" & vbNewLine
		Else
			Response.Write XMLDOM.documentElement.XML
		End If
		Set XMLDOM = Nothing
	Else
		If PhotoID <> "" Then
			If Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_Photo Where ID=" & PhotoID).Eof Then
				Response.Redirect "showerr.asp?ErrCodes=<li>提交了错误的参数！&action=plus"
			End If
		End If
		Call GetCurrentUserInfoXML(AvatarXMLDOM, ShopID)
		Call GetCurrentPhotoXML(AvatarXMLDOM)
		Dv_Plus.CheckLogin
		Dvbbs.Stats = template.Strings(26)
		Dvbbs.Nav()
		Dvbbs.Head_Var 2, 0, "", ""
		Dvbbs.ActiveOnline()
		Call AvatarNav
		Call Main
		Dvbbs.Footer
	End If
	Set AvatarXMLDOM = Nothing
	Set Dv_Plus = Nothing
End If

Sub Main()
	Dim AvatarXSLT, AvatarXMLStyle, AvatarProc
	
	Set AvatarXMLStyle = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	'AvatarXMLStyle.loadXML template.HTML(3)
	AvatarXMLStyle.load Server.MapPath("Dv_Plus/Avatar/Plus_Avatar_Photo.xslt")
	Set AvatarXSLT = Server.CreateObject("Msxml2.XSLTemplate" & MsxmlVersion)
	AvatarXSLT.stylesheet = AvatarXMLStyle
	Set AvatarProc = AvatarXSLT.createProcessor()
	AvatarProc.input = AvatarXMLDOM
	AvatarProc.transform()
	Response.Write AvatarProc.output
	Set AvatarXSLT = Nothing
	Set AvatarXMLStyle = Nothing
End Sub
%>