<?php
include("qs.php");
require( '../data/config.php');
$conn=mysql_connect($db_host,$db_user,$db_pass);
mysql_query("set names 'utf8'");
mysql_select_db($db_name);
if (PHP_VERSION >= '5.1' && !empty($timezone))
{
    date_default_timezone_set($timezone);
}
?>
<!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" />
<LINK href="images/index.css" type=text/css rel=stylesheet />
</head>
<body>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 
            CALLPADDING="0">
              <TBODY>
			                <TR BORDER="0" WIDTH="100%">
                <TD style="PADDING-LEFT: 8px; PADDING-TOP: 8px" vAlign=top 
                align=left bgColor=#ffffff height=30 colspan="8">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="34%" height="20"><img src="images/url_01.gif" width="7" height="10" />&nbsp;<strong>文章列表</strong></td>
                    <td height="20"><div align="right"><a href="art_w.php">添加</a>&nbsp;&nbsp;</div></td>
                  </tr>
                </table>				 </TD>
              </TR>
<form id="form1" name="form1" method="post" action="serch.php" onsubmit="return checkform(this);">
<TR BORDER="0" WIDTH="100%">
                <TD style="PADDING-LEFT: 8px; PADDING-TOP: 8px" vAlign=top 
                align=left bgColor=#ffffff height=30 colspan="8">请输入搜索标题:
                <input name="title" type="text" id="title" />
                <span class="help">
                <input type="submit" name="dosubmit" value="搜索" class="btn">
                </span></TD>
</TR>
</form>	
		  <form id="form2" name="form2" method="post" action="art_w.php">
			  <tr>
                    <td height="20" bgcolor="#999999" style="PADDING-LEFT: 8px; PADDING-TOP: 8px"><input type="checkbox" name="selall" title="全选"  onClick="select_all('form2','ChkKindId[]',this.name)">&nbsp;</td>
                    <td width="40%" bgcolor="#999999" style="PADDING-LEFT: 8px; PADDING-TOP: 8px"><span class="STYLE1">名称</span></td>
                <td width="9%" bgcolor="#999999" class="STYLE1"><div align="center">所属栏目</div></td>
                    <td width="11%" bgcolor="#999999" class="STYLE1"><div align="center">发布日期</div></td>
                    <td bgcolor="#999999"><div align="center" class="STYLE1">点击量</div></td>
                    <td bgcolor="#999999"><div align="center"><span class="STYLE1">是否</span>推荐</div></td>
                    <td bgcolor="#999999"><div align="center"><span class="STYLE1">是否</span>审核</div></td>
                    <td bgcolor="#999999"><div align="center">操作</div></td>
			  </tr>
				<?php 
$sql="select count(*) from news_art";
$resultc=mysql_query($sql) or die(mysql_error());
$rsc=mysql_fetch_array($resultc);
$num=$rsc[0];
$pagesize=10; 
if(_get('page')<>"")
   {
   $page=_get('page')-1;
   if($page<0)$page=0;
   if($page>(intval($num/$pagesize)))$page=intval($num/$pagesize);
   }
else
	$page=0;
		  $sql="select * from news_art order by id desc limit ".$pagesize*$page.",".$pagesize;
		  $rsql=mysql_query($sql);
		  while($rs=mysql_fetch_object($rsql))
		  {
		  ?>
              <TR BORDER="0" WIDTH="100%" bgcolor="#EEEEEE" onmousemove="this.style.color='#000000';this.style.backgroundColor='#D5D5D5'" onmouseout="this.style.backgroundColor='#EEEEEE';this.style.color='#000000'">
                <TD width="6%"  height=20 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;"><input name="ChkKindId[]" type="checkbox" id="ChkKindId[]" value="<?php echo $rs->id;?>"  /></TD>
                <TD  height=20 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px; border-bottom:#666666 dotted 1px;">
                <?php if(strlen($rs->title)>50) echo mb_substr($rs->title,0,25,"gb2312")."…"; else echo $rs->title;?></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;">
                  
                  <div align="center"><?php echo $class[$rs->aid];?>				  </div></TD>
                <TD 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->date;?>
                </div></TD>
                <TD width="7%" 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php echo $rs->rq;?>
                </div></TD>
                <TD width="6%" 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;">
                  <div align="center">
                    <?php if($rs->tj==1) echo "<font color=red>是</font>"; else echo "<font color=#006600>否</font>";?>
                </div></TD>
                <TD width="6%" 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center">
                  <?php if($rs->show1==1) echo "<font color=red>是</font>"; else echo "<font color=#006600>否</font>";?>
                </div></TD>
                <TD width="15%" 
                align=left vAlign=top style="PADDING-LEFT: 8px; PADDING-TOP: 8px;border-bottom:#666666 dotted 1px;"><div align="center"><a href="art_w.php?id=<?php echo $rs->id;?>">更改</a> <a href="../../html/<?php echo ereg_replace('-',"",$rs->date);?>/<?php echo ereg_replace('-',"",$rs->date).$rs->id.".html";?>" target="_blank">查看</a> </div></TD>
              </TR>
		  <?php }?>
			<TR BORDER="0" WIDTH="100%">
              <TD height="30"  colspan="8">&nbsp;&nbsp;
                <input type="image" src="images/del.gif" align="absmiddle" border="0" name="del" onclick="javascript:return chkform(form2.name,'确定刪除吗？','del');" />
		                      <input type="image" src="images/tj.gif" align="absmiddle" border="0" name="tj" onclick="javascript:return chkform(form2.name,'確定推荐吗？','tj');" />
&nbsp;
<input type="image" src="images/utj.gif" align="absmiddle" border="0" name="utj" onclick="javascript:return chkform(form2.name,'確定取消推荐吗？','utj');" />
&nbsp;
<input type="image" src="images/butsh.gif" align="absmiddle" border="0" name="sh" onclick="javascript:return chkform(form2.name,'確定通过审核吗？','sh');" />
&nbsp;
<input type="image" src="images/butush.gif" align="absmiddle" border="0" name="ush" onclick="javascript:return chkform(form2.name,'確定取消审核吗？','ush');" />
<input name="action" type="hidden" id="action" /></TD>
			</TR>
		  </form>
<TR BORDER="0" WIDTH="100%">
			  <TD height="30"  colspan="8">
			  <div class="page">
		  共<?php echo ceil($num/$pagesize);?>页
	      <a href="art.php?page=1">首页</a><?php if($page>0) echo " <a href='art.php?page=".$page."'>上一页</a> ";
for($i=($page>4?($page-3):1);$i<=($page<(ceil($num/$pagesize)-4)?(($page>=5?($page-3):1)+8):ceil($num/$pagesize));$i++)
    {
	if(($page+1)==($i))
	echo "&nbsp;".$i."&nbsp;";
	else
	echo "<a href=art.php?page=".$i.">[".($i)."]</a>";
	}
	?><?php if($page<ceil($num/$pagesize)-1) echo " <a href='art.php?page=".($page+2)."'>下一页</a> ";?><a href="art.php?page=<?php echo round(ceil($num/$pagesize));?>">末页</a>		  </div>			  </TD>
			  </TR>
      </TABLE>
</body>
</html>
<script language="JavaScript" >

function chkform(theForm,msg,action){
	if (confirm(msg)){

		document.forms[theForm].action.value = action;
		document.forms[theForm].submit();
		return true;
	}else{
		return false;
	}
}

// -------- 全選或取消 checkbox 方塊
<!--
function select_all(formName, elementName, selectAllName) {
	if(document.forms[formName].elements[selectAllName].checked) {
		
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
		
			document.forms[formName].elements[elementName].checked = true;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
			document.forms[formName].elements[elementName][i].checked = true;
		}
	}
	else {
		if(document.forms[formName].elements[selectAllName].length = 1 &&
		    typeof(document.forms[formName].elements[elementName]) != "undefined" ) {
			document.forms[formName].elements[elementName].checked = false;

		    for(var i = 0; i < document.forms[formName].elements[elementName].length; i++)
				document.forms[formName].elements[elementName][i].checked = false;
		}
	}
}
//-->

</script>
<script language="javascript">
function checkform(theform)
{
if(theform.title.value=="")
  {
  alert("搜索标题不能为空！");
  theform.title.focus();
  return false;
  }
if(theform.title.value.length < 5)
  {
  alert("为了提高搜索性能,请精确查找");
  theform.title.focus();
  return false;
  }
return true;
}
</script>