<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.CodePage=65001%>
<%Response.Charset="utf-8"%>
<!--#include file="conn.asp"-->

<%
if not jianbook.isadmin() then
response.end()
end if



if request("act")="email" then
jianbook.demojson()

sql="select * from [info]"
rs.open sql,conn,3,3
if request("ismail")=1 then
rs("ismail")=1
else
rs("ismail")=0
end if

if request("ismailu")=1 then
rs("ismailu")=1
else
rs("ismailu")=0
end if
if request("regmall")=1 then
rs("regmall")=1
else
rs("regmall")=0
end if
rs("smtp")=request("smtp")
rs("mailuser")=request("mailuser")
rs("mailpass")=request("mailpass")
rs("mailreceive")=request("mailreceive")

rs.update
rs.close

jianbook.regemail "测试邮件","邮箱设置成功",request("mailreceive")


end if
	







if request("act")="del_user" then
jianbook.demojson()
conn.execute"delete from [user] where id="&request("id")
response.write "{""info"": ""删除成功"",""status"": ""y""}"
end if

if request("act")="del_type" then
jianbook.demojson()
conn.execute"delete from [type] where id="&request("id")
response.write "{""info"": ""删除成功"",""status"": ""y""}"
end if


'统计查询
if request("act")="list" then
num=ucase(request("limit"))
page=ucase(request("page"))



stemp="{""data"":["

sql1="select * from [count] where ip<>''"




if request("type")<>"" then
 sql=sql&" and instr(type,"&request("type")&")>0"
end if

if request("date_min")<>"" then
 sql=sql&" and datediff('d',intime,#"&request("date_min")&"#)<=0"
end if

if request("date_max")<>"" then
 sql=sql&" and datediff('d',intime,#"&request("date_max")&"#)>=0"
end if

if request("key")<>"" then
sql=" and ip like '%"&request("key")&"%' "
end if

mysql=sql1&sql&" order by id desc"

rs.open mysql,conn,1,1


if not rs.eof then
if request("page")="" then 
currentPage=1 
else 
currentPage=cint(request("page")) 
end if 
perpage=num
rs.PageSize = perpage 
rs.AbsolutePage=currentpage 
page_count=0
i=(page-1)*num 
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = rs.PageSize) 
i = i + 1 
page_count=page_count+1
if totalrec mod perpage=0 then 
n= totalrec \ perpage 
else 
n= totalrec \ perpage+1 
end if 
if cint(page)=n then
ss=totalrec
else
ss=page*num
end if
if trim(rs("useragent"))="" or isnull(rs("useragent")) then
useragent=""
else
useragent=Replace(Replace(rs("useragent"), " ", ""), "			","")
end if

curl=Replace(Replace(Replace(rs("url"), " ", ""),"	",""), "\","")


if i=ss then
hr=""
else
hr=","
end if
stemp=stemp&"{""id"":"""&rs("id")&""",""ip"":"""&rs("ip")&""",""useragent"":"""&useragent&""",""pv"":"""&rs("pv")&""",""addr"":"""&rs("addr")&""",""url"":"""&curl&""",""intime"":"""&rs("intime")&"""}"&hr&""

rs.movenext
wend
end if

stemp=stemp&"],""count"":"""&rs.recordcount&""",""code"":""0"",""msg"":""""}"

response.write stemp
rs.close

end if






'会员列表查询
if request("act")="userlist" then
num=ucase(request("limit"))
page=ucase(request("page"))



stemp="{""data"":["

sql1="select * from [user] where del=0"

if request("zt")<>"" then
 sql=sql&" and zt="&request("zt")
end if


if request("sid")<>"" then
 sql=sql&" and sid="&request("sid")
end if


if request("type")<>"" then
 sql=sql&" and instr(type,"&request("type")&")>0"
end if

if request("date_min")<>"" then
 sql=sql&" and datediff('d',intime,#"&request("date_min")&"#)<=0"
end if

if request("date_max")<>"" then
 sql=sql&" and datediff('d',intime,#"&request("date_max")&"#)>=0"
end if

if request("key")<>"" then
sql=" and email like '%"&request("key")&"%' "
end if

mysql=sql1&sql&" order by id desc"

rs.open mysql,conn,1,1


if not rs.eof then
if request("page")="" then 
currentPage=1 
else 
currentPage=cint(request("page")) 
end if 
perpage=num
rs.PageSize = perpage 
rs.AbsolutePage=currentpage 
page_count=0
i=(page-1)*num 
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = rs.PageSize) 
i = i + 1 
page_count=page_count+1
if totalrec mod perpage=0 then 
n= totalrec \ perpage 
else 
n= totalrec \ perpage+1 
end if 
if cint(page)=n then
ss=totalrec
else
ss=page*num
end if


if i=ss then
hr=""
else
hr=","
end if
stemp=stemp&"{""id"":"""&rs("id")&""",""email"":"""&rs("email")&""",""username"":"""&rs("username")&""",""num"":"""&rs("num")&""",""lasttime"":"""&rs("lasttime")&""",""intime"":"""&rs("intime")&""",""ip"":"""&rs("addr")&""",""addr"":"""&look_ip(rs("addr"))&"""}"&hr&""

rs.movenext
wend
end if

stemp=stemp&"],""count"":"""&rs.recordcount&""",""code"":""0"",""msg"":""""}"

response.write stemp
rs.close

end if







'查询号码
if request("act")="user_point" then
num=ucase(request("limit"))
page=ucase(request("page"))

if request("key")<>"" then
sql="select * from user where email='"&request("key")&"'"
rs.open sql,conn,1,1
if not rs.eof then
uid=rs("id")
end if
rs.close
end if

stemp="{""data"":["

sql1="select uid,sum(point)as tpoint from [user_point] "

if request("key")<>"" then
 sql=sql&" where uid="&uid
end if

mysql=sql1&sql&" group by uid"

rs.open mysql,conn,1,1
if not rs.eof then
if request("page")="" then 
currentPage=1 
else 
currentPage=cint(request("page")) 
end if 
perpage=num
rs.PageSize = perpage 
rs.AbsolutePage=currentpage 
page_count=0
i=(page-1)*num 
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = rs.PageSize) 
i = i + 1 
page_count=page_count+1
if totalrec mod perpage=0 then 
n= totalrec \ perpage 
else 
n= totalrec \ perpage+1 
end if 
if cint(page)=n then
ss=totalrec
else
ss=page*num
end if


sql="select * from [user] where id="&rs("uid")

rst.open sql,conn,1,1
if not rst.eof then
username=rst("email")
end if
rst.close


if i=ss then
hr=""
else
hr=","
end if
stemp=stemp&"{""uid"":"""&username&""",""point"":"""&rs("tpoint")&"""}"&hr&""

rs.movenext
wend
end if

stemp=stemp&"],""count"":"""&rs.recordcount&""",""code"":""0"",""msg"":""""}"

response.write stemp
rs.close

end if

if request("act")="auzinfo1" then

on error resume next
domain=Request.ServerVariables("SERVER_NAME")

SendURL ="http://"&jianbook.sysinfo("author")&"/api/auz/ajax.asp?act=auzinfo"

postdata="key="&jianbook.sysinfo("key")&"&domain="&domain&"&vieson="&jianbook_version

Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP") 
 objXMLHTTP.Open "post", SendURL, false
 
 objXMLHTTP.setRequestHeader "CONTENT-TYPE", "application/x-www-form-urlencoded" 
  objXMLHTTP.Send(postdata)
  
  
  getPageContent = BytesToBstr(objXMLHTTP.ResponseBody,"utf-8")  
  response.Write getPageContent


Set objXMLHTTP = Nothing 

end if



%>



