📄 topic_ok.jsp
字号:
<%
/*
* Copyright: Copyright (c) 2004
* @author http://hi.baidu.com/lael80*/
%>
<%@ page contentType="text/html; charset=gb2312" errorPage=""%>
<jsp:useBean id="workDB" scope="page" class="javabean.Conn"/>
<jsp:useBean id="workFC" scope="page" class="javabean.Func"/>
<%
java.util.Date date=new java.util.Date();
String topic_date=date.toLocaleString();
String topic_ip=request.getRemoteAddr();
String forum=request.getParameter("forum");
String topic_theme=workFC.UnitoGB(request.getParameter("topic_theme"));
String topic_content=workFC.UnitoGB(request.getParameter("textarea"));
String edit=request.getParameter("edit");
String errcodes="";
String topic_type=request.getParameter("topic_type");
try{
if(!workFC.cNULL(edit)&&Integer.parseInt(workDB.queryData("select UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(topic_date) from user_topic where user_name='"+session.getAttribute("u_name")+"' order by topic_id desc limit 1"))<15){
response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>为了防止有人灌水,不能在十五秒内连续发贴"));
return;
}
}catch(Exception e){}
if(!workFC.cNULL(edit)&&workDB.queryCount("select count(topic_id) from user_topic where user_name='"+session.getAttribute("u_name")+"' and topic_theme='"+workFC.HtmltoStr(workFC.GBtoUni(topic_theme))+"' and topic_content='"+workFC.HtmltoStr(workFC.GBtoUni(topic_content))+"' and topic_forum="+forum)!=0){
response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni("<li>为了防止有人灌水,不能在同一论坛发表相同的主题"));
return;
}
if(!workFC.cNULL(String.valueOf(session.getAttribute("u_name")))){
errcodes="<li>您还没有注册或登录,没有权限发表主题";
response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni(errcodes));
}
if(workFC.cNULL(String.valueOf(session.getAttribute("u_name")))){
if(workDB.queryData("select user_type from user_info where user_name='"+session.getAttribute("u_name")+"'").equals("50")){
errcodes="<li>您的帐号已被锁定,暂时不能发贴,如有疑问请给版主留言";
response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni(errcodes));
}else{
if(workFC.cNULL(edit)){
if(workDB.queryCount("select count(user_id) from user_info where user_name='"+session.getAttribute("u_name")+"' and (user_type="+forum+" or user_type=100)")==0){
if(workDB.queryCount("select count(topic_id) from user_topic where user_name='"+session.getAttribute("u_name")+"' and topic_id="+edit)==0){
errcodes="<li>错误贴子参数或您没有权限修改别人的贴子";
}
}
}
if(!workFC.cNULL(topic_theme)||!workFC.CheckLen(topic_theme,100)){
errcodes="<li>您主题的标题超出允许长度或为0,应该为(1-100)字节";
}
if(!workFC.cNULL(topic_content)||!workFC.CheckLen(topic_content,50000)){
errcodes=errcodes+"<li>您发表的主题内容超出允许长度或为0,应该为(1-50000)字节";
}
if(!workFC.cNULL(errcodes)){
if(workFC.cNULL(edit)){
String tmp="\r\n\r\n[该主题由 "+workFC.UnitoGB(String.valueOf(session.getAttribute("u_name")))+" 于 "+topic_date+" 编辑过]";
String sql="update user_topic set topic_theme='"+workFC.HtmltoStr(workFC.GBtoUni(topic_theme))+"',topic_content='"+workFC.HtmltoStr(workFC.GBtoUni(topic_content+tmp))+"' where topic_id="+edit;
workDB.executeUpdate(sql);
response.sendRedirect("display.jsp?forum="+forum+"&topic="+edit+"&pageid=1&id=1");
}else{
String sql="";
if(workDB.queryCount("select count(user_id) from user_info where user_name='"+session.getAttribute("u_name")+"' and (user_type="+forum+" or user_type=100)")!=0){
if(workFC.cNULL(topic_type)&&topic_type.equals("1")){
workDB.executeUpdate("delete from user_topic where topic_forum="+forum+" and topic_type=1");
sql="insert into user_topic(user_name,topic_theme,topic_content,topic_date,topic_forum,topic_type,topic_ip) Values('"+session.getAttribute("u_name")+"','"+workFC.HtmltoStr(workFC.GBtoUni("[公告]"+topic_theme))+"','"+workFC.HtmltoStr(workFC.GBtoUni(topic_content))+"','"+topic_date+"',"+forum+",1,'"+topic_ip+"')";
}
}
if(!workFC.cNULL(sql))sql="insert into user_topic(user_name,topic_theme,topic_content,topic_date,topic_forum,topic_ip) Values('"+session.getAttribute("u_name")+"','"+workFC.HtmltoStr(workFC.GBtoUni(topic_theme))+"','"+workFC.HtmltoStr(workFC.GBtoUni(topic_content))+"','"+topic_date+"',"+forum+",'"+topic_ip+"')";
workDB.executeUpdate(sql);
String topic_id=workDB.queryData("select max(topic_id) from user_topic");
response.sendRedirect("display.jsp?forum="+forum+"&topic="+topic_id+"&pageid=1&id=1");
}
}
if(workFC.cNULL(errcodes)){
response.sendRedirect("result.jsp?errcodes="+workFC.GBtoUni(errcodes));
}
}
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -