PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Wap/Plus/DownLoad.asp

https://github.com/joechen2010/health
ASP | 313 lines | 292 code | 15 blank | 6 comment | 0 complexity | 6104c3b8d9613d258cee7f6cbd27ed3c MD5 | raw file
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
  2. <%
  3. Option Explicit
  4. Response.Buffer=true
  5. %>
  6. <%Response.ContentType="text/vnd.wap.wml; charset=utf-8" %><?xml version="1.0" encoding="utf-8"?>
  7. <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
  8. <!--#include file="../Conn.asp"-->
  9. <!--#include file="../KS_Cls/Kesion.CommonCls.asp"-->
  10. <!--#include file="../KS_Cls/Kesion.Label.CommonCls.asp"-->
  11. <%
  12. Dim KSCls
  13. Set KSCls = New DownLoad
  14. KSCls.Kesion()
  15. Set KSCls = Nothing
  16. %>
  17. <%
  18. Class DownLoad
  19. Private KS,KSUser, KSRFObj
  20. Private FileContent,RSObj,SqlStr,ShowInfoStr,InfoPurview,ReadPoint,ChargeType,PitchTime,ReadTimes,DownUrl
  21. Private DomainStr,ID,ChannelID,ClassPurview,UserLoginTF,PayTF,DownUrlTF,TitleStr,Rs,SQL,FoundErr,SoftName,DownID,Hits
  22. Private Sub Class_Initialize()
  23. Set KS=New PublicCls
  24. Set KSUser=New UserCls
  25. Set KSRFObj = New Refresh
  26. End Sub
  27. Private Sub Class_Terminate()
  28. Call CloseConn()
  29. Set KS=Nothing:Set KSUser=Nothing
  30. End Sub
  31. Public Sub Kesion()
  32. DownUrlTF=false
  33. DomainStr=KS.GetDomain
  34. UserLoginTF=Cbool(KSUser.UserLoginChecked)
  35. ID = KS.ChkClng(KS.S("ID"))
  36. ChannelID = KS.ChkClng(KS.S("ChannelID"))
  37. DownID = KS.ChkClng(KS.S("DownID"))
  38. PayTF=KS.S("PayTF")
  39. If ID = 0 Then
  40. TitleStr="下载错误提示"
  41. ShowInfoStr = ShowInfoStr & "错误的系统参数!请输入正确的" & KS.C_S(ChannelID,3) & "ID<br/>"
  42. FoundErr=True
  43. End If
  44. If DownID = 0 Then
  45. TitleStr="下载错误提示"
  46. ShowInfoStr = ShowInfoStr & "错误的系统参数!请输入正确的" & KS.C_S(ChannelID,3) & "ID<br/>"
  47. FoundErr=True
  48. End If
  49. If FoundErr Then Call ShowInfo :Exit Sub
  50. SqlStr= "Select a.*,ClassPurview From " & KS.C_S(ChannelID,2) & " a inner join ks_class b on a.tid=b.id Where a.ID=" & ID
  51. Set RSObj=Server.CreateObject("Adodb.Recordset")
  52. RSObj.Open SqlStr,Conn,1,3
  53. IF RSObj.Eof And RSObj.Bof Then
  54. TitleStr="下载错误提示"
  55. ShowInfoStr = ShowInfoStr & "找不到你要下载的" & KS.C_S(ChannelID,3) & "!<br/>"
  56. FoundErr=True:Call ShowInfo :Exit Sub
  57. End IF
  58. ID=RSObj("ID")
  59. InfoPurview=Cint(RSObj("InfoPurview"))
  60. ReadPoint=Cint(RSObj("ReadPoint"))
  61. ChargeType=Cint(RSObj("ChargeType"))
  62. PitchTime=Cint(RSObj("PitchTime"))
  63. ReadTimes=Cint(RSObj("ReadTimes"))
  64. ClassPurview=Cint(RSObj("ClassPurview"))
  65. If InfoPurview=2 or ReadPoint>0 Then
  66. IF UserLoginTF=false Then
  67. Call GetNoLoginInfo
  68. Else
  69. IF KS.FoundInArr(RSObj("ArrGroupID"),KSUser.GroupID,",")=false and readpoint=0 Then
  70. ShowInfoStr = ShowInfoStr & "对不起,你没有下载本" & KS.C_S(ChannelID,3) & "的权限!<br/>"
  71. FoundErr=True:Call ShowInfo :Exit Sub
  72. Else
  73. Call PayPointProcess()
  74. End If
  75. End If
  76. ElseIF InfoPurview=0 And (ClassPurview=1 Or ClassPurview=2) Then
  77. If UserLoginTF=false Then
  78. Call GetNoLoginInfo
  79. Else
  80. '============继承栏目收费设置时,读取栏目收费配置===========
  81. ReadPoint=Cint(RSObj("DefaultReadPoint"))
  82. ChargeType=Cint(RSObj("DefaultChargeType"))
  83. PitchTime=Cint(RSObj("DefaultPitchTime"))
  84. ReadTimes=Cint(RSObj("DefaultReadTimes"))
  85. '============================================================
  86. If ClassPurview=2 Then
  87. IF KS.FoundInArr(RSObj("ArrGroupID"),KSUser.GroupID,",")=false Then
  88. ShowInfoStr="对不起,你所在的用户组没有下载的权限!<br/>"
  89. Else
  90. Call PayPointProcess()
  91. End If
  92. Else
  93. Call PayPointProcess()
  94. End If
  95. End If
  96. Else
  97. Call PayPointProcess()
  98. End If
  99. If DownUrlTF=true Then
  100. RSObj("Hits") = RSObj("Hits") + 1
  101. If DateDiff("D", RSObj("LastHitsTime"), Now()) <= 0 Then
  102. RSObj("HitsByDay") = RSObj("HitsByDay") + 1
  103. Else
  104. RSObj("HitsByDay") = 1
  105. End If
  106. If DateDiff("ww", RSObj("LastHitsTime"), Now()) <= 0 Then
  107. RSObj("HitsByWeek") = RSObj("HitsByWeek") + 1
  108. Else
  109. RSObj("HitsByWeek") = 1
  110. End If
  111. If DateDiff("m", RSObj("LastHitsTime"), Now()) <= 0 Then
  112. RSObj("HitsByMonth") = RSObj("HitsByMonth") + 1
  113. Else
  114. RSObj("HitsByMonth") = 1
  115. End If
  116. RSObj("LastHitsTime") = Now()
  117. RSObj.Update
  118. On Error Resume Next
  119. Dim DownArr:DownArr=Split(Split(RSObj("DownUrls"),"|||")(DownID-1),"|")
  120. If Err Then
  121. TitleStr="下载错误提示"
  122. ShowInfoStr = ShowInfoStr & "非法访问!<br/>"
  123. Call ShowInfo :Exit Sub
  124. End If
  125. If DownArr(0)="0" Then
  126. DownUrl=replace(DownArr(2),"&","&amp;")
  127. If lcase(left(DownUrl,4))<>"http" Then DownUrl=KS.Setting(2) & KS.Setting(3) & DownUrl
  128. Response.Write "<wml>"
  129. Response.Write "<head>"
  130. Response.Write "<meta http-equiv=""Cache-Control"" content=""no-Cache""/>"
  131. Response.Write "<meta http-equiv=""Cache-Control"" content=""max-age=0""/>"
  132. Response.Write "</head>"
  133. Response.Write "<card id=""main"" title=""" & TitleStr & """ ontimer="""& DownUrl&"""><timer value=""3""/>"
  134. Response.Write "<p align=""center"">"
  135. Response.Write "请稍候正在下载...<br/>"
  136. Response.Write "如果你的手机没能下载,请点击<a href="""&DownUrl&""">这里</a>下载<br/>"
  137. Response.Write "<anchor>点击返回<go href=""../Show.asp?ID="&ID&"&amp;ChannelID="&ChannelID&"&amp;"&KS.WapValue&""" method=""post""></go></anchor><br/>"
  138. Response.Write "<anchor>返回首页<go href="""&KS.GetGoBackIndex&""" method=""post""></go></anchor><br/>"
  139. Response.Write "</p>"
  140. Response.Write "</card>"
  141. Response.Write "</wml>"
  142. Exit Sub
  143. Else
  144. Set Rs = Server.CreateObject("ADODB.Recordset")
  145. SQL = "SELECT top 1 AllDownHits,DayDownHits,HitsTime FROM KS_DownSer WHERE downid="& KS.ChkClng(KS.S("Sid"))
  146. Rs.Open SQL,Conn,1,3
  147. If Not(Rs.BOF And Rs.EOF) Then
  148. hits = CLng(Rs("AllDownHits"))+1
  149. Rs("AllDownHits").Value = hits
  150. If DateDiff("D", Rs("HitsTime"), Now()) <= 0 Then
  151. Rs("DayDownHits").Value = Rs("DayDownHits").Value + 1
  152. Else
  153. Rs("DayDownHits").Value = 1
  154. Rs("HitsTime").Value = Now()
  155. End If
  156. Rs.Update
  157. End If
  158. Rs.Close:Set Rs = Nothing
  159. Dim RS_S:Set RS_S=Server.CreateObject("ADODB.RECORDSET")
  160. RS_S.Open "Select IsOuter,DownloadPath,UnionID From KS_DownSer Where DownID=" & KS.ChkClng(KS.S("Sid")),Conn,1,1
  161. If Not RS_S.Eof Then
  162. Response.Write "<wml>"
  163. Response.Write "<head>"
  164. Response.Write "<meta http-equiv=""Cache-Control"" content=""no-Cache""/>"
  165. Response.Write "<meta http-equiv=""Cache-Control"" content=""max-age=0""/>"
  166. Response.Write "</head>"
  167. Select Case RS_S(0)
  168. Case 0
  169. Response.Write "<card id=""main"" title=""" & TitleStr & """ ontimer="""&RS_S(1) & DownArr(2)&"""><timer value=""3""/>"
  170. Response.Write "<p align=""center"">"
  171. Response.Write "请稍候正在下载...<br/>"
  172. Response.Write "如果你的手机没能下载,请点击<a href="""&DownArr(2)&""">这里</a>下载<br/>"
  173. Case 2
  174. Response.Write "<card id=""main"" title=""操作提示"">"
  175. Response.Write "<p align=""center"">"
  176. Response.Write "WEB迅雷专用下载地址,请返回选择其它下载地址...<br/>"
  177. Case 3
  178. Response.Write "<card id=""main"" title=""操作提示"">"
  179. Response.Write "<p align=""center"">"
  180. Response.Write "FLASHGET(快车)专用下载地址,请返回选择其它下载地址...<br/>"
  181. End Select
  182. Response.Write "<anchor>点击返回<go href=""Show.asp?ID="&ID&"&amp;ChannelID="&ChannelID&"&amp;"&KS.WapValue&""" method=""post""></go></anchor><br/>"
  183. Response.Write "<anchor>返回首页<go href="""&KS.GetGoBackIndex&""" method=""post""></go></anchor><br/>"
  184. Response.Write "</p>"
  185. Response.Write "</card>"
  186. Response.Write "</wml>"
  187. Exit Sub
  188. End If
  189. RS_S.Close:Set RS_S=Nothing
  190. End If
  191. Else
  192. TitleStr="操作提示"
  193. End If
  194. Call ShowInfo()
  195. RSObj.Close:Set RSObj=Nothing
  196. End Sub
  197. '收费扣点处理过程
  198. Sub PayPointProcess()
  199. If Cint(ReadPoint)>0 or InfoPurview=2 or (InfoPurview=0 And (ClassPurview=1 Or ClassPurview=2)) Then
  200. IF UserLoginTF=false Then Call GetNoLoginInfo :Exit Sub
  201. Dim UserChargeType:UserChargeType=KSUser.ChargeType
  202. If UserChargeType=1 Then
  203. Select Case ChargeType
  204. Case 0:Call CheckPayTF("1=1")
  205. Case 1
  206. If DataBaseType=1 Then
  207. Call CheckPayTF("datediff(hour,AddDate," & SqlNowString & ")<" & PitchTime)
  208. Else
  209. Call CheckPayTF("datediff('h',AddDate," & SqlNowString & ")<" & PitchTime)
  210. End If
  211. Case 2:Call CheckPayTF("Times<" & ReadTimes)
  212. Case 3
  213. If DataBaseType=1 Then
  214. Call CheckPayTF("datediff(hour,AddDate," & SqlNowString & ")<" & PitchTime & " or Times<" & ReadTimes)
  215. Else
  216. Call CheckPayTF("datediff('h',AddDate," & SqlNowString & ")<" & PitchTime & " or Times<" & ReadTimes)
  217. End If
  218. Case 4
  219. If DataBaseType=1 Then
  220. Call CheckPayTF("datediff(hour,AddDate," & SqlNowString & ")<" & PitchTime & " and Times<" & ReadTimes)
  221. Else
  222. Call CheckPayTF("datediff('h',AddDate," & SqlNowString & ")<" & PitchTime & " and Times<" & ReadTimes)
  223. End If
  224. Case 5:Call PayConfirm()
  225. End Select
  226. Elseif UserChargeType=2 Then
  227. If KSUser.GetEdays <=0 Then
  228. ShowInfoStr="对不起,你的账户已过期" & KSUser.GetEdays & "天,此" & KS.C_S(ChannelID,3) & "需要在有效期内才可以下载,请及时与我们联系!<br/>"
  229. Else
  230. Call GetContent()
  231. End If
  232. Else
  233. Call GetContent()
  234. End If
  235. Else
  236. Call GetContent()
  237. End IF
  238. End Sub
  239. '检查是否过期,如果过期要重复扣点券
  240. '返回值 过期返回 true,未过期返回false
  241. Sub CheckPayTF(Param)
  242. Dim SqlStr:SqlStr="Select top 1 Times From KS_LogPoint Where ChannelID=" & ChannelID & " And InfoID=" & ID & " And InOrOutFlag=2 and UserName='" & KSUser.UserName & "' And (" & Param & ") Order By ID"
  243. Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
  244. RS.Open SqlStr,conn,1,3
  245. IF RS.Eof And RS.Bof Then
  246. Call PayConfirm()
  247. Else
  248. RS.Movelast
  249. RS(0)=RS(0)+1
  250. RS.Update
  251. Call GetContent()
  252. End IF
  253. RS.Close:Set RS=nothing
  254. End Sub
  255. Sub PayConfirm()
  256. If UserLoginTF=false Then Call GetNoLoginInfo():Exit Sub
  257. If ReadPoint=0 Then GetContent():Exit Sub
  258. If Cint(KSUser.Point)<ReadPoint Then
  259. ShowInfoStr="对不起,你的可用" & KS.Setting(45) & "不足!下载本" & KS.C_S(ChannelID,3) & "需要" & ReadPoint & "" & KS.Setting(46) & KS.Setting(45) &",你还有" & KSUser.Point & "" & KS.Setting(46) & KS.Setting(45) & ",请及时与我们联系!<br/>"
  260. Else
  261. If PayTF="yes" Then
  262. IF Cbool(KS.PointInOrOut(ChannelID,RSObj("ID"),KSUser.UserName,2,ReadPoint,"系统","下载收费" & KS.C_S(ChannelID,3) & ":<br>" & RSObj("Title")))=True Then
  263. '支付投稿者提成
  264. Dim PayPoint:PayPoint=(ReadPoint*KS.C_C(RSObj("Tid"),11))/100
  265. If PayPoint>0 Then
  266. Call KS.PointInOrOut(ChannelID,RSObj("ID"),RSObj("Inputer"),1,PayPoint,"系统",KS.C_S(ChannelID,3) & "“" & RSObj("Title") & "”的提成")
  267. End If
  268. Call GetContent()
  269. End If
  270. Else
  271. ShowInfoStr="下载本软件需要消耗" & ReadPoint & "" & KS.Setting(46) & KS.Setting(45) &",你目前尚有" & KSUser.Point & "" & KS.Setting(46) & KS.Setting(45) &"可用,下载本" & KS.C_S(ChannelID,3) & "后,您将剩下" & KSUser.Point-ReadPoint & "" & KS.Setting(46) & KS.Setting(45) &"<br/>你确实愿意花" & ReadPoint & "" & KS.Setting(46) & KS.Setting(45) & "来下载本" & KS.C_S(ChannelID,3) & "吗?<br/><a href=""?ID=" & ID & "&PayTF=yes&DownID=" & DownID & """>我愿意</a> <a href=""" &DomainStr & """>我不愿意</a><br/>"
  272. End If
  273. End If
  274. End Sub
  275. Sub GetNoLoginInfo()
  276. ShowInfoStr="对不起,你还没有登录,本" & KS.C_S(ChannelID,3) & "至少要求本站的注册会员才可下载!<br/>如果你还没有注册,请<a href=""" & DomainStr & "User/Reg/"">点此注册</a>吧!<br/>如果您已是本站注册会员,赶紧<a href=""" & domainstr & "User/Login/"">点此登录</a>吧!<br/>"
  277. End Sub
  278. Sub GetContent()
  279. TitleStr=RSObj("Title")
  280. DownUrlTF=True
  281. End Sub
  282. Function ShowInfo()
  283. Response.Write "<wml>" &vbcrlf
  284. Response.Write "<head>" &vbcrlf
  285. Response.Write "<meta http-equiv=""Cache-Control"" content=""no-Cache""/>" &vbcrlf
  286. Response.Write "<meta http-equiv=""Cache-Control"" content=""max-age=0""/>" &vbcrlf
  287. Response.Write "</head>" &vbcrlf
  288. Response.Write "<card id=""main"" title=""" & TitleStr & """>" &vbcrlf
  289. Response.Write "<p align=""center"">" &vbcrlf
  290. Response.Write ""&ShowInfoStr&"" &vbcrlf
  291. Response.Write "<anchor>点击返回<go href=""Show.asp?ID="&ID&"&amp;ChannelID="&ChannelID&"&amp;"&KS.WapValue&""" method=""post""></go></anchor><br/>" &vbcrlf
  292. Response.Write "<anchor>返回首页<go href="""&KS.GetGoBackIndex&""" method=""post""></go></anchor><br/>" &vbcrlf
  293. Response.Write "</p>" &vbcrlf
  294. Response.Write "</card>" &vbcrlf
  295. Response.Write "</wml>"
  296. End Function
  297. End Class
  298. %>