📄 userpoption.java
字号:
package com.laoer.bbscs.user;import java.sql.*;import java.io.*;import java.util.*;import com.laoer.bbscs.db.*;import com.laoer.bbscs.txthtml.*;import com.laoer.bbscs.admin.BBSConf;import com.laoer.bbscs.bbs.ShowDoc;import com.laoer.bbscs.tool.MD5;/** * <p>Title: BBS-CS</p> * <p>Description: BBS-CS(BBS式虚拟社区系统)</p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: loveroom.com.cn</p> * @author 龚天乙(laoer) * @version 3.0 */public class UserPoption { String SQL = ""; DbTrans DBSQL; DoText myDoText; ResultSet rs = null; public UserPoption() { this.DBSQL = new DbTrans(); this.myDoText = new DoText(); } public boolean setNickName(String strUserID, String strNickName) { SQL = "update user set nick='"+ strNickName +"' where ID="+ strUserID; try { DBSQL.executeQuery(SQL); return true; } catch (SQLException e){ return false; } } public String getFriendList(String strUserID, String pages, String fileName) { String strFriendList = ""; PageBreak myPageBreak = new PageBreak(); BBSConf myBBSConf = new BBSConf(); String strCountSQL = ""; String strSQL = ""; strCountSQL = "select count(*) as total from friend where UID="+ strUserID; strSQL = "select ID,FID,Fname,comment from friend where UID="+ strUserID; rs = myPageBreak.getPageBreak(pages,strCountSQL,strSQL,20); String tablecolor = ""; int n = 2; int i = 1; try { while (rs.next()) { if ((i %= n)==1) { tablecolor = myBBSConf.gettabletintcolor(); } else { tablecolor = myBBSConf.gettabledarkcolor(); } strFriendList += "<tr bgcolor="+ tablecolor +">\n"; strFriendList += "<td width=89><CENTER><a href='userinfo.jsp?UID="+ rs.getInt("FID")+"'>"+myDoText.iso2gb(rs.getString("Fname"))+"</a></CENTER></td>\n"; strFriendList += "<td width=260>"+myDoText.iso2gb(rs.getString("comment"))+"</td>\n"; strFriendList += "<td width=50><div align=center><a href='delfriend.jsp?F_ID="+rs.getInt("ID")+"'>删除</a></div></td>\n"; strFriendList += "</tr>\n"; i++; } } catch (SQLException e){ } strFriendList += "<td colspan=3>"+ myPageBreak.listPageBreak(fileName) +"</td>\n"; myPageBreak.close(); return strFriendList; } public boolean isHaveFriend(String strUserID, String strFName) { int myfriend = 0; SQL = "select count(*) as myfriend from friend where UID="+ strUserID +" and Fname='"+ strFName +"'"; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { myfriend = rs.getInt("myfriend"); } rs.close(); } catch (SQLException e) { } if (myfriend != 0) { return true; } else { return false; } } public boolean addFriend(String strUserID, String strUserName, String strFID, String strFName, String strComment) { SQL = "insert into friend (UID,Uname,FID,Fname,comment) values ('"+ strUserID +"','"+ strUserName +"','"+ strFID +"','"+ strFName +"','"+ strComment +"')"; try { DBSQL.executeQuery(SQL); return true; } catch (SQLException e) { return false; } } public boolean isMyFriend(String F_ID, String strUserID, String strUserName) { int isfnum = 0; SQL = "select count(*) as isfnum from friend where ID="+ F_ID +" and UID="+ strUserID +" and Uname='"+ strUserName +"'"; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { isfnum = rs.getInt("isfnum"); } rs.close(); } catch (SQLException e) { } if (isfnum == 1) { return true; } else { return false; } } public boolean delMyFriend(String F_ID) { SQL = "delete from friend where ID="+ F_ID; try { DBSQL.executeQuery(SQL); return true; } catch (SQLException e) { return false; } } public boolean setUpdateMydate(String strUserID, String height, String weight, String interest, String graduate, String favourpeople, String dreamjob, String favourart, String favourmusic, String favourchat, String favourbook, String dreamlover, String favourteam, String homepage, String favourplace, String favourmovie, String oicqno, String icqno, String sex, String brief) { int numMyData = 0; SQL = "select count(*) as numMyData from mydata where UID = "+strUserID; try { rs = DBSQL.executeQuery(SQL); if (rs.next()) { numMyData = rs.getInt("numMyData"); } rs.close(); } catch (SQLException e) { } if (numMyData == 0) { SQL = "insert into mydata (UID) values ('"+ strUserID +"')"; try { DBSQL.executeUpdate(SQL); } catch (SQLException e) { } } SQL = "update mydata set height='"+ height +"',weight='"+ weight +"',interest='"+ interest +"',graduate='"+ graduate +"',favourpeople='"+ favourpeople +"',dreamjob='"+ dreamjob +"',favourart='"+ favourart +"',favourmusic='"+ favourmusic +"',favourplace='"+ favourplace +"',favourmovie='"+ favourmovie +"',favourchat='"+ favourchat +"',favourbook='"+ favourbook +"',dreamlover='"+ dreamlover +"',favourteam='"+ favourteam +"',homepage='"+ homepage +"',oicqno='"+ oicqno +"',icqno='"+ icqno +"',sex='"+ sex +"',brief='"+ brief +"' where UID="+ strUserID; try { DBSQL.executeUpdate(SQL); return true; } catch (SQLException e) { return false; } } public String getListShuqian(String strUserID, String pages, String fileName) { String strListShuqian = ""; PageBreak myPageBreak = new PageBreak(); BBSConf myBBSConf = new BBSConf(); String strCountSQL = ""; String strSQL = ""; strCountSQL = "select count(*) as total from shuqian where UID="+ strUserID; strSQL = "select * from shuqian where UID="+ strUserID; rs = myPageBreak.getPageBreak(pages,strCountSQL,strSQL,10); String tablecolor = ""; int n = 2; int i = 1; try { while (rs.next()) { if ((i %= n)==1) { tablecolor = myBBSConf.gettabletintcolor(); } else { tablecolor = myBBSConf.gettabledarkcolor(); } strListShuqian += "<tr bgcolor="+tablecolor+">"; strListShuqian += "<td width=322><a href="+rs.getString("url")+" title=\""+myDoText.iso2gb(rs.getString("alt"))+"\" target=_blank>"+myDoText.iso2gb(rs.getString("sqname"))+"</a></td>\n"; strListShuqian += "<td width=70>\n"; strListShuqian += "<div align=center><a href=delshuqian.jsp?sq_ID="+rs.getString("ID")+">删除</a> <a href=shuqian.jsp?sqID="+rs.getString("ID")+">更新</a></div>\n"; strListShuqian += "</td>\n</tr>\n"; i++; } } catch (SQLException e){ } strListShuqian += "<td colspan=2>"+ myPageBreak.listPageBreak(fileName) +"</td>\n"; myPageBreak.close(); return strListShuqian; } public boolean addShuQian(String strUserID, String sqname, String url, String alt) { SQL = "insert into shuqian (UID,sqname,url,alt) values ('"+ strUserID +"','"+ sqname +"','"+ url +"','"+ alt +"')"; try { DBSQL.executeUpdate(SQL); return true; } catch (SQLException e) { return false; } } public boolean upDateShuQian(String strUserID, String sqID, String sqname, String url, String alt) { SQL = "update shuqian set sqname='"+ sqname +"',url='"+ url +"',alt='"+ alt +"' where ID="+ sqID +" and UID="+ strUserID; try { DBSQL.executeUpdate(SQL); return true; } catch (SQLException e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -