📄 newpost.java
字号:
package com.laoer.bbscs.bbs.business;
import java.sql.*;
import java.io.*;
import java.util.*;
import com.laoer.bbscs.db.*;
import com.laoer.bbscs.sysinfo.*;
import com.laoer.bbscs.util.*;
import org.apache.log4j.*;
/**
* <p>Title: 天乙社区V5.0</p>
* <p>Description: BBS-CS天乙社区V5.0</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: laoer.com</p>
* @author 龚天乙
* @version 5.0
*/
public class NewPost {
static Logger logger = Logger.getLogger(NewPost.class.getName());
private static Vector inPostNew = new Vector();
public NewPost() {
}
public static synchronized void intoNewPost(ForumInfo aForum) {
/*
int len = inPostNew.size();
if (len > 9) {
inPostNew.removeElementAt(len - 1);
}
inPostNew.add(0, aForum);*/
try {
String filepath = Util.getPubFilePath();
File file = new File(filepath + "newpost.htm");
String strDetail = "";
StringBuffer sb = new StringBuffer();
if (file.exists()) {
FileInputStream bw = new FileInputStream(file);
int _len = bw.available();
byte[] str = new byte[_len];
if (bw.read(str) == -1) {
strDetail = "";
}
else {
if (Sys.isLocale()) {
strDetail = new String(str);
}
else {
strDetail = new String(str, "UTF8");
}
}
bw.close();
bw = null;
while (Util.getAppearTimes(strDetail, "<!--NEWPOST") > 9) {
strDetail = strDetail.substring(0,
strDetail.lastIndexOf("<!--NEWPOST"));
}
}
sb.append("<!--NEWPOST-" + aForum.getID() + "--><tr><td>");
sb.append("<a href='readAction.do?sid=###&bid=" +
aForum.getBoardID() + "&recid=" + aForum.getID2() +
"&pages=1' title='"+aForum.getTitle()+"'>" +
Util.getCutString(Util.stripslashes(aForum.getTitle()), 8) +
"</a>");
sb.append("<font color=#FF0000> [" + aForum.getBoardName() + "]</font>");
sb.append("</td></tr><!--ENDNEWPOST-" + aForum.getID() + "-->");
sb.append(strDetail);
FileOutputStream wf = new FileOutputStream(filepath + "newpost.htm");
if (Sys.isLocale()) {
wf.write(sb.toString().getBytes());
}
else {
wf.write(sb.toString().getBytes("UTF8"));
}
wf.close();
}
catch (IOException e) {
logger.error(e);
}
}
public static synchronized void delNewPost(long fid) {
/*
int len = inPostNew.size();
ForumInfo aForum = null;
for (int i = 0; i < len; i++) {
aForum = (ForumInfo) inPostNew.get(i);
if (aForum.getID() == fid) {
inPostNew.removeElementAt(i);
//return;
}
}*/
try {
String filepath = Util.getPubFilePath();
File file = new File(filepath + "newpost.htm");
String strDetail = "";
StringBuffer sb = new StringBuffer();
if (file.exists()) {
FileInputStream bw = new FileInputStream(file);
int _len = bw.available();
byte[] str = new byte[_len];
if (bw.read(str) == -1) {
strDetail = "";
}
else {
if (Sys.isLocale()) {
strDetail = new String(str);
}
else {
strDetail = new String(str, "UTF8");
}
}
bw.close();
bw = null;
int index = strDetail.indexOf("<!--NEWPOST-" + fid + "-->");
String end = "<!--ENDNEWPOST-" + fid + "-->";
if (index != -1) {
strDetail = strDetail.substring(0, index) +
strDetail.substring(strDetail.indexOf(end) + end.length(),
strDetail.length());
FileOutputStream wf = new FileOutputStream(filepath + "newpost.htm");
if (Sys.isLocale()) {
wf.write(strDetail.getBytes());
}
else {
wf.write(strDetail.getBytes("UTF8"));
}
wf.close();
}
}
}
catch (IOException e) {
}
}
public synchronized void createFile() {
int len = inPostNew.size();
StringBuffer sb = new StringBuffer();
ForumInfo aForum = null;
int n = 2;
if (len > 0) {
for (int i = 0; i < len; i++) {
aForum = (ForumInfo) inPostNew.get(i);
sb.append("<tr><td>");
sb.append("<a href='" + Sys.getURL() + "readAction.do?sid=###&bid=" +
aForum.getBoardID() + "&recid=" + aForum.getID2() +
"&pages=1' title='"+aForum.getTitle()+"'>" +
Util.getCutString(Util.stripslashes(aForum.getTitle()), 8) +
"</a>");
sb.append("<font color=#FF0000> [" + aForum.getBoardName() + "]</font>");
sb.append("</td></tr>");
}
}
else {
sb.append("<!--No New Post-->");
}
try {
String filepath = Util.getPubFilePath();
File file = new File(filepath + "newpost.htm");
if (file.exists()) {
file.delete();
}
FileOutputStream wf = new FileOutputStream(filepath + "newpost.htm");
if (Sys.isLocale()) {
wf.write(sb.toString().getBytes());
}
else {
wf.write(sb.toString().getBytes("UTF8"));
}
wf.close();
}
catch (IOException e) {
logger.error(e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -