<%@ Language="VBSCRIPT" codepage="936" %>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../KS_Cls/KS.PublicCls.asp"-->
<!--#include file="../KS_Cls/KS.RCls.asp"-->
<!--#include file="config.asp"-->
<%
response.cachecontrol="no-cache"
response.addHeader "pragma","no-cache"
response.expires=-1
response.expiresAbsolute=now-1
Response.CharSet="gb2312"

Dim KS:Set KS=New PublicCls
Dim KMRFObj:Set KMRFObj= New RefreshFunction

dim CurrPage,RS,SqlStr,iCurPage,ipresize,icount,ipagecount

CurrPage=KS.ChkClng(KS.S("curpage"))
If CurrPage<=0 Then CurrPage=CurrPage+1

Dim L_P,PageParamArr,PerPageNumber
Dim LabelID:LabelID=KS.S("LabelID")   '标签ID
Dim ClassID:ClassID=KS.S("ClassID")   '栏目ID
Set RS=Server.CreateObject("ADODB.RECORDSET")
RS.Open "Select LabelContent From KS_Label Where ID='" & LabelID & "'",Conn,1,1
If RS.Eof And RS.Bof Then
Else
 L_P=Replace(Replace(Replace(Replace(RS(0),")}",""),"{$",""),"(",","),"""","")
End If
RS.Close
If L_P="" Then Response.End
PageParamArr=Split(L_P,",")

 
 PerPageNumber=cint(PageParamArr(1))        '每页条数
 Dim Param,Asort,CurrPageStr
  If KS.S("refreshtype") = "Special" Then     '刷新专题
		If DataBaseType=1 Then
		  Param = " WHERE patindex('" & KS.S("SpecialID") & "',specialid)>0 AND Verific=1 And DelTF=0"
		Else
		 Param = " WHERE instr(specialid,'" & KS.S("SpecialID") & "')>0 AND Verific=1 And DelTF=0"
		End If
 Else
	If CBool(PageParamArr(2)) = True Then
			Param = " WHERE Tid in (" & KS.GetFolderTid(ClassID) & ")  AND Verific=1 AND DelTF=0"
	Else
			Param = " Where Tid='" & ClassID & "' AND Verific=1 AND DelTF=0"
	End If
 End If
 If Lcase(Left(Trim(PageParamArr(13)),2))<>"id" Then  
	 ASort = " order by IsTop Desc," & PageParamArr(13) & ",ID Desc"
 Else
	 Asort = " order by IsTop Desc," & PageParamArr(13)
End IF
Dim PageNum,TempStr,totalput,TempIDArrStr
	RS.Open "SELECT ID FROM " & KS.C_S(ChannelID,2) & Param & ASort, Conn, 1, 1
	IF Not RS.Eof Then
	 TotalPut = Conn.Execute("select Count(id) from " & KS.C_S(ChannelID,2) & Param)(0)  '总记录数
	 if (TotalPut mod PerPageNumber)=0 then
			PageNum = TotalPut \ PerPageNumber
	 else
			PageNum = TotalPut \ PerPageNumber + 1
	 end if
	 If CurrPage = 1 Then
			TempIDArrStr=GetTempIDArrStr(RS)
	 Else
	   If (CurrPage - 1) * PerPageNumber < totalPut Then
				RS.Move (CurrPage - 1) * PerPageNumber
				TempIDArrStr=GetTempIDArrStr(RS)
		Else
				CurrPage = 1
				TempIDArrStr=GetTempIDArrStr(RS)
		End If
	 End If
		SqlStr = "SELECT ID,Title,Tid,Fname,AddDate,PhotoUrl,Discount,Price_Original,Price,Price_Market,Price_Member,ProID FROM KS_Product Where ID in (" & TempIDArrStr & ") AND Verific=1 AND DelTF=0 order by IsTop Desc," & PageParamArr(13)
	Dim P_T:P_T=PageParamArr(21)
	If P_T>2 Then P_T=P_T-2			
	 TempStr =  KMRFObj.KS_Pro_L(SqlStr, PageParamArr(4), PageParamArr(3), PageParamArr(11),  PageParamArr(9), PageParamArr(5),PageParamArr(6), PageParamArr(7), PageParamArr(8),KS.G_O_T_S(PageParamArr(10)), PageParamArr(12), PageParamArr(14), PageParamArr(15), PageParamArr(16),"",PageParamArr(17),PageParamArr(18),PageParamArr(19),P_T,PageParamArr(22),PageParamArr(23),PageParamArr(24),PageParamArr(25),PageParamArr(26),PageParamArr(27))
	Response.Write TempStr
	Else
	Response.Write("对不起，该栏目下没有任何" & KS.C_S(ChannelID,3)& "!")
	End If
Response.Write "{ks:page}" & TotalPut & "|" & PerPageNumber & "|" & PageNum & "|" & KS.C_S(ChannelID,4) & "|" & KS.C_S(ChannelID,3) & "|" & PageParamArr(20)
rs.close
set rs=nothing
conn.close
set conn=nothing
  
Function GetTempIDArrStr(rs)
	Dim I,K,SQL
	SQL=RS.GetRows(-1)
	For K=0 To Ubound(SQL,2)
		 GetTempIDArrStr = GetTempIDArrStr &SQL(0,K) & ","
		 I = I + 1
		  If I >= PerPageNumber Then Exit For
	Next
	GetTempIDArrStr = Left(GetTempIDArrStr, Len(GetTempIDArrStr) - 1)
End Function
%>
