📄 managernews.java
字号:
dbConn.ExeUpdate(s1);
dbConn.CloseConn();
}
public String contentFilter(String s) throws Exception {
String s1 = handle.Replace("\"", "\\\"", s);
s1 = handle.Replace("\n", "", s1);
s1 = handle.Replace("\r", "", s1);
return s1;
}
public void delModule(HttpServletRequest httpservletrequest, String s,
String s1) throws Exception {
String s3 = handle.getString(httpservletrequest, "mid_module");
String as[] = handle.Split(",", s3);
int i = Integer.parseInt(as[0]);
String s4 = as[1];
handle.Del(httpservletrequest, "module\\" + s4 + "\\detail_news.jsp");
handle.Del(httpservletrequest, "module\\" + s4);
String s2 = "DELETE FROM " + s + " WHERE mid=?";
dbConn.getPreparedStatement(s2);
dbConn.setInt(1, i);
dbConn.ExeUpdate();
s2 = "DELETE FROM " + s1 + " WHERE mid=?";
dbConn.getPreparedStatement(s2);
dbConn.setInt(1, i);
dbConn.ExeUpdate();
}
public Vector getAllTypeName(String s) throws Exception {
Vector vector = new Vector();
try {
String s1 = "SELECT * FROM " + s + " ORDER BY id DESC";
for (ResultSet resultset = dbConn.ExeQuery(s1); resultset.next(); vector
.addElement(resultset.getString("title")))
;
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getAllTypeName():" + sqlexception.getMessage());
}
return vector;
}
public Vector getCommendNews(String s, int i) throws Exception {
String s1 = "";
String as[] = new String[3];
Vector vector = new Vector();
try {
String s3 = "SELECT * FROM " + s + " WHERE commend = 1";
for (ResultSet resultset = dbConn.ExeQuery(s3); resultset.next();) {
String as1[] = CheckSplit(s, resultset.getString("pagination"),
resultset.getString("id"),
resultset.getString("topic"), resultset
.getString("date_time"));
if (!as1[1].equals(s1)) {
String s4 = handle.Convert2Path(Integer.parseInt(as1[0]),
as1[2]);
String s2 = as1[1];
newsBean newsbean = new newsBean();
newsbean.setTopic(s2);
newsbean.setHtmlFileName(s4);
newsbean.setDateTime(handle.Split(" ", as1[2])[0]);
vector.addElement(newsbean);
s1 = as1[1];
}
}
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getCommendNews():" + sqlexception.getMessage());
}
return vector;
}
public Vector getConditionStr(String s, String s1) {
String s2 = "";
String s3 = null;
String s4 = null;
Vector vector = new Vector();
if (s1.indexOf("&&") != -1) {
s3 = "AND";
s4 = "&&";
} else {
s3 = "OR";
s4 = "||";
}
String as[] = handle.Split(s4, s1);
if (as.length == 1) {
s2 = s2 + s + " LIKE '%" + as[0] + "%'";
} else {
int i;
for (i = 0; i < as.length - 1; i++)
s2 = s2 + s + " LIKE '%" + as[i] + "%' " + s3 + " ";
s2 = s2 + s + " LIKE '%" + as[i] + "%'";
}
s2 = handle.Replace(s3 + " " + s + " LIKE '%%'", "", s2);
vector.addElement(s2);
vector.addElement(as);
return vector;
}
public Vector getHotNews(String s, int i) throws Exception {
String s1 = "";
String as[] = new String[3];
Vector vector = new Vector();
try {
String s2 = "SELECT * FROM "
+ s
+ " WHERE date_time >= '2002-11-30 16:15:09' ORDER BY click DESC";
for (ResultSet resultset = dbConn.ExeQuery(s2); resultset.next()
&& vector.size() != i;) {
String as1[] = CheckSplit(s, resultset.getString("pagination"),
resultset.getString("id"),
resultset.getString("topic"), resultset
.getString("date_time"));
if (!as1[1].equals(s1)) {
String s3 = handle.Convert2Path(Integer.parseInt(as1[0]),
as1[2]);
newsBean newsbean = new newsBean();
newsbean.setTopic(as1[1]);
newsbean.setHtmlFileName(s3);
newsbean.setDateTime(handle.Split(" ", as1[2])[0]);
vector.addElement(newsbean);
s1 = as1[1];
}
}
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getHotNews():" + sqlexception.getMessage());
}
return vector;
}
public String getModule(int i, String s, String s1) throws Exception {
String s3 = null;
try {
String s2 = "SELECT * FROM " + s + " AS a," + s1
+ " AS b WHERE a.tid=? AND a.mid=b.mid";
dbConn.getPreparedStatement(s2);
dbConn.setInt(1, i);
ResultSet resultset = dbConn.ExeQuery();
if (resultset.next())
s3 = resultset.getString("module");
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getModule():" + sqlexception.getMessage());
}
return s3;
}
public Vector getModuleBeanVector(ServletContext sc,
String s, String s1) throws Exception {
Vector vector = new Vector();
try {
String s2 = "SELECT * FROM " + s + " ORDER BY mid DESC";
for (ResultSet resultset = dbConn.ExeQuery(s2); resultset.next();) {
File file = new File(sc.getRealPath(".")
+ "\\module\\" + resultset.getString("module"));
File file1 = new File(sc.getRealPath(".")
+ "\\module\\" + resultset.getString("module")
+ "\\detail_news.jsp");
if (!s1.equals("all")) {
if (file.exists() && file1.exists()) {
moduleBean modulebean = new moduleBean();
modulebean.setMid(resultset.getInt("mid"));
modulebean.setModule(resultset.getString("module"));
vector.addElement(modulebean);
}
} else {
moduleBean modulebean1 = new moduleBean();
modulebean1.setMid(resultset.getInt("mid"));
modulebean1.setModule(resultset.getString("module"));
vector.addElement(modulebean1);
}
}
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getModuleBeanVector():"
+ sqlexception.getMessage());
}
return vector;
}
public int getNid(String s) throws Exception {
int i = 0;
try {
String s1 = "SELECT * FROM " + s;
dbConn.getPreparedStatement(s1);
ResultSet resultset = dbConn.ExeQuery();
if (resultset.next())
i = resultset.getInt("id");
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getNid():" + sqlexception.getMessage());
}
return i;
}
public Hashtable getSearchResultHashable(
HttpServletRequest httpservletrequest, int i, String s, String s1,
String s2) throws Exception {
Object obj = null;
int j = 0;
float f = 0.0F;
boolean flag = false;
Hashtable hashtable = new Hashtable();
Hashtable hashtable1 = new Hashtable();
Vector vector = new Vector();
String s4 = handle.getString(httpservletrequest, "CurrentPage", "0");
String s5 = handle.getString(httpservletrequest, "keywords");
s5 = handle.GBK2ISO(s5);
String s6 = handle.getString(httpservletrequest, "type");
Object obj1 = null;
Object obj2 = null;
Vector vector1 = getConditionStr(s6, s5);
String s9 = (String) vector1.elementAt(0);
try {
String s3 = "SELECT * FROM " + s1 + " WHERE " + s9
+ " ORDER BY id DESC";
ResultSet resultset = dbConn.ExeQuery(s3);
resultset.last();
j = resultset.getRow();
hashtable = turn_page(s4, i, j);
int l = Integer.parseInt(String.valueOf(hashtable.get("pt_st"))) + 1;
int i1 = Integer.parseInt(String.valueOf(hashtable.get("pt_en"))) + 1;
resultset.absolute(l);
for (int k = l; k < i1; k++) {
f++;
int j1 = resultset.getInt("id");
String s7 = resultset.getString("content");
String s8 = resultset.getString("topic");
s7 = handle.Replace(handle.ISO2GBK(s5), "<font color=red>"
+ handle.ISO2GBK(s5) + "</font>", s7);
s8 = handle.Replace(handle.ISO2GBK(s5), "<font color=red>"
+ handle.ISO2GBK(s5) + "</font>", s8);
if (s7.length() > 216)
s7 = s7.substring(0, 216) + "……";
newsBean newsbean = new newsBean();
newsbean.setHtmlFileName(handle.Convert2Path(resultset
.getInt("id"), resultset.getString("date_time")));
newsbean.setTopic(s8);
newsbean.setContent(s7);
newsbean.setDateTime(resultset.getString("date_time"));
newsbean.setTypeName(getTypeName(s2, resultset
.getInt("type_id")));
vector.addElement(newsbean);
if (!resultset.next())
break;
}
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getSearchResultHashable():"
+ sqlexception.getMessage());
}
String s10 = navigationSearch(hashtable, s, s5, s6);
hashtable1.put("RecordCount", String.valueOf(j));
hashtable1.put("newsBeanVector", vector);
hashtable1.put("TurpageStr", s10);
return hashtable1;
}
public Hashtable getStatSum(HttpServletRequest httpservletrequest, String s)
throws Exception {
Hashtable hashtable = new Hashtable();
float f = 0.0F;
int i = 0;
String s2 = handle.getString(httpservletrequest, "yearSt", "");
String s3 = handle.getString(httpservletrequest, "monthSt", "");
String s4 = handle.getString(httpservletrequest, "yearEn", "");
String s5 = handle.getString(httpservletrequest, "monthEn", "");
try {
String s1 = "SELECT SUM(click) AS sumClick,AVG(click) AS sumAvgClick FROM "
+ s;
dbConn.getPreparedStatement(s1);
ResultSet resultset = dbConn.ExeQuery();
if (resultset.next())
hashtable.put("sumClick", new Integer(resultset
.getInt("sumClick")));
s1 = "SELECT AVG(click) AS avgClick FROM " + s
+ " GROUP BY type_id";
dbConn.getPreparedStatement(s1);
for (ResultSet resultset1 = dbConn.ExeQuery(); resultset1.next();)
f += resultset1.getFloat("avgClick");
s1 = "SELECT (MAX(click) - MIN(click)) AS subClick FROM " + s
+ " GROUP BY type_id";
dbConn.getPreparedStatement(s1);
for (ResultSet resultset2 = dbConn.ExeQuery(); resultset2.next();)
i += resultset2.getInt("subClick");
dbConn.CloseConn();
} catch (SQLException sqlexception) {
System.err.println("getStatSum():" + sqlexception.getMessage());
}
hashtable.put("sumAvgClick", new Float(f));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -