<!--#include file="../ACT_inc/ACT.User.asp"-->
<%
Dim ACTCLS,ModeID
Set ACTCLS = New TypeArticle
ACTCLS.Execute()
Set ACTCLS = Nothing
Class TypeArticle
	Private ACT_L,UserHS,ACT_Lable,ID,CurrPage,SqlStr,TemplateContent,Rs,ChargeType,PitchTime,ReadTimes,ClassID
	Private UserLoginTF,TypeContent,InfoPurview,ReadPoint,Pay,ClassPurview
		Private Sub Class_Initialize()
		  Set ACT_L = New ACT_Code
		  Set UserHS = New ACT_User
		End Sub
		Private Sub Class_Terminate()
		 Set AcTCMS=Nothing
		 Set ACT_L=Nothing
		 Set UserHS=Nothing 
		End Sub
		Sub Execute()
			 UserLoginTF=Cbool(UserHS.UserLoginChecked)
			 ID = ACTCMS.ChkNumeric(ACTCMS.RSQL(Request.QueryString("ID")))
			 CurrPage=ACTCMS.ChkNumeric(request.QueryString("Page"))
			 ModeID=ACTCMS.ChkNumeric(request.QueryString("ModeID"))
			 If ModeID=0 Then ModeID=1
			 Pay=request("Pay")
			 If CurrPage<=0 Then CurrPage=CurrPage+1
			 If ID = 0 Or ID = "" Then Exit Sub
			 Set Rs=actcms.actexe("Select * From "&ACTCMS.ACT_C(ModeID,2)&" where ID=" & ID)
			 If Rs.Eof And Rs.Bof Then
				Call ACTCMS.Alert("您要查看的文章已删除。或是您非法传递注入参数!!",AcTCMS.ActCMSDM):Response.End
			 ElseIf Rs("ChangesLink") = 1 Then
				 Response.Redirect Rs("FileName")
			End If
			TypeContent=Rs("Content")
			If ACTCMS.ACT_L(rs("ClassID"),6)<>"" Then
				If UserHS.GroupID<>ACTCMS.ACT_L(rs("ClassID"),6) Then
					  Call ACTCMS.Alert("对不起，你所在的用户组没有查看的权限1!",AcTCMS.ActCMSDM)
				End If 
			Else 
				If rs("GroupID_ACT")<>"" And ACTCMS.FoundInArr(Rs("GroupID_ACT"),UserHS.GroupID,",")=False Then 
					  Call ACTCMS.Alert("对不起，你所在的用户组没有查看的权限!",AcTCMS.ActCMSDM)
				End If 
				If rs("Score_ACT")>0 Then 
					If  rs("Score_ACT")>UserHS.Score Then 
						TypeContent="对不起，您的帐号可用余额不足,阅读本文需要<font color=red>"&rs("Score_ACT")&"</font>点数,您还有<font color=green>"&UserHS.Score& "</font>点数请及时与我们联系！</div>" 
					Else 
						Dim SqlStr:SqlStr="Select top 1 ID From Point_Log_ACT Where ModeID="&ModeID&" And InfoID=" & ID & " And PointFlag=2 and UserName='" & UserHS.UserName & "'  Order By ID"
						Dim CheckRS:Set CheckRS=Server.CreateObject("ADODB.RECORDSET")
						CheckRS.Open SqlStr,conn,1,3
						IF CheckRS.Eof Then
							If Pay="yes" Then
								 Dim RsPoint:Set RsPoint=Server.CreateObject("ADODB.RECORDSET")
								 RsPoint.Open "Select * From Point_Log_ACT Where ID is null",Conn,1,3
								 RsPoint.AddNew
								 RsPoint("ModeID")=ModeID
								 RsPoint("InfoID")=ID
								 RsPoint("UserName")=UserHS.UserName
								 RsPoint("PointFlag")=2
								 RsPoint("User")="系统"
								 RsPoint("Descript")="阅读收费文章：<br>" &Rs("Title")
								 RsPoint("AddDate")=now
								 RsPoint("IP")=ACTCMS.getip()
								 RsPoint.Update
								 RsPoint.Close:Set RsPoint=Nothing
							Else 
								TypeContent="<b>内容简介</b>：<br>"&left(Rs("Intro"),100)&"<p><p><div align=center>阅读本文需要消耗 <font color=red>" & rs("Score_ACT") & "</font>点数,您目前尚有 <font color=green>" & UserHS.Score & " </font>点数可用,阅读本文后，您将剩下 <font color=blue>" & UserHS.Score- rs("Score_ACT") & " </font> 点数</div><div align=center>您确实愿意花 <font color=red>" & rs("Score_ACT") &"</font> 点数来阅读此文吗?</div><div>&nbsp;</div><div align=center><a href=""?ModeID="&ModeID&"&ID=" & ID & "&Pay=yes&Page=" & CurrPage &""">我愿意</a>    <a href=""" &ACTCMS.ActCMSDM & """>我不愿意</a></div>"
							End If 
						End If
				End If 
					CheckRS.Close:Set CheckRS=Nothing
				End If 
			End If 

			 If RS("isAccept")<>0 Then
				 If UserHS.UserName<>RS("ArticleInput") Then
				   Call ACTCMS.Alert("对不起，该文章还没有通过审核!",AcTCMS.ActCMSDM)
				   Response.End
			     End If 
			 End If
			Application(AcTCMSN & "ACTCMS_TCJ_Type") = "ARTICLECONTENT"
			Application(AcTCMSN & "ClassID") = Rs("ClassID")
			Application(AcTCMSN & "ModeID")=ModeID
			Application(AcTCMSN & "ID")=Rs("ID")
			 ID = Rs("ID")
			 ClassID=Rs("ClassID")
			 TemplateContent = ACT_L.LoadTemplate(Rs("TemplateUrl"))
			 TemplateContent = ACT_L.LabelReplaceAll(TemplateContent)
			 Dim ContentArr:ContentArr=Split(TypeContent,"[NextPage]")
			 Dim TotalPage,N,ArticlePageStr
			 TotalPage = Cint(UBound(ContentArr) + 1)
			   If TotalPage > 1 Then
					   If CurrPage = 1 Then
						 ArticlePageStr = "<p><div Class=""PageCss"" align=center><a href=""?ModeID=" & ModeID & "&ID=" & ID & "&Page=" &(CurrPage + 1) & """>下一页</a><br>"
					   ElseIf CurrPage = TotalPage Then
						 ArticlePageStr = "<p><div Class=""PageCss"" align=center><a href=""?ModeID=" & ModeID & "&ID=" & ID & "&Page=" &(CurrPage - 1) & """>上一页</a><br>"
					   Else
						ArticlePageStr = "<p><div Class=""PageCss"" align=center><a href=""?ID=" & ID & "&Page=" &(CurrPage - 1) & """>上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=""?ModeID=" & ModeID & "&ID=" & ID & "&Page=" &(CurrPage + 1) & """>下一页</a><br>"
					   End If
					   ArticlePageStr = ArticlePageStr & "本文共<b> " & TotalPage & " </b>页,第&nbsp;&nbsp;"
				   For N = 1 To TotalPage
						 If CurrPage = N Then
						  ArticlePageStr = ArticlePageStr & "<b Class=""PageCss"">[" & N & "]</b>&nbsp;"
						 Else
						  ArticlePageStr = ArticlePageStr & "<a Class=""PageCss"" href=""?ModeID=" & ModeID & "&ID=" & ID & "&Page=" & N & """>[" & N & "]</a>&nbsp;"
						 End If
					  If TotalPage > 8 Then
					   If N Mod 8 = 0 Then ArticlePageStr = ArticlePageStr & "<p>"
					  End If
					Next
					ArticlePageStr = ContentArr(CurrPage-1) & ArticlePageStr & "页</div></p>"
				 Else
				  ArticlePageStr = TypeContent
				 End If
			TemplateContent= ACT_L.ReplaceArticleContent(ModeID,Rs,TemplateContent,ArticlePageStr)
			 response.write TemplateContent&vbcrlf & "<!-- Created Page at " & Now() & " ,By ActCMS.Com ,ACT Content Management System(ActCMS)  -->" & vbCrLf
		End Sub

	   Sub LoginIng()
		   If UserLoginTF=false Then 
			   TypeContent="<div align=center>对不起，您还没有登录，本文至少要求本站的注册会员才可查看!</div><div align=center>如果您还没有注册，请<a href=""" & ACTCMS.ACTCMSDM & "User/Reg.asp""><font color=red>点此注册</font></a>吧!</div><div align=center>如果您已是本站注册会员，赶紧<a href=""" & ACTCMS.ACTCMSDM & "User/login.asp""><font color=red>点此登录</font></a>吧！</div>"
		  Exit Sub
		  End If 
	   End Sub

End Class 
%>