PageRenderTime 63ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/BuyPost.asp

http://cfbbs.googlecode.com/
ASP | 392 lines | 367 code | 9 blank | 16 comment | 0 complexity | 434c320c5df227f6f2ae2e255dd8a058 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <!-- #include file="conn.asp" -->
  2. <!-- #include file="inc/const.asp" -->
  3. <!--#include file="inc/dv_clsother.asp"-->
  4. <%
  5. Dvbbs.LoadTemplates("dispbbs")
  6. Dim Rootid,PostTable,Action,RootID_a
  7. Dim AnnounceID,Rs,SQL,i
  8. Action = Request("action")
  9. PostTable=Request("PostTable")
  10. PostTable=Checktable(PostTable)
  11. Rootid=Request("ID")
  12. RootID_a=Request("rootid")
  13. AnnounceID=Request("ReplyID")
  14. Select Case Action
  15. Case "view" : Dvbbs.stats="?????????"
  16. Case "buy" : Dvbbs.stats="??????"
  17. Case "Send" : Dvbbs.stats="????"
  18. Case "Close" : Dvbbs.stats="????"
  19. Case Else
  20. Dvbbs.stats="????"
  21. End Select
  22. Dvbbs.Nav()
  23. Dvbbs.Head_var 1,Application(Dvbbs.CacheName&"_boardlist").documentElement.selectSingleNode("board[@boardid='"&Dvbbs.BoardID&"']/@depth").text,"",""
  24. If Rootid="" Or Not IsNumeric(Rootid) Then Dvbbs.AddErrCode(35)
  25. If AnnounceID="" or Not IsNumeric(AnnounceID) Then Dvbbs.AddErrCode(35)
  26. If Dvbbs.UserID=0 Then Dvbbs.AddErrCode(6)
  27. Dvbbs.ShowErr()
  28. Select Case Action
  29. Case "view" : view()
  30. Case "buy" : Buy()
  31. Case "Send" : SendMoney()
  32. Case "Close" : Close()
  33. Case Else
  34. main()
  35. End Select
  36. Dvbbs.ShowErr()
  37. Dvbbs.Activeonline()
  38. Dvbbs.Footer
  39. Dvbbs.PageEnd()
  40. '????
  41. Sub Close()
  42. Dim PostBuyUser,ToUserName,PostUserID,GetMoney,Topic,TopAnnounceID,LogMsg
  43. Dim TempStr
  44. Sql = "Select Top 1 PostBuyUser,GetMoney,Topic,AnnounceID From "&PostTable&" where RootID="&Rootid&" and ParentID=0 and GetMoneyType=1 and PostUserID="&Dvbbs.UserID
  45. Set Rs=Dvbbs.Execute(Sql)
  46. If Rs.eof and Rs.bof Then
  47. Dvbbs.AddErrCode(32)
  48. Exit Sub
  49. Else
  50. PostBuyUser = Rs(0)
  51. GetMoney = Rs(1)
  52. Topic = Rs(2)
  53. TopAnnounceID = Rs(3)
  54. End If
  55. Rs.Close
  56. TempStr = Split(PostBuyUser,"|||",2)
  57. TempStr(0) = cCur(TempStr(0))
  58. If Request.Form("ReAct")="SaveClose" Then
  59. Dim SendMoney
  60. If Not Dvbbs.ChkPost Then
  61. Dvbbs.AddErrCode(16)
  62. Exit Sub
  63. End If
  64. SendMoney = GetMoney-TempStr(0)
  65. If SendMoney<0 Then SendMoney = 0
  66. '?????????
  67. If SendMoney>0 Then
  68. Dvbbs.Execute("update [Dv_user] set UserMoney=UserMoney+"&SendMoney&" where userid="&Dvbbs.UserID)
  69. Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text = cCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text )+SendMoney '??????
  70. End If
  71. '??????
  72. Dvbbs.Execute("update Dv_Topic set GetMoneyType=5 where TopicID="&Rootid)
  73. Dvbbs.Execute("update "&PostTable&" set GetMoneyType=5 where AnnounceID="&TopAnnounceID)
  74. LogMsg = "<b>????</b>?????????<a href=""Dispbbs.asp?boardid="&Dvbbs.BoardID&"&id="&Rootid&""" target=_blank><b>"&Topic&"</b></a>?????????????<b>"&SendMoney&"</b>"
  75. Dim Dv_LogMsg
  76. Dv_LogMsg = "?????????????"&Topic&"?????????????"&SendMoney
  77. Dvbbs.Execute("Insert Into Dv_Log (l_AnnounceID,l_BoardID,l_touser,l_username,l_content,l_ip,l_type) values (" & Rootid & "," & Dvbbs.BoardID & ",'" & Dvbbs.MemberName & "','" & Dvbbs.MemberName & "','" & Dvbbs.CheckStr(Dv_LogMsg) & "','" & Dvbbs.UserTrueIP & "',5)")
  78. Dvbbs.Dvbbs_Suc(LogMsg)
  79. Else
  80. %>
  81. <FORM METHOD=POST ACTION="buypost.asp?action=Close">
  82. <table cellpadding=3 cellspacing=1 align=center class=tableborder1>
  83. <tr><th colspan=2>? <%=Topic%> ? ????????</th></tr>
  84. <tr>
  85. <td class=tablebody1 colspan=2><li>?????????????????????</td>
  86. </tr>
  87. <tr>
  88. <td class=tablebody2 align=right width="30%">???????</td>
  89. <td class=tablebody1 width="70%"><%=GetMoney%></td>
  90. </tr>
  91. <tr>
  92. <td class=tablebody2 align=right>????????</td>
  93. <td class=tablebody1><%=TempStr(0)%></td>
  94. </tr>
  95. <tr>
  96. <td class=tablebody2 align=right>????????</td>
  97. <td class=tablebody1><%=GetMoney-TempStr(0)%></td>
  98. </tr>
  99. <tr><td class=tablebody2 colspan=2 align=center>
  100. <INPUT TYPE="submit" value="????"> <INPUT TYPE="button" value="??" onclick="history.go(-1)">
  101. </td></tr>
  102. <INPUT TYPE="hidden" NAME="react" value="SaveClose">
  103. <INPUT TYPE="hidden" NAME="PostTable" value="<%=PostTable%>">
  104. <INPUT TYPE="hidden" NAME="ID" value="<%=Rootid%>">
  105. <INPUT TYPE="hidden" NAME="ReplyID" value="<%=AnnounceID%>">
  106. <INPUT TYPE="hidden" NAME="BoardID" value="<%=Dvbbs.BoardID%>">
  107. </table>
  108. <%
  109. End If
  110. End Sub
  111. '?????
  112. Sub SendMoney()
  113. Dim PostBuyUser,ToUserName,PostUserID,GetMoney,Topic,TopAnnounceID,LogMsg
  114. Dim TempStr,IsSendUser
  115. Sql = "Select Top 1 PostBuyUser,GetMoney,Topic,AnnounceID From "&PostTable&" where RootID="&Rootid&" and ParentID=0 and GetMoneyType=1 and PostUserID="&Dvbbs.UserID
  116. Set Rs=Dvbbs.Execute(Sql)
  117. If Rs.eof and Rs.bof Then
  118. Dvbbs.AddErrCode(32)
  119. Exit Sub
  120. Else
  121. PostBuyUser = Rs(0)
  122. GetMoney = Rs(1)
  123. Topic = Rs(2)
  124. TopAnnounceID = Rs(3)
  125. End If
  126. Rs.Close
  127. ToUserName = Request("UserName")
  128. TempStr = Split(PostBuyUser,"|||",2)
  129. TempStr(0) = cCur(TempStr(0))
  130. If Instr(PostBuyUser,"|||"&ToUserName&",")>0 Then
  131. IsSendUser = "<font class=Redfont>[???]</font>"
  132. Else
  133. IsSendUser = "<font color=gray>[???]</font>"
  134. End If
  135. If Request.Form("ReAct")="SaveMoney" Then
  136. If Not Dvbbs.ChkPost Then
  137. Dvbbs.AddErrCode(16)
  138. Exit Sub
  139. End If
  140. Dim SendMoney
  141. SendMoney = Request.Form("SendMoney")
  142. If Not Isnumeric(SendMoney) Then
  143. Dvbbs.AddErrCode(35)
  144. Exit Sub
  145. Else
  146. SendMoney = cCur(SendMoney)
  147. End If
  148. If TempStr(0) < 0 Then Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>???????????????????&action=OtherErr"
  149. TempStr(0) = TempStr(0)+SendMoney
  150. If SendMoney<1 or TempStr(0)>GetMoney Then
  151. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>???????????????????&action=OtherErr"
  152. Exit Sub
  153. End If
  154. '???????????GetMoney??
  155. Sql = "Select username,PostUserID,GetMoney From "&PostTable&" where AnnounceID="&AnnounceID
  156. Dvbbs.SqlQueryNum=Dvbbs.SqlQueryNum+1
  157. set Rs=Dvbbs.iCreateObject("adodb.recordset")
  158. Rs.open sql,conn,1,3
  159. If Rs.eof and Rs.bof Then
  160. Dvbbs.AddErrCode(32)
  161. Dvbbs.ShowErr()
  162. Else
  163. ToUserName = Rs(0)
  164. PostUserID = Rs(1)
  165. If PostUserID=Dvbbs.UserID Then
  166. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>???????????????&action=OtherErr"
  167. Exit Sub
  168. End If
  169. Rs(2) = Rs(2)+SendMoney
  170. Rs.Update
  171. End If
  172. Rs.close
  173. TempStr(1) = TempStr(1) & "|||" &ToUserName&","&SendMoney
  174. PostBuyUser = TempStr(0) & "|||" & TempStr(1)
  175. '???????????
  176. Dvbbs.Execute("update [Dv_user] set UserMoney=UserMoney+"&SendMoney&" where userid="&PostUserID)
  177. '????????PostBuyUser??
  178. Dvbbs.Execute("update "&PostTable&" set PostBuyUser = '"&PostBuyUser&"' where AnnounceID="&TopAnnounceID)
  179. LogMsg = "???????<a href=""Dispbbs.asp?BoardID="&Dvbbs.BoardID&"&ID="&Rootid&"&ReplyID="&Announceid&"&Skin=1"" target=_blank><b>"&Topic&"</b></a>???????????<b>"&ToUserName&"</b>???????<b>"&SendMoney&"</b>???????????<b>"& GetMoney-TempStr(0) &"</b>?"
  180. Dvbbs.Dvbbs_Suc(LogMsg)
  181. Else
  182. %>
  183. <FORM METHOD=POST ACTION="buypost.asp?action=Send">
  184. <table cellpadding=3 cellspacing=1 align=center class=tableborder1>
  185. <tr><th colspan=2>? <%=Topic%> ? ??????</th></tr>
  186. <tr>
  187. <td class=tablebody1 align=right width="30%">???????</td>
  188. <td class=tablebody1 width="70%"><%=GetMoney%></td>
  189. </tr>
  190. <tr>
  191. <td class=tablebody1 align=right>????????</td>
  192. <td class=tablebody1><%=TempStr(0)%></td>
  193. </tr>
  194. <tr>
  195. <td class=tablebody1 align=right>???????</td>
  196. <td class=tablebody1><%=Server.HtmlEncode(ToUserName)%> <%=IsSendUser%></td>
  197. </tr>
  198. <tr>
  199. <td class=tablebody1 align=right>?????????</td>
  200. <td class=tablebody1><INPUT TYPE="text" NAME="SendMoney" value=""> ??<b><font class="Redfont"><%=(GetMoney-TempStr(0))%></font></b>???</td>
  201. </tr>
  202. <tr><td class=tablebody2 colspan=2 align=center>
  203. <INPUT TYPE="submit" value="??"> <INPUT TYPE="button" value="??" onclick="history.go(-1)">
  204. </td></tr>
  205. <INPUT TYPE="hidden" NAME="react" value="SaveMoney">
  206. <INPUT TYPE="hidden" NAME="PostTable" value="<%=PostTable%>">
  207. <INPUT TYPE="hidden" NAME="ID" value="<%=Rootid%>">
  208. <INPUT TYPE="hidden" NAME="ReplyID" value="<%=AnnounceID%>">
  209. <INPUT TYPE="hidden" NAME="BoardID" value="<%=Dvbbs.BoardID%>">
  210. </table>
  211. <%
  212. End If
  213. End Sub
  214. '??????
  215. Sub Buy()
  216. Dim PostBuyUser,ToUserName,PostUserID,GetMoney,GetMoneyType,IsUpdate,LogMsg,Topic,TempStr
  217. IsUpdate = False
  218. Sql = "Select PostBuyUser,username,PostUserID,GetMoney,GetMoneyType,Topic From "&PostTable&" where RootID="&Rootid&" and ParentID=0 and GetMoneyType=3"
  219. If Not IsObject(Conn) Then ConnectionDatabase
  220. Dvbbs.SqlQueryNum=Dvbbs.SqlQueryNum+1
  221. Set Rs = Dvbbs.iCreateObject("adodb.recordset")
  222. Rs.open Sql,conn,1,3
  223. If Rs.eof and Rs.bof Then
  224. Dvbbs.AddErrCode(32)
  225. Dvbbs.ShowErr()
  226. Else
  227. PostBuyUser = Rs(0)
  228. ToUserName = Rs(1)
  229. PostUserID = Rs(2)
  230. GetMoney = Rs(3)
  231. GetMoneyType = Rs(4)
  232. Topic = Rs(5)
  233. If Not IsNumeric(GetMoney) Then GetMoney=0
  234. If GetMoney < 0 Then Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>??????????????????&action=OtherErr"
  235. If Instr(PostBuyUser,"|||$PayMoney|||") AND Dvbbs.UserID<>PostUserID AND GetMoney<>0 and InStr(PostBuyUser,"|||"&Dvbbs.Membername&"|||")=0 Then
  236. TempStr = Split(Rs(0),"|||",2)
  237. Dim BuyMoneyInfo
  238. BuyMoneyInfo = Split(TempStr(0),"@@@")
  239. BuyMoneyInfo(1) = cCur(BuyMoneyInfo(1))
  240. BuyMoneyInfo(2) = Clng(BuyMoneyInfo(2))
  241. '??????(???“-1”????)
  242. If BuyMoneyInfo(1)=0 Then
  243. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>???????&action=OtherErr"
  244. Exit Sub
  245. ElseIf BuyMoneyInfo(1)>0 Then
  246. BuyMoneyInfo(1) = BuyMoneyInfo(1) - 1
  247. End If
  248. '?VIP???????GetMoney??0
  249. 'If BuyMoneyInfo(2)=0 and Dvbbs.VipGroupUser Then
  250. 'GetMoney = 0
  251. 'End If
  252. '?????????(??????????“,”?????????????)
  253. If BuyMoneyInfo(3)<>"" Then
  254. If Instr(","&BuyMoneyInfo(3)&",",","&Dvbbs.Membername&",")=0 Then
  255. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>????????????????????&action=OtherErr"
  256. Exit Sub
  257. End If
  258. End If
  259. If GetMoney>CCur(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text) Then
  260. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>????????????????&action=OtherErr"
  261. Exit Sub
  262. End If
  263. BuyMoneyInfo(0) = cCur(BuyMoneyInfo(0)) + GetMoney '*ToolsSetting(4)
  264. TempStr(0) = BuyMoneyInfo(0) & "@@@" & BuyMoneyInfo(1) & "@@@" & BuyMoneyInfo(2) & "@@@" & BuyMoneyInfo(3)
  265. Rs(0) = TempStr(0) & "|||" & TempStr(1) & Dvbbs.Membername & "|||"
  266. Rs.Update
  267. Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text -GetMoney
  268. Dvbbs.Execute("update [Dv_user] set UserMoney="&Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermoney").text &" where userid="&Dvbbs.userid)
  269. Dvbbs.Execute("update [Dv_user] set UserMoney=UserMoney+"&GetMoney&" where userid="&PostUserID)
  270. IsUpdate = True
  271. Else
  272. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>?????????????????????&action=OtherErr"
  273. Exit Sub
  274. End If
  275. End If
  276. Rs.Close : Set Rs=Nothing
  277. If IsUpdate Then
  278. LogMsg = "??????<a href=""Dispbbs.asp?boardid="&Dvbbs.BoardID&"&id="&Rootid&""" target=_blank><b>"&Topic&"</b></a>???????????<b>"&GetMoney&"</b>?<b>"&ToUserName&"</b>??????"&GetMoney
  279. Dvbbs.Dvbbs_Suc(LogMsg)
  280. End If
  281. End Sub
  282. Sub Main()
  283. dim re
  284. dim po,ii
  285. dim reContent
  286. dim strContent
  287. dim PostBuyUser
  288. po=0
  289. ii=0
  290. dim usermoney
  291. If Rootid_a="" Or Not IsNumeric(Rootid_a) Then Dvbbs.AddErrCode(35)
  292. set rs=Dvbbs.Execute("select userWealth from [Dv_user] where userid="&Dvbbs.Userid)
  293. usermoney=rs(0)
  294. Dvbbs.SqlQueryNum=Dvbbs.SqlQueryNum+1
  295. set rs=Dvbbs.iCreateObject("adodb.recordset")
  296. sql="select body,PostBuyUser,username,PostUserID,GetMoneyType From "&PostTable&" where Announceid="&Announceid
  297. rs.open sql,conn,1,3
  298. If rs.eof and rs.bof Then
  299. Dvbbs.AddErrCode(32)
  300. Dvbbs.ShowErr()
  301. Else
  302. If rs(4)>0 Then
  303. Response.redirect "showerr.asp?ErrCodes=<Br>"+"<li>????????????????????????&action=OtherErr"
  304. Exit Sub
  305. End If
  306. strContent=Dvbbs.HTMLEncode(rs(0))
  307. PostBuyUser=Trim(rs(1))
  308. 'Response.Write PostBuyUser
  309. 'Response.End
  310. Set re=new RegExp
  311. re.IgnoreCase =true
  312. re.Global=True
  313. re.Pattern="(^.*)(\[UseMoney=*([0-9]*)\])(.*)(\[\/UseMoney\])(.*)"
  314. po=re.Replace(strContent,"$3")
  315. If IsNumeric(po) Then
  316. ii=int(po)
  317. Else
  318. ii=0
  319. End If
  320. Set re=Nothing
  321. If Dvbbs.membername=rs(2) Then
  322. response.write "<script>alert('??????????????????');</script>"
  323. ElseIf usermoney >ii then
  324. If (not isnull(PostBuyUser)) Or PostBuyUser<>"" Then
  325. If InStr("|"&PostBuyUser&"|","|"&Dvbbs.membername&"|")>0 Then
  326. response.write "<script>alert('????????????');</script>"
  327. Else
  328. Dvbbs.Execute("update [Dv_user] set userWealth=userWealth-"&ii&" where userid="&Dvbbs.userid)
  329. Dvbbs.Execute("update [Dv_user] set userWealth=userWealth+"&ii&" where userid="&rs(3))
  330. If IsNull(Rs(1)) or Rs(1)="" Then
  331. rs(1)=Dvbbs.membername
  332. Else
  333. rs(1)=rs(1) & "|" & Dvbbs.membername
  334. End If
  335. Rs.Update
  336. response.write "<script>alert('?????');</script>"
  337. End If
  338. Else
  339. Dvbbs.Execute("update [Dv_user] set userWealth=userWealth-"&ii&" where userid="&Dvbbs.userid)
  340. Dvbbs.Execute("update [Dv_user] set userWealth=userWealth+"&ii&" where userid="&rs(3))
  341. rs(1)=Dvbbs.membername
  342. Rs.Update
  343. response.write "<script>alert('?????');</script>"
  344. End If
  345. Else
  346. response.write "<script>alert('???????');</script>"
  347. End If
  348. End If
  349. Rs.Close
  350. Set Rs=Nothing
  351. Response.Write "<script language=""javascript"">"
  352. Response.Write "parent.location.href='"
  353. Response.Write "dispbbs.asp?boardid="&request("boardid")&"&ID="&RootID_a&"&replyID="&AnnounceID&"&star=1&skin=1#"&AnnounceID
  354. Response.Write "';"
  355. Response.Write "</script>"
  356. End Sub
  357. Sub view()
  358. Dim PostBuyUser
  359. sql="select PostBuyUser from "&PostTable&" where Announceid="&Announceid
  360. Set rs=Dvbbs.Execute(sql)
  361. PostBuyUser=Trim(rs(0))
  362. Response.Write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1>"
  363. Response.Write "<TBODY><TR>"
  364. Response.Write "<Th height=24 colspan=1>?????????</Th>"
  365. Response.Write "</TR>"
  366. Response.Write "<tr><TD class=tablebody2>"
  367. If (not isnull(PostBuyUser)) Or PostBuyUser<>"" Then
  368. PostBuyUser=Replace(PostBuyUser,"|","<li>")
  369. Response.Write "<li>"&PostBuyUser
  370. Else
  371. Response.Write "<br><li>???????"
  372. End If
  373. Response.Write "</td></tr>"
  374. Response.Write "</table>"
  375. Set rs=Nothing
  376. End Sub
  377. Function checktable(Table)
  378. Table=Right(Trim(Table),2)
  379. If Not IsNumeric(table) Then Table=Right(Trim(Table),1)
  380. If Not IsNumeric(table) Then Dvbbs.AddErrCode(35)
  381. checktable="Dv_bbs"&table
  382. End Function
  383. %>