📄 cipserver.java
字号:
if (obj.getClass().getName().compareTo("Reg")==0)
{
client_Reg(obj);
}
else
{
if (obj.getClass().getName().compareTo("FromU238")==0)
{
cipServer.from_Send_U238(obj);
}
if (obj.getClass().getName().compareTo("SCMessage")==0)
{
client_SCMessage(obj);
}
if (obj.getClass().getName().compareTo("GLogin")==0)
{
System.out.println("222");
client_GLogin(obj);
client_AD(objectOut);
client_OnlineUser(obj);
client_Title(obj,"Login");
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)onlineuser.elementAt(i);
obj2.client_Title(obj,"Login");
}
}
if (obj.getClass().getName().compareTo("Login")==0)
{
System.out.println("66");
client_Login(obj);
System.out.println("77");
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)onlineuser.elementAt(i);
obj2.client_Title(obj,"Login");
}
}
if (obj.getClass().getName().compareTo("Chat")==0)
{
Chat objJS=(Chat)obj;
if (objJS.YNSL.equals("1"))
{
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.textSL.append("("+dateSystemTime+")"+"〖私聊〗刚才"+objJS.fromwho+"对"+objJS.towho+objJS.ChatXQ+"用了一次私聊功能!私聊的内容为:"+objJS.chatinformation+"\n");
cipServer.autoSave();
}
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)onlineuser.elementAt(i);
obj2.client_Chat(obj);
}
}
else if (obj.getClass().getName().compareTo("Title")==0)
{
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)onlineuser.elementAt(i);
obj2.client_Title(obj,"1");
}
}
else if((!(obj.getClass().getName().compareTo("GLogin")==0))&&(!(obj.getClass().getName().compareTo("Login")==0))&&(!(obj.getClass().getName().compareTo("PM")==0))&&(!(obj.getClass().getName().compareTo("FromU238")==0)))
{
SCMessage scmessage=new SCMessage();
scmessage.scMessage="OK!"+"服务器受到连接消息!并已经连接成功了!";
objectOut.writeObject(scmessage);
System.out.println(obj.getClass().getName());
client_AD(objectOut);
client_OnlineUser(obj);
}
if (obj.getClass().getName().compareTo("PM")==0)
{
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)onlineuser.elementAt(i);
obj2.client_PM(obj);
}
}
if (obj.getClass().getName().compareTo("AD")==0)
{
client_AD(objectOut);
}
if (obj.getClass().getName().compareTo("Exit")==0)
{
client_Exit(obj);
}
if (obj.getClass().getName().compareTo("OnlineUser")==0)
{
client_OnlineUser(obj);
}
}
System.out.println("1313");
objectOut.flush();
System.out.println("1414");
}
}
catch(SocketException e)
{
System.out.println("86688668 SocketException\n"+e);
for(int i=0;i<onlineuser.size();i++)
{
Connect obj2=(Connect)cipServer.onlineuser.elementAt(i);
if (obj2.custName.equals(this.custName))
cipServer.onlineuser.remove(i);
}
//System.out.println(this.custName+"离开了!"+"("+this.custName+")\n");
//cipServer.text.append("("+dateSystemTime+")"+this.custName+"离开了!"+"("+this.custName+")\n");
System.out.println(this.custName+"离开了!\n");
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+this.custName+"离开了!\n");
cipServer.autoSaveAddExit("("+dateSystemTime+")"+this.custName+"离开了!");
cipServer.autoSave();
cipServer.displayOnlineUser("Exit",this.custName);
}
catch(IOException e)
{
System.out.println("89988998 IOException\n"+e);
}
catch(ClassNotFoundException e)
{
System.out.println("58855885 ClassNotFoundException\n"+e);
}
}
public void client_SCMessage(Object object)
{
Object obj=object;
obj=(SCMessage)obj;
}
public void client_GLogin(Object object)
{
GLogin obj=(GLogin)object;
obj.GLoginMessage="1";
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+obj.name+"连接服务器了!\n");
cipServer.autoSaveAddC("("+dateSystemTime+")"+obj.name+"连接服务器了!");
cipServer.autoSave();
custName=obj.name;
if (!(obj.VER.equals("v1.21")))
{
obj.GLoginMessage="0";
cipServer.text.append("("+dateSystemTime+")"+obj.name+"由于版本不符合!已经被强行退出程序了!"+obj.name+"使用的版本是:"+obj.VER+"\n");
cipServer.autoSave();
}
cipServer.displayOnlineUser("GLogin","");
System.out.println("19");
try
{
System.out.println("20");
objectOut.writeObject(obj);
System.out.println("21");
objectOut.flush();
System.out.println("22");
}
catch(IOException e){System.out.println("client_Login IOException\n"+e);}
System.out.println("23");
}
public void client_Reg(Object object)
{
Reg obj=(Reg)object;
RegSCMessage regSCMessage=new RegSCMessage();
try
{
String entry=obj.Name+"|"+obj.Pass;
String name=obj.Name;
String pass=obj.Pass;
String pass2=obj.Pass2;
String s;
String sA;
String sF;
String sName;
String sTN;
String YN="0";
String all="\n|————————"+"\n|名字:"+obj.Name+"\n|密码:"+obj.Pass+"\n|年龄:"+obj.Age+"\n|性别:"+obj.Sex+"\n|门派:"+obj.jhmp+"\n|网站:"+obj.WebURL+"\n|QQ:"+obj.QQ+"\n|来自:"+obj.From+"\n|备注:"+obj.Other+"\n|IP:"+obj.IP+"\n|————————\n";
custIP=obj.IP;
if (obj.Name.length()<=0)
{
System.out.println("用户名不能为空");
regSCMessage.RegscMessage="经常在江湖里混怎么能没有名字呢?\n(用户名不能为空)";
}
else if (obj.Name.length()>7)
{
System.out.println("用户名不能大于7位!");
regSCMessage.RegscMessage="老大!您的大名太长了!别人叫您也太不方便了啊!请重新想个短点的!\n(用户名不能大于7位!)";
}
else if (obj.Name.equals("大家"))
{
System.out.println("您所注册的用户名为系统保留用户名!请重新选择一个!谢谢!");
regSCMessage.RegscMessage="想冒充网管是么?还是想嘿本江湖啊!\n(您所注册的用户名为系统保留用户名!请重新选择一个!谢谢!)";
}
else if (!(obj.Pass.equals(obj.Pass2)))
{
System.out.println("两次输入的密码不同!请重新输入!");
regSCMessage.RegscMessage="到底是哪个作为江湖进出的口令啊!想耍我么?哼!!!\n(两次输入的密码不同!请重新输入!)";
}
else if ((obj.Pass.length()<6)||(obj.Pass2.length()<6))
{
System.out.println("密码不能小于6位!");
regSCMessage.RegscMessage="江湖口令太短了吧!这样别人很容易冒充您的!请重新设定!\n(密码不能小于6位!)";
}
else if ((obj.Pass.length()>30)||(obj.Pass2.length()>30))
{
System.out.println("密码不能大于30位!");
regSCMessage.RegscMessage="江湖口令太长了吧!这样对您来说会非常不方便的!当然对黑客也不方便咯~~~\n(密码不能大于30位!)";
}
else if((name.length()!=0)&&(obj.Pass.length()!=0)&&(obj.Pass2.length()!=0)&&(obj.Age.length()!=0)&&(obj.Sex.length()!=0)&&(obj.jhmp.length()!=0)&&(obj.WebURL.length()!=0)&&(obj.QQ.length()!=0)&&(obj.From.length()!=0)&&(obj.Other.length()!=0))
{
String GL="0";
for (int i=0;i<obj.Name.length();i++)
{
String LSYZ=obj.Name.substring(i,i+1);
if ((LSYZ.equals("|"))||(LSYZ.equals("/")))
GL="1";
}
for (int i=0;i<obj.Pass.length();i++)
{
String LSYZ=obj.Pass.substring(i,i+1);
if ((LSYZ.equals("|"))||(LSYZ.equals("/")))
GL="1";
}
for (int i=0;i<obj.Pass2.length();i++)
{
String LSYZ=obj.Pass2.substring(i,i+1);
if ((LSYZ.equals("|"))||(LSYZ.equals("/")))
GL="1";
}
if (GL.equals("1"))
{
System.out.println("用户名与密码中不能包含“|”和“/”!请重新输入!");
regSCMessage.RegscMessage="想做黑客是么?这是不可能的!哼!!!\n(用户名与密码中不能包含“|”和“/”!请重新输入!)";
}
else
{
try
{
FileReader logFile=new FileReader("UsePost"+cipServer.SystemSetUsePost+"Register.txt");
BufferedReader br=new BufferedReader(logFile);
while((s=br.readLine())!=null)
{
sF=s;
if (s.length()==0)
continue;
if (s.length()>=name.length())
{
String sTN1="";
String sZSTN="";
int fff=0;
for(int sss=0;sss<s.length();sss++)
{
sTN=s.substring(sss,sss+1);
if (!(sTN.equals("|")))
{
continue;
}
else
{
fff=1;
}
}
if (fff!=1)
{
continue;
}
for(int ii=0;ii<s.length();ii++)
{
sTN=s.substring(ii,ii+1);
if (!(sTN.equals("|")))
{
sTN1=""+sTN1+sTN;
}
else if (sTN.equals("|"))
{
sZSTN=sTN1;
}
}
sTN=s.substring(name.length(),name.length()+1);
sName=sF.substring(0,name.length());
sA=name.substring(0,name.length());
if (sZSTN.equals(sA))
{
System.out.println("已经存在此用户了!请重新输入一个!");
regSCMessage.RegscMessage="想冒充他人是不?还是想做黑客?\n(已经存在此用户了!请重新输入一个!)";
YN="1";
}
}
else if (s.length()<name.length())
{
continue;
}
}
br.close();
if (!(YN.equals("1")))
{
if (!(entry.equals(s)))
{
FileWriter logFile1=new FileWriter("UsePost"+cipServer.SystemSetUsePost+"Register.txt",true);
BufferedWriter br1=new BufferedWriter(logFile1);
br1.write(entry);
br1.newLine();
br1.flush();
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+obj.Name+"注册了!密码是:"+obj.Pass+"("+custIP+")\n");
cipServer.autoSaveAddReg("("+dateSystemTime+")"+obj.Name+"注册了!密码是:"+obj.Pass+"("+custIP+")");
cipServer.autoSave();
System.out.println("OK1");
regSCMessage.RegscMessage="OK";
br1.close();
FileWriter logFile1other=new FileWriter("UsePost"+cipServer.SystemSetUsePost+"RegisterAll.txt",true);
BufferedWriter br1other=new BufferedWriter(logFile1other);
br1other.write(all);
br1other.newLine();
br1other.flush();
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+obj.Name+"注册了!所有注册资料如下:"+all+"("+custIP+")\n");
cipServer.autoSave();
System.out.println("OK1");
regSCMessage.RegscMessage="OK";
br1other.close();
}
}
}
catch(FileNotFoundException e)
{
FileWriter logFile1=new FileWriter("UsePost"+cipServer.SystemSetUsePost+"Register.txt",true);
BufferedWriter br1=new BufferedWriter(logFile1);
br1.write(entry);
br1.newLine();
br1.flush();
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+obj.Name+"注册了!密码是:"+obj.Pass+"("+custIP+")\n");
cipServer.autoSaveAddReg("("+dateSystemTime+")"+obj.Name+"注册了!密码是:"+obj.Pass+"("+custIP+")");
cipServer.autoSave();
System.out.println("OK2");
regSCMessage.RegscMessage="OK";
br1.close();
FileWriter logFile1other=new FileWriter("UsePost"+cipServer.SystemSetUsePost+"RegisterAll.txt",true);
BufferedWriter br1other=new BufferedWriter(logFile1other);
br1other.write(all);
br1other.newLine();
br1other.flush();
calendar=new GregorianCalendar();
dateSystemTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
cipServer.text.append("("+dateSystemTime+")"+obj.Name+"注册了!全部注册资料如下:"+all+"("+custIP+")\n");
cipServer.autoSave();
System.out.println("OK1");
regSCMessage.RegscMessage="OK";
br1other.close();
}
catch(IOException e)
{
System.out.println("3 Cannot write to the server");
regSCMessage.RegscMessage="3 Cannot write to the server\n" + e;
}
}
}
else
{
System.out.println("注册资料
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -