<!--#include file="{nextpath}fy_inc/fy.User.asp"-->
<%
		Dim ACTCLS,ModeID
		Dim Url,urlarr,ACT_L,UserHS,ACT_Lable,PerPageNumber,TypeContent,UserID,PayTF,classid,Type_file_Content,Purview
		Dim CurrPage,ID,InfoPurview,ReadPoint,ClassPurview,ClassReadPoint,UserLoginTF,ChargeType,PitchTime,ReadTimes
  	  Set ACT_L = New ACT_Code
	  Set UserHS = New ACT_User
 		     Dim  SqlStr,TemplateContent,Rs,sqlstrs
		     UserLoginTF=Cbool(UserHS.UserLoginChecked)
   			 ID = rsql(fycms.s("id"))
 			 CurrPage=ChkNumeric(fycms.s("page"))
			 ModeID={modeid}
 			 If ModeID=0 Then ModeID=1
   			 If CurrPage<=0 Then CurrPage=CurrPage+1
 			 If IsNumeric(ID)=True Then 
				If Len(ID)<9 Then 
					sqlstrs=" id="&ID
				Else 
					sqlstrs=" classid="&ID

				End If 
 			 Else 
 					sqlstrs=" pinyin='"&ID&"'"
			 End If
 			 Set Rs=fycms.actexe("Select * From "&fycms.ACT_C(ModeID,2)&" where " & sqlstrs)
			 If Rs.Eof And Rs.Bof Then
				Call fycms.Alert("Ҫ鿴ɾǷע!!",fycms.Domain):Response.End
			 ElseIf Rs("actlink") = 1 Then
				 Response.Redirect Rs("FileName")
			End If
 			 Type_file_Content=fycms.Htmljapan(getcontentxml(modeid,id,rs("addtime")))
 			 InfoPurview = Cint(rs("infopurview"))
			 ReadPoint   = Cint(rs("readpoint"))
			 ChargeType  = Cint(rs("ChargeType"))
			 
			 PitchTime   = Cint(rs("pitchtime"))
			 ReadTimes   = Cint(rs("readtimes"))
			 UserID   = ChkNumeric(rs("userid"))
			 classid   = rs("classid")
			ClassPurview= Cint(fycms.ACT_L(rs("classid"),19))
			ClassReadPoint= Cint(fycms.ACT_L(rs("classid"),20))
 			
			Dim ClassChargeType,ClassPitchTime,ClassReadTimes
			
 			Select Case InfoPurview
				
				Case "0"
					Call checkclassinfo()
				Case "1"
					IF UserLoginTF=false Then Purview=True:Call GetNoLoginInfo()
				Case "2"
   					If  fycms.FoundInArr(rs("arrGroupID"),Trim(UserHS.GroupID),",")=False  Then 
						  die("Բڵûûв鿴Ȩ1!")
					 Else
						  Call PayPointProcess()
					End If 

			End Select 
 		    If  ReadPoint>0 Then Call PayPointProcess()
 
		Sub checkclassinfo()
 		 IF  (ClassPurview=1 or ClassPurview=2 Or ClassReadPoint>0) Then 
 		 If UserLoginTF=false Then
			    Purview=true
			    Call GetNoLoginInfo
			  Else     
 			     classReadPoint  = Cint(fycms.ACT_L(classid,20))
				 classChargeType = Cint(fycms.ACT_L(classid,21))
				 classPitchTime  = Cint(fycms.ACT_L(classid,22))
				 classReadTimes  = Cint(fycms.ACT_L(classid,23))
 				 If ClassPurview=2 Then
				
 					If fycms.FoundInArr(fycms.ACT_L(classid,6),Trim(UserHS.GroupID),",")=false Then
						  die("Բڵûûв鿴Ȩ!")
					 Else
						Call PayPointProcess()
					 End If
				 Else    
 					 Call PayPointProcess()
 				End If
			  End If
		End If 


		End Sub 



	   'շѿ۵㴦
	   Sub PayPointProcess()
  	       Dim UserChargeType:UserChargeType=UserHS.ChargeType
		
	        If (Cint(ReadPoint)>0 or InfoPurview=2 or (InfoPurview=0 And (ClassPurview=1 Or ClassPurview=2))) and UserHS.UserID<>UserID Then
 					     If UserChargeType=1 Then
							 Select Case ChargeType
							  Case 0:Call CheckPayTF("1=1")
							  Case 1:Call CheckPayTF("datediff('h',AddDate," & NowString & ")<" & PitchTime)
							  Case 2:Call CheckPayTF("Times<" & ReadTimes)
							  Case 3:Call CheckPayTF("datediff('h',AddDate," & NowString & ")<" & PitchTime & " or Times<" & ReadTimes)
							  Case 4:Call CheckPayTF("datediff('h',AddDate," & NowString & ")<" & PitchTime & " and Times<" & ReadTimes)
							  Case 5:Call PayConfirm()
							  End Select
						Elseif UserChargeType=2 Then
				          If UserHS.GetEdays <=0 Then
						    Purview=true
						     typeContent="<div align=center>Բ˻ѹ <font color=red>" & UserHS.GetEdays & "</font> ,ҪЧڲſԲ鿴뼰ʱϵ</div>"
 						  End If
 						end if
 					   End IF
	   End Sub







 	   Sub GetNoLoginInfo()
		   TypeContent="<div align=center>Բûе¼ҪվעԱſɲ鿴!</div><div align=center>ûעᣬ<a href=""" & fycms.actsys & "User/Reg.asp""><font color=red>ע</font></a>!</div><div align=center>ǱվעԱϽ<a href=""" & fycms.actsys & "User/login.asp""><font color=red>˵¼</font></a>ɣ</div>"
	   End Sub

	   'ǷڣҪظ۵ȯ
	   'ֵ ڷ true,δڷfalse
	   Sub CheckPayTF(Param)
	    
	    Dim SqlStr:SqlStr="Select top 1 Times From Point_Log_fy Where ModeID=" & ModeID & " And InfoID=" & ID & " And PointFlag=2 and UserID=" & UserHS.UserID & " And (" & Param & ") Order By ID"
    	    Dim RS:Set RS=Server.CreateObject("ADODB.RECORDSET")
		RS.Open SqlStr,conn,1,3


		IF RS.Eof And RS.Bof Then
			Call PayConfirm()	
		Else
		       RS.Movelast
			   RS(0)=RS(0)+1
			   RS.Update
		End IF
		 RS.Close:Set RS=nothing
	   End Sub
	   

	   Sub PayConfirm()
	   Purview=true
	     If UserLoginTF=false Then Call GetNoLoginInfo():Exit Sub
		 If ReadPoint<=0 Then Exit Sub
 			 If Cint(UserHS.Point)<ReadPoint Then
 					 TypeContent="<div style=""text-align:center"">ԲĿ" & fycms.fycms_Sys(24) & "!ĶҪ <span style=""color:red"">" & ReadPoint & "</font> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) &",㻹 <span style=""color:green"">" & UserHS.Point & "</span> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) & "</div>,뼰ʱϵ" 
			 Else 
 					If ChkNumeric(fycms.s("pay"))="1" Then
						Call fycms.PointInOrOut(ModeID,ID,UserHS.UserID,2,ReadPoint,"ϵͳ","Ķĵշ",0)
 						 Dim PayPoint:PayPoint=(ReadPoint*fycms.ACT_L(classid,24))/100
						 If PayPoint>0 Then
						 
						Call fycms.PointInOrOut(ModeID,ID,UserID,1,PayPoint,"ϵͳ","Ķĵշ",0)

 						 End If
 						 
					Else
						TypeContent="<div align=center>ĶҪ <font color=red>" & ReadPoint & "</font> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) &",Ŀǰ <font color=green>" & UserHS.Point & "</font> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) &",Ķĺʣ <font color=blue>" & UserHS.Point-ReadPoint & "</font> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) &"</div><div align=center>ȷʵԸ⻨ <font color=red>" & ReadPoint & "</font> " & fycms.fycms_Sys(25) & fycms.fycms_Sys(24) & "Ķ?</div><div>&nbsp;</div><div align=center><a href=""?id="& ID & "&page=" & CurrPage &"&pay=1"">Ը</a>    <a href=""" &fycms.actsys & """>ҲԸ</a></div>"
					End If
			 End If
	   End Sub

 


			 If rs("isAccept")<>0 Then
				 If UserHS.UserName<>rs("ArticleInput") Then
				   Call fycms.Alert("Բ𣬸»ûͨ!",fycms.Domain)
				   Response.End
			     End If 
			 End If
			Application(fycmsN & "fycms_TCJ_Type") = "ARTICLECONTENT"
			Application(fycmsN & "classid") = rs("classid")
			Application(fycmsN & "modeid")=ModeID
			Application(fycmsN & "id")=rs("id")
			 id = rs("id")
			 classid=rs("classid")
			 TemplateContent = LoadTemplate(rs("templateurl"))
	 
			Dim ContentArr
			If fycms.ACT_C(modeid,18)="1" Then
				 ContentArr=Split(getcontentxml(modeid,rs("id"),rs("addtime")),"[NextPage]")
			Else 
				If rs("content")<>"" Then 
 					ContentArr = Split(rs("content"),"[NextPage]")
				Else 
 					ContentArr = Split("&nbsp;","[NextPage]")
				End If 
			End If 
 			 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="{rewriteurl}&(CurrPage + 1) & """>һҳ</a><br>"
					   ElseIf CurrPage = TotalPage Then
						 ArticlePageStr = "<p><div Class=""PageCss"" align=center><a href="{rewriteurl}&(CurrPage - 1) & """>һҳ</a><br>"
					   Else
						ArticlePageStr = "<p><div Class=""PageCss"" align=center><a href="{rewriteurl}&(CurrPage - 1) & """>һҳ</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="{rewriteurl}&(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="{rewriteurl} & 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
					If fycms.ACT_C(modeid,18)="1" Then
						  ArticlePageStr = Type_file_Content
					Else 
						  ArticlePageStr = rs("content")
					End If 
				 End If
			 If Purview=True Then ArticlePageStr=typecontent
   			 Dim newt:Set newt=New Cls_Template
			 Dim userlogin:userlogin=CBool(UserHS.UserLoginChecked)
			 If userlogin=True Then 
				TemplateContent=rep(TemplateContent,"{fy:userlogin}","1=1")
			 Else 
				TemplateContent=rep(TemplateContent,"{fy:userlogin}","1=0")
			 End If 
 			
  
			 If  fycms.ACT_C(ModeID,13)=0 Then 
				TemplateContent=rep(TemplateContent,"{fy:Commentcode}","1=1")
			 Else 
				TemplateContent=rep(TemplateContent,"{fy:Commentcode}","1=0")
			 End If 
			  
			  TemplateContent=newt.GetContent(ModeID,rs,TemplateContent,ArticlePageStr)'Զ庯
			If userlogin=True Then 
				Dim usersqlstr,usrs
				usersqlstr="select f.*,u.* from User_fy F inner join "&fycms.ACT_U(UserHS.UModeID,2)&" U on F.userid=U.uid where u.uid="&userhs.userid&"   order by u.uid desc"
				Set usrs=fycms.actexe(usersqlstr)
				If  Not   usrs.eof Then  TemplateContent = newt.GetUserInfo(TemplateContent,usrs)
			Else 
				TemplateContent = newt.GetnoUserInfo(TemplateContent,"")
			End If 	 
			  
			  
			  echo TemplateContent&vbcrlf & "<!-- Created Page at " & Now() & " ,By fycms.com ,fycms Content Management System(fycms)  -->" & vbCrLf
 		Call CloseConn
  
  %>