<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p02")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<html>
<head>
<title>搜索新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="../admin/cs.css" rel="stylesheet" type="text/css">
<script language="javascript">
function goto(frm)
{
	var gourl ="news_search.asp?act=search&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}</script>
<script language="JavaScript" type="text/JavaScript">

function ConfirmDel()
{
   if(confirm("确认删除？，并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,i,title,topn,searchSql
act=trim(request.QueryString("act"))
if(act="search") then
	searchType=Cint(request.Form("searchType"))
	
	if not isempty(request("perpage")) then 
		recpage=cint(request("perpage"))
	else recpage=10
	end if
	if not isempty(request("page")) then 
		currentpage=request("page")
	else currentpage=1
	end if
	if(request.Form("title")<>"") then
		title=trim(request("title"))
	else
		response.Write("<script>alert(""搜索关键字不能为空!"");history.back();</script>")
		response.End()
	end if
	if not isempty(request("topn")) then 
		topn=Clng(request("topn"))
	else topn=10
	end if
%>
<form name="form2" method="post" action="news_search.asp?act=search">
<table width="100%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td height="22" colspan="2" bgcolor="#FF9900"><div align="center"><span class="style1">◆ 新闻搜索 ◆</span></div></td>
  </tr>
  <tr>
    <td width="50%" height="22" bgcolor="#FFFFFF"><div align="right">关键字：</div></td>
    <td width="50%" bgcolor="#FFFFFF"><div align="left">
      <input name="title" type="text" id="title3" size="30" maxlength="50" value="<%=title%>">
    </div></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">按：</div></td>
    <td bgcolor="#FFFFFF"><select name="searchType" id="searchType">
      <option value="0" <%if(request("searchType")=1) then response.Write("selected")%>>ID</option>
      <option value="1" <%if(request("searchType")=1) then response.Write("selected")%>>标题</option>
      <option value="2" <%if(request("searchType")=2) then response.Write("selected")%>>作者</option>
      <option value="3" <%if(request("searchType")=3) then response.Write("selected")%>>来源</option>
      <option value="4" <%if(request("searchType")=4) then response.Write("selected")%>>内容</option>
    </select></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">每页显示条数：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="perpage" type="text" id="perpage3" size="5" maxlength="5" value="<%=recpage%>">
    </div></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">取前几条：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="topn" type="text" id="topn4" size="5" maxlength="5" value="<%=topn%>">
    </div></td>
  </tr>
  <tr>
    <td height="22" colspan="2" bgcolor="#FFFFFF">      
        <div align="center">&nbsp;&nbsp;      &nbsp;&nbsp;
        <input type="submit" name="Submit" value="开始搜索" style="font-size:12px; ">
        </div>      
    </td>
  </tr>
</table></form>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="6" bgcolor="#FF9900"><div align="center" class="style1">◆ 搜索列表 ◆</div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="7%" height="22" bgcolor="#EEEEEE"><div align="center">id</div></td>
    <td width="59%" bgcolor="#EEEEEE"><div align="center">标题</div></td>
    <td width="11%" bgcolor="#EEEEEE"><div align="center">添加时间</div></td>
    <td width="9%" bgcolor="#EEEEEE"><div align="center">查看</div></td>
    <td width="6%" bgcolor="#EEEEEE"><div align="center">修改</div></td>
    <td width="6%" bgcolor="#EEEEEE"><div align="center">删除</div></td>
  </tr>
  <!-- 开始按行循环----------------------->
  <%
  		set rs=server.createobject("adodb.recordset")
		searchSql="select top "&topn&" id,title,moditime,pagepath,classid from news where "
		select case searchType
			case 0
				searchSql=searchSql&"id="&title
			case 1
				searchSql=searchSql&"title like '%"&title&"%'"
			case 2
				searchSql=searchSql&"author like '%"&title&"%'"
			case 3
				searchSql=searchSql&"news_from like '%"&title&"%'"
			case 4
				searchSql=searchSql&"content like '%"&title&"%'"
			case else
				searchSql=searchSql&"title like '%"&title&"%'"
		end select
  		rs.open searchSql,conn,3,1
		allrec=rs.recordcount
		totalpage=int((allrec+recpage-1)/recpage)		
		if(currentpage>1) then
			rs.move(currentpage-1)*recpage
		end if
		do while not rs.eof
		'classname=conn.execute("select title from catalogs where id="&rs("classid"))(0)
	%>
  <tr>
    <td height="20" bgcolor="#FFFFFF"><div align="center"><%=rs("id")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("title")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><%=rs("moditime")%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="<%=SiteUrl&"/"&rs("pagepath")%>" target="_blank">查看</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="news_modi.asp?id=<%=rs("id")%>&classid=<%=rs("classid")%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs("id")%>&table=news" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  
  <%
    rs.movenext
	  i=i+1
	   if i>=recpage then 
		exit do
	   end if
	  loop
	 ' end sub
	  rs.close
	  set rs=nothing
  %>
  <tr>
    <td height="22" colspan="6" bgcolor="#FFFFFF"><div align="center"><form name="form1" method="post" action="" style="margin:0 0 0 0">
          <%n=currentpage+1
p=currentpage-1
if p>0then
response.write("["&"<a href='news_search.asp?act=search&title="&title&"&perpage="&recpage&"&topn="&topn&"&page="&cstr(p)&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
else response.write("上一页&nbsp;&nbsp;&nbsp;")
end if 
if (n-1)*recpage>=allrec then 
response.write("下一页" )
else
response.Write("["&"<a href='news_search.asp?act=search&title="&title&"&perpage="&recpage&"&topn="&topn&"&page="&cstr(n)&"'>下一页</a>]")
end if
response.write("&nbsp;共"&allrec&"条&nbsp;")
response.Write("&nbsp;共"&totalpage&"页&nbsp;")
response.Write("&nbsp;第"&currentpage&"页&nbsp;")
%>
          <input type="hidden" name="hid" value="<%=totalpage%>">
		  <input type="hidden" name="title" value="<%=title%>">
		  <input type="hidden" name="perpage" value="<%=recpage%>">
		  <input type="hidden" name="topn" value="<%=topn%>">
&nbsp;&nbsp;
    </form></div></td>
  </tr>
  <!--按行循环结束------------------------>
</table>
<%
else
%>
<form name="form2" method="post" action="news_search.asp?act=search">
<table width="100%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td height="22" colspan="2" bgcolor="#FF9900"><div align="center"><span class="style1">◆ 新闻搜索 ◆</span></div></td>
  </tr>
  <tr>
    <td width="50%" height="22" bgcolor="#FFFFFF"><div align="right">关键字：</div></td>
    <td width="50%" bgcolor="#FFFFFF"><div align="left">
      <input name="title" type="text" id="title" size="30" maxlength="50">
    </div></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">按：</div></td>
    <td bgcolor="#FFFFFF"><select name="searchType" id="searchType">
      <option value="0">ID</option>
      <option value="1" selected>标题</option>
      <option value="2">作者</option>
      <option value="3">来源</option>
      <option value="4">内容</option>
    </select></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">每页显示条数：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="perpage" type="text" id="perpage" value="10" size="5" maxlength="5">
    </div></td>
  </tr>
  <tr>
    <td height="22" bgcolor="#FFFFFF"><div align="right">取前几条：</div></td>
    <td bgcolor="#FFFFFF"><div align="left">
      <input name="topn" type="text" id="topn" value="50" size="5" maxlength="5">
    </div></td>
  </tr>
  <tr>
    <td height="22" colspan="2" bgcolor="#FFFFFF">
      
        <div align="center">&nbsp;&nbsp;      &nbsp;&nbsp;
        <input type="submit" name="Submit" value="开始搜索" style="font-size:12px; ">
        </div>
     
    </td>
  </tr>
</table>
</form>
<%end if%>
</body>
</html>
<%
call connclose()
%>
