作 者: precom (皮蛋) 2000.12.10
reply.jsp
1<html><head>
2<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
3<title>张家界电话黄页(网上114)</title></head>
4<style type="text/css">
5<!--
6BODY { FONT-FAMILY: "宋体","Arial Narrow", "Times New Roman"; FONT-SI
7ZE: 9pt }
8.p1 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
9E: 12pt }
10A:link { COLOR: #00793d; TEXT-DECORATION: none }
11A:visited { TEXT-DECORATION: none }
12A:hover { TEXT-DECORATION: underline}
13TD { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZE
14: 9pt }
15.p2 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
16E: 9pt; LINE-HEIGHT: 150% }
17.p3 { FONT-FAMILY: "宋体", "Arial Narrow", "Times New Roman"; FONT-SIZ
18E: 9pt; LINE-HEIGHT: 120% }
19
20\-->
21</style>
22<body>
23
24
@ page contentType="text/html; charset=GB2312"
@ page language="java" import="java.sql.*"
1<jsp:usebean class="ymbean.opDb" id="testInq" scope="page"></jsp:usebean>
int pages=1;
int pagesize=10;
int count=0;
int totalpages=0;
String countsql="",inqsql="",updatesql="",lwhere="",insertsql="",st=
"";
String lw_title="",lw_author="",pagetitle="",author_http="",author_e
mail="",lw_ico="0",
lw_content="",lw_class1="";
String author_ip="",lw_time="",lw_class2="",lw_type="",zt_time="",zt
_author="";
int answer_num=0,click_num=0;
int inquire_item=1;
String inquire_itemt="",inquire_value="";
String lurlt="<a "+e+"<hr="" ";="" &";="" &zt_author="+zt_author+" ("iso8859_1"));="" (author_email='"+zt_author+"' (e.hasmoreelements())="" (exception="" (lw_time='"+ zt_time+"' )="" *="" +lw_class1+"'="" ;="" time="+zt_time+
" and="" catch="" e="request.getParameterNames();" e)="" e.nextelement();="" enumeration="" href='reply.jsp?";' integer(request.getparameter("pages")).intvalue();="" lurlt='lurlt+"lw_class1="+lw_class1+"&lw_class2="+lw_class2+"&zt' lw_class1="new" lw_class2='"+lw
class2+
"' lwhere=" where ( lw_class1='" name="(String)" o8859_1"));="" or="" out.print("error1:="" out.print(lwhere);="" pages="new" string="" string(request.getparameter("lw_class1").getbytes="" string(request.getparameter("lw_class2").getbytes="" string(request.getparameter("zt_author").getbytes="" string(request.getparameter("zt_time").getbytes("is="" try{="" while="" zt_author='"+zt
_author+"' zt_time='"+zt_time+
"' {="" {}="" }="" 取显示的页页序数="" 取查询参数="" 只显示主贴="">");
}
try{
//取得参数 留言内容
lw_class1=new String(request.getParameter("lw_class1").getBytes("ISO
8859_1"));
lw_class2=new String(request.getParameter("lw_class2").getBytes("ISO
8859_1"));
lw_title=new String(request.getParameter("lw_title").getBytes("ISO88
59_1"));
lw_author=new String(request.getParameter("lw_author").getBytes("ISO
8859_1"));
pagetitle=new String(request.getParameter("pagetitle").getBytes("ISO
8859_1"));
author_http=new String(request.getParameter("author_http").getBytes(
"ISO8859_1"));
author_email=new String(request.getParameter("author_email").getByte
s("ISO8859_1"));
zt_time=new String(request.getParameter("zt_time").getBytes("ISO8859
_1"));
zt_author=new String(request.getParameter("zt_author").getBytes("ISO
8859_1"));
lw_ico=request.getParameter("gifface");
} catch (Exception e) {}
try{
lw_content=new String(request.getParameter("lw_content").getBytes("I
SO8859_1"));
String requestMethod=request.getMethod();
requestMethod=requestMethod.toUpperCase();
if(requestMethod.indexOf("POST")<0)
{ out.print("非法操作!");
return;
}
//形成其他数据项
author_ip=request.getRemoteAddr() ;
lw_time=testInq.getCurrentDate("yyyyMMddHHmmss");
lw_type=""+"c"; //从贴
answer_num=0;
click_num=0;
//================
st="','";
//保证留言所有数据项的长度在正常范围内
if(lw_title.length()>50) lw_title=lw_title.substring(0,50);
if(lw_author.length()>20) lw_author=lw_author.substring(0,20);
if(author_http.length()>40) author_http=author_http.substring(0,40);
if(author_email.length()>50) author_email=author_email.substring(0,4
0);
if(zt_author.length()>50) zt_author=zt_author.substring(0,40);
if(lw_content.length()>4000) lw_content=lw_content.substring(0,4000)
;
insertsql="insert into guestbook values('"+lw_title+st+lw_author+st+
author_http+st+
author_email+st+lw_ico+st+lw_time+"',"+answer_num+","+cli
ck_num+",'"+
author_ip+st+lw_class1+st+lw_class2+st+lw_type+st+zt_time
+st+zt_author+st+
lw_content+"')";
//out.print(insertsql);
//插入留言
try{
st=testInq.executeUpdate(insertsql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg="+st);
else
{
updatesql="update guestbook set answer_num=answer_num + 1 "+l
where;
//增加回复人数统计
try{
st=testInq.executeUpdate(updatesql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg="+st);
}catch (Exception e) { }
}
}catch (Exception e) { out.print("留言出错:"+e);}
} catch (Exception e) {}
1
//验证留言输入项合法性的javascript
String ljs=" <script language="JavaScript"> \n"+
" <!-- \n"+
" function ValidInput() \n"+
" {if(document.sign.lw_author.value=="") \n"+
" {alert("请填写您的大名。"); \n"+
" document.sign.lw_author.focus(); \n"+
" return false;} \n"+
" if(document.sign.lw_title.value=="") \n"+
" {alert("请填写留言主题。"); \n"+
" document.sign.lw_title.focus(); \n"+
" return false;} \n"+
" if (document.sign.author_email.value!="") \n"+
" { if ((document.sign.author_email.value.indexOf("@")<0)//(document
.sign.author_email.value.indexOf(":")!=-1)) \n"+
" {alert("您填写的EMail无效,请填写一个有效的Email!"); \n"+
" document.sign.author_emaill.focus(); \n"+
" return false; \n"+
" } \n"+
" } \n"+
" return true; \n"+
" } \n"+
" function ValidSearch() \n"+
" { if(document.frmsearch.findstr.value=="") \n"+
" {alert("不能搜索空串!"); \n"+
" document.frmsearch.findstr.focus(); \n"+
" return false;} \n"+
" } \n"+
" //--> \n"+
" </script> ";
out.print(ljs);
1
2
//显示最近时间发表的一页留言
countsql="select count(lw_title) from guestbook "+lwhere;
inqsql ="select lw_title,lw_author,lw_time,lw_content,author_ip, "+
" author_email from guestbook "+lwhere+" order by lw_time desc
" ;
updatesql="update guestbook set click_num=click_num + 1 "+lwhere;
//增加浏览人数统计
try{
st=testInq.executeUpdate(updatesql);
if(st.indexOf("executeUpdate ok")<0)
out.print("msg="+st);
}catch (Exception e) { }
- //out.print(inqsql);
- if(pages>0)
- {
- try {
- try{
- ResultSet rcount=testInq.executeQuery(countsql);
- if(rcount.next())
- {
- count = rcount.getInt(1);
- }
- rcount.close();
- } catch (Exception el1) { out.println("count record error
- "+el1+"<br/>" );
out.println(countsql);
}
totalpages=(int)(count/pagesize);
if(count>totalpages*pagesize) totalpages++;
st=""+
" <table align="center" border="0" cellpadding="0" cellspacing="0" width='"95%"'> "+
" <tbody> <tr> <td 00%"="" align="middle" bgcolor="#97badd" width='"1'><font color="#ff0000">"+
" 共 "+totalpages+" 页,"+count+"
条. "+" 当前页: "+pages+
" </font></td></tr></tbody></table><br/> ";
out.print(st);
//out.print(" 共 "+totalpages+" 页,"+
count+" 条. "+" 当前页: "+pages+"<br/>");
st=" <center> "+
" <table border="0" cellpadding="2" cellspacing="1" width='"95%"'> "+
" <tbody> "+
" <tr> "+
" <td align="middle" bgcolor="#6699cc" width='"55%"'><font "="" "+="" color="#ffffff">留言主题</font></td> "+
" <td align="middle" bgcolor="#6699cc" width="50"><font "="" "+="" color="#ffffff">回应数</font></td> "+
" <td align="middle" bgcolor="#6699cc" width="40"><font "="" "+="" color="#ffffff">点击数</font></td> "+
" <td align="middle" bgcolor="#6699cc" width="100"><font "="" "+="" color="#ffffff">作者名</font></td> "+
" <td align="middle" bgcolor="#6699cc" width="140"><font "="" "+="" color="#ffffff">发表/回应时间</font></td></tr> ";
//out.print(st);
if(count > 0 )
{
ResultSet rs = testInq.executeQuery(inqsql);
ResultSetMetaData metaData = rs.getMetaData();
int i;
// 跳过pages -1 页,使cursor指向pages并准备显示
for(i=1;i<=(pages - 1)*pagesize;i++) rs.next();
//显示第pages页开始
st= " <center> <table border="0" cellspacing="1" width='"95%"'> <tbody> ";
out.print(st);
String linestr="";
for(i=1;i<=pagesize;i++)
if(rs.next())
{
lw_title=rs.getString("lw_title");
lw_author=rs.getString("lw_author");
lw_time=rs.getString("lw_time");
lw_content=rs.getString("lw_content");
author_ip=rs.getString("author_ip");
author_email=rs.getString("author_email");
st=lw_time.substring(0,4)+"-"+lw_time.substring(4,6)+"-"
+lw_time.substring(6,8)+":"+
lw_time.substring(8,10)+":"+lw_time.substring(10,12)+
":"+lw_time.substring(12,14);
try{lw_content=testInq.addBr(testInq.removeComment(lw_co
ntent));} catch (Exception e) {}
linestr =""+
" <tr bgcolor="#bed9fc"> "+
" <td align="left" width='"75%"'><font "="" "+="" color="#0000cd">留言主题:</font><strong>"
+lw_title+"</strong></td> "+
" <td align="left" width='"25%"'><font color="#0000cd">留言时间:</font>"+st+"</td></tr> "+
" <tr bgcolor="#e7f1fe"> "+
" <td "="" "+="" colspan="2" width='"700"' wrap="yes"><br/>"+lw_content+"
<br/><br/></td></tr> "+
" <tr bgcolor="#bed9fc"> "+
" <td align="right" colspan="2" width='"100%"'>
<font "="" "+="" color="#0000cd">作者:</font>"+lw_author+"
<font "="" "+="" color="#0000cd">来源:</font>"+author_ip+"
</td></tr>";
out.println(linestr);
}
rs.close();
//显示第pages页结束
st= " </tbody></table></center><br/> "+
" <center><a "="" "+="" href='"guestbook.jsp"'><font "="" "+="" color="blue" face="楷体_GB2312" size="4">返回留言板
首页</font></a></center><br/> "+
" <hr align="center" noshade="" size="1" width='"95%"'/> ";
out.print(st);
int iFirst=1,iLast=totalpages,iPre,iNext;
if(pages<=1) iPre=1;
else iPre=pages - 1;
if(pages>=totalpages) iNext=totalpages;
else iNext=pages + 1;
int n=(int)(count/pagesize);
if(n*pagesize<count) if(n="" n++;="">1)
{
//for(i=1;i<=n;i++) out.print("<a "+i+"="" href="inquire.jsp?pages=">"+i+" </a>");
//out.print("<hr "="" align="center" noshade="" size="1" width='"95%'/>");
String lt1="返回主页",lt2="第一页",lt3="上一页",lt4="下一
页",lt5="最后一页",lt6="";
lt6="<a href="http://www.zj.hn.cn">"+ lt1 + " </a>"+
lurlt + "pages="+iFirst+"><font color="red">"+lt2+"&nbs
p; </font></count)></tbody></table></center></a>"+
lurlt + "pages="+iPre+"><font color="red">"+lt3+"
" +
lurlt + "pages="+iNext+"><font color="red">"+lt4+"
; " +
lurlt + "pages="+iLast+"><font color="red">"+lt5+"
; ";
st=""+
" <table align="center" border="0" cellpadding="0" cellspacing="0" width='"95%"'> "+
" <tbody> <tr> <td 00%"="" align="middle" bgcolor="#97badd" width='"1'><font color="#ff0000">"+
lt6+
" </font></td></tr></tbody></table><br/> ";
out.print(st);
}
}
} catch (Exception e) { out.println("error: "+e); }
}
1
2
//留言板界面尾部
String lbottom="";
lbottom=lbottom+
" <center> \n"+
" <form action="reply.jsp" method="post" name="sign"> \n"+
" <input name="lw_class1" type="hidden" value="cnzjj_gt"/> \n"+
" <input name="lw_class2" type="hidden" value="+lw_class2+"/> \n"
+
" <input name="pages" type="hidden" value="1"/> \n"+
" <input name="zt_time" type="hidden" value="+zt_time+"/> \n"+
" <input name="zt_author" type="hidden" value="+zt_author+"/> \n"
+
" <table bgcolor="#d5e8fd" border="0" cellspacing="1" width='"95%"'> \n"+
" <tbody> \n"+
" <tr> \n"+
" <td align="middle" bgcolor="#e6e6fa" colspan="2" nowrap=""><strong><font "="" \n"+="" color="blue" face="楷体_GB2312" size="5">发 表 意 见</font></strong> &nbs
p; [加*的内容必须填写] </td></tr> \n"+
" <tr> \n"+
" <td nowrap="" width='"45%"'> \n"+
" <div align="left"> \n"+
" <table bgcolor="#d5e8fd" border="0" cellspacing="1" width='"100%"'>
\n"+
" <tbody> \n"+
" <tr> \n"+
" <td nowrap="" width='"100%"'>*留言主题:<input "="" \n"+="" ame="lw_title" maxlength="40" n="" size="36"/></td></tr> \n"+
" <tr> \n"+
" <td nowrap="" width='"100%"'>*网上大名:<input "="" \n"+="" ame="lw_author" maxlength="18" n="" size="36"/></td></tr> \n"+
" <tr> \n"+
" <td nowrap="" width='"100%"'> 主页标题:<input "="" \n"+="" maxlength="40" name="pagetitle" size="36"/></td></tr> \n"+
" <tr> \n"+
" <td nowrap="" width='"100%"'> 主页地址:<input "="" \n"+="" maxlength="255" name="author_http" size="36"/></td></tr> \n"+
" <tr> \n"+
" <td nowrap="" width='"100%"'>*电子邮件:<input "="" \n"+="" ame="author_email" maxlength="40" n="" size="36"/></td></tr></tbody></table></div></td> \n"+
" <td nowrap="" valign="top" width='"55%"'> \n"+
" <div align="left"> \n"+
" <table bgcolor="#b6d7fc" border="0" cellspacing="1" width='"100%"'>
\n"+
" <tbody> \n"+
" <tr> \n"+
" <td width='"100%"'>请在下面填写你的留言:</td></tr> \n"+
" <tr> \n"+
" <td width='"100%"'><textarea cols="50" name="lw_content" rows="7"></textarea></td></tr></tbody></table></div></td></tr> \n"+
" <tr> \n"+
" <td bgcolor="#fbf7ea" colspan="2" nowrap="">表情\n"+
" <input checked="" name="gifface" type="radio" value="1"/><img "="" (152="" \n"+="" alt='"1.gif' bytes)"="" height="15" src='"1.gif"' width="15"/> <i "="" \n"+="" name="gifface" nput="" type="radio" value="2"><img "="" (174="" \n"+="" alt='"2.gif' bytes)"="" height="15" src='"2.gif"' width="15"/> <input name="gifface" type="radio" value="3"/><img "="" (147="" \n"+="" alt='"3.gif' bytes)"="" height="15" src='"3.gif"' width="15"/> <i "="" \n"+="" name="gifface" nput="" type="radio" value="4"><img "="" (172="" \n"+="" alt='"4.gif' bytes)"="" height="15" src='"4.gif"' width="15"/> <input name="gifface" type="radio" value="5"/><img "="" (118="" \n"+="" alt='"5.gif' bytes)"="" height="15" src='"5.gif"' width="15"/> <i "="" \n"+="" name="gifface" nput="" type="radio" value="6"><img "="" (180="" \n"+="" alt='"6.gif' bytes)"="" height="15" src='"6.gif"' width="15"/> <input name="gifface" type="radio" value="7"/><img "="" (180="" \n"+="" alt='"7.gif' bytes)"="" height="15" src='"7.gif"' width="15"/> <i "="" \n"+="" name="gifface" nput="" type="radio" value="8"><img "="" (96="" \n"+="" alt='"8.gif' bytes)"="" height="15" src='"8.gif"' width="15"/> <input name="gifface" type="radio" value="9"/><img "="" (162="" \n"+="" alt='"9.gif' bytes)"="" height="15" src='"9.gif"' width="15"/> <i "="" \n"+="" name="gifface" nput="" type="radio" value="10"><img "="" (113="" "="" \n"+="" alt='"10.gif' bytes)="" height="15" src='"10.gif"' width="15"/> <input name="gifface" type="radio" value="11"/><img "="" (93="" \n"+="" alt='"11.gif' bytes)"="" height="15" src='"11.gif"' width="15"/> <
INPUT \n"+
" name=gifface type=radio value=12> <img "="" (149="" )"="" \n"+="" alt='"12.gif' bytes="" height="14" src='"12.gif"' width="15"/> \n"+
" <input "="" \n"+="" name="gifface" type="radio" value="13"/> <img "="" (149="" )"="" \n"+="" alt='"13.gif' bytes="" height="14" src='"13.gif"' width="15"/> \n"+
" <input "="" \n"+="" name="gifface" type="radio" value="14"/> <img "="" (149="" )"="" \n"+="" alt='"14.gif' bytes="" height="14" src='"14.gif"' width="15"/> \n"+
" <input "="" \n"+="" name="gifface" type="radio" value="15"/> <img "="" (149="" )"="" \n"+="" alt='"15.gif' bytes="" height="14" src='"15.gif"' width="15"/> \n"+
" <input "="" \n"+="" name="gifface" type="radio" value="16"/> <img "="" (149="" )"="" \n"+="" alt='"16.gif' bytes="" height="14" src='"16.gif"' width="15"/> </i></i></i></i></i></td> \n"+
" </tr> \n"+
" <tr> \n"+
" <td align="middle" colspan="2" nowrap=""><input name="cmdGO" onclick='"re' turn="" type="submit" validinput()"="" value='"提' 交"=""/> \n"+
" <input e='"预' name="cmdPrev" onclick='"return' type="submit" validinput()"="" valu="" 览"=""/> \n"+
" <input name="cmdCancel" type="reset" value='"重' 写"=""/> <inpu name="cmdBack" onclick="javascript:history.go(-1)" t="" type="button" value='"返' 回"=""> \n"+
" </inpu></td></tr></tbody></table></form></center> ";
out.print(lbottom);
1
2</font></font></font></body></html>
作 者: precom (皮蛋) 2000.12.10