<?php
require_once("../global/checkuser2.php");
?>
<!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=utf-8" />
<title>收件箱</title>
<link href="index.css" rel="stylesheet" />
<script> 
          var checkall=document.getElementsByName("ggid[]");  
           function selectall(){                          //全选  
                for(var $i=0;$i<checkall.length;$i++){  
                    checkall[$i].checked=true;  
                }  
            }  
            function fanselect(){                        //反选  
                for(var $i=0;$i<checkall.length;$i++){  
                   if(checkall[$i].checked){  
                       checkall[$i].checked=false;  
                   }else{  
                        checkall[$i].checked=true;  
                    }  
                }  
           }           
         function noselect(){                          //全不选  
               for(var $i=0;$i<checkall.length;$i++){  
                    checkall[$i].checked=false;  
              }  
          }   
 function check(){
		  for(var $i=0;$i<checkall.length;$i++){  
                    if(checkall[$i].checked==true){
					   return true;
					}
                }  
			alert("请先选择要删除的公告");
			 return false;
		  }        
 </script>
</head>

<body>
<div class="bigdiv">
<table cellspacing="0" cellpadding="0" style="font-size:14px;"><tr><td style="text-align:left;border-left:none;">您的位置：邮件系统/<a href="gonggao.php">系统公告</a></td><td style="border-left:none;text-align:right;" class="g"><a href="ggadd.php">发布公告</a>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>
<div style="float:left;width:100%;border-bottom:2px solid #337abb;height:25px;font-size:14px;line-height:25px;"><ul>
<li style="float:left;width:100px;text-align:center;border:2px solid #337abb;border-top:1px solid #337abb;border-bottom:none;background:#337abb;margin-left:20px;display:inline;"><a style="color:#FFF;" href="gonggao.php">系统公告</a></li>
</ul></div>
<div class="list">
<form action='function.php?mod=deleteggs' method='post' onsubmit="return check()">
<table cellspacing="0" cellpadding="0"><tr style="background:#d3edf9;"><td style="width:4%;border-left:none;">&nbsp;</td><td style="width:8%;">发布人</td><td style="width:58%;">标题</td><td style="width:13%;">日期</td><td style="width:8%" class="g">操作</td></tr></table>
<table cellspacing="0" cellpadding="0">
<?php
ob_start();
require_once("../global/page.class.php");
require_once("../global/connect.php");
$pageSize=15;
$total=mysql_num_rows(mysql_query("SELECT * FROM gonggao")); 
pageft($total,$pageSize,1,1,1,9,20,0);
$sql="SELECT * FROM  gonggao order by id DESC limit $firstcount,$pageSize";
$sql=mysql_query($sql);
if($sql){ob_end_clean();
while($row=mysql_fetch_array($sql)){
$id=$row['id'];
$content=str_replace(" ","",strip_tags($row['content']));
$content=utf8Substr($content,0,30);
echo "<tr><td style='width:4%;border-left:none;'><input type='checkbox' name='ggid[]' value='$id'></td><td style='width:8%;'>".$row['send']."</td><td style='width:58%;text-align:left;'>&nbsp;<a href='showgg.php?id=$id'>".$row['title']."<font style='color:#666666;fontsize:12px;'>&nbsp;--&nbsp;$content</font></a></td><td style='width:13%;'>".$row['date']."</td><td style='width:8%;' class='g'><a href='function.php?id=$id&mod=deletegg'>[删除]</a></td></tr>";
}}else
echo "<tr><td style='width:100%;color:red;border-left:none;text-align:center;'>暂时没有记录!</td></tr>";
ob_end_flush();
//字符串截取
function utf8Substr($str, $from, $len) 
{ 
return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. 
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', 
'$1',$str); 
} 
?>
</table>
<div>&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' value="全选" onclick="selectall()"/><input type="button" value="反选" onclick="fanselect()"/><input type="button" value="全不选" onclick="noselect()"/><input type="submit" value="批量删除"/>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $pagenav;?></div></form>
</div>
</div>
</body>
</html>
