<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->
<%call head()
Call saycarda("好友管理")
dim TP,ids,Action
Action=Request.QueryString("Action")
IF  Action="f" Then
	call friend
else

	call hait
end if

sub friend

TP=trim(request("TP"))
if TP<>"" then
bz=trim(request("bz"))
ids=trim(request("ids"))
if ids="" or IsNumeric(ids)=False then
  Call Error("ID无效！")
end if
'检查ID是否存在
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT id FROM users where id="&ids,conn,1,1
if rs.eof then
  rs.close
  set rs=Nothing
  Call Error("ID不存在！")
end if
  rs.close
  set rs=Nothing
if clng(ids)=myid then
  Call Error("不能加自己为好友！")
end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from myfriend where cid="&myid&" and did="&ids,conn,1,2
if not rs.eof Then
response.write "对方已经是你的好友！修改备注成功!"
Call head1()
response.end
end if
rs.addnew
rs("did")=IDS
rs("cid")=myid
rs("beizhu")=bz
rs.update
rs.close
set rs=Nothing

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from guest",conn,1,2
rs.addnew
rs("fnr")="会员"&myni&"(id:"&myid&")将您加为好友"
rs("sid")=IDS
rs("fid")=0
rs.update
rs.close
set rs=nothing
 Response.Write "添加好友成功！"
else
 dim idp
 idp=request.querystring("ids")

 if idp<>"" then
 Response.Write "您将添加ID:"&idp&"为好友<br/>"

 if vipdj>0 then
 Response.Write "<input name='bz"&tt&"' emptyok='false'/><br/>"
 Response.Write "您是VIP会员,享有好友备注功能！<br/>"
 end If
 if saytk=>2 Then
response.write "<input type=""hidden"" name=""ids"" value="""&idp&"""/>"
response.write "<input type=""hidden"" name=""tp"" value=""1""/>"
%>

<input type="submit" name="Submit" value="确定添加"></form><br/><%
else
 Response.Write "<anchor>确定添加"
 Response.Write "<go href=""get.asp?Action=f&amp;saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
 Response.Write "<postfield name=""bz"" value=""$(bz"&tt&")""/>"
 Response.Write "<postfield name=""ids"" value="""&idp&"""/>"
 Response.Write "<postfield name=""TP"" value=""1""/>"
 Response.Write "</go></anchor>"
 End if
 Else
if saytk=>2 then
	Response.write "<form name=""form"" method=""post"" action=""get.asp?Action=f&amp;saytk="&saytk&"&amp;sid="&sid&""">"
end if

if saytk=>2 Then
 Response.Write "好友ID<br/>"
 Response.Write "<input name='ids' format='*N' emptyok='false'/><br/>"
 if vipdj>0 then
 Response.Write "<input name='bz' emptyok='false'/><br/>"
 Response.Write "您是VIP会员,享有好友备注功能！<br/>"
 end if
response.write "<input type=""hidden"" name=""tp"" value=""1""/>"
%>

<input type="submit" name="Submit" value="确定添加"></form><br/><%
Else
 Response.Write "好友ID<br/>"
 Response.Write "<input name='ids"&tt&"' format='*N' emptyok='false'/><br/>"
 if vipdj>0 then
 Response.Write "<input name='bz"&tt&"' emptyok='false'/><br/>"
 Response.Write "您是VIP会员,享有好友备注功能！<br/>"
 end if
 Response.Write "<anchor>确定添加"
 Response.Write "<go href=""get.asp?Action=f&amp;saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
 Response.Write "<postfield name=""bz"" value=""$(bz"&tt&")""/>"
 Response.Write "<postfield name=""ids"" value=""$(ids"&tt&")""/>"
 Response.Write "<postfield name=""TP"" value=""1""/>"
 Response.Write "</go></anchor>"
 end If
 end if
  end if
 Response.Write "<br/><a href=""myfriend.asp?saytk="&saytk&"&amp;sid="&sid&""">好友列表</a>"
end  sub
sub hait

TP=trim(request("TP"))
if TP<>"" then
ids=trim(request("ids"))
if ids="" or IsNumeric(ids)=False then
  Call Error("ID无效！")
end if
'检查ID是否存在
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT id FROM users where id="&ids,conn,1,1
if rs.eof then
  Call Error("ID不存在！")
end if
  rs.close
  set rs=Nothing
if clng(ids)=myid then
  Call Error("不能加自己为黑名单！")
end if
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from myhait where jid="&myid&" and bid="&ids,conn,1,2
if not rs.eof then
  Response.Write ("对方已经是你的黑名单！")
  Response.Write "<br/><a href=""/bbs/myhait.asp?saytk="&saytk&"&amp;sid="&sid&""">黑名单管理</a>"
  Call headsay()
  Response.end
end if
rs.addnew
rs("bid")=IDS
rs("jid")=myid
rs.update
rs.close
set rs=nothing
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from guest",conn,1,2
rs.addnew
rs("fnr")="会员"&myni&"(id:"&myid&")将您加为黑名单"
rs("sid")=IDS
rs("fid")=0
rs.update
rs.close
set rs=nothing
 Response.Write "添加黑名单成功！"
else
 Response.Write "黑名单ID<br/>"
 Response.Write "<input name='ids"&tt&"' format='*N' emptyok='false'/><br/>"
 Response.Write "<anchor>确定添加"
 Response.Write "<go href=""get.asp?Action=h&amp;saytk="&saytk&"&amp;sid="&sid&""" method=""post"" accept-charset=""utf-8"">"
 Response.Write "<postfield name=""ids"" value=""$(ids"&tt&")""/>"
 Response.Write "<postfield name=""TP"" value=""1""/>"
 Response.Write "</go></anchor>"
end if
 Response.Write "<br/><a href=""myhait.asp?saytk="&saytk&"&amp;sid="&sid&""">黑名单列表</a>"
end  sub
conn.close
set conn=nothing%>
<%call headsay()%>