|
|
Java-Quelltext |
1 |
public TextField(int width) { |
[/spoiler]|
|
MySQL-Abfrage(n) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
package handler;
import knuddels.Client;
import tools.popup.Popup;
import knuddels.Server;
import tools.KCodeParser;
public class EditHandler {
public static void handle(String[] tokens, Client client) {
String realname = tokens[3].trim();
String stadt = tokens[4].trim();
String land = tokens[5].trim();
String hobbys = tokens[6].trim();
String job = tokens[7].trim();
String motto = tokens[8].trim();
realname = KCodeParser.parse(realname, !client.isModerator(), 0, 10, 20);
realname = Server.get().parseSmileys(realname);
stadt = KCodeParser.parse(stadt, !client.isModerator(), 0, 10, 20);
stadt = Server.get().parseSmileys(stadt);
land = KCodeParser.parse(land, !client.isModerator(), 0, 10, 20);
land = Server.get().parseSmileys(land);
hobbys = KCodeParser.parse(hobbys, !client.isModerator(), 0, 10, 20);
hobbys = Server.get().parseSmileys(hobbys);
job = KCodeParser.parse(job, !client.isModerator(), 0, 10, 20);
job = Server.get().parseSmileys(job);
motto = KCodeParser.parse(motto, !client.isModerator(), 0, 10, 20);
motto = Server.get().parseSmileys(motto);
String errors = "";
if(realname.length() > 50) {
errors += String.format("#Deine Angabe unter _'Real Name'_ ist %s Zeichen _zu lang_.", (realname.length()-50));
}
if(stadt.length() > 50) {
errors += String.format("#Deine Angabe unter _'Stadt'_ ist %s Zeichen _zu lang_.", (stadt.length()-50));
}
if(land.length() > 50) {
errors += String.format("#Deine Angabe unter _'Land'_ ist %s Zeichen _zu lang_.", (land.length()-50));
}
if(hobbys.length() > 80) {
errors += String.format("#Deine Angabe unter _'Hobbys'_ ist %s Zeichen _zu lang_.", (realname.length()-80));
}
if(job.length() > 50) {
errors += String.format("#Deine Angabe unter _'Job'_ ist %s Zeichen _zu lang_.", (job.length()-50));
}
if(motto.length() > 400) {
errors += String.format("#Deine Angabe unter _'Motto'_ ist %s Zeichen _zu lang_.", (motto.length()-400));
}
if(!errors.isEmpty()) {
client.send(Popup.create("Problem", "Problem", String.format("#Bei der Änderung deiner Daten sind folgende _Probleme_ aufgetreten:#%s", errors), 400, 250));
return;
}
client.send(Popup.create("Änderungen übernommen", "Änderungen übernommen", "#Alle Änderungen wurden _gespeichert_.", 400, 250));
client.setRealName(realname);
client.setStadt(stadt);
client.setLand(land);
client.setHobbys(hobbys);
client.setJob(job);
client.setMotto(motto);
}
}
|
|
|
MySQL-Abfrage(n) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
/* Banana-Chat - The first Open Source Knuddels Emulator * Copyright (C) 2011 Flav <http://banana-coding.com> * * Diese Datei unterliegt dem Copyright von Banana-Coding und * darf verändert, aber weder in andere Projekte eingefügt noch * reproduziert werden. * * Der Emulator dient - sofern der Client nicht aus Eigenproduktion * stammt - nur zu Lernzwecken, das Hosten des originalen Clients * ist untersagt und wird der Knuddels GmbH gemeldet. */ package knuddels; import handler.*; import java.io.IOException; import java.io.InputStream; import java.net.Socket; /** * * @author Flav */ public class SessionHandler extends Thread { private Socket socket; public SessionHandler(Socket socket) { this.socket = socket; } @Override public void run() { Client client = new Client(socket); try { InputStream in = socket.getInputStream(); byte type = (byte) in.read(); if (type == 0x00) { while (true) { byte[] buffer = Protocol.decode(in); String[] tokens = new String(buffer, "UTF8").split("\u0000"); String opcode = tokens[0]; if (opcode.equals(ReceiveOpcode.EXCEPTION.getValue())) { } else if (opcode.equals(ReceiveOpcode.DISCONNECT.getValue())) { } else if (opcode.equals(ReceiveOpcode.CHAT.getValue())) { ChatHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.PING.getValue())) { PingHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.POLL.getValue())) { PollHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.LINK_CLICKED.getValue())) { } else if (opcode.equals(ReceiveOpcode.JOIN_CHANNEL.getValue())) { JoinChannelHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.Q_TOKEN.getValue())) { } else if (opcode.equals(ReceiveOpcode.REQUEST_USER_LIST.getValue())) { } else if (opcode.equals(ReceiveOpcode.HANDSHAKE.getValue())) { HandshakeHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.REQUEST_HELP.getValue())) { RequestHelpHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.LEAVE_CHANNEL.getValue())) { LeaveChannelHandler.handle(tokens, client); } else if (opcode.equals(ReceiveOpcode.WHOIS.getValue())) { } else if (opcode.equals(ReceiveOpcode.EDIT.getValue())) { EditHandler.handle(tokens, client); } else { System.out.println(String.format("Unhandled opcode: %s", opcode)); } } } else if (type == 0x02) { // registration } } catch (IOException e) { } finally { client.disconnect(); } } } |
Benutzer, die sich für diesen Beitrag bedankt haben: