<!--#include file="../inc/Conn.asp"-->
<!--#include file="../Inc/Cls.Common.asp"-->
<!--#include file="../Inc/Cls.Templates.asp"-->
<!--#include file="../Inc/Cls.Content.asp"-->
<!--#include file="Channel_Config.asp"-->
<%

   Dim ID,PrevArticle,NextArticle,ParentPath,Charge,repeatCharge,ChargeUser,IsCharge,CountOut,Title,User,ClassDir,i,LinkUrl,IsPrice

   ID=WRMPS.CheckStr(Request("ID"),1)
   If ID = "" Then Call WRMPS.ErrView("返回"&ChannelName&"首页","index.asp","<li>操作错误",0)
   Call DBConnBegin()
   '阅读收费
   If WRMPS.CheckStr(Request("Pay"),0) = "Enter" Then
     IsCharge = 0
	 Set Rs = Server.CreateObject("ADODB.Recordset")
	 Rs.Open"Select WM_Charge,WM_RepeatCharge,WM_ChargeUser,WM_Title,WM_Post From WM_Article Where WM_Passed=1 and WM_IsDeleted=0 and WM_id="&ID ,conn,1,1
	 If Not Rs.Eof Then
	   User = Rs(4)
	   Charge = Rs(0)
	   IsPrice = 0
	   If IsNUll(User) Then
	     IsPrice = 1
	   Else
	     If User <> MemName Then IsPrice = 1
	   End If
	   If IsPrice = 1 and Charge > 0 Then
	    RepeatCharge = Rs(1)
	    ChargeUser = Rs(2)
	    Title = Rs(3)
	     If WRUser.ChkLogin Then
	       If Instr(","&ChargeUser&",",","&MemName&",") = 0 Then
			 IsCharge = 1
		   Else
		     If RepeatCharge > 0 and IsEmpty(WRMPS.GetCookies("ReadPay_A_"&ID)) Then
	           IsCharge = 1
			 End If
		   End If
		 Else
		   Call WRMPS.AjaxLogin("",0,"此文章为收费内容，须会员才可阅读，请先登录或注册！")
		 End If
	  Else
         Call WRMPS.ErrView("返回"&ChannelName&"首页","index.asp","<li>操作错误",0)
	  End If
	  Rs.Close
      If IsCharge = 1 Then
         Call WRDB.SaveConsume(0,MemName,0,Int("-"&Charge),0,0,"阅读收费文章“"&Title&"”")
         If Instr(","&ChargeUser&",",","&MemName&",") = 0 Then Conn.Execute ("Update WM_Article Set WM_ChargeUser = '"&ChargeUser &","&MemName&"' Where WM_Passed=1 and WM_IsDeleted=0 and WM_id="&ID)
	     WRMPS.SCookies "ReadPay_A_"&ID,"True",0
		 Set Rs = Conn.Execute("Select WM_AddTime,WM_ClassDir From WM_Article Where WM_ID="&ID)
		 If Not Rs.Eof Then
	       Call WRMPS.ErrView("返回内容而面",WRMPS.GetShowUrl(1,1,0,ID,Rs(0),ChannelDir&Rs(1),ChannelID),"<li>支付成功，正在进入内容而面...",0)
		 End If
		 Rs.Close
		 Set Rs = Nothing
      End If
	 End If
   End If
   '转向连接和静态判断
   Set Rs = Server.CreateObject("ADODB.Recordset")
   Rs.open"Select WM_AddTime,WM_ClassDir,WM_LinkUrl,WM_Post,WM_Charge,WM_RepeatCharge,WM_ChargeUser From WM_Article Where WM_ID="&ID ,Conn,1,1
	   User = Rs(3)
	   Charge = Rs(4)
	   IsCharge = 0 ' 不收费
	   If IsNUll(User) Then
	     If Int(Mem(0)(15)) > 0 And Charge > 0 Then IsCharge = 1
	   Else
	     If User <> MemName and Int(Mem(0)(15)) > 0 And Charge > 0 Then IsCharge = 1
	   End If
	   If IsCharge = 1 Then
	    RepeatCharge = Rs(5)
	    ChargeUser = Rs(6)
	     If WRUser.ChkLogin Then
		   If WRMPS.CheckStr(Request("Page"),1) < 2 Then
	         If Instr(","&ChargeUser&",",","&MemName&",") = 0 Then
	           Call WRMPS.ErrView("","","<strong>收费提醒</strong><li>此为收费内容，阅读费用为："&Charge&" "&WR_Pay(5)&"！<li><a href="&WR_Setting(3)&ChannelDir&"/Show.asp?Pay=Enter&ID="&ID&">确认交费阅读？</a><li><a href="&WR_Setting(3)&">返回首页？</a>",0)
		      Else
		       If RepeatCharge > 0 and IsEmpty(WRMPS.GetCookies("ReadPay_A_"&ID)) Then
	             Call WRMPS.ErrView("","","<strong>收费提醒</strong><li>此为收费内容，阅读费用为："&Charge&" "&WR_Pay(5)&"！<li><a href="&WR_Setting(3)&ChannelDir&"/Show.asp?Pay=Enter&ID="&ID&">确认交费阅读？</a><li><a href="&WR_Setting(3)&">返回首页？</a>",0)
			   End If
		     End If
		   End If
		 Else
		   Call WRMPS.AjaxLogin("",0,"此文章为收费内容，须会员才可阅读，请先登录或注册！")
		 End If
		 WRMPS.DelCookies "ReadPay_A_"&ID
	   End If
	   LinkUrl = Rs(2)
	   If LinkUrl <> "" Then
	     Conn.Execute("Update WM_Article Set WM_Hit = WM_Hit+1 Where WM_ID = "&ID)
		 Response.Redirect LinkUrl
		 Response.End
	   End If
       '如果启用静态页
	   ClassDir = Rs(1)
       If Int(WRMPS.IsCreHtml(CreateHTML,"Show")) = 3 Then Response.Redirect WRMPS.GetShowUrl(1,1,0,ID,Rs(0),ChannelDir&ClassDir,ChannelID)
   Rs.Close
   Set Rs = Nothing

   Set ClsPage = New Cls_Page
   TempStr = ClsPage.PageArticleShow(ID,1,0,0)
   Set ClsPage = Nothing
   Call ClassEnd()
   Call DBConnEnd()
   Response.Write TempStr
%>
