<!-- #include file="../clsMain.asp" -->
<!-- #include file="config.txt" -->
<%
dim myPlus
	Set myPlus = New JyPlus
	myPlus.PlusId = "HappyLover"
	myPlus.PlusName = "幸福恋人"
	myPlus.PlusEdition = "2.0"
	myPlus.PlusLastUpdateTime = "2005-4-5"
	
Sub alterTable
	AddColumn "Dv_user","plus_love_love","varchar(20)"
	AddColumn "Dv_user","plus_love_wantlove","varchar(20)"
	AddColumn "Dv_user","plus_love_time","smalldatetime null"
End Sub


Sub WantLove()
	dim sql,rs,plus_love_wantlove,rs2,notice
	dim UserSex0,UserSex1
	plus_love_wantlove=checkStr(request("WantLove"))
	if plus_love_wantlove=myPlus.UserName then
		setAlert("拜托，都老大不小的人了，还玩什么自恋啊~~")
	end if
	'判断是否重复求爱
	'判断是否移情别恋
	sql="select plus_love_wantlove,UserSex from [DV_User] where username='"&myPlus.UserName&"'"
	set rs=conn.execute(sql)
	if Rs(0)=plus_love_wantlove then
		setAlert("死缠烂打是没有用的。\r求爱宣言发一次就够了。")	
	elseif rs(0)>"" then
		conn.execute("update [DV_User] set plus_love_wantlove='',userCP=userCP"&UserConfig(2,0)&",userEP=userEP"&UserConfig(2,1)&" where username='"&myPlus.UserName&"'")
		notice="您移情别恋，魅力值"&UserConfig(2,0)&",经验值"&UserConfig(2,1)&"。\r\r"
	end if
	UserSex0=Rs(1)
	
	sql="select plus_love_love,plus_love_wantlove,UserSex from [DV_User] where username='"&plus_love_wantlove&"'"
	set rs=conn.execute(sql)
	if rs.eof then
		Call PageTo(notice&"没有找到您要求爱的对象，请检查您的输入。","plus_HappyLover.asp")
	elseif Rs(1)=myPlus.UserName then
		Call setAlert(notice&"嘻嘻~对方已经主动向你求爱了，你就接受他(她)吧！","plus_HappyLover.asp")
	elseif Rs(2)=UserSex0 and (isAllowSameSex=false) then
		Call setAlert(notice&"目前本论坛不允许同性恋公开化！","plus_HappyLover.asp")
	elseif Rs(0)>"" then
		notice=notice&"你爱的人已经有恋人了。\r您的求爱宣言也许要很久以后才会有回音。"
	else
		notice=notice&"已经为你传递了向"&plus_love_wantlove&"的求爱宣言，请您静候佳音。\r祝你成功！\r"
	end if	
	'执行求爱操作，并发送短消息
	conn.execute("update DV_User set plus_love_wantlove='"&plus_love_wantlove&"',userCp=userCp"&UserConfig(0,0)&",userEp=userEp"&UserConfig(0,1)&" where username='"&myPlus.UserName&"'")
	conn.execute("update DV_User set userCp=userCp"&UserConfig(0,2)&" where username='"&plus_love_wantlove&"'")
	notice=notice&"您向"&plus_love_wantlove&"求爱，魅力值"&UserConfig(0,0)&",经验值"&UserConfig(0,1)&"。\r"
	notice=notice&plus_love_wantlove&"魅力值。"&UserConfig(0,2)&"\r\r"			
	Call myPlus.sendmessage(myPlus.UserName,plus_love_wantlove,"幸福恋人系统消息：求爱信","亲爱的，您愿意成为我的论坛恋人吗？向全论坛宣告我们的爱情？答应我吧。"&Chr(10)&Chr(10)&"您可以选择：[url=plus_HappyLover.asp?action=agree&action2=接受求爱&username="&myPlus.UserName&"]答应[/url]　　[url=plus_HappyLover.asp?action=agree&action2=&username="&myPlus.UserName&"]不答应[/url]") 
	Call myPlus.update_user_msg(plus_love_wantlove)
	Call PageTo(notice,"plus_HappyLover.asp")
End Sub

Sub OverLove()
dim rs,sql
	sql="select plus_love_love from DV_user where username='"&myPlus.UserName&"'"
	set rs=conn.execute(sql)
	if rs(0)="" then
		Call pageTo("您已经是单身贵族了。","plus_HappyLover.asp")
	else
		conn.execute("update DV_user set plus_love_love='',userCP=userCP"&UserConfig(4,0)&",userEP=userEP"&UserConfig(4,1)&" where plus_love_love='"&myPlus.UserName&"'")
		conn.execute("update DV_user set plus_love_love='',userCP=userCP"&UserConfig(4,0)&",userEP=userEP"&UserConfig(4,1)&" where plus_love_love='"&rs(0)&"'")		
		Call myPlus.sendmessage(myPlus.UserName,rs(0),"幸福恋人系统消息：我们分手吧","经过三秒钟的慎重考虑，我终于决定和你分手。"&Chr(10)&"祝你幸福！"&Chr(10)&Chr(10)&"（备注：以上内容为系统自动生成）") 
		Call myPlus.update_user_msg(Rs("plus_love_love"))
		Call pageTo("成功解除了你们的恋爱关系。\r欢迎你回到单身贵族的行列。","plus_HappyLover.asp")
	end if
End Sub

Sub AgreeLove()
dim sql,rs,plus_love_wantlove,rs2,notice
	plus_love_wantlove=checkStr(request("username"))
	if len(plus_love_wantlove)=0 then
		setAlert("错误的参数")
	else
		plus_love_wantlove=checkStr(plus_love_wantlove)
	end if
	'检查用户是否存在
	sql="select plus_love_wantlove from [DV_User] where username='"&plus_love_wantlove&"'"
	set rs=conn.execute(sql)		
	if rs.eof then
		call pageTo("该用户不存在。\r请检查您是否从本站安全链接进入。","plus_HappyLover.asp")
	elseif rs(0)<>MyPlus.UserName then
		call pageTo("该用户没有向您发出求爱请求。\r或许该请求已被回应，或许对方已经撤回请求。","plus_HappyLover.asp")
	end if
	
if request("action2")="接受求爱" then
	'接受求爱
	sql="select plus_love_love from [DV_User] where username='"&MyPlus.UserName&"'"
	set rs=conn.execute(sql)		
	if rs(0)>"" then
		call setAlert("您必须先和您的恋人解除恋爱关系才可以接受别人的求爱。")
	end if
	
	conn.execute("update [DV_User] set plus_love_wantlove='',plus_love_love='"&plus_love_wantlove&"',userCp=userCp"&UserConfig(3,0)&",userEp=userEp"&UserConfig(3,1)&",plus_love_time="&MyPlus.strSqlNow&" where username='"&MyPlus.UserName&"'")
	conn.execute("update [DV_User] set plus_love_wantlove='',plus_love_love='"&MyPlus.UserName&"',userCp=userCp"&UserConfig(3,0)&",userEp=userEp+"&UserConfig(3,1)&",plus_love_time="&MyPlus.strSqlNow&" where username='"&plus_love_wantlove&"'")				
	call MyPlus.sendmessage(MyPlus.UserName,plus_love_wantlove,"幸福恋人系统消息：接受求爱","经过再三考虑，我终于还是接受了你的请求。"&Chr(10)&"你以后要好好对我哦！"&Chr(10)&"现在我们一起去论坛发贴庆祝吧！") 
	Call MyPlus.update_user_msg(plus_love_wantlove)
	call pageTo("恭喜你们成功确定了恋爱关系！\r你和您的恋人各加100点经验值和100点魅力值！\r记得请大家吃糖哦^_^","plus_HappyLover.asp")
else
	'拒绝求爱
	conn.execute("update [DV_User] set plus_love_wantlove='',userCp=userCp-50,userEp=userEp-20 where username='"&plus_love_wantlove&"'")
	call MyPlus.sendmessage(MyPlus.UserName,plus_love_wantlove,"幸福恋人系统消息：拒绝求爱","经过再三考虑，我觉得我们还是不适合做恋人，做普通朋友也很好啊！"&Chr(10)&"真诚的祝愿你在论坛上找寻到你的真爱！") 
	Call MyPlus.update_user_msg(plus_love_wantlove)
	call pageTo("拒绝了对方的求爱。\对方魅力值"&UserConfig(1,0)&"、经验值"&UserConfig(1,1)&"。","plus_HappyLover.asp")
end if	
End Sub
%>