<!--#include file="../sosokad_Inc/code.asp"-->
<!--#include file="../sosokad_Inc/conn.asp"-->
<!--#include file="../sosokad_Inc/config.asp"-->
<%if session("LoginName")="" or session("AdminPass")="" or session("LoginName")=false or session("AdminPass")=false then response.Write"<script>alert('你还没有登录或者登录超时，请重新登录！');location.href='login.asp';</script>"
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from Gq_Admin where AdminName='"&session("LoginName")&"' and password='"&session("AdminPass")&"'",conn,1,1
if rs.eof and rs.bof then
	response.Write"<script>alert('你还没有登录或者登录超时，请重新登录！');location.href='login.asp';</script>"

end if
rs.close
set rs=nothing%>
<html>
<head>
<title>sosokad私服信息采集</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="admin_style.css">
</head>
<BODY  bgcolor="#FFCC00" leftMargin=0 topMargin=0>
<table cellpadding="5" cellspacing="1"><tr><td style="line-height:200%;">
<%
Function GetHttpPage(HttpUrl)
	If IsNull(HttpUrl)=True Or HttpUrl="$False$" Then
		GetHttpPage="$False$"
		Exit Function
	End If
	Cset="gb2312"
	const TimeInterval=120
	'设定时间间隔
	'如果下载时间很慢，就写成120秒
	const lResolve=50
	'解析域名超时时间,秒
	const lConnect=100
	'连接站点超时时间,秒
	const lSend=100
	'发送数据请求超时时间,秒
	const lReceive=200
	'下载数据超时时间,秒
	Dim Http
	Set Http=server.createobject("MSXML2.ServerXMLHTTP")
	http.setTimeouts lResolve*1000,lConnect*1000,lSend*1000,lReceive*1000
	Http.open "GET",HttpUrl,False
	On Error Resume Next
	Http.Send()
	Select Case http.readyState
		Case 0
			GetHttpPage="$False$"
			response.Write "<font color=red>"&HttpUrl&"</font>对象初始化失败<br>"
			Err.Clear
			set http=nothing
			Exit Function
		Case 1
			GetHttpPage="$False$"
			response.Write "<font color=red>"&HttpUrl&"</font>域名分析超时/连接站点超时<br>"
			Err.Clear
			set http=nothing
			Exit Function
		Case 2
			GetHttpPage="$False$"
			response.Write "<font color=red>"&HttpUrl&"</font>发送数据请求超时,是不是服务器出故障了<br>"
			Err.Clear
			set http=nothing
			Exit Function
		Case 3
			GetHttpPage="$False$"
			response.Write "<font color=red>"&HttpUrl&"</font>数据下载超时/等待反馈时间超时<br>"
			Err.Clear
			set http=nothing
			Exit Function
		Case 4
			'下载成功
	End Select
	If http.status<>200  then
		'GetHttpPage="$False$"
		'response.Write "<font color=red>"&HttpUrl&"</font>下载失败"&Err.description&"<br>"
		Err.Clear
		'set http=nothing
		'Exit Function
	END IF
	GetHTTPPage=bytesToBSTR(Http.responseBody,Cset)
	Set Http=Nothing
	If Err.number<>0 then
		Err.Clear
	End If
End Function

'==================================================
'函数名：BytesToBstr
'作  用：将获取的源码转换为中文
'参  数：Body ------要转换的变量
'参  数：Cset ------要转换的类型
'==================================================
Function BytesToBstr(Body,Cset)
	Dim Objstream
	Set Objstream = Server.CreateObject("adodb.stream")
	objstream.Type = 1
	objstream.Mode =3
	objstream.Open
	objstream.Write body
	objstream.Position = 0
	objstream.Type = 2
	objstream.Charset = Cset
	BytesToBstr = objstream.ReadText 
	objstream.Close
	set objstream = nothing
End Function

Function safestr(str)
	safestr=Replace(Replace(str,"'",""),";","")
End Function

Function dealNum(userName_) 
	Dim RegExpObj 
	Dim i,n 
	Dim userName,tempStr,resultStr 

	userName=Trim(userName_) 
	Set RegExpObj=new RegExp 
	RegExpObj.Global = True 
	RegExpObj.Pattern="^[0-9]+$" '数字

	resultStr=userName 
	n=Len(userName) 
	for i=1 to n 
		tempStr=Mid(userName,i,1) 
		if not RegExpObj.test(tempStr) then resultStr=Replace(resultStr,tempStr,"") 
	next 

	Set RegExpObj=nothing 
	dealNum=resultStr 
End Function


function chk_ip(strIP) 
	dim boolIsIP 
	dim arrIP 
	boolIsIP=true  '函数初始值为true 

	arrIP=split(strIP,".") '将输入的IP用"."分割为数组，数组下标从0开始，所以有效IP分割后的数组上界必须为3 
	if ubound(arrIP)<>3 then 
		boolIsIP=false  
	else 
		for intLoop=0 to Ubound(arrIP) 
			if not isnumeric(arrIP(intLoop)) then '检查数组元素中各项是否为数字，如果不是则不是有效IP 
				boolIsIP=false 

			else 
				if arrIP(intLoop)>255 or arrIP(intLoop)<0 then '检查IP数字是否满足IP的取值范围 
					boolIsIP=false 
				end if 
			end if 
		next 
	end if 
	chk_ip=boolIsIp 
end function



dim aa,a1,a2,rs,j,k,href,star,sftime,Hour1,Hour2,Minute1,Minute2,z1,z2,z3,z2num,action,isz1,isz2,isz3,tempnum,topic,time1,content,classid
if Request("stype")="sf" then
'###########################################################
'#							   #
'#------------------sosokad采集私服数据开始--------------------#
'#							   #
'###########################################################

Server.ScriptTimeout = 99999
z1=safestr(Request("z1"))
z2=dealnum(Request("z2"))
z2num=dealnum(Request("z2num"))
if z2num="" then z2num=0
z3=dealnum(Request("z3"))
action=request("action")
if action="haosf" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/haosf.asp")
elseif action="w91530" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/91530.asp")
elseif action="sf123" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/sf123.asp")
elseif action="yg8" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/yg8.asp")
elseif action="zhaosf" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/zhaosf.asp")
elseif action="w3000ok" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/3000ok.asp")
elseif action="sf666" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/176sf666.asp")
elseif action="xp13" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/cxp13.asp")
elseif action="w23u" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/23u.asp")
elseif action="w3gwoool" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/3gwoool.asp")
elseif action="zhaowoool" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/zhaowoool.asp")
elseif action="ggwoool" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/ggwoool.asp")
elseif action="j173" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/j173.asp")
elseif action="w39my" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/39my.asp")
elseif action="w9958my" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/9958my.asp")
elseif action="yaozz" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/yaozz.asp")
elseif action="huaseo" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/huaseo.asp")
elseif action="hj123" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/hj123.asp")
elseif action="w600wz" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/tw123.asp")
elseif action="haomir" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/haomir.asp")
elseif action="zhaohj" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/zhaohj.asp")
elseif action="yoyohj" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/yoyohj.asp")
elseif action="w51hj" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/51hj.asp")
elseif action="sf7" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/sf7.asp")
elseif action="yaosf" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/yaosf.asp")
elseif action="w45ss" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/45ss.asp")
elseif action="hjqiqi" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/hjqiqi.asp")
elseif action="w36uc" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/36uc.asp")
elseif action="w00ok" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/00ok.asp")
elseif action="pao51" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/pao51.asp")
elseif action="w51ucf" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/51ucf.asp")
elseif action="laozx" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/laozx.asp")
elseif action="zhuxiansf" then
	bb=GetHTTPPage("http://cj.sosokad_com.com:88/cj/zhuxiansf.asp")
else
	response.end
end if
if instr(bb,"你的IP：")>0 then
	response.write bb
	response.end
end if
a1=Split(bb,"$$")
for j = Lbound(a1) to (Ubound(a1)-1)
	a2=Split(a1(j),"|")
	'格式 区名 | IP地址 | 开区时间 | 小时 | 分钟   | 线路 | 介绍    | qq | 主页     | 下载

	'格式 Name | Ip     | Sdate    | Hour | Minute | Addr | Xingzhi | QQ | Homepage | Download

	'格式 0    | 1      | 2        | 3    | 4      | 5    | 6       | 7  | 8        | 9

	'response.write a2(0)
	'response.end


	'判断是否日期限制,今天,明天,后天
	if z1="" then
		isz1="0"
	else
		if z1=a2(2) then
			isz1="0"
		else
			isz1="1"
		end if
	end if

	'判断是否时段数量限制
	if z2="" or z2num="0" then
		isz2="0"
	else
		tempnum=0
		sql="select count(*) as tempnum from Gq_sfdata where sdate=#"&a2(2)&"# and hour="&cint(a2(3))&" and minute="&cint(a2(4))
		'response.write sql
		'response.end
		set rs=conn.execute(sql)
		tempnum=tempnum+rs("tempnum")
		set rs=nothing
		if cint(z2num)>tempnum then
			isz2="0"
		else
			isz2="1"
		end if
	end if

	if z3<>"1" and z3<>"2" then
		isz3="0"
	elseif z3="1" then
		if chk_ip(a2(1))=true then
			isz3="0"
		else
			isz3="1"
		end if
	elseif z3="2" then
		if chk_ip(a2(1))=false then
			isz3="0"
		else
			isz3="1"
		end if
	end if
	if isz1="0" and isz2="0" and isz3="0" then

        	set rs=Server.CreateObject("ADODB.RecordSet")
		sql="select * from Gq_sfdata where name='"&a2(0)&"' and ip='"&a2(1)&"'"
		rs.Open sql,conn,1,3
		if rs.eof then
			rs.addnew
			rs("Name")=a2(0)
			rs("Ip")=a2(1)
			rs("GameId")=mirsfID
			'rs("Service")="0"
			rs("Sdate")=a2(2)
			rs("Hour")=a2(3)
			rs("Minute")=a2(4)
			rs("Addr")=a2(5)
			rs("Xingzhi")=a2(6)
			rs("QQ")=a2(7)
			rs("Homepage")=a2(8)
			rs("Download")=a2(9)
			rs("addtime")=now()
			rs("hits")=0
			rs("Ulock")=1
			rs("isBest")=SF_top
			if SF_top="1" then
				rs("besttime") = now()
			end if

			if SF_hot="1" then
				rs("hot") = 1
			end if
			if SF_hot="1" then
				rs("hottime") = now()
			end if
			rs("Daytime")=mirsfday
			rs.update
			response.write a2(0)&"<font color='#FF0000'>(采集成功!开机时间："&a2(2)&")</font><br>"
			response.Flush
		else
			response.write a2(0)&"<font color='#0000FF'>(数据已存在!)</font><br>"
			response.Flush
		end if
		rs.close
		set rs=nothing
	end if
next


elseif Request("stype")="art" then
'###########################################################
'#							   #
'#------------------sosokad采集文章数据开始--------------------#
'#							   #
'###########################################################

Server.ScriptTimeout = 99999
'dim 
classid=dealnum(Request("classid"))
cat_id=dealnum(Request("cat_id"))
set rs=conn.execute("select * from Gq_NewsClass where cat_id="&cat_id)
cat_name=rs("cat_name")
set rs=nothing

z2=dealnum(Request("z2"))
z2num=dealnum(Request("z2num"))
if z2num="" then z2num=200
bb=GetHTTPPage("http://cj.sosokad_com.com/cj/art.asp?action=getnum&classid="&classid&"&num1="&z2num)
if instr(bb,"你的IP：")>0 then
	response.write bb
	response.end
end if
num1=Split(bb,"$num1$")(1)
response.write "<font color=""#202020""><b>共要采集 "&num1&" 条文章数据!</font></b><br>"&vbcrlf
response.flush
a1=Split(Split(bb,"$id$")(1),",")
for j = Ubound(a1) to Lbound(a1) step -1
	aa=GetHTTPPage("http://cj.sosokad_com.com/cj/art.asp?action=getrow&classid="&classid&"&id="&a1(j))
		topic=Split(aa,"$topic$")(1)
		time1=Split(aa,"$time1$")(1)
		content=Split(aa,"$content$")(1)
		writer=request.form("writer")
        copyright=request.form("copyright")
        	set rs=Server.CreateObject("ADODB.RecordSet")
		sql="select * from Gq_Article where art_Title='"&Replace(topic,"'","''")&"'"
		rs.Open sql,conn,1,3
		if rs.eof then
			rs.addnew
			rs("cat_id")=cat_id
			rs("art_Title")=topic
			rs("Content")=Content
			rs("writer")=writer
			rs("copyright")=copyright
			rs("Isbest")=0
			rs("art_date")=time1
			rs("art_count")=0
			rs.update
			response.write topic&"<font color='#FF0000'>(采集成功!)</font><br>"
			response.Flush
		else
			response.write topic&"<font color='#0000FF'>(数据已存在!)</font><br>"
			response.Flush
		end if
		rs.close
		set rs=nothing
next

response.write "<font color=""#202020""><b>采集完成!</font></b><br>"&vbcrlf
response.flush

end if
CloseConn
%>
</td></tr></table>
</body>
</html>
