<!--#include file="../conn.asp"-->
<!--#include file="Function.asp"-->
<%
Response.ContentType="application/xml"
Response.Write("<?xml version=""1.0"" encoding=""utf-8""?>")
Response.Write("<mypop>")

Dim rs,mynote,mytp,nc,id,Ynum
Dim page,maxperpage,minid,n,idcount
nc=Trim(Request.QueryString("nc"))
id=Trim(Request.QueryString("id"))

maxperpage=25
page=clng(Request.QueryString("page"))

Dim AskD
Set AskD = Server.CreateObject("KwAsk.FunAsk")
	opendb
	set AskD.myConn =conn
	AskD.myPredb =predb
	AskD.Getsetting()
	siteinfo=AskD.siteinfo
	setting=AskD.setting

Select Case nc
   case "0"
        set rs=conn.execute("select count(askid) from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askuser="&id)
		idcount=rs(0) 
		set rs=nothing
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askuser="&id&" order by askid desc")
		else
			set rs=conn.execute("select min(askid) from (select top "&(page-1)*maxperpage&" askid from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askuser="&id&" order by askid desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid<"&minid&" and askuser="&id&" order by askid desc")
		end if
   
   case "1"
        set rs=conn.execute("select count(a.askid) from ("&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid) inner join "&predb&"ans c on c.askid=a.askid where c.ansuser="&id&"")
		idcount=rs(0) 
		set rs=nothing
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" a.askid,title,asktime,ansnum,classid,classname,a.ispass,state from ("&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid) inner join "&predb&"ans c on c.askid=a.askid where c.ansuser="&id&" order by c.ansid desc")
		else
			set rs=conn.execute("select min(askid) from (select top "&(page-1)*maxperpage&" a.askid from ("&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid) inner join "&predb&"ans c on c.askid=a.askid where c.ansuser="&id&" order by c.ansid desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" a.askid,title,asktime,ansnum,classid,classname,a.ispass,state from ("&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid) inner join "&predb&"ans c on c.askid=a.askid where a.askid<"&minid&" and c.ansuser="&id&" order by c.ansid desc")
		end if
   
   case "2"
      set rs=conn.execute("select mytp from "&predb&"user where id="&id)
	  mytp=rs("mytp")
	  set rs=nothing
	  IF mytp&""="" Then mytp=",0,0"
	  mytp=right(mytp,len(mytp)-1)
	  
        set rs=conn.execute("select count(askid) from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mytp&")")
		idcount=rs(0) 
		set rs=nothing
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mytp&") order by askid desc")
		else
			set rs=conn.execute("select min(askid) from (select top "&(page-1)*maxperpage&" askid from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mytp&") order by askid desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid<"&minid&" and askid in("&mytp&") order by askid desc")
		end if
	  
   case "3"
      set rs=conn.execute("select mynote from "&predb&"user where id="&id)
	  mynote=rs("mynote")
	  set rs=nothing
	  IF mynote&""="" Then mynote=",0,0"
	  mynote=right(mynote,len(mynote)-1)
	  
      set rs=conn.execute("select mytp from "&predb&"user where id="&id)
	  mytp=rs("mytp")
	  set rs=nothing
	  IF mytp&""="" Then mytp=",0,0"
	  mytp=right(mytp,len(mytp)-1)
	  
        set rs=conn.execute("select count(askid) from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mynote&")")
		idcount=rs(0) 
		set rs=nothing
		If idcount Mod maxperpage = 0 Then
			n = idcount \ maxperpage
		else
			n = idcount \ maxperpage + 1
		end If
		
        IF page>n then page=n
        IF page<1 then page=1

		if page=1 then
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mynote&") order by askid desc")
		else
			set rs=conn.execute("select min(askid) from (select top "&(page-1)*maxperpage&" askid from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid in("&mynote&") order by askid desc) d")
			minid=rs(0)
			set rs=nothing
           set rs=conn.execute("select top "&maxperpage&" askid,title,asktime,ansnum,classid,classname,ispass,state from "&predb&"ask a inner join "&predb&"class b on a.sclass=b.classid where askid<"&minid&" and askid in("&mynote&") order by askid desc")
		end if
	  
End Select

  if rs.bof and rs.eof then
		Response.Write("<siteinfo><title>#</title></siteinfo>")
   else
        do while not rs.eof
		
	IF rs("isPass")=0 then
	   Ynum=75
	Else
	select case rs("state")
	case 0
	   Ynum=120
	case 1
	   Ynum=45
	case 2
	   Ynum=150
	case 3
	   Ynum=135
	case 4
	   Ynum=90
	case 5
	   Ynum=60
	case 6
	   Ynum=30
	case 7
	   Ynum=15
	end select
	End IF
		
		Response.Write "<siteinfo>"
		Response.Write "<title><![CDATA[<a href=""../"
		IF setting(34)=0 Then
		Response.Write "ask.asp?id="&rs("askid")
		Else
		Response.Write "ask-"&rs("askid")&".html"
		End IF
		Response.Write """ target=""_blank"">"&AskD.leftstr(rs("title"),38)&"</a>]]></title>"
		Response.Write "<state><![CDATA[<div style=""background-image: url(../images/state.gif);height:15px;width:90px;background-position: center "&Ynum&"px;background-repeat: repeat-y;margin-top: 6px;""></div>]]></state>"
		Response.Write "<asktime>"&rs("asktime")&"</asktime>"
		Response.Write "<ansnum>"&rs("ansnum")&"</ansnum>"
		Response.Write "<classname><![CDATA[<a href=""../"

    IF setting(34)=0 Then
	    Response.Write "List.asp?classid="&rs("CLassID")
	Else
	    Response.Write "List-"&rs("CLassID")&".html"
	End IF
		
		Response.Write """ target=""_blank"">"&AskD.leftstr(rs("classname"),8)&"</a>]]></classname>"
		Response.Write "<del><![CDATA[<a href=""javascript:openWindow('UserControl.asp?act=del&id="&id&"&nc="&nc&"&askid="&rs("askid")&"', '300', '120', '用户自助管理');"">删除</a>]]></del>"
		Response.Write "</siteinfo>"
		rs.movenext
		loop
   end if
set rs=nothing
set AskD.myConn =Nothing
closedb
Set AskD = nothing

IF n>1 Then
   Response.Write("<page><p><![CDATA[<div>共<b>"&idcount&"</b>则 <font color=""#FF0000"">"&page&"</font>/"&n&"页&nbsp;&nbsp; <a href=""javascript:"" onclick=""AjaxUpop("&nc&","&id&",1)"">首页</a>&nbsp;&nbsp; <a href=""javascript:"" onclick=""AjaxUpop("&nc&","&id&","&page-1&")"">上一页</a>&nbsp;&nbsp; <a href=""javascript:"" onclick=""AjaxUpop("&nc&","&id&","&page+1&")"">下一页</a>&nbsp;&nbsp; <a href=""javascript:"" onclick=""AjaxUpop("&nc&","&id&","&n&")"">尾页</a></div>]]></p></page>")
Else
   Response.Write("<page><p>#</p></page>")
End if
Response.Write("</mypop>")
%>