<html>
<head>
<title>私服信息采集</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="admin_style.css">
<LINK href="Images/Style.css" type=text/css rel=stylesheet>
</head>
<BODY  bgcolor="#FFCC00" leftMargin=0 topMargin=0>
<%
if session("LoginName")="" then
Response.Redirect("showerr.asp?action=error&message=" & server.URLEncode(errmsg) & "")
end if
%>
<!--#include file="../iNCchuanqi/Cls_Config.asp"-->
<%
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Database)
'如果你的服务器采用较老版本Access驱动，请用下面连接方法
'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(DB_set)
conn.Open connstr
sub CloseConn()
	On Error Resume Next
	If IsObject(Conn) Then
		conn.close
		set conn=nothing
	end if
end sub
'以上是链接数据库
Dim serverip
 serverip="http://cj.41995.cn"
%>
<table width=98% align="center" border="0" cellspacing="1" cellpadding="2" class="tableBorder">
<tr> 
<th>私服采集说明</th>
</tr>
<tr>
<td class=tablerow1>
<%
Function GetHttpPage(HttpUrl)
on error resume next
   If IsNull(HttpUrl)=True Or HttpUrl="$False$" Then
      GetHttpPage="$False$"
      Exit Function
   End If
   Dim Http
   Set Http=server.createobject("MSXML2.XMLHTTP")

   Http.open "GET",HttpUrl,False

   Http.Send()
   If Http.Readystate<>4 then
      Set Http=Nothing 
      GetHttpPage="$False$"
      Exit function
   End if
   GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
   Set Http=Nothing
   If Err.number<>0 then
      Err.Clear
   End If
End Function

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

 randomize

sid=""
g_sid=""
set rs = server.createobject("adodb.recordset")
sql="select * from Gq_Config "
rs.open sql,conn,1,3
if trim(cstr(rs("hostpwd")&""))="" then 
aa=clng(rnd()*9999999)+1
sid=GetHttpPage(serverip&"/reghost.asp?do=1&t="&aa&"&pwd="&aa&"&url="&"http://"&Request.ServerVariables("http_host"))

if sid="" then


Response.Write "初始化失败，请刷新页面<hr>"
Response.End
else

rs("hostpwd")=aa
rs.update
g_sid=sid
Response.Write "初始化注册成功，返回sid="&sid&"<hr>"

end if

else


aa=cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))
sid=GetHttpPage(serverip&"/reghost.asp?do=2&t="&aa&"&pwd="&rs("hostpwd")&"&url="&"http://"&Request.ServerVariables("http_host"))


if trim(sid)="" then 



aa2=cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))
sid2=GetHttpPage(serverip&"/reghost.asp?do=1&t="&aa2&"&pwd="&aa2&"&url="&"http://"&Request.ServerVariables("http_host"))

if sid2="" then


Response.Write "初始化失败，请刷新页面<hr>"
Response.End
else

rs("hostpwd")=aa2
rs.update
g_sid=sid2
Response.Write "初始化注册成功，返回sid="&sid2&"<hr>"

end if






else



g_sid=sid



end if




end if



Response.Write "g_sid="&g_sid&"<hr>" 


aa2=cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))
ssss3=GetHttpPage(serverip&"/reghost.asp?do=3&t="&aa2&"&sid="&g_sid&"&url="&"http://"&Request.ServerVariables("http_host"))





Response.Write "您是:"&ssss3&"<hr>" 




if request.QueryString("action")="" then%>
<br>

<input type="button" value="管理我的私服采集规则" onClick="self.location='<%=serverip%>/Admin_rolus.asp?uid=<%=g_sid%>';">
<input type="button" value="添加我的私服采集规则" onClick="self.location='<%=serverip%>/Admin_rolus.asp?uid=<%=g_sid%>&action=add';">

<br>
<b>私服采集介绍:</b><br>
1、用户可以自己设置采集规则,想采集什么站点就采集什么站点！<br>
2、用户可以管理自己添加的采集站点！<br>
3、建议选择信息较少的站点采集避免很慢很卡！<br>
4、有疑问请在www.41995.cn上面留言或者加QQ：3341100
反馈
<p></tr>
<tr>
<td class="TableRow2">
<form method="POST" action="?action=caiji">


<%
aa2=cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))
ssss3=GetHttpPage(serverip&"/reghost.asp?do=4&t="&aa2&"&sid="&g_sid&"&url="&"http://"&Request.ServerVariables("http_host"))

Response.Write ""&ssss3&"" 


%>









<br><input type="submit" value="采集私服">
</form><input type="submit" value="免费版不支持定时采集">
</form>
</TD>
</TR></TBODY></TABLE>
<%
end if
if request.QueryString("action")="caiji" then
dim Trs,sql8,i8,Texts

aa2=cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))&"_"&cstr(clng(rnd()*99999))
Texts=GetHttpPage(serverip&"/reghost.asp?do=5&t="&aa2&"&sid="&Request.Form("fruit"))
dim T1,T2,t3 : t3=0
if instr(Texts,"<body>")>0 then
Texts=mid(Texts,instr(Texts,"<body>"))
Texts=mid(Texts,1,instrrev("</body>"))
end if


'response.Write Texts&"<hr>"


t1=split(texts,"<br>")
t3=ubound(t1)
for i8=0 to ubound(t1)-1

'response.Write t1(i8)&"<hr>"


 t2=split(t1(i8),"{}")
  if ubound(t2)=23 then 
  '写入数据库
  sql8="select * from Gq_sfdata where name='" & t2(1) & "'"
  Set Trs = Server.CreateObject("ADODB.recordset")
  trs.CacheSize=20
  trs.open sql8,conn,1,3
  if trs.eof then
   trs.addnew
   for i1=1 to 21 : if not isnull(t2(i1)) and t2(i1)<>"" then trs(i1)=t2(i1) :end if : next
   trs(22)=3
   trs("hits")=0
   'trs("addr")="中国"
   trs("daytime")=5
   trs.update
   response.Write t2(1) & " <font color=red >" & t2(5) &"</font> 添加成功<br>"
  else
   response.Write t2(1) & " <font color=red >" & t2(5) &"</font> 已存在<br>"
  end if
  'trs.close
  end if
next


set trs=nothing
conn.close
set conn=nothing
response.Write "共采集了" & t3 & "条信息"
end if
%>
</body>
</html>
