?? browse.jsp
字號:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="anni.gbook.*"%>
<%@page import="anni.tools.*"%>
<%@ include file="config.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><%=gbname%></title>
<meta http-equiv=Content-Type content="text/html; charset=GBK">
<LINK href="<%=styleFile%>" rel=stylesheet>
<script type="text/javascript" src="check.js"></script>
<script language="JavaScript">
var limit_name = <%=limit_name%>;
var limit_email = <%=limit_email%>;
var limit_pagename = <%=limit_pagename%>;
var limit_pageurl = <%=limit_pageurl%>;
var limit_text = <%=limit_text%>;
function ow(url)
{
window.open(url,'','width=640,height=400,resizable=yes,scrollbars=1,directories=no');
return;
}
function check()
{
var item = document.form1;
if(item.newname.value=="")
{
alert("請輸入您的姓名");
item.newname.focus();
return;
}
if(!checkSafe(item.newname.value))
{
alert("姓名不能包括&;`'\\\"|*?~<>^()[]{}$\\n\\r");
item.newname.focus();
return;
}
if(checkLength(item.newname.value) > limit_name)
{
alert("昵稱最長不能超過"+limit_name+"位字符");
item.newname.focus();
return;
}
if(!checkEmail(item.newemail.value))
{
alert("請輸入有效的email");
item.newemail.focus();
return;
}
if(checkLength(item.newemail.value) > limit_email)
{
alert("EMAIL最長不能超過"+limit_email+"位字符");
item.newemail.focus();
return;
}
if(item.newpageurl.value!="" && item.newpageurl.value!="http://" && !checkUrl(item.newpageurl.value))
{
alert("請輸入有效的url");
item.newpageurl.focus();
return;
}
if(checkLength(item.newpagename.value) > limit_pagename)
{
alert("主頁名稱最長不能超過"+limit_pagename+"位字符");
item.newpagename.focus();
return;
}
if(checkLength(item.newpageurl.value) > limit_pageurl)
{
alert("主頁地址最長不能超過"+limit_pageurl+"位字符");
item.newpageurl.focus();
return;
}
if(item.newtext.value=="")
{
alert("請輸入留言內容");
item.newname.focus();
return;
}
if(!checkSafe(item.newtext.value))
{
alert("留言內容不能包括&;`'\\\"|*?~<>^()[]{}$\\n\\r");
item.newtext.focus();
return;
}
if(checkLength(item.newtext.value) > limit_text)
{
alert("留言最長不能超過"+limit_text+"位字符");
item.newtext.focus();
return;
}
item.action="service?method=BoardAction&action=add";
item.submit();
}
</script>
</head>
<body>
<center>
<!-------------------->
<p>
<table cellpadding='4' cellspacing='0' border='0' width='80%' align='center' class="write">
<tr bgcolor="#eeeeef">
<td>
<center><b><%=gbname%>--打<font color="red">*</font>號的必填 </b></center>
<hr size="1" color="gray">
<table border="0" cellpadding="3" cellspacing="2" width="100%" align="center"><form name="form1" action="gb_write.jsp" method="post" ><%String token = String.valueOf(System.currentTimeMillis()); session.setAttribute("token",token);%><input type="hidden" name="token" value="<%=token%>">
<tr>
<td width="20%">你的姓名:<font color=red>*</font></td>
<td width="30%"><input type="text" name="newname"></td>
<td width="20%">電子郵件:<font color=red>*</font></td>
<td width="30%"> <input type="text" name="newemail"></td>
</tr>
<tr>
<td width="20%">主頁名稱:</td>
<td width="30%"><input type="text" name="newpagename"></td>
<td width="20%">主頁地址:</td>
<td width="30%"><input type="text" name="newpageurl" value="http://"></td>
</tr>
<tr>
<td width="20%">性別:</td>
<TD width="40%"><font color="#b50000">男 </font><input type="radio" name="sex" value="0" checked> <font color="#19C108">女</font>
<input type="radio" name="sex" value="1"></td>
<td width="10%">個性頭像:</td>
<td width="30%">
<select size="1" name="img" onChange="document.images['face'].src=options[selectedIndex].value;">
<%
for(int imgi=1;imgi<=59;imgi++)
{
String s = "Image"+imgi+".gif";
out.println("<option value=images/"+s+">"+s+"</option>");
}
%>
</select> <a href="javascript:ow('gb_img.jsp');" title="查看所有頭像"><img src="images/Image1.gif" border=0 name="face" width=32 height=32></a>
</td>
</tr>
<tr>
<td>留言內容:<font color="red">*</font><br><font color="#336699">支持JUBB(類似UBB代碼),具體支持哪些代碼自己試吧</font></td>
<td colspan="3"><textarea name="newtext" cols="50" rows="8"></textarea></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="button" name="Submit" value="提交" onclick="check()">
<input type="reset" name="Submit2" value="重填">
</div></td>
</tr></form>
</table>
</td>
</tr>
</table>
</p><!-------------------->
<%
List all = (List)request.getAttribute("all");
//System.out.println("all : "+all);
int count = all.size();
String currentPage0 = (String)request.getAttribute("currentPage");
int currentPage = 0;
try
{
currentPage = Integer.parseInt(currentPage0);
}
catch (NumberFormatException ex)
{
ex.printStackTrace();
}
if(currentPage<0 || currentPage>count/6)
{
currentPage=0;
}
UBB2 ubb = new UBB2();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
int id;
String name;
String email;
String pageName;
String pageUrl;
int sex;
String img;
String content;
String ip;
Date dateTime;
String reply;
String emailMessage;
String homePage;
String dateFormat;
String contentFormat;
String username;
BoardInfo info;
int pageNum = (count+6-1)/6;//總共多少頁
int start = currentPage*6;
int end = (currentPage+1)*6;
if(end>count)
{
end=count;
}
//System.out.println(start+"|"+end);
for(int i=start;i<end;i++)
{
info = (BoardInfo)all.get(i);
/*
id = info.getId();
name = info.getName();
email = info.getEmail();
pageName = info.getPageName();
pageUrl = info.getPageUrl();
sex = info.getSex();
img = info.getImg();
content = info.getContent();
ip = info.getIp();
dateTime = info.getDateTime();
reply = info.getReply();
if(sex==0)
{
//男人
username = "<font color=#b50000><b>"+name+"</b></font>";
}
else
{
//女人
username = "<font color=#19C108><b>"+name+"</b></font>";
}
if(email == null || email.equals(""))
{
emailMessage = "<font color=gray>郵件</font>";
}
else
{
emailMessage = "<a href=\"mailto:"+email+"\" title=\"給"+name+"寫信\">郵件</a>";
}
if(pageName == null || pageName.equals("") || pageUrl == null || pageUrl.equals(""))
{
homePage = "<font color=gray>主頁</font>";
}
else
{
homePage = "<a href="+pageUrl+" target=_blank title=訪問"+name+"的主頁《"+pageName+"》>主頁</a>";
}
contentFormat = content;
contentFormat = contentFormat.replaceAll("<","<");
contentFormat = contentFormat.replaceAll(">",">");
contentFormat = contentFormat.replaceAll("\r\n","<br>");
contentFormat = ubb.reAll(content);
dateFormat = sdf.format(dateTime);
*/
%>
<table cellpadding="5" cellspacing="1" border="0" width="80%" align="center" class="write" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all; WORD-WRAP: break-word">
<tr>
<td colspan="4"><p><img src="<%=info.getImg()%>" border="0" align="left"><%=info.getContentFormat()%></p></td>
</tr>
<%
if(info.getReply() != null && !info.getReply().equals(""))
{
%>
<tr>
<td colspan="4" width="100%">
<table cellspacing="1" cellpadding="3" bgcolor="black" width="98%">
<tr bgcolor="#feffef">
<td><p>回復:<br><font color="#9800cc"><%=info.getReply()%></font></p></td>
</tr>
</table>
</td>
</tr>
<%
}
%>
<tr bgcolor="#eeefff" align="center"><td align="left" width="35%">
昵稱:<%=info.getUsername()%></td>
<Td width="25%"><font color="#7489ff"><%=info.getDateFormat()%></font></td>
<Td width="10%"><%=info.getHomePage()%> <%=info.getEmailMessage()%></td>
<td width="30%" bgcolor="#eeeeee"><a href="viewip.jsp?id=<%=info.getId()%>" title="查看IP" target="_blank">查看IP</a> <a href="service?method=BoardAction&action=viewReply&id=<%=info.getId()%>" title="回復留言">回復</a> <a href="delete.jsp?id=<%=info.getId()%>" title="刪除留言">刪除</a>
</td></tr>
</table>
<table cellspacing="0" cellpadding="0" width="100%" height="10"><tr><td></td></tr></table>
<%
}
%>
<table cellspacing="1" cellpadding="3" width="80%" height="30" bgcolor="black"><Tr bgcolor="#eeeeff"><Td>
<%
//開始分頁
if(pageNum > 1)
{
out.println("共有留言<font color=red>"+count+"</font>條,共有<font color=red>"+pageNum+"</font>頁");
for(int pgi = 1;pgi <= pageNum;pgi++)
{
if(pgi == currentPage+1)
{
out.println("<font color=gray>第"+pgi+"頁</font>");
}
else
{
//out.println("<a href="+request.getRequestURL()+"?pg="+pgi+" title=第"+pgi+"頁>第"+pgi+"頁</a>");
out.println("<a href=service?method=BoardAction&action=browse¤tPage="+(pgi-1)+
" title=第"+pgi+"頁>第"+pgi+"頁</a>");
}
}
}
else
{
out.println("當前只有<font color=red>1</font>頁,共<font color=red>"+count+"</font>條留言");
}
%>
</td></tr></table>
<p><%@include file="copyright.jsp"%></p>
</center>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -