<%@ page contentType="text/html;charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="conn.jsp"%>
<%
String showmas="n";//showmas="y"时可在首页中填写留言,showmas="n"不可在首页中填写留言
String test="n";//test="y"时留言通过审核后才可以显示,test="n"时留言可以直接显示
password="admin";//管理员密码
String mm=null;mm=(String)session.getAttribute("pass");
int i=0,x=0;//计数器
int showrow=8;//每页显示条数
int pages=0;//当前页数
int start; //本页开始条数
String sql="";
if(test.equals("n")||password.equals(mm)){
sql="select * from scott.lyb order by id desc";
}else{
sql="select * from scott.lyb where test='y' order by id desc";
}
ResultSet rs=stmt.executeQuery(sql);
String strp=(String)request.getParameter("pages");
int sig=1,alt;
if(strp==null){sig=1;}else{
for(int i1=0;i1<strp.length();i1++){
alt=strp.charAt(i1);
if(alt<48||alt>57){
sig=1;break;
}else{ sig=2;}
}
}
if(sig==1){pages=1;}else{pages=Integer.parseInt(strp);}
rs.last();
int count=rs.getRow();
int laspc;
int pa=count/showrow;
if(count%showrow>0){pa=pa+1;laspc=count%showrow;}else{laspc=showrow;}
if(pages<0)pages=1;
if(pages>pa)pages=pa;
start=(pages-1)*showrow+1;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>留言版</title>
<style type="text/css">
<!--
body {
background-image: url(img/bg.gif);
margin-top: 0px;
margin-bottom: 5px;
}
.style1 {color: #FF0000}
.style2 {color: #FFFFFF}
td{font-size:14px}
th{font-size:16px}
a:link{text-decoration:none;color:#0000ff}
a:visited{text-decoration:none;color:#0000ff}
a:hover{text-decoration:underline;color:#ff0000}
.l {font-size:13px}
.l a:link{text-decoration:none;color:#0000ff}
.l a:visited{text-decoration:none;color:#0000ff}
.l a:hover{text-decoration:none;color:#ff0000}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
function check_form(theform)
{
if (theform.text.value=="")
{
alert("您还没留下您的意见呢!");
theform.text.focus();
return false;
}
if (theform.title.value=="")
{
alert("请留下您意见的主题!");
theform.title.focus();
return false;
}
if (theform.name.value=="")
{
alert("请输入您的大名!");
theform.name.focus();
return false;
}
}
function checkall(check) {
var i = <%=start%>;
var theObj;
for(; i<=<%=(showrow+start)%>; i++)
{
theObj = eval("form1.del" + i);
if (theObj != null)
theObj.checked = check;
}
}
function allcheck() {
if (document.form1.a.checked == true)
checkall(true);
else
checkall(false);
}
</script>
</head>
<body><form name="form1" method="post" action="dell.jsp">
<table width="780" border="0" align="center" cellspacing="0" bgcolor="#f8fff7">
<tr>
<td height="2"></td>
</tr>
<tr>
<td><img src="img/top.gif" width="778" height="80"></td>
</tr>
<tr>
<td><hr></td>
</tr>
<tr>
<td class="l"> <a href=index.jsp>首页</a> </td>
</tr>
<tr>
<td height="10"><% for(int y=0;y<showrow;y++){%><input name="d<%=y%>" type="hidden" id="a1"><% }%></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="1" bgcolor="#c1d1c1">
<tr>
<td bgcolor="#f8f8f8"><%
%><table width="100%" border="0" cellspacing="0">
<tr>
<td width="41%" class="l"> 第<%=pages%>页 共<%=pa%>页 <% if(pages>1){%>
<a href="index.jsp">首页</a> <a href="index.jsp?pages=<%=pages-1%>">上页</a> <% } if(pages<pa){%>
<a href="index.jsp?pages=<%=pages+1%>">下页</a> <a href="index.jsp?pages=<%=pa%>">尾页</a> <% }%></td>
<td width="59%" class="l"><div align="right"><% if(password.equals(mm)){ %>
<input name="imageField" type="image" src="img/del1.jpg" width="76" height="21" border="0" >
<input name="showrow" type="hidden" id="showrow" value="<%=showrow%>">
<input name="pages" type="hidden" id="pages" value="<%=pages%>">
<% }else{
if(showmas.equals("n")){%>
<p><a href="send.jsp">发表留言</a></p> <% } %>
<p><a href="log.jsp">留言管理</a></p>
<% }%>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="10"></td>
</tr>
</table>
<table width="780" border="0" align="center" bgcolor="#EFF0E2" style="BORDER-BOTTOM: #4F7B0D 1px solid; BORDER-LEFT: #4F7B0D 1px solid; BORDER-RIGHT: #4F7B0D 1px solid; BORDER-TOP: #4F7B0D 1px solid">
<tr bgcolor=rgb(128,128,192)>
<th width="53" height="20"><span class="style2"><% if(password.equals(mm)){out.print("<input type=\"checkbox\" id=\"a\" onclick=\"return allcheck()\">");}else{out.print("编号");}%></span></th>
<th width="336" bgcolor=rgb(128,128,192)><span class="style2">主题</span></th>
<th width="83"><span class="style2">留言者</span></th>
<th width="217"><span class="style2">留言时间</span></th>
<th width="69"><span class="style2">回复</span></th>
</tr>
<%
rs.absolute(start);
rs.previous();
while(rs.next()){
%>
<tr bgcolor="#F8FFF7">
<td><div align="center"><% if(password.equals(mm)){%><input name="del<%=rs.getRow()%>" type="checkbox" value="<%=rs.getString(1)%>"><%}else{out.print(rs.getRow());}%></div></td>
<td>
<div align="center"><a href="show.jsp?id=<%=rs.getString(1)%>" target="_blank"><%=rs.getString(2)%></a></div></td>
<td><div align="center"><%=rs.getString(3)%></div></td>
<td><div align="center"><%=rs.getString(4)%></div></td>
<td><div align="center" class="style1"><% if(rs.getString(5).equals("y")){out.print("已回复");}%></div></td>
</tr>
<%
i++;
if(i==showrow)break;
}
%>
</table>
<%
rs.close();
stmt.close();
%>
<table width="780" border="0" align="center" cellspacing="0">
<tr>
<td height="10"></td>
</tr>
<tr>
<td><table width="100%" border="0" align="center" cellspacing="1" bgcolor="#c1d1c1">
<tr>
<td bgcolor="#f8fff7" class="l"><div align="right">
<%
if(pa<=5){
for(int j=1;j<pa+1;j++){
if(j==pages){%><font color=#ff0000>第<%=pages%>页</font> <% }else{%><a href="index.jsp?pages=<%=j%>">第<%=j%>页</a> <% }
}
}else if(pages<4){
for(int k=1;k<pages+3;k++){
if(k==pages){%><font color=#ff0000>第<%=k%>页</font> <% }else{ %><a href="index.jsp?pages=<%=k%>">第<%=k%>页</a> <% }
}
}else if((pa-pages)<4){
for(int l=pa-5;l<=pa;l++){if(l==pages){ %><font color="#FF0000">第<%=l%>页</font> <% }else{ %><a href="index.jsp?pages=<%=l%>">第<%=l%>页</a> <% }}
}else{
for(int m=pages-3;m<pages+3;m++){if(m==pages){ %><font color="#FF0000">第<%=m%>页</font> <% }else{ %><a href="index.jsp?pages=<%=m%>">第<%=m%>页</a> <% }}
}%> 共<%=pa%>页 <%=count%>条 </div></td>
</tr>
</table></td>
</tr>
</table></form>
<%
if(!password.equals(mm)){
if(showmas.equals("y")){
%>
<form name="form2" method="post" action="act.jsp" onSubmit="return check_form(this)">
<table width="780" border="0" align="center" cellspacing="1" bgcolor="#4F7B0D">
<tr bgcolor="#EFF3E7">
<td colspan="2"><table width="100%" border="0" cellspacing="1">
<tr>
<th bgcolor="#4F7B0D"><span class="style2">填 写 留 言</span></th>
</tr>
</table></td>
</tr>
<tr bgcolor="#EFF3E7">
<td width="459" bgcolor="#EFF3E7"><div align="center">
<table width="100%" border="0">
<tr>
<td class="l"><div align="center">留言内容 <span class="style1">*</span></div></td>
</tr>
<tr>
<td><div align="center">
<textarea name="text" cols="55" rows="8" id="text" style="BORDER: #4F7B0D 1px solid; background: #f8fff7;color: #4F7B0D; overflow:auto;"></textarea>
</div></td>