<%
Response.Buffer = True 
Server.ScriptTimeOut=999999
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1 
Response.Expires = 0 
Response.CacheControl = "no-cache"
%>
<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p05")
'''''''''''''''''''''''''''''''''''''''''''''''
dim starts,id,sendSql,countSql,percentNum,isChannel
if not isempty(request("id")) then
	id=Clng(request("id"))
else
	id=1
end if

if not isempty(request("start")) then
	starts=Clng(request("start"))
else
	starts=0
end if
if(application("TOT_Reset_Robot")="") then
	application.Lock()
	application("TOT_Reset_Robot")=0
	application.UnLock()
end if
if(application("TOT_Reset_Total")="") then
	application.Lock()
	application("TOT_Reset_Total")=0
	application.UnLock()
end if
if(starts=1) then
	application.Lock()
	application("TOT_Reset_Robot")=0
	application.UnLock()
end if
sendSql="select top 1 id,flag from catalogs where id>"&id
countSql="select count(*) from catalogs where 1=1"
application.Lock()
application("TOT_Reset_Total")=conn.execute(countSql)(0)
application.UnLock()
sendSql=sendSql&" order by id asc"

set rs=server.createobject("adodb.recordset")
rs.open sendSql,conn,3,1
if not rs.eof and not rs.bof then
	id=rs("id")
	isChannel=Cint(rs("flag"))	
	application.Lock()
	application("TOT_Reset_Robot")=application("TOT_Reset_Robot")+1
	application.UnLock()
else
	response.Write("发布完成！共发布"&application("TOT_Reset_Total")&"条栏目页面")
	response.Write("<p><a href=""send.asp"">返回</a></p>")
	application("TOT_Reset_Robot")=""
	application("TOT_Reset_Total")=""
	'application.Contents.removeall
	response.End()
end if
rs.close
set rs=nothing
call connclose()
percentNum=Cint((application("TOT_Reset_Robot")*100)/application("TOT_Reset_Total"))
%>
<style type="text/css">
<!--
.style1 {color: #000000}
body{font-size:12px;}
-->
</style>
<div align="center"><table width="400" height="20" border="1" cellpadding="0" cellspacing="0" bordercolor="#D4D0C8" bgcolor="#FFFFFF">
  <tr>
    <td>
      <table id="stat_w" width="1%"  border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#003399">
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table>
      <span class="style1" id="P_num"></span></td>
  </tr>
</table>
<Br>正在发布新闻，共<%=application("TOT_Reset_Total")%>条&nbsp;&nbsp;第<%=application("TOT_Reset_Robot")%>条</div>
<script type="text/javascript" language="javascript">
var HTTP;
function CallServer(Url)
{
	HTTP = new ActiveXObject("Microsoft.XMLHTTP");
	HTTP.onreadystatechange = doAction;
	var ReturnValue=HTTP.open("POST", Url, false);
	HTTP.send("");
	return HTTP.responseText;
}
function doAction() {		
        if (HTTP.readyState == 4) // 收到完整的服务器响应
		{
			if (HTTP.status == 500) {//服务器错误				
				document.write("服务器出现内部错误。");				

            }
            else if (HTTP.status == 200) {//HTTP服务器响应的值OK
				//document.write(HTTP.responseText);//将服务器返回的字符串写到页面中ID为message的区域
				document.write("id:"+<%=id%>+"<br>");
				document.write('<meta http-equiv="refresh" content="0;URL=send_all.asp?id=<%=id%>">');
				document.getElementById('stat_w').width ="<%=percentNum%>%";
				document.getElementById('P_num').innerHTML ="<%=percentNum%>%";
            } 
			else {
                alert(HTTP.status);
            }
        }
}
function resetHtml()
{
	var ReturnValue;	
	ReturnValue=CallServer('send_list.asp?classid=<%=id%>&flag=<%=isChannel%>');
	document.write(ReturnValue);
}
resetHtml();
</script>
<p align="center"><a href="#">系统运行中...</a></p>
