<!-- #include file="../conn.asp" -->
<!-- #include file="../cls_md5.asp" -->
<!-- #include file="../cls_main.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>天空软件站软件信息采集系统</title>
<style type="text/css">
<!--
body,td,th,* {
	font-size: 9pt;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
-->
</style></head>

<BODY topmargin="3">

<% 
MyDbpath="../"
Server.ScriptTimeOut = 60000000
dim ishion
set ishion = new cls_main

If Not IsObject(Conn) Then ConnectionDatabase

dim TypeID,strHttp,Rs,founderr
TypeID = 1 '天空站下载预定义ID号
strHttp1 = "http://www.downloadsky.com/"
strHttp = "http://www.skycn.com/"
'What'sNew
Set Rs=server.createobject("adodb.recordset")
founderr = false
select case Request("action")
	case "batch1" '批量抓取
		call batch1()
	case "batch2"
		call batch2()
	case "a"
		call a()
	case "new"
		call NewList()
	case else
		call main()
end select
Set Rs = Nothing
'call soft("http://www.skycn.com/soft/11805.html")
If IsObject(Conn) Then
	Conn.Close
	Set Conn = Nothing
End If
Set ishion = nothing
sub a()

	call soft(Trim(Request.Form("URL")))
end sub
sub batch1()
	dim strID,strURL,intIndex,i,n
	strID = Trim(Request.Form("skycnid"))
	n = 1
	if Request("index") = "" then
		intIndex = 0
		
	else
		intIndex = Request("index")
	end if
	
	for i = intIndex to ubound(split(strID,","))
	
	strURL = strHttp & "soft/" & Trim(split(strID,",")(i)) & ".html"
	strURL1 = strHttp1 & "soft/" & Trim(split(strID,",")(i)) & ".html"
	call soft(strURL,strURL1)
	if founderr then	
		intIndex = i + 1 '下一个索引
		Response.Write("<form name=""form1"" method=""post"" action=""admin_skycn.asp""><tr><td  align=""center"">")
		Response.Write("<input type=""hidden"" name=""skycnid"" value="""&strID&"""><input type=""hidden"" name=""index"" value="""&intIndex&""">")
		Response.Write("<input type=""hidden"" name=""action"" value=""batch1"">")
		Response.Write("<input type=""submit"" name=""Submit"" value="" 跳过此软件,继续批量更新.. "">")
		Response.Write("</td></tr></form></table>")
		exit sub '有重复软件时停止下一个软件更新
	end if
	if i = ubound(split(strID,",")) then
		Response.Write("<div align=""center""> <a href="""">操作完成</a></div>")
		exit sub
	end if
	if n = 30 then
		intIndex = i + 1 '下一个索引
	
		Response.Write("<form name=""form1"" method=""post"" action=""admin_skycn.asp"">")
		Response.Write("<input type=""hidden"" name=""skycnid"" value="""&strID&"""><input type=""hidden"" name=""index"" value="""&intIndex&""">")
		Response.Write("<input type=""hidden"" name=""action"" value=""batch1"">")
		Response.Write("</form>")
		Response.Write("<SCRIPT language=javascript>"& vbNewLine)
		Response.Write("document.form1.submit();"& vbNewLine)
		Response.Write("</SCRIPT>")
		exit for
	end if
	n = n + 1
	next	
end sub
sub batch2()
	dim NextID,strURL,i,n
	n = 1
	if Request("NextID") = "" then
		NextID = Request("s1")
	else
		NextID = Request("NextID")
	end if
	for i = NextID to Request("s2")
		strURL = strHttp & "soft/" & i & ".html"
		strURL1 = strHttp1 & "soft/" & i & ".html"
		call soft(strURL,strURL1)
		
	if founderr then	
		NextID = i + 1 '下一个索引
		Response.Write("<form name=""form1"" method=""post"" action=""admin_skycn.asp""><tr><td  align=""center"">")
		Response.Write("<input type=""hidden"" name=""NextID"" value="""&NextID&""">")
		Response.Write("<input type=""hidden"" name=""s2"" value="""&Request("s2")&""">")
		Response.Write("<input type=""hidden"" name=""action"" value=""batch2"">")
		Response.Write("<input type=""submit"" name=""Submit"" value="" 跳过此软件,继续批量更新.. "">")
		Response.Write("</td></tr></form></table>")
		exit sub '有重复软件时停止下一个软件更新
	end if
	
		if n = 30 then
			NextID = i + 1 '下一个索引
	
			Response.Write("<form name=""form1"" method=""post"" action=""admin_skycn.asp"">")
			Response.Write("<input type=""hidden"" name=""NextID"" value="""&NextID&""">")
			Response.Write("<input type=""hidden"" name=""s2"" value="""&Request("s2")&""">")
			Response.Write("<input type=""hidden"" name=""action"" value=""batch2"">")
			Response.Write("</form>")
			Response.Write("<SCRIPT language=javascript>"& vbNewLine)
			Response.Write("document.form1.submit();"& vbNewLine)
			Response.Write("</SCRIPT>")
			exit for
		end if
		n = n + 1
	next
	
end sub
sub main()
	If ishion.adminName = "" Then
		ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统。"
	         Call ishion.SystemMsg
               exit sub
	ElseIf ishion.checkPermission(ishion.adminName, "55") = False Then
		ishion.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
	    	 Call ishion.SystemMsg
             exit sub
	End if
%>
<table width="98%" border="0" cellpadding="3" cellspacing="1">
  <tr align="center">
    <td><font color="#FF0000"><b>宏亮软件园</b></font>天空软件站软件信息采集系统</td>
  </tr>
<form name="form2" method="post" action="admin_skycn.asp">
  <tr>
    <td>一、按ID序号采集：开始ID<input name="s1" type="text" id="s1" size="5" maxlength="5">
      结束ID<input name="s2" type="text" id="s2" size="5" maxlength="5"> <input type="submit" name="Submit" value=" 开始采集软件 "> <input name="action" type="hidden" value="batch2"></td> 
    </tr>
</form>
  <tr>
    <td>二、采集最近更新：<a href="?action=new">点此开始采集</a></td>
  </tr>
  <form name="form3" method="post" action="z_skyurl.asp" target="_blank">
  <tr>
    <td>　下载站点：
      <input name="url" type="text" id="url" value="http://gd-http.skycn.net:8080" size="35" maxlength="100">　
      <input type="submit" name="Submit" value="查看今日天空软件下载地址">
      </a></td>
  </tr>
  </form>
  <tr>
    <td>三、分站下载地址管理</td>
  </tr>
  <tr>
    <td><script language="javascript">
function add_sort(formName){
  if(formName.boardname.value==""){     
      alert("请输入分站名!");
      formName.boardname.focus();
      return false;
      }
  else
      return true;
}

function edit_sort(formName){
  if(formName.type_id.value=="" || formName.sort_name.value==""){
      alert("请在分站中选择要修改的分站名!");
      return false;
      }
  else if(formName.old_boardname.value!=formName.sort_name.value){
      alert("请重新选择要修改的分站名!");
      return false;
      }
  else if(formName.boardname.value==""){
      alert("请输入新分站名!");
      formName.boardname.focus();
      return false;
      }
  else
      return true;
}

</script>
<table width="700" border="0" cellspacing="1" cellpadding="2" align="center" bgcolor="#f0f0f0">
  <tr> 
    <td height="25" align="center"><b><font color="#666666">维护分站</font></b></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="5" bordercolorlight="#000000" bordercolordark="#FFFFFF" class=p9 align="center">
        <tr> 
          <td height="206" align="center" class="p9" width="50%" valign="top"> 
            <table width="100%" border="0" cellspacing="2" cellpadding="2" class="p9" height="199">
              <tr> 
                <td height="22" bgcolor="#f0f0f0">　现有分站列表：</td>
              </tr>
              <tr> 
                <td valign="top" align=center> 
                  
<SCRIPT language="JavaScript">
function display1(Q_subtree,Q_img){
  
  if (Q_subtree.style.display=="none"){ 
       Q_subtree.style.display="";     
     Q_img.src="../images/tree_collapse.gif";
    }
  else
      {
       Q_subtree.style.display="none";      
       Q_img.src="../images/tree_expand.gif";
  } 
}

function del_sort(temp,tag,mark){
      if(tag=="Yes"){
          var msg=window.confirm ("该分站下的地址也会被删除,\n你真的要删除该分站吗?");
          if(msg==true){
		  if (mark=="root"){
			document.delform.deltype.value=mark;
			}else{
			document.delform.deltype.value=mark;
			}
		  
              document.delform.id.value=temp;     
              document.delform.submit();  
          }
      }
      else
          alert("该分站下还有网址,不能删除!");
}

function chang_news_sort(id,sort_name,level_name){
  document.frm_edit.type_id.value=id;
  document.frm_edit.sort_name.value=sort_name;
  document.frm_edit.level_name.value=level_name;
  document.frm_edit.old_boardname.value=sort_name;
}

</SCRIPT>
<TABLE cellSpacing=0 cols=5 cellPadding=0 width=300 border=0>  
  <TBODY>  
  <form name="delform" action="sort_ok.asp?version=cn" method="post">
  <TR> 
    <TD style="line-height:16px" width=16></TD>
    <TD style="line-height:16px" width="230"></TD>    
    <TD style="line-height:16px" width=23></TD>    
  </TR>
  <TR> 
    <TD style="line-height:16px" width="16"><IMG src="../images/tree_collapse.gif" border=no></TD>
    <TD style="line-height:16px" colSpan=2>分站名　　　　　　　　　　　　　　　　　　删除</TD>    
  </TR>   
      <%
	    Set Rsaddr=server.createobject("adodb.recordset")
		sqladdr="select * from ishion_Down_SiteSetting where ID=1"&" "
		rsaddr.open sqladdr,conn,1,3
		ID=rsaddr("ID")
		DownloadNamea=rsaddr("DownloadName")
		DownloadName=split(DownloadNamea,",")
		DownloadURLa=rsaddr("DownloadURL")
		DownloadURL=split(DownloadURLa,",")
		for i=0 to Ubound(DownloadName)
	  %>
          <TR> 
          <TD style="line-height:16px" width="16">
		  <% 
		      if i=Ubound(DownloadName)-1 then 
		        img="../images/tree_end.gif"
			  else
			    img="../images/tree_split.gif"
			  end if
		  %>
		  <img src="<%=img%>" border=no width="16" height="16"></TD>
          <TD style="line-height:16px"><A href="#here" onclick="javascript:chang_news_sort('<%=i%>','<%=DownloadName(i)%>','root');"><%=DownloadName(i)%></A></TD>
          <TD style="line-height:16px" width="23">
		  <a href="javascript:del_sort('<%=i%>','Yes','root')"><b>×</b></a>
		  </TD>
          </TR>
          <TR id="subtree2"><TD style="line-height:16px"><img src="../images/tree_vertline.gif" border=0></TD>
              <TD style="line-height:16px"><A href="#here" onclick="javascript:chang_news_sort('<%=i%>','<%=DownloadURL(i)%>','child');"><%=DownloadURL(i)%></a></TD>
              <TD style="line-height:16px"></TD>
          </TR>
          <%Next%>
        <input type="hidden" name="deltype">
  <input type="hidden" name="id"><input type="hidden" name="sort_action" value="del">
  </form>
  </TBODY>
</TABLE>

                </td>
              </tr>
            </table>
          </td>
          <td height="206" align="center" class="p9" valign="top" width="50%"> 
            <table width="100%" border="0" cellspacing="2" cellpadding="2" class="box" height="96">
              <form name="frm_add" method="post" action="sort_ok.asp?version=cn" onSubmit="javascript:return add_sort(document.frm_add);">
                <tr> 
                  <td height="22" bgcolor="#f0f0f0">　新增分站:</td>
                </tr>
                <tr> 
                  <td height="8">　分站名:　  
                    <input type="text" name="boardname" class=p9 style="width:230px;height:22px">
                  </td>
                </tr>
                <tr> 
                  <td height="21">　所属于:　  
                    <select name="root_sort" class=p9 style="width:230px;height:22px">
                      <option value=0>分站</option>
                      <%	for i=0 to Ubound(DownloadName)-1%>
                      <option value="<%=i%>"><%=DownloadName(i)%></option>
                      <%Next%>
                    </select>
                  </td>
                </tr>
                <tr> 
                  <td height="2">　操　作:　  
                    <input type="Submit" name="Submit4" value="新增" style="width:60px;height:22px" class=p9>
                    <input type="reset" name="Submit22" value="取消" style="width:60px;height:22px" class=p9> 
                    <input type="hidden" name="sort_action" value="add_new"> 
                  </td>
                </tr>
              </form>
            </table>
            <br>
            <table width="100%" border="0" cellspacing="2" cellpadding="2" class="box" height="84">
              <form name="frm_edit" method="post" action="sort_ok.asp?version=cn" onSubmit="javascript:return edit_sort(document.frm_edit);">
                <tr> 
                  <td height="22" bgcolor="#f0f0f0">　修改分站:</td>
                </tr>
                <tr> 
                  <td height="2">　原分站名:  
                    <input type="text" name="old_boardname" class=p9 style="width:230px;height:22px" readonly>
                  </td>
                </tr>
                <tr> 
                  <td height="2">　新分站名:  
                    <input type="text" name="boardname" class=p9 style="width:230px;height:22px">
                  </td>
                </tr>
                <tr> 
                  <td height="7">　操　作:　  
                    <input type="submit" name="Submit" value="修改" style="width:60px;height:22px" class=p9>
                    <input type="reset" name="Submit2" value="取消" style="width:60px;height:22px" class=p9> 
                    <input type="hidden" name="type_id"> 
                    <input type="hidden" name="level_name"> 
                    <input type="hidden" name="sort_name"> 
                    <input type="hidden" name="sort_action" value="edit"> 
                  </td>
                </tr>
              </form>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td height="10"></td>
  </tr>
</table></td>
  </tr>
  <tr>
  <td align="center">
<br>
天空软件入库程序修改宏亮软件园（<a href="http://www.hldown.cn">http://www.hldown.cn</a>）
  </td>
  </tr>
</table>

<%
end sub
sub soft(url,url1)
	'Response.CharSet = "GB2312"
	dim myGather,strHtml,strReg,i,stru
	set myGather=new ishionGather
	i=split(split(url,"/")(4),".")(0)
	strHtml = myGather.GetBody(url)
	if strHtml = "" then exit sub
	'strReg = "<td bgcolor='#DFE6EE' align='center' height='25'>[!--string--]<td width=422 align=center>"
	'strHtml = myGather.skycn_soft(strHtml,strReg)
	dim str(12)
	strHtml =replace(strHtml,vbCrLf,"")
	'Response.Write strHtml
	'response.end
	'软件名称
	strReg = "<title>[!--string--] - 天空软件站 - "
	str(1) = myGather.skycn_soft(strHtml,strReg)
	'软件大小
	strReg = "<strong>软件大小：</strong></td> <td>[!--string--]KB</td>" 
	str(2) = myGather.skycn_soft(strHtml,strReg)
	 '软件语言
	strReg = "<strong>软件语言：</strong></td> <td>[!--string--]</td>"
	str(3) = myGather.skycn_soft(strHtml,strReg)
	 '软件类别
	strReg = "<strong>软件类别：</strong></td> <td>[!--string--]</td>"
	str(4) = myGather.skycn_soft(strHtml,strReg)
	'应用平台
	strReg = "<strong>应用平台：</strong></td> <td>[!--string--]</td>" 
	str(5) = myGather.skycn_soft(strHtml,strReg)
	 '加入时间
	strReg = "<strong>更新时间：</strong></td> <td>[!--string--]</td>"
	str(6) = myGather.skycn_soft(strHtml,strReg)
	'下载次数
	strReg = "<strong>下载次数：</strong></td> <td>[!--string--]</td>" 
	str(7) = myGather.skycn_soft(strHtml,strReg)
	 '推荐等级
	strReg = "../images/star[!--string--].gif"
	str(8) = myGather.skycn_soft(strHtml,strReg)
	'联系人
	strReg = "<font title=""与他联系：复制此地址后请手工添加@字符"">[!--string--]</font>" 	
	str(9) = myGather.skycn_soft(strHtml,strReg)
	str(9)=replace(str(9),"<img src=../images/at.gif width=7 height=10>","@")
	'开发商
	strReg = "<strong>开 发 商：</strong></td> <td style=""word-break: break-all; word-wrap:break-word;"">[!--string--]</td>" 
	str(10) = myGather.skycn_soft(strHtml,strReg)
	If str(10)<>"" then str(10) = myGather.dellink(str(10))
	 '软件介绍
	strReg = "<table width=""548"" border=""0"" align=""center"" cellpadding=""2"" cellspacing=""0""> <tr> <td>[!--string--]</td>"
	str(11) = myGather.skycn_soft(strHtml,strReg)
	
	'下载地址
	strReg = "<table width=""550"" border=""0"" cellpadding=""0"" cellspacing=""0""> <tr><td width=120 valign=top>[!--string--]</td>"
	str(12) = myGather.skycn_soft(strHtml,strReg)

	str(11)=replace(str(11),"&nbsp;","")
	str(11)=replace(str(11)," ","")
	str(11)=replace(str(11),"'", "''")
    str(12)=replace(str(12),"<img src=""../images/pic_down.gif"" width=""14"" height=""14"" hspace=""2"">","")
    str(12)=replace(str(12),"<A href='","")
    str(12)=replace(str(12),"<a href='","")
    str(12)=replace(str(12),"http://count.skycn.com/softdownload.php?id="&i&"&url=","")
    str(12)=replace(str(12),"' target=_blank>",",")
    str(12)=replace(str(12),"</A><br>","$")
    str(12)=replace(str(12),"</a><br>","$")
	'Response.Write ("<br>"&len(str(12))-1&"<br>")
	if trim(str(12))<>"暂停下载" and trim(str(12))<>"" then  str(12)=left(str(12),len(str(12))-1)
	'for i = 1 to 12
	'Response.Write (str(i)&"<br>")
	'next
	'Response.End()
	
	set myGather = nothing
	
	Response.Write("<li>采集软件"&i&"：<a href="""&url&""" target=""_blank"">"&str(1)&"</a></li>")
	Response.Flush
	'Response.End()
	dim ID,sql,softName,softVer,sName
	ID = 0
	if ubound(split(str(1)," V"))>=1 then
		softVer = " V"&split(str(1)," V")(ubound(split(str(1)," V")))
		softName = replace(str(1),softVer,"")
		sName = softName  '搜索相关软件
		'Response.Write(softName&" "&softVer)
		'exit sub
	else
		softName = str(1)
		softVer = ""
		sName = Left(softName,7)		
	end if
	sql="select ID from ishion_Down_Resource where md5='"&md5(url1,16)&"'"
	rs.open sql,conn,1,1
	if not rs.eof then ID = rs(0)
	dim cRs,a
	set cRs = conn.execute("select rootID,Depth,catalogID,catalogName from ishion_Down_Catalog where catalogName='"&Trim(split(str(4),"/")(2))&"'")
	if not(cRs.eof and cRs.bof) then
		rootID = cRs(0)
		Depth= cRs(1)
		catalogID = cRs(2)
		catalogName = cRs(3)
	else
		rootID = 1
		Depth = 1
		catalogID = 1
		catalogName = Trim(split(str(4),"/")(2))
	end if
	set cRs = nothing

	if rs.eof and rs.bof then
		sql="INSERT INTO ishion_Down_Resource(ResName,ResVer,rootID,Depth,catalogID,catalogName,content,Excerpt,IndexKeys,md5,authorURL,ResLicence,ResType,ResLanguage,ResSize,System,DateAndTime,UpdateTime,ResRank,authorEmail,isAuditing,UserName) VALUES ('"&softName&"','"&softVer&"',"&rootID&","&Depth&","&catalogID&",'"&catalogName&"','"&delads(str(11))&"','"&cutStr(replace(delads(str(11)),"<br />",""),200)&"','"&GetSpellChar(softName)&"','"&md5(url1,16)&"','"&str(10)&"','"&Trim(split(str(4),"/")(1))&"','"&Trim(split(str(4),"/")(0))&"','"&str(3)&"',"&str(2)&",'"&replace(str(5),"/",",")&"','"&str(6)&"','"&now()&"',"&str(8)&",'"&str(9)&"','1','admin')"
		'Response.Write(sql)
		conn.execute sql
	else			
		sql="update ishion_Down_Resource set ResName='"&softName&"',ResVer='"&softVer&"',rootID="&rootID&",Depth="&Depth&",catalogID="&catalogID&",catalogName='"&catalogName&"',content='"&delads(str(11))&"',Excerpt='"&cutStr(replace(delads(str(11)),"<br />",""),200)&"',IndexKeys='"&GetSpellChar(softName)&"',md5='"&md5(url1,16)&"',authorURL='"&str(10)&"',ResLicence='"&Trim(split(str(4),"/")(1))&"',ResType='"&Trim(split(str(4),"/")(0))&"',ResLanguage='"&str(3)&"',ResSize="&str(2)&",System='"&replace(str(5),"/",",")&"',DateAndTime='"&str(6)&"',UpdateTime='"&now()&"',ResRank="&str(8)&",authorEmail='"&str(9)&"',isAuditing=1,UserName='admin' where ID = " & ID&""
		'Response.Write(sql)
	    'response.end
		conn.execute sql
   	end if
	'延迟时间
	a = now
	While DateDiff("s",a,now) <0.5
	Wend
	rs.close
	'追加入库
	if ID=0 then
		id=conn.execute("select max(id) from ishion_Down_Resource")(0)
		sql="INSERT INTO ishion_Down_Address(Name,URL,Hits,ResourceID,SiteID)VALUES ('"&str(1)&"','"&str(12)&"',0,"&ID&","&TypeID&")"
		'Response.Write(sql)
		conn.execute sql
	else
		sql="delete from ishion_Down_Address where ResourceID = " &ID
		conn.execute sql
		sql="INSERT INTO ishion_Down_Address(Name,URL,Hits,ResourceID,SiteID)VALUES ('"&str(1)&"','"&str(12)&"',0,"&ID&","&TypeID&")"
		'Response.Write(str(12))
		conn.execute sql
	end if
end sub
Public Function delads(str)
	dim oReg
	set oReg=new regExp
	oReg.Global=true
	oReg.IgnoreCase=true '不区分大小写	
	oReg.Pattern = "(<IFRAME\b.*?>)([\S\s]*?)(</IFRAME>)"
	delads = oReg.Replace(str,"")
	Set oReg = nothing
End Function
sub NewList()
	If ishion.adminName = "" Then
		ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统。"
	         Call ishion.SystemMsg
               exit sub
	ElseIf ishion.checkPermission(ishion.adminName, "55") = False Then
		ishion.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
	    	 Call ishion.SystemMsg
             exit sub
	End if


	Response.CharSet = "GB2312"
	dim myGather,strHtml,strReg,intPage,i,offset
strReg ="<font color=#0000ff>文件大小</font></td></tr>[!--string--]<tr><td colspan=4><table border='0' width='100%' cellspacing='0'><tr><td align='left'>"
	set myGather=new ishionGather
	strHtml	= myGather.GetBody("http://www.skycn.com/h_search1.php?offset=0&h_indate="&date()&"&andor=and&sor=00&get=indate&az=2")
	intPage = myGather.skycn_getpage(strHtml)
	strHtml = myGather.skycn_smallurl(strHtml,strReg) %>
<SCRIPT language=javascript>
function CheckOthers(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
//		if (e.name != 'chkall')
			if (e.checked==false)
			{
				e.checked = true;// form.chkall.checked;
			}
			else
			{
				e.checked = false;
			}
	}
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
//		if (e.name != 'chkall')
			e.checked = true// form.chkall.checked;
	}
}

</SCRIPT>
<form name="form1" method="post" action="admin_skycn.asp"><b>以下是天空下载，最新更新的软件，请选择您要更新的项目</B><BR> 
<table>
<% Response.Write(strHtml)
strHtml = Empty
If intPage> 1 then
	for i = 2 to intPage
	offset = 20*(i-1)
	strHtml	= myGather.GetBody("http://www.skycn.com/h_search1.php?offset="&offset&"&h_indate="&date()&"&andor=and&sor=00&get=indate&az=2")
	strHtml = myGather.skycn_smallurl(strHtml,strReg)
	Response.Write(strHtml)
	strHtml = Empty
	next
end if
 %>
</table>
<input type="button" onclick="CheckAll(this.form)" value=" 全选 "> <input type="button" onclick="CheckOthers(this.form)" value=" 反选 ">
采集入库方式：
<input name="t" type="radio" value="1" checked>追加入库
<input type="radio" name="t" value="2">更新入库
<input type="submit" name="Submit" value=" 开始采集软件 "> <input name="action" type="hidden" value="batch1">
</form>
<%
set myGather = nothing
end sub
	'//截取指定长度字符串
	'//返回类型：字符串
	Function cutStr(str,strlen)
		Dim l,t,c,i
		l=len(str)
		t=0
		For i=1 to l
		c=Abs(Asc(Mid(str,i,1)))
		If c>255 then
			t=t+2
		Else
			t=t+1
		End if
		If t>=strlen then
			cutStr=left(str,i)&".."
			Exit for
		Else
			cutStr=str
		End if
		Next
		cutStr=replace(cutStr,chr(10),"")
	End Function
	'获取字符中首字字符
	'返回：A-Z ;123 ; ###
	Function GetSpellChar(str)
		Dim tmp
		Getspellchar="@"
		tmp=65536+asc(str)
		if(tmp>=45217 and tmp<=45252) or (tmp=65601) or (tmp=65633) or (tmp=37083) then
			Getspellchar= "A1"
		elseif(tmp>=45253 and tmp<=45760) or (tmp=65602) or (tmp=65634) or (tmp=39658) then
			Getspellchar= "B1"
		elseif(tmp>=45761 and tmp<=46317) or (tmp=65603) or (tmp=65635) or (tmp=33405) then
			Getspellchar= "C1"
		elseif(tmp>=46318 and tmp<=46930) or (tmp=61884) or(tmp=63468) or (tmp=65604) or (tmp>=36820 and tmp<=38524) or (tmp=65636) then
			Getspellchar= "D1"
		elseif(tmp>=46931 and tmp<=47009) or (tmp>=46827 and tmp<=46842) or (tmp=65605) or (tmp=65637) or (tmp=61513) then '46827 46833 46842
			Getspellchar= "E1"
		elseif(tmp>=47010 and tmp<=47296) or (tmp=65606) or (tmp=65638) or (tmp=61320) or (tmp=63568) or (tmp=36281) then
			Getspellchar= "F1"
		elseif(tmp>=47297 and tmp<=47613) or (tmp=65607) or (tmp=65639) or (tmp=35949) or (tmp=36089) or (tmp=36694) or (tmp=34808) then
			Getspellchar= "G1"
		elseif(tmp>=47614 and tmp<=48118) or (tmp=59112) or (tmp=40296) or (tmp=65608) or (tmp=65640) then
			Getspellchar= "H1"
		elseif(tmp=65641) or (tmp=65609) or (tmp=65641) then
			Getspellchar= "I1"
		elseif(tmp>=48119 and tmp<=49061 and tmp<>48739) or (tmp>=62430 and tmp<=62430) or (tmp=65610) or (tmp=65642) or (tmp=39048) then
			Getspellchar= "J1"
		elseif(tmp>=49062 and tmp<=49323) or (tmp=65611) or (tmp=65643) then
			Getspellchar= "K1"
		elseif(tmp>=49324 and tmp<=49895) or (tmp>=58838 and tmp<=58838) or (tmp=65612) or (tmp=65644) or (tmp=62418) or (tmp=48739) then
			Getspellchar= "L1"
		elseif(tmp>=49896 and tmp<=50370) or (tmp=63432) or (tmp=65613) or (tmp=65645) then
			Getspellchar= "M1"
		elseif(tmp>=50371 and tmp<=50613) or (tmp=65614) or (tmp=65646) then
			Getspellchar= "N1"
		elseif(tmp>=50614 and tmp<=50621) or (tmp=65615) or (tmp=65615) or (tmp=65647) then
			Getspellchar= "O1"
		elseif(tmp>=50622 and tmp<=50905) or (tmp=65616) or (tmp=65648) then
			Getspellchar= "P1"
		elseif(tmp>=50906 and tmp<=51386) or (tmp>=62659 and tmp<=63172) or (tmp=63464) or (tmp=63226) or (tmp=65617) or (tmp=65649) then
			Getspellchar= "Q1"
		elseif(tmp>=51387 and tmp<=51445) or (tmp=65618) or (tmp=65650) then
			Getspellchar= "R1"
		elseif(tmp>=51446 and tmp<=52217) or (tmp=65619) or (tmp=65651) or (tmp=34009) then
			Getspellchar= "S1"
		elseif(tmp>=52218 and tmp<=52697) or (tmp=65620) or (tmp=65652) then
			Getspellchar= "T1"
		elseif(tmp=65621) or (tmp=65653) then
			Getspellchar= "U1"
		elseif(tmp=65622) or (tmp=65654) then
			Getspellchar= "V1"
		elseif(tmp>=52698 and tmp<=52979) or (tmp=65623) or (tmp=65655) then
			Getspellchar= "W1"
		elseif(tmp>=52980 and tmp<=53688) or (tmp=63182) or (tmp=65624) or (tmp=65656) then
			Getspellchar= "X1"
		elseif(tmp>=53689 and tmp<=54480) or (tmp=65625) or (tmp=65657) then
			Getspellchar= "Y1"
		elseif(tmp>=54481 and tmp<=62383 and tmp<>59112 and tmp<>58838 and tmp<>57566) or (tmp=65626) or (tmp=65658) or (tmp=38395) or (tmp=39783) then
			Getspellchar= "Z1"
		end if
		if(tmp>=65601 and tmp<=65658) then Getspellchar= UCase(left(Trim(str),1))	'字母
		if(tmp>=65584 and tmp<=65593) then Getspellchar= "123"	'数字
		'Response.Write(tmp)
	End function
	'相关下载资源
	'参数：Keys,cutNum
	'for 标准版 and 高级版
	Public Function MutualityDownRes(Keys, topNum, ID)
		Dim tRs, s
		If topNum = 0 Then
			Set tRs = Execute("Select ID,ResName,ResVer From ishion_Down_Resource where (ResName like '%" & Keys & "%') And ID<>" & ID & " and isAuditing=1 order by ID Desc")
		Else
			Set tRs = Execute("Select top " & topNum & " ID,ResName,ResVer From ishion_Down_Resource where (ResName like '%" & Keys & "%') And ID<>" & ID & " and isAuditing=1 order by ID Desc")
		End If
		If tRs.EOF And tRs.BOF Then
			s = ""
		Else
			dim arrA,arrB,i
			i = 1
			Do While Not tRs.EOF
			If i = 1 then
				arrA = tRs(0)
				arrB = tRs(1) & " " & tRs(2)
			Else
				arrA = arrA & "," & tRs(0)
				arrB = arrB & ",," & tRs(1) & " " & tRs(2)
			End If 
			i = i + 1
			tRs.MoveNext
			Loop
			s = arrA & "|||" & arrB
		End If
		Set tRs = Nothing
		MutualityDownRes = s
		s = Null
	End Function
'========================================
class ishionGather
':模拟XML获取http标记资源（用过之后就知道为什么XML有用：））
'利用引擎搜索(显示引擎信息或其超连接网站上的信息或直接一个指定页面的相关信息，利用正则和xmlHttp,
'程序的使用需要会构造正则)
'---------------------------------------------------------------
private oReg,oxmlHttp,tempReg'一个正则，一个微软xmlhttp
'---------------------------------------------------------------
Public sub class_initialize()'对象建立触发
	set oReg=new regExp
	oReg.Global=true
	oReg.IgnoreCase=true '不区分大小写	
End sub
'---------------------------------------------------------------
Public sub class_terminate()'对象销毁触发
	set oReg=nothing	'必须手动释放class内的自建对象，asp只自动释放由class定义的对象
	'If IsObject(tempReg) Then
	If typename(tempReg)<>"nothing" then	'方法体内的对象释放资源
		set tempReg=nothing
	end if
End sub
Public Function GetBody(url)
	GetBody=""
	set oXmlHttp = server.createobject("Microsoft.XmlHttp")
	With oXmlHttp 
	.Open "Get", url, False, "", ""
	on error resume next
	.Send()
	if err.number<>0 then exit function
	GetBody = BytesToBstr(.ResponseBody)
	End With 
	set oXmlHttp = nothing
End Function
'---------------------------------------------------------------
'引擎级搜索
'功能介绍：获得url的返回信息(通常用于引擎查找)，提取其中的EngineerReg的特定信息，返回matches集合到
'函数名。获得url查询结果,搜寻出用engineerReg正则定义的结果,生成一个matches集合,
'由于无法建立集合及操作集合个数（vbscript）,最好再自己遍历集合，也可以考虑二维数组
Public Function Engineer(url,EngineerReg)
	dim strConent
	strContent = GetBody(url)
	if isnull(EngineerReg) then
		Engineer=AbsoluteURL(strContent,url)
	else
		oReg.Pattern=EngineerReg
		set Engineer=oReg.Execute(strContent)
		'set Engineer=oReg.Execute(AbsoluteURL(strContent,url)) 
	end if
End Function
'---------------------------------------------------------------
'汉字编码
Public Function bytes2BSTR(vIn) 
	dim i,strReturn,ThisCharCode,NextCharCode
	strReturn = "" 
	For i = 1 To LenB(vIn) 
		ThisCharCode = AscB(MidB(vIn,i,1)) 
		If ThisCharCode < &H80 Then 
			strReturn = strReturn & Chr(ThisCharCode) 
		Else 
			NextCharCode = AscB(MidB(vIn,i+1,1)) 
			strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) 
			i = i + 1 
		End If
	Next 
	bytes2BSTR = strReturn
End Function
Public Function BytesToBstr(strContent)
	dim objstream
	set objstream = Server.CreateObject("adodb.stream")
	objstream.Type = 1
	objstream.Mode =3
	objstream.Open
	objstream.Write strContent
	objstream.Position = 0
	objstream.Type = 2
	objstream.Charset = "GB2312"
	BytesToBstr = objstream.ReadText
	objstream.Close
	set objstream = nothing
End function
'---------------------------------------------------------------
'替换，将strContent中的replaceReg描述的字符串用resultReg描述的替换，返回到searchReplace去
'将正则的replace封装了。
public Function SearchReplace(strContent,ReplaceReg,ResultReg)
	oReg.Pattern=ReplaceReg
	SearchReplace=oReg.replace(strContent,ResultReg)
End Function
'---------------------------------------------------------------
'将strContent中的相对URL变成oXmlHttp中指定的url的绝对地址(http/https/ftp/mailto:)
'正则可以修改修改。
Public Function AbsoluteURL(strContent,byval url)
	dim tempReg
	set tempReg=new RegExp
	tempReg.IgnoreCase=true
	tempReg.Global=true
	tempReg.Pattern="(^.*\/).*$"
	Url=tempReg.replace(url,"$1")
	tempReg.Pattern="((?:src|href).*?=[\'\u0022](?!ftp|http|https|mailto))"
	AbsoluteURL=tempReg.replace(strContent,"$1"+Url)
	set tempReg=nothing
end Function
'---------------------------------------------------------------
'字符中处理
'str 要处理的字符集
'start 开始字符集
'last 结束字符集
'参数
Public Function GetContent(str,start,last,n)
	If Instr(lcase(str),lcase(start))>0 then
		select case n
		case 0	'左右都截取（都取前面）（去处关键字）
		GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
		GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))-1)
		case 1	'左右都截取（都取前面）（保留关键字）
		GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
		GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))+Len(last)-1)
		case 2	'只往右截取（取前面的）（去除关键字）
		GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
		case 3	'只往右截取（取前面的）（包含关键字）
		GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
		case 4	'只往左截取（取后面的）（包含关键字）
		GetContent=Left(str,InstrRev(lcase(str),lcase(start))+Len(start)-1)
		case 5	'只往左截取（取后面的）（去除关键字）
		GetContent=Left(str,InstrRev(lcase(str),lcase(start))-1)
		case 6	'只往左截取（取前面的）（包含关键字）
		GetContent=Left(str,Instr(lcase(str),lcase(start))+Len(start)-1)
		case 7	'只往右截取（取后面的）（包含关键字）
		GetContent=Right(str,Len(str)-InstrRev(lcase(str),lcase(start))+1)
		case 8	'只往左截取（取前面的）（去除关键字）
		GetContent=Left(str,Instr(lcase(str),lcase(start))-1)
		case 9	'只往右截取（取后面的）（包含关键字）
		GetContent=Right(str,Len(str)-InstrRev(lcase(str),lcase(start)))
		end select
	Else
		GetContent=""
	End if
End function
'去除超级链接标签
Public Function dellink(str)
	oReg.Pattern = "(<a\b.*?>)([\S\s]*?)(</a>)"
	dellink = oReg.Replace(str,"$2")
End Function
'最近更新列表
Public Function skycn_getpage(str)
	skycn_getpage = GetContent(str,"<b>找到</b>：<font color=red>","</font>",0)
	If (cint(skycn_getpage) mod 20) > 0 then
	 	skycn_getpage = skycn_getpage \ 20 + 1
	Else
		skycn_getpage = skycn_getpage \ 20
	End if
End Function
Public Function skycn_smallurl(str,strReg)
	skycn_smallurl = GetContent(str,split(strReg,"[!--string--]")(0),split(strReg,"[!--string--]")(1),0)	
	oReg.Pattern = "(<A.*)(soft/)(\d+)(.*><b>)(.*)(</b></A>)"
	skycn_smallurl = oReg.Replace(skycn_smallurl,"ID：$3 <input type=""checkbox"" name=""skycnid"" value=""$3"" checked><b>$5</b>")
	skycn_smallurl = dellink(skycn_smallurl)
End Function
'软件信息内容
Public Function skycn_soft(str,strReg)
	skycn_soft = GetContent(str,split(strReg,"[!--string--]")(0),split(strReg,"[!--string--]")(1),0)
End Function

End class
sub s1()
'URL一定是包含文件扩展名的完整地址,结果是集合，集合中的每个项目是数组,应该这样引用子查询:myMatches(0).subMatches(0)
set myMatches=myGather.engineer("http://www.skycn.com/new/00.html","soft/\d(.*).html")
if myMatches.count=0 Then
	response.write "没有你正则的字符串"
end if
if myMatches.count>0 then
	'response.write myMatches.count&"<br>"
for each key in myMatches
response.write key.firstindex&":"&cstr(key.value)&"<br>"
next
end if
end sub

 %>
</body>
</html>

