<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/collectfunc.asp" -->
<%
'获得大类
dim first,classid,catalogcache
classid=Cint(request("classid"))
dim i
set rs=server.CreateObject("adodb.recordset")
sql="select id,title from catalogs where parentid="&classid&" order by id asc"
rs.open sql,conn,3,1
if not rs.eof then
	first=rs.GetRows()
	if(ubound(first,2)<0) then
	response.Write("暂时没有分类")
	end if
else
	response.Write("暂时没有分类,请先添加分类!")
	response.End()
end if
rs.close
set rs=nothing
Function getcatalogs(parentid,str)
	Dim Sql,rstemp,TemptempStr,tempStr	
	tempStr=str&"&nbsp;"
	sql="select id,title from catalogs where parentid="&parentid
	Set rstemp = Conn.Execute(Sql)
	do while Not rstemp.Eof
		getcatalogs = getcatalogs &"<option value="&rstemp(0)&">│"&tempStr&"└"&rstemp(1)&"</option>"&Chr(10)
		getcatalogs = getcatalogs & getcatalogs(rstemp(0),tempStr)
		rstemp.MoveNext
	loop
	rstemp.close
	Set rstemp = Nothing
End Function
Function getcatalogoption()
	dim ret
	ret=""
	for i=0 to ubound(first,2)
		ret=ret&"<option value="&first(0,i)&">├"&first(1,i)&"</option>"&Chr(10)
    	ret=ret&getcatalogs(first(0,i),"")
	next
	getcatalogoption=ret
end Function
function getIndustryOptions(cid)
	dim rs,sql,first,ifselect,i
	set rs=server.CreateObject("adodb.recordset")
	sql="select id,title from catalogs where parentid="&PlugIn_InfoId&" order by id asc"
	rs.open sql,conn,3,1
	if not rs.eof then
		first=rs.GetRows()
	else
		
	end if
	rs.close
	set rs=nothing
	if(isarray(first)) then
  	for i=0 to ubound(first,2)
			if(first(0,i)=cid) then
				ifselect=" selected"
			else
				ifselect=""
			end if
			response.Write("<option value="&first(0,i)&" "&ifselect&">"&first(1,i)&"</option>"&Chr(10))	    	
		next	
	end if
end function

dim act
act=request.QueryString("act")
if(act="do") then
	dim c_str,is_debug
	is_debug=true
	dim f_url,f_charset,f_list_start,f_list_end,f_title_start,f_title_end,f_url_start,f_url_end,f_qq_start,f_qq_end,f_msn_start,f_msn_end,f_desc_start,f_desc_end,IndustryId
	f_url=request.Form("f_url")
	f_charset=request.Form("f_charset")	
	f_list_start=request.Form("f_list_start")
	f_list_end=request.Form("f_list_end")
	f_title_start=request.Form("f_title_start")
	f_title_end=request.Form("f_title_end")
	f_url_start=request.Form("f_url_start")
	f_url_end=request.Form("f_url_end")
	f_qq_start=request.Form("f_qq_start")
	f_qq_end=request.Form("f_qq_end")
	f_msn_start=request.Form("f_msn_start")
	f_msn_end=request.Form("f_msn_end")
	f_desc_start=request.Form("f_desc_start")
	f_desc_end=request.Form("f_desc_end")
	IndustryId=Cint(request.Form("IndustryId"))
	TaskName=request.form("TaskName")
	set rs=server.CreateObject("adodb.recordset") 
	rs.open "select * from t_info_gather where 1=1",conn,3,3
	rs.addnew
	rs("TaskName")=TaskName
	rs("f_url")=f_url
	rs("f_charset")=f_charset
	rs("IndustryId")=IndustryId
	rs("f_list_start")=f_list_start
	rs("f_list_end")=f_list_end
	rs("f_title_start")=f_title_start
	rs("f_title_end")=f_title_end
	rs("f_url_start")=f_url_start
	rs("f_url_end")=f_url_end
	rs("f_qq_start")=f_qq_start
	rs("f_qq_end")=f_qq_end
	rs("f_msn_start")=f_msn_start
	rs("f_msn_end")=f_msn_end
	rs("f_desc_start")=f_desc_start
	rs("f_desc_end")=f_desc_end
	rs.update
	rs.close
	set rs=nothing
	set rs=server.CreateObject("adodb.recordset") 
	dim lastid
	rs.open "select top 1 id from t_info_gather order by id desc",conn,3,1
	if not rs.eof then
		lastid=rs(0)
	else
		lastid=1
	end if
	rs.close
	set rs=nothing
	response.write("<p align=""center"">成功添加信息采集!</p><p align=""center""><a href=""info_gather_manage.asp"">返回管理</a></p>")
	response.Redirect("info_gather_mod.asp?id="&lastid)
else

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.pformleft {padding:3px; line-height:20px;}
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" name="form1" method="post" action="?act=do">
  <table width="89%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="26" colspan="2" bgcolor="#BAC5D9"><div align="center" class="style1">添加分类信息采集</div></td>
    </tr>
    <tr>
      <td width="23%" height="32">任务名称：</td>
      <td width="77%"><input name="TaskName" type="text" id="TaskName" /></td>
    </tr>
    <tr>
      <td height="32">采集地址：</td>
      <td><input name="f_url" type="text" id="f_url" /></td>
    </tr>
    <tr>
      <td height="32">编码：</td>
      <td><input name="f_charset" type="text" id="f_charset" value="gb2312" />
        gb2312,utf-8</td>
    </tr>
    <tr>
      <td height="32">采集到分类：</td>
      <td><span class="pformleft">
        <select name="IndustryId" >
          <%
	catalogcache=application(CachePrefix&"_catalogoption_"&classid)
	if(catalogcache="" or isempty(catalogcache) or len(catalogcache)<1) then
  		application.Lock()
		application(CachePrefix&"_catalogoption_"&classid)=getcatalogoption()
		application.UnLock()
		response.Write(application(CachePrefix&"_catalogoption_"&classid))
	else
		response.Write(catalogcache)
	end if
	%>
        </select>
      </span></td>
    </tr>
    <tr>
      <td colspan="2"><hr /></td>
    </tr>
    <tr>
      <td colspan="2"><div align="center">
        <input type="submit" name="Submit" value="添加采集" />
        <input type="reset" name="Submit2" value="重  写" />
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>

<%
end if
call connclose()
%>