package forum;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
public class Utilities {
public static String getTopics(String forum_id){
String topics = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT count(*) topics FROM forum_message " +
"WHERE forum_id =\"" + forum_id + "\" " +
"AND reply_id=\"0\"");
while(rs.next()){
topics = rs.getString("topics");
}
db.close();
}catch(Exception e){}
return topics;
}
public static String getforumReplies(String forum_id){
String replies = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT count(*)-" + getTopics(forum_id) + " replies FROM forum_message " +
"WHERE forum_id =\"" + forum_id + "\"");
while(rs.next()){
replies = rs.getString("replies");
}
db.close();
}catch(Exception e){}
return replies;
}
public static String getReplies(String forum_id,String thread_id){
String replies = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT count(*)-1 replies FROM forum_message " +
"WHERE forum_id=\"" + forum_id + "\" AND thread_id =\"" + thread_id + "\"");
while(rs.next()){
replies = rs.getString("replies");
}
db.close();
}catch(Exception e){}
return replies;
}
public static String getMorePages(String replies,String forum_id,String thread_id,boolean pages)
{
String morePages = "";
if(!((Integer.parseInt(replies)+1) < (Integer.parseInt(Variable.getMessagePerPage()) + 1))){
if(pages){morePages += " ( ";}
for(int i=0;i< (Integer.parseInt(replies)+1);i += (Integer.parseInt(Variable.getMessagePerPage())) ){
morePages +=
"<a href=message.jsp?forum_id=" + forum_id + "&thread_id=" + thread_id +
"&start="+ i +
" class=\"pathBarLink\">" + ((i/(Integer.parseInt(Variable.getMessagePerPage())))+1)+ "</a> ";
}
if(pages){morePages += " )</span>";}
}
return morePages;
}
public static String getforumTile(String forum_id){
String forumTitle = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT title FROM forum_forums "+
"WHERE forum_id=\""+ forum_id + "\"");
while(rs.next()){
forumTitle = rs.getString("title");
}
db.close();
}catch(Exception e){}
return forumTitle;
}
public static String getThreadTile(String forum_id,String thread_id){
String threadTitle = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT title FROM forum_threads "+
"WHERE forum_id=\""+ forum_id + "\" " +
"AND thread_id=\"" + thread_id + "\"");
while(rs.next()){
threadTitle = rs.getString("title");
}
db.close();
}catch(Exception e){}
return threadTitle;
}
public static String getforumInfo(String forum_id){
String forumInfo = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT forum_info FROM forum_forums "+
"WHERE forum_id=\""+ forum_id + "\"");
while(rs.next()){
forumInfo = rs.getString("forum_info");
}
db.close();
}catch(Exception e){}
if(forumInfo.equals(null)){
forumInfo = "";
}
return forumInfo;
}
public static String lastPostInfo(String forum_id){
String lastPostInfo = null;
String thread_id = null;
String title = null;
String date_time = null;
String user = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT MAX(date_time) date_time FROM forum_message "+
"WHERE forum_id=\""+ forum_id + "\"");
while(rs.next()){
date_time = rs.getString("date_time");
}
ResultSet rs2 = db.selectQuery(
"SELECT thread_id,user FROM forum_message "+
"WHERE forum_id=\""+ forum_id + "\" "+
"AND date_time=\"" + date_time + "\"");
while(rs2.next()){
thread_id = rs2.getString("thread_id");
user = rs2.getString("user");
}
ResultSet rs3 = db.selectQuery(
"SELECT * FROM forum_threads "+
"WHERE thread_id=\""+ thread_id + "\" "+
"AND forum_id=\"" + forum_id + "\"");
while(rs3.next()){
title = rs3.getString("title");
}
if(date_time == null){
date_time = "No info";
}
if(user == null){
user = "No info";
}
if(title == null){
title = "No info";
}
lastPostInfo = date_time + "<br>In: " + title + "<br>By: " + user;
db.close();
}catch(Exception e){}
return lastPostInfo;
}
public static String lastActionInfo(String forum_id,String thread_id){
String lastPostInfo = null;
String date_time = null;
String user = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT MAX(date_time) date_time FROM forum_message "+
"WHERE forum_id=\""+ forum_id + "\" "+
"AND thread_id=\"" + thread_id + "\"");
while(rs.next()){
date_time = rs.getString("date_time");
}
ResultSet rs2 = db.selectQuery(
"SELECT user FROM forum_message "+
"WHERE forum_id=\""+ forum_id + "\" "+
"AND thread_id=\"" + thread_id + "\" "+
"AND date_time=\"" + date_time + "\"");
while(rs2.next()){
user = rs2.getString("user");
}
if(date_time == null){
date_time = "No info";
}
if(user == null){
user = "No info";
}
lastPostInfo = date_time + "<br>Last post by: " + user;
db.close();
}catch(Exception e){}
return lastPostInfo;
}
public static void addView(String forum_id,String thread_id){
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
db.query(
"UPDATE forum_threads SET views = views + 1 "+
"WHERE forum_id =\"" + forum_id + "\" "+
"AND thread_id=\"" + thread_id + "\"");
db.close();
}catch(Exception e){}
}
public static String getViews(String forum_id,String thread_id){
String views = null;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT views FROM forum_threads "+
"WHERE forum_id=\""+ forum_id + "\" "+
"AND thread_id=\"" + thread_id + "\"");
while(rs.next()){
views = rs.getString("views");
}
db.close();
}catch(Exception e){}
return views;
}
public static int getMessageLength(String forum_id,String thread_id,String reply_id)
{
int messageLength = 0;
try{
DBConnectie db = new DBConnectie(Variable.getDb(),Variable.getDbLogin(),Variable.getDbPassword());
db.connect();
ResultSet rs = db.selectQuery(
"SELECT message FROM foru
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
forum_Java_EE.rar_This Is It (279个子文件)
forum.css.bak 3KB
forum.css.bak 3KB
Utilities.class 7KB
Include.class 7KB
Include.class 6KB
Utilities.class 5KB
Filter.class 5KB
FilterBack.class 5KB
Login.class 4KB
Filter.class 4KB
FilterBack.class 4KB
ChangeMessage.class 3KB
ChangeProfile.class 3KB
AddReply.class 3KB
AddThread.class 3KB
AddUser.class 3KB
ChangeMessage.class 3KB
AddForum.class 3KB
ChangeProfile.class 2KB
DeleteReply.class 2KB
DeleteThread.class 2KB
Login.class 2KB
AddUser.class 2KB
AddThread.class 2KB
DeleteForum.class 2KB
DBConnectie.class 2KB
AddReply.class 2KB
AddForum.class 2KB
DeleteReply.class 2KB
DeleteThread.class 2KB
DeleteForum.class 2KB
Logout.class 2KB
DBConnectie.class 2KB
Logout.class 1KB
Variable.class 998B
Variable.class 928B
Cookies.class 888B
Test.class 744B
Test.class 744B
Cookies.class 568B
forum.css 3KB
forum.css 3KB
bounce.gif 5KB
bounce.gif 5KB
frusty.gif 3KB
frusty.gif 3KB
puke.gif 2KB
puke.gif 2KB
bid.gif 2KB
bid.gif 2KB
fuck.gif 2KB
fuck.gif 2KB
wub.gif 1KB
wub.gif 1KB
blink.gif 1KB
blink.gif 1KB
kwijl.gif 1012B
kwijl.gif 1012B
wacko.gif 946B
wacko.gif 946B
unsure.gif 897B
unsure.gif 897B
hammer.gif 770B
hammer.gif 770B
silly.gif 714B
silly.gif 714B
huh.gif 708B
huh.gif 708B
ph34r.gif 705B
rolleyes.gif 705B
ph34r.gif 705B
rolleyes.gif 705B
angry.gif 699B
angry.gif 699B
mellow.gif 698B
mellow.gif 698B
lol.gif 690B
lol.gif 690B
scream.gif 321B
scream.gif 321B
good.gif 139B
good.gif 139B
mysql-connector-java-5.1.3.jar 631KB
Utilities.java 8KB
Filter.java 7KB
Include.java 7KB
FilterBack.java 7KB
Login.java 5KB
AddThread.java 3KB
ChangeProfile.java 3KB
AddUser.java 2KB
AddReply.java 2KB
ChangeMessage.java 2KB
AddForum.java 2KB
DeleteReply.java 2KB
DeleteThread.java 2KB
Logout.java 1KB
DeleteForum.java 1KB
DBConnectie.java 1KB
Variable.java 691B
共 279 条
- 1
- 2
- 3
资源评论
JonSco
- 粉丝: 94
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功