📄 useraction.java
字号:
package fengyun.Fastmail.beans.admin;
import java.io.*;
import java.sql.*;
import fengyun.Fastmail.beans.*;
public class UserAction {
private static BeansConstants CONST = BeansConstants.getInstance();
private String action = null;
private String userid = null;
private String username = null;
private String location = null;
private String zipcode = null;
private String phone = null;
private String year = null;
private String month = null;
private String day = null;
private String cardNumber = null;
private String regdate = null;
private String birthday = null;
private int gender = 0;
private int occupation = 0;
private int education = 0;
private int province = 0;
private int certificateType = 1;
public void setUserid(String userid) { this.userid = userid; }
public String getUserid() { return userid; }
public String getUsername() { return username; }
public String getLocation() { return location; }
public String getZipcode() { return zipcode; }
public String getPhone() { return phone; }
public String getCardNumber() { return cardNumber; }
public String getDay() { return day; }
public String getYear() { return year; }
public String getMonth() { return month; }
public int getEducation() { return education; }
public int getOccupation() { return occupation; }
public int getProvince() { return province; }
public int getCertificateType() { return certificateType; }
public int getGender() { return gender; }
public String getRegdate() { return regdate; }
public String getBirthday() { return birthday; }
public boolean select() {
try {
Mysql mysql = new Mysql();
ResultSet rs = mysql.executeQuery("select *,year(birthday) as year,month(birthday) as month,dayofmonth(birthday) as day from profile where userid='"+userid+"'");
boolean next = rs.next();
if (next) {
username = rs.getString("username");
gender = rs.getInt("gender");
certificateType = rs.getInt("certificateType");
education = rs.getInt("education");
occupation = rs.getInt("occupation");
province = rs.getInt("province");
location = rs.getString("location");
zipcode = rs.getString("zipcode");
cardNumber = rs.getString("cardNumber");
phone = rs.getString("phone");
year = rs.getString("year");
month = rs.getString("month");
day = rs.getString("day");
birthday = rs.getString("birthday");
regdate = rs.getString("regdate");
}
rs.close();
mysql.close();
return next;
} catch (Exception ex) {
System.err.println("UserAction.select():");
ex.printStackTrace(System.err);
return false;
}
}
public static void setQuota(String uid,String quota) {
try {
String sql = "update mailbox set quota="+quota+" where userid='"+uid+"'";
Mysql mysql = new Mysql();
mysql.executeUpdate(sql);
mysql.close();
} catch (Exception ex) {
System.err.println("UserAction.setQuota():");
ex.printStackTrace(System.err);
}
}
public static int getQuota(String uid) {
int quota = 0;
try {
String sql = "select quota from mailbox where userid='"+uid+"'";
Mysql mysql = new Mysql();
ResultSet rs = mysql.executeQuery(sql);
if (rs.next()) quota = rs.getInt("quota");
mysql.close();
} catch (Exception ex) {
System.err.println("UserAction.getQuota():");
ex.printStackTrace(System.err);
}
return quota;
}
public static void password(String uid, String pass) {
try {
String sql = "update mailbox set password=password('"+pass+"') where userid='"+uid+"'";
Mysql mysql = new Mysql();
mysql.executeUpdate(sql);
mysql.close();
} catch (Exception ex) {
System.err.println("UserAction.password():");
ex.printStackTrace(System.err);
}
}
public static void delete(String userid) {
String home = null;
try {
Mysql mysql = new Mysql();
ResultSet rs = mysql.executeQuery("select * from mailbox where userid='"+userid+"'");
if (rs.next()) {
home = rs.getString("home");
} else {
return ;
}
File homedir = new File (home);
if (homedir.exists()) {
deleteDirectory(home);
}
String profilesql = "delete from profile where userid='"+userid+"'";
String mailboxsql = "delete from mailbox where userid='"+userid+"'";
String folderlistsql = "delete from folderlist where userid='"+userid+"'";
String addresssql = "delete from address where userid='"+userid+"'";
mysql.executeUpdate(profilesql);
mysql.executeUpdate(mailboxsql);
mysql.executeUpdate(folderlistsql);
mysql.executeUpdate(addresssql);
mysql.close();
} catch (Exception ex) {
System.err.println("UserAction.delete():");
ex.printStackTrace(System.err);
}
}
public static void deleteDirectory(String home) {
Runtime r=Runtime.getRuntime();
Process p=null;
String cmd[]={"rm","-rf",home};
try{
p=r.exec(cmd);
} catch(Exception e){
System.out.println("error executing: "+cmd[0]);
}
}
public boolean isValid() {
if (userid != null && !userid.equals("")) return true; else return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -