<!-- #include file="conn.asp" -->
<!-- #include file="bbsuser.asp" -->
<%
postuser=request("postuser")
   sql="select friend from clubuser where clubuser_name='"&request.cookies("name")&"'"
   set rs=server.createobject("adodb.recordset")
   rs.open sql,conn,1,1
if rs("friend")<>"" and instr(rs("friend"),"|")>0 then
   myarray=split(rs("friend"),"|")
   for i=0 to UBound(myarray)
     if InStr(myarray(i),request("postuser"))>0 then
        response.write "<script language='javascript'>"
        response.write "alert('你已经加入了该用户为好友！');"
        response.write "history.go(-1);"
        response.write "</script>"
        response.end
	 else
	    postuser=rs("friend")&request("postuser")&"|"
	 end if
   next
else
postuser=request("postuser")&"|"
end if
   str="update clubuser set friend='"&postuser&"' where clubuser_name='"&request.cookies("name")&"'"
   conn.execute(str)
   msg=request.cookies("bbsuser")&"请求加为好友！"
   smscontent=request.cookies("bbsuser")&"请求加为好友！"
   sql="insert into sms(title,content,sender,accepter,bbssystem) values('"&msg&"','"&smscontent&"','"&request.cookies("name")&"','"&request("postuser")&"',2)"
   conn.execute(sql)
   conn.close
   response.write "<script language='javascript'>"
   response.write "alert('加入成功,但必须等你的好友确认！');"
   response.write "history.go(-1);"
   response.write "</script>"
   response.end
%>