<!--#include file="Inc.asp"-->
<!--#include file="ydzq.asp"-->

<%Call head()
dim mesall,tid,TP,txts
mesall = Trim(Request.Form("mesall"))
tid = Trim(Request("tid"))
TP=Trim(Request("TP"))
if tid="" or Isnumeric(tid)=False  then
Call Error("card title='提交错误'><p>ID无效！")
end if
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select * from sell where id="&tid,conn,1,1
if rs.eof then
  Call Error("card title='提交错误'><p>帖子不存在！")
  end if
  sellname=rs("name")
  rs.close
  set rs=nothing
if TP<>"" then

txts="推荐帖子[br](url=/bbs/topic.asp?tid="&tid&"&amp;sid=[sid])"&sellname&"(/url)"

dim objgbrs,ids
 set objgbrs=Server.CreateObject("ADODB.Recordset")
  objgbrs.open"select * from myfriend where cid="&myid&" order by id desc",conn,1,1
 Do While Not objgbrs.EOF
      ids=objgbrs("did")
      qfmsg
     objgbrs.MoveNext
  Loop
objgbrs.close
set objgbrs=nothing
Function qfmsg()
  sql="insert into guest(fid,sid,fnr) values ("
  sql=sql & sqlstr(myid) & ","
  sql=sql & sqlstr(ids) & ","
  sql=sql & sqlstr(txts) & ")"
  Application.Lock
  conn.execute(sql)
  Application.Unlock
End function
function sqlstr(data)
sqlstr="'" & Replace(data,"'","'") & "'"
End function

Else

if mesall="" then
  conn.close
  set conn=Nothing
    Call cardz("提交错误","irecommend.asp?tid="&tid&"&amp;sid="&sid&"&amp;saytk="&saytk&"")

  Call headsay()
  response.end
end if

if IsNumeric(Replace(mesall,";",""))=False then
  conn.close
  set conn=Nothing
  Call cardz("提交错误","irecommend.asp?tid="&tid&"&amp;sid="&sid&"&amp;saytk="&saytk&"")
 
  Call headsay()
  response.end
end if

if left(mesall,1)=";" then
mesall=mid(mesall,2)
end if

dim splmesall,s
splmesall=split(mesall,";")

dim total
total = 0

for s = 0 to ubound(splmesall)

'发信
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from guest",conn,1,2
rs.addnew
rs("fnr")="推荐帖子[br](url=/bbs/topic.asp?tid="&tid&"&amp;sid=[sid])"&sellname&"(/url)"
rs("sid")=splmesall(s)
rs("fid")=myid
rs.update

 total = total + 1
  rs.Close
next
set rs=Nothing

End if
conn.close
set conn=Nothing
Call cardz("推荐成功！","topic.asp?tid="&tid&"&amp;sid="&sid&"&amp;saytk="&saytk&"")
 
Response.write "推荐成功！正在返回...<br/><a href='topic.asp?tid="&tid&"&amp;sid="&sid&"'>返回主贴</a>" & chr(13)
%>
<!--#include file="fanhui.asp"-->
<%Call headsay()%>