⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userin.java

📁 BBS-CS是采用JSP+JavaBean+Servlet开发的一套网络虚拟社区系统。
💻 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;/** * <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 UserIn {  String SQL = "";  DbTrans DBSQL;  ResultSet rs = null;  UserInfo myUserInfo;  DoText myDoText;  BBSConf myBBSConf;  int UserExp = 0;  int power = 0;  int hpower = 0;  String jibie = "";  public UserIn() {      this.DBSQL = new DbTrans();      this.myUserInfo = new UserInfo();      this.myDoText = new DoText();      this.myBBSConf = new BBSConf();  }  //public void setUserInfo(String strUserID) {  //    myUserInfo.setUserInfo(strUserID);  //}  public void setUserIn(String strUserID) {      getUserLevel(strUserID);      SQL = "update userdata set exp="+ this.UserExp +",power="+ this.power +",hpower="+ this.hpower +" where UID="+strUserID;      try {          DBSQL.executeQuery(SQL);      }      catch (SQLException e) {      }  }  public int getUserExp(String strUserID) {      int cishu = 0;      int bx = 0;      int artunm = 0;      int staytime = 0;      myUserInfo.setUserInfo(strUserID);      cishu = myUserInfo.getUserCiShu();      UserData myUserData = new UserData();      myUserData.setUserData(strUserID);      bx = myUserData.getUserBx();      artunm = myUserData.getUserArtNum();      staytime = myUserData.getUserStatyTime();      this.power = myUserData.getUserPower();      this.UserExp = (cishu/4)+artunm+(staytime/3600)+bx;      return this.UserExp;  }  public String getUserLevel(String strUserID) {      int exp = getUserExp(strUserID);      String jibie = "";      if (exp>=0 && exp<=10) {          this.hpower=10;          jibie="新手上路";      }      if (exp>=11 && exp<=50) {          this.hpower=15;          jibie="初出江湖";      }      if (exp>=51 && exp<=130) {          this.hpower=20;          jibie="一般站友";      }      if (exp>=131 && exp<=260) {          this.hpower=30;          jibie = "中级站友";      }      if (exp>=261 && exp<=450) {          this.hpower = 40;          jibie="高级站友";      }      if (exp>=451 && exp<=700) {          this.hpower = 50;          jibie = "老 站 友";      }      if (exp>=701 && exp<=1100) {          this.hpower=60;          jibie="青铜长老";      }      if (exp>=1101 && exp<=1900) {          this.hpower = 80;          jibie = "白银长老";      }      if (exp>=1901 && exp<=3000) {          this.hpower = 100;          jibie = "黄金长老";      }      if (exp>=3001 && exp<=4500) {          this.hpower = 120;          jibie = "白金长老";      }      if (exp>=4501 && exp<=6500) {          this.hpower = 140;          jibie = "钻石长老";      }      if (exp>=6501 && exp<=9000) {          this.hpower = 170;          jibie = "本站元老";      }      if (exp>=9001) {          this.hpower=200;          jibie="开国大老";      }      return jibie;  }  public int getUserPower() {      return this.power;  }  public int getUserHPower() {      return this.hpower;  }  public int getSumNote(String strUserID) {      int znote = 0;      SQL = "select count(*) as znote from guestbook where UID="+ strUserID;      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              znote = rs.getInt("znote");          }          rs.close();      }      catch (SQLException e){      }      return znote;  }  public int getSumNewNote(String strUserID) {      int wnote = 0;      SQL = "select count(*) as wnote from guestbook where UID="+ strUserID +" and yd=0";      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              wnote = rs.getInt("wnote");          }          rs.close();      }      catch (SQLException e){      }      return wnote;  }  public int getNumMyFriend(String strUserID) {      int myfriend = 0;      SQL = "select count(*) as myfriend from friend where UID="+ strUserID;      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              myfriend = rs.getInt("myfriend");          }          rs.close();      }      catch (SQLException e){      }      return myfriend;  }  public int getNumOMyFriend(String strUserID) {      int friendonlie = 0;      SQL = "select count(*) as friendonlie from user,friend where friend.UID="+ strUserID +" and user.ID=friend.FID and (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(user.logintime))<=180";      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              friendonlie = rs.getInt("friendonlie");          }          rs.close();      }      catch (SQLException e){      }      return friendonlie;  }  public String getAdv() {      String strAdv = "";      Random r = new Random();      int rnum;      rnum = r.nextInt(2)+1;      if (rnum == 1) {          strAdv = "<a href=http://www.loveroom.com.cn target=_blank><img src=images/shmail.gif width=468 height=60 border=0></a>";      }      else if (rnum == 2) {          strAdv = "<script src=http://mysms.163.com/person?username=laoer&type=1></script>";      }      else {          strAdv = "<a href=http://www.loveroom.com.cn target=_blank><img src=images/shmail.gif width=468 height=60 border=0></a>";      }      return strAdv;  }  public String getHotArt() {      String strHotArt = "";      String tablecolor = "";      int n = 2;      int i = 1;      SQL = "select id2,board,title,time,click from forum  where (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(time))<=604800 and new=1 and delsign = 0 order by click desc limit 0,10";      try {          rs = DBSQL.executeQuery(SQL);          while (rs.next()) {              if ((i %= n)==1) {                  tablecolor = myBBSConf.gettabletintcolor();              }              else {                  tablecolor = myBBSConf.gettabledarkcolor();              }              strHotArt += "<tr>\n";              strHotArt += "<td bgcolor=";              if ((i %= n)==1) {                  strHotArt += tablecolor;              } else {                  strHotArt += tablecolor;              }              strHotArt += "><a href='showdoc.jsp?bid="+rs.getString("board")+"&recid="+rs.getString("id2")+"&pages=1'>";              strHotArt += "<span class=bt>"+myDoText.iso2gb(rs.getString("title"))+"</span></a>";              strHotArt += "<font color=#FF0000> [点击"+rs.getInt("click")+"次  发表于"+rs.getString("time")+"]</font></td>\n";              strHotArt += "</tr>\n";              i++;          }          rs.close();      }      catch (SQLException e){      }      return strHotArt;  }  public String getNewArt() {      String strHotArt = "";      String tablecolor = "";      int n = 2;      int i = 1;      SQL = "select id2,board,boardname,title,time,havepic from forum  where new=1 and delsign = 0 order by time desc limit 0,10";      try {          rs = DBSQL.executeQuery(SQL);          while (rs.next()) {              if ((i %= n)==1) {                  tablecolor = myBBSConf.gettabletintcolor();              }              else {                  tablecolor = myBBSConf.gettabledarkcolor();              }              strHotArt += "<tr>\n";              strHotArt += "<td bgcolor=";              if ((i %= n)==1) {                  strHotArt += tablecolor;              } else {                  strHotArt += tablecolor;              }              strHotArt += "><a href='showdoc.jsp?bid="+rs.getString("board")+"&recid="+rs.getString("id2")+"&pages=1'>";              strHotArt += "<span class=bt>"+myDoText.iso2gb(rs.getString("title"))+"</span></a>";              strHotArt += "<font color=#FF0000> ["+myDoText.iso2gb(rs.getString("boardname"))+"]</font></td>\n";              strHotArt += "</tr>\n";              i++;          }          rs.close();      }      catch (SQLException e){      }      return strHotArt;  }  public String getUserPH() {      String strUserPH = "";      String tablecolor = "";      int n = 2;      int i = 1;      SQL = "select user.name,user.nick,userdata.UID,userdata.exp from user,userdata where user.ID=userdata.UID order by userdata.exp desc limit 0,10";      try {          rs = DBSQL.executeQuery(SQL);          while (rs.next()) {          if ((i %= n)==1) {                  tablecolor = myBBSConf.gettabletintcolor();              }              else {                  tablecolor = myBBSConf.gettabledarkcolor();              }              strUserPH += "<tr>\n";              strUserPH += "<td bgcolor=";              if ((i %= n)==1) {              strUserPH += tablecolor;              } else {              strUserPH += tablecolor;              }              strUserPH += "><a href='userinfo.jsp?UID="+rs.getInt("UID")+"'><span class=bt>";              strUserPH += myDoText.iso2gb(rs.getString("name"))+"</span></a>[经验值:"+rs.getInt("exp")+"]</td>\n";              strUserPH += "</tr>\n";              i++;          }          rs.close();      }      catch (SQLException e){      }      return strUserPH;  }  public String getHotBoard() {      String strHotBoard = "";      SQL = "select ID,boardname from board order by xu";      try {          rs = DBSQL.executeQuery(SQL);          while (rs.next()) {              strHotBoard += "["+myDoText.iso2gb(rs.getString("boardname"))+"]<br>";              strHotBoard += getHotBoards(rs.getString("ID"));          }          rs.close();      }      catch (SQLException e){      }      return strHotBoard;  }  public String getHotBoards(String bid) {      String strHotBoards = "";      SQL = "select ID,boardsname from boards where boardID = "+bid+" order by artcount desc limit 0,3";      ResultSet rs1 = null;      try {          rs1 = DBSQL.executeQuery(SQL);          while (rs1.next()) {              strHotBoards += "<a href='right.jsp?bid="+rs1.getString("ID")+"&pages=1'>"+myDoText.iso2gb(rs1.getString("boardsname"))+"</a> ";          }          rs1.close();      }      catch (SQLException e){      }      strHotBoards += "<br>";      return strHotBoards;  }  public String getUserPic(String strUserID) {      String strUserPic = "";      int photonum = 0;      String picname = "";      SQL = "select count(*) as photonum from photo where UID="+strUserID;      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              photonum = rs.getInt("photonum");          }          rs.close();      }      catch (SQLException e){      }      if (photonum!=0) {          SQL = "select picname from photo where UID="+strUserID;          try {              rs = DBSQL.executeQuery(SQL);              if (rs.next()) {                  picname = rs.getString("picname");                  strUserPic = "<a href='upload/"+picname+"' target='_blank'><img src=upload/"+ picname +" width=200 height=150 border=0></a>";              }              rs.close();          }          catch (SQLException e){          }      }      else {          strUserPic = "<img src=images/photo.gif width=200 height=150>";      }      return strUserPic;  }  public boolean isHaveStar() {      int numStar = 0;      SQL = "select count(*) as numStar from photo where isstart = 1";      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              numStar = rs.getInt("numStar");          }          rs.close();      }      catch (SQLException e){      }      if (numStar != 0) {          return true;      }      else {          return false;      }  }  public String getStarPic() {      String strStarPic = "";      SQL = "select picname from photo where isstart = 1";      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              strStarPic = rs.getString("picname");          }          rs.close();      }      catch (SQLException e){      }      return strStarPic;  }  public String getStarBrief() {      String strStarBrief = "";      UserMyData StarUserMyData = new UserMyData();      String StarUID = "";      SQL = "select UID from photo where isstart = 1";      try {          rs = DBSQL.executeQuery(SQL);          if (rs.next()) {              StarUID = rs.getString("UID");          }          rs.close();      }      catch (SQLException e){          return "";      }      StarUserMyData.setUserMyData(StarUID);      strStarBrief = StarUserMyData.getBrief();      StarUserMyData.close();      return strStarBrief;  }  public void close() {      try {          DBSQL.close();      }      catch (SQLException e){      }      myUserInfo.close();      myBBSConf.close();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -