[Commands] Cleanup #ban, #ipban, #flag, #kick, #setlsinfo, and #setpass Commands. (#2104)

* [Commands] Cleanup #ban, #ipban, #flag, and #kick Commands.
- Cleanup messages and logic.
- Add ServerFlagUpdate_Struct for flag updates.

* Add #setlsinfo and #setpass to cleanup.

* Update setlsinfo.cpp

* Update database.cpp

* Update database.cpp

* Update command.cpp
This commit is contained in:
Kinglykrab 2022-05-07 23:28:45 -04:00 committed by GitHub
parent 07b46ed445
commit d9c41526e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 312 additions and 227 deletions

View File

@ -92,112 +92,123 @@ Database::~Database()
*/
uint32 Database::CheckLogin(const char* name, const char* password, const char *loginserver, int16* oStatus) {
if(strlen(name) >= 50 || strlen(password) >= 50)
if (strlen(name) >= 50 || strlen(password) >= 50)
return(0);
char tmpUN[100];
char tmpPW[100];
char temporary_username[100];
char temporary_password[100];
DoEscapeString(tmpUN, name, strlen(name));
DoEscapeString(tmpPW, password, strlen(password));
DoEscapeString(temporary_username, name, strlen(name));
DoEscapeString(temporary_password, password, strlen(password));
std::string query = StringFormat("SELECT id, status FROM account WHERE `name`='%s' AND ls_id='%s' AND password is not null "
"and length(password) > 0 and (password='%s' or password=MD5('%s'))",
tmpUN, EscapeString(loginserver).c_str(), tmpPW, tmpPW);
std::string query = fmt::format(
"SELECT id, status FROM account WHERE `name` = '{}' AND ls_id = '{}' AND password is NOT NULL "
"AND length(password) > 0 AND (password = '{}' OR password = MD5('{}'))",
temporary_username,
EscapeString(loginserver),
temporary_password,
temporary_password
);
auto results = QueryDatabase(query);
if (!results.Success())
{
if (!results.Success() || !results.RowCount()) {
return 0;
}
if(results.RowCount() == 0)
return 0;
auto row = results.begin();
uint32 id = atoi(row[0]);
auto id = std::stoul(row[0]);
if (oStatus)
*oStatus = atoi(row[1]);
if (oStatus) {
*oStatus = std::stoi(row[1]);
}
return id;
}
//Get Banned IP Address List - Only return false if the incoming connection's IP address is not present in the banned_ips table.
bool Database::CheckBannedIPs(const char* loginIP)
bool Database::CheckBannedIPs(std::string login_ip)
{
std::string query = StringFormat("SELECT ip_address FROM banned_ips WHERE ip_address='%s'", loginIP);
auto query = fmt::format(
"SELECT ip_address FROM banned_ips WHERE ip_address = '{}'",
login_ip
);
auto results = QueryDatabase(query);
if (!results.Success())
{
if (!results.Success() || results.RowCount() != 0) {
return true;
}
if (results.RowCount() != 0)
return true;
return false;
}
bool Database::AddBannedIP(char* bannedIP, const char* notes) {
std::string query = StringFormat("INSERT into banned_ips SET ip_address='%s', notes='%s'", bannedIP, notes);
bool Database::AddBannedIP(std::string banned_ip, std::string notes) {
auto query = fmt::format(
"INSERT into banned_ips SET ip_address = '{}', notes = '{}'",
EscapeString(banned_ip),
EscapeString(notes)
);
auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
return true;
}
bool Database::CheckGMIPs(const char* ip_address, uint32 account_id) {
std::string query = StringFormat("SELECT * FROM `gm_ips` WHERE `ip_address` = '%s' AND `account_id` = %i", ip_address, account_id);
bool Database::CheckGMIPs(std::string login_ip, uint32 account_id) {
auto query = fmt::format(
"SELECT * FROM `gm_ips` WHERE `ip_address` = '{}' AND `account_id` = {}",
login_ip,
account_id
);
auto results = QueryDatabase(query);
if (!results.Success())
if (!results.Success()) {
return false;
}
if (results.RowCount() == 1)
if (results.RowCount() == 1) {
return true;
}
return false;
}
bool Database::AddGMIP(char* ip_address, char* name) {
std::string query = StringFormat("INSERT into `gm_ips` SET `ip_address` = '%s', `name` = '%s'", ip_address, name);
auto results = QueryDatabase(query);
return results.Success();
}
void Database::LoginIP(uint32 AccountID, const char* LoginIP) {
std::string query = StringFormat("INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP);
void Database::LoginIP(uint32 account_id, std::string login_ip) {
auto query = fmt::format(
"INSERT INTO account_ip SET accid = {}, ip = '{}' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()",
account_id,
login_ip
);
QueryDatabase(query);
}
int16 Database::CheckStatus(uint32 account_id)
{
std::string query = StringFormat(
"SELECT `status`, TIMESTAMPDIFF(SECOND, NOW(), `suspendeduntil`) FROM `account` WHERE `id` = %i",
account_id);
auto query = fmt::format(
"SELECT `status`, TIMESTAMPDIFF(SECOND, NOW(), `suspendeduntil`) FROM `account` WHERE `id` = {}",
account_id
);
auto results = QueryDatabase(query);
if (!results.Success())
return 0;
if (results.RowCount() != 1)
if (!results.Success() || results.RowCount() != 1) {
return 0;
}
auto row = results.begin();
int16 status = atoi(row[0]);
int16 status = std::stoi(row[0]);
int32 date_diff = 0;
if (row[1] != nullptr)
date_diff = atoi(row[1]);
if (row[1]) {
date_diff = std::stoi(row[1]);
}
if (date_diff > 0)
if (date_diff > 0) {
return -1;
}
return status;
}
@ -307,9 +318,7 @@ bool Database::SetAccountStatus(const std::string& account_name, int16 status)
LogInfo("Account [{}] is attempting to be set to status [{}]", account_name, status);
std::string query = fmt::format(
SQL(
UPDATE account SET status = {} WHERE name = '{}'
),
"UPDATE account SET status = {} WHERE name = '{}'",
status,
account_name
);
@ -807,36 +816,34 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
return atoi(row[0]);
}
uint32 Database::GetAccountIDByName(const char* accname, const char *loginserver, int16* status, uint32* lsid) {
if (!isAlphaNumeric(accname))
uint32 Database::GetAccountIDByName(std::string account_name, std::string loginserver, int16* status, uint32* lsid) {
if (!isAlphaNumeric(account_name.c_str())) {
return 0;
}
std::string query = StringFormat("SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '%s' AND `ls_id`='%s' LIMIT 1",
EscapeString(accname).c_str(), EscapeString(loginserver).c_str());
auto query = fmt::format(
"SELECT `id`, `status`, `lsaccount_id` FROM `account` WHERE `name` = '{}' AND `ls_id` = '{}' LIMIT 1",
EscapeString(account_name),
EscapeString(loginserver)
);
auto results = QueryDatabase(query);
if (!results.Success()) {
if (!results.Success() || !results.RowCount()) {
return 0;
}
if (results.RowCount() != 1)
return 0;
auto row = results.begin();
auto account_id = std::stoul(row[0]);
uint32 id = atoi(row[0]);
if (status)
*status = atoi(row[1]);
if (lsid) {
if (row[2])
*lsid = atoi(row[2]);
else
*lsid = 0;
if (status) {
*status = static_cast<int16>(std::stoi(row[1]));
}
return id;
if (lsid) {
*lsid = row[2] ? std::stoul(row[2]) : 0;
}
return account_id;
}
void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID) {

View File

@ -121,16 +121,15 @@ public:
/* General Information Queries */
bool AddBannedIP(char* bannedIP, const char* notes); //Add IP address to the banned_ips table.
bool AddGMIP(char* ip_address, char* name);
bool CheckBannedIPs(const char* loginIP); //Check incoming connection against banned IP table.
bool CheckGMIPs(const char* loginIP, uint32 account_id);
bool AddBannedIP(std::string banned_ip, std::string notes); //Add IP address to the banned_ips table.
bool CheckBannedIPs(std::string login_ip); //Check incoming connection against banned IP table.
bool CheckGMIPs(std::string login_ip, uint32 account_id);
bool CheckNameFilter(const char* name, bool surname = false);
bool CheckUsedName(const char* name);
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
uint32 GetAccountIDByChar(uint32 char_id);
uint32 GetAccountIDByName(const char* accname, const char *loginserver, int16* status = 0, uint32* lsid = 0);
uint32 GetAccountIDByName(std::string account_name, std::string loginserver, int16* status = 0, uint32* lsid = 0);
uint32 GetCharacterID(const char *name);
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0, float* oX = 0, float* oY = 0, float* oZ = 0);
uint32 GetGuildIDByCharID(uint32 char_id);
@ -142,7 +141,7 @@ public:
std::string GetCharNameByID(uint32 char_id);
std::string GetNPCNameByID(uint32 npc_id);
std::string GetCleanNPCNameByID(uint32 npc_id);
void LoginIP(uint32 AccountID, const char* LoginIP);
void LoginIP(uint32 account_id, std::string login_ip);
/* Instancing */

View File

@ -1776,6 +1776,11 @@ struct ServerDzCreateSerialized_Struct {
char cereal_data[0];
};
struct ServerFlagUpdate_Struct {
uint32 account_id;
int16 admin;
};
#pragma pack()
#endif

View File

@ -490,7 +490,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app)
if (!is_player_zoning) {
SendExpansionInfo();
SendCharInfo();
database.LoginIP(cle->AccountID(), long2ip(GetIP()).c_str());
database.LoginIP(cle->AccountID(), long2ip(GetIP()));
}
cle->SetIP(GetIP());
@ -997,7 +997,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
// Voidd: Anti-GM Account hack, Checks source ip against valid GM Account IP Addresses
if (RuleB(World, GMAccountIPList) && GetAdmin() >= (RuleI(World, MinGMAntiHackStatus))) {
if(!database.CheckGMIPs(long2ip(GetIP()).c_str(), GetAccountID())) {
if(!database.CheckGMIPs(long2ip(GetIP()), GetAccountID())) {
LogInfo("GM Account not permited from source address [{}] and accountid [{}]", long2ip(GetIP()).c_str(), GetAccountID());
eqs->Close();
}

View File

@ -752,15 +752,14 @@ void ConsoleSetPass(
connection->SendLine("Format: setpass accountname password");
}
else {
std::string prefix = "eqemu";
std::string prefix = "eqemu";
std::string raw_user = "";
ParseAccountString(args[0], raw_user, prefix);
int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(raw_user.c_str(), prefix.c_str(), &tmpstatus);
auto account_id = database.GetAccountIDByName(raw_user, prefix);
if (!tmpid) {
if (!account_id) {
connection->SendLine("Error: Account not found");
}
}

View File

@ -124,7 +124,7 @@ int command_init(void)
command_add("apply_shared_memory", "[shared_memory_name] - Tells every zone and world to apply a specific shared memory segment by name.", AccountStatus::GMImpossible, command_apply_shared_memory) ||
command_add("attack", "[Entity Name] - Make your NPC target attack an entity by name", AccountStatus::GMLeadAdmin, command_attack) ||
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", AccountStatus::GMImpossible, command_augmentitem) ||
command_add("ban", "[name] [reason]- Ban by character name", AccountStatus::GMLeadAdmin, command_ban) ||
command_add("ban", "[Character Name] [Reason]- Ban by character name", AccountStatus::GMLeadAdmin, command_ban) ||
command_add("bind", "- Sets your targets bind spot to their current location", AccountStatus::GMMgmt, command_bind) ||
#ifdef BOTS
@ -178,7 +178,7 @@ int command_init(void)
command_add("findtask", "[search criteria] - Search for a task", AccountStatus::Guide, command_findtask) ||
command_add("findzone", "[search criteria] - Search database zones", AccountStatus::GMAdmin, command_findzone) ||
command_add("fixmob", "[race|gender|texture|helm|face|hair|haircolor|beard|beardcolor|heritage|tattoo|detail] [next|prev] - Manipulate appearance of your target", AccountStatus::QuestTroupe, command_fixmob) ||
command_add("flag", "[status] [acctname] - Refresh your admin status, or set an account's admin status if arguments provided", AccountStatus::Player, command_flag) ||
command_add("flag", "[Status] [Account Name] - Refresh your admin status, or set an account's Admin status if arguments provided", AccountStatus::Player, command_flag) ||
command_add("flagedit", "- Edit zone flags on your target. Use #flagedit help for more info.", AccountStatus::GMAdmin, command_flagedit) ||
command_add("flags", "- displays the Zone Flags of you or your target", AccountStatus::Player, command_flags) ||
command_add("flymode", "[0/1/2/3/4/5] - Set your or your player target's flymode to ground/flying/levitate/water/floating/levitate_running", AccountStatus::Guide, command_flymode) ||
@ -216,11 +216,11 @@ int command_init(void)
command_add("interrupt", "[message id] [color] - Interrupt your casting. Arguments are optional.", AccountStatus::Guide, command_interrupt) ||
command_add("invsnapshot", "- Manipulates inventory snapshots for your current target", AccountStatus::QuestTroupe, command_invsnapshot) ||
command_add("invul", "[On|Off]] - Turn player target's or your invulnerable flag on or off", AccountStatus::QuestTroupe, command_invul) ||
command_add("ipban", "[IP address] - Ban IP by character name", AccountStatus::GMMgmt, command_ipban) ||
command_add("ipban", "[IP] - Ban IP", AccountStatus::GMMgmt, command_ipban) ||
command_add("iplookup", "[charname] - Look up IP address of charname", AccountStatus::GMMgmt, command_iplookup) ||
command_add("iteminfo", "- Get information about the item on your cursor", AccountStatus::Steward, command_iteminfo) ||
command_add("itemsearch", "[search criteria] - Search for an item", AccountStatus::Steward, command_itemsearch) ||
command_add("kick", "[charname] - Disconnect charname", AccountStatus::GMLeadAdmin, command_kick) ||
command_add("kick", "[Character Name] - Disconnect a player by name", AccountStatus::GMLeadAdmin, command_kick) ||
command_add("kill", "- Kill your target", AccountStatus::GMAdmin, command_kill) ||
command_add("killallnpcs", " [npc_name] Kills all npcs by search name, leave blank for all attackable NPC's", AccountStatus::GMMgmt, command_killallnpcs) ||
command_add("lastname", "[Last Name] - Set you or your player target's lastname", AccountStatus::Guide, command_lastname) ||
@ -324,9 +324,9 @@ int command_init(void)
command_add("setgraveyard", "[zone name] - Creates a graveyard for the specified zone based on your target's LOC.", AccountStatus::GMMgmt, command_setgraveyard) ||
command_add("sethp", "[Health] - Set your or your target's Health", AccountStatus::GMAdmin, command_sethp) ||
command_add("setlanguage", "[language ID] [value] - Set your target's language skillnum to value", AccountStatus::Guide, command_setlanguage) ||
command_add("setlsinfo", "[email] [password] - Set login server email address and password (if supported by login server)", AccountStatus::Steward, command_setlsinfo) ||
command_add("setlsinfo", "[Email] [Password] - Set loginserver email address and password (if supported by loginserver)", AccountStatus::Steward, command_setlsinfo) ||
command_add("setmana", "[Mana] - Set your or your target's Mana", AccountStatus::GMAdmin, command_setmana) ||
command_add("setpass", "[accountname] [password] - Set local password for accountname", AccountStatus::GMLeadAdmin, command_setpass) ||
command_add("setpass", "[Account Name] [Password] - Set local password by account name", AccountStatus::GMLeadAdmin, command_setpass) ||
command_add("setpvppoints", "[Amount] - Set your or your player target's PVP points", AccountStatus::GMAdmin, command_setpvppoints) ||
command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", AccountStatus::Guide, command_setskill) ||
command_add("setskillall", "[Skill Level] - Set all of your or your target's skills to the specified skill level", AccountStatus::Guide, command_setskillall) ||

View File

@ -5,67 +5,70 @@ extern WorldServer worldserver;
void command_ban(Client *c, const Seperator *sep)
{
if (sep->arg[1][0] == 0 || sep->arg[2][0] == 0) {
c->Message(Chat::White, "Usage: #ban <charname> <message>");
int arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #ban [Character Name] [Reason]");
return;
}
auto account_id = database.GetAccountIDByChar(sep->arg[1]);
std::string message;
int i = 2;
while (1) {
if (sep->arg[i][0] == 0) {
break;
}
if (message.length() > 0) {
message.push_back(' ');
}
message += sep->arg[i];
++i;
}
if (message.length() == 0) {
c->Message(Chat::White, "Usage: #ban <charname> <message>");
std::string character_name = sep->arg[1];
if (character_name.empty()) {
c->Message(Chat::White, "Usage: #ban [Character Name] [Reason]");
return;
}
if (account_id == 0) {
c->Message(Chat::Red, "Character does not exist.");
std::string reason = sep->argplus[2];
if (reason.empty()) {
c->Message(Chat::White, "Usage: #ban [Character Name] [Reason]");
return;
}
std::string query = StringFormat(
"UPDATE account SET status = -2, ban_reason = '%s' "
"WHERE id = %i", EscapeString(message).c_str(), account_id
auto account_id = database.GetAccountIDByChar(character_name.c_str());
if (!account_id) {
c->Message(
Chat::White,
fmt::format(
"Character {} does not exist."
).c_str(),
character_name
);
return;
}
auto query = fmt::format(
"UPDATE account SET status = -2, ban_reason = '{}' WHERE id = {}",
EscapeString(reason),
account_id
);
auto results = database.QueryDatabase(query);
auto results = database.QueryDatabase(query);
c->Message(
Chat::Red,
"Account number %i with the character %s has been banned with message: \"%s\"",
account_id,
sep->arg[1],
message.c_str());
Chat::White,
fmt::format(
"Account ID {} with the character {} has been banned for the following reason: \"{}\"",
account_id,
character_name,
reason
).c_str()
);
ServerPacket flagUpdatePack(ServerOP_FlagUpdate, 6);
*((uint32 *) &flagUpdatePack.pBuffer[0]) = account_id;
*((int16 *) &flagUpdatePack.pBuffer[4]) = -2;
ServerPacket flagUpdatePack(ServerOP_FlagUpdate, sizeof(ServerFlagUpdate_Struct));
ServerFlagUpdate_Struct *sfus = (ServerFlagUpdate_Struct *) flagUpdatePack.pBuffer;
sfus->account_id = account_id;
sfus->admin = -2;
worldserver.SendPacket(&flagUpdatePack);
Client *client = nullptr;
client = entity_list.GetClientByName(sep->arg[1]);
client = entity_list.GetClientByName(character_name.c_str());
if (client) {
client->WorldKick();
return;
}
ServerPacket kickPlayerPack(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
ServerPacket kickPlayerPack(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
ServerKickPlayer_Struct *skp = (ServerKickPlayer_Struct *) kickPlayerPack.pBuffer;
strcpy(skp->adminname, c->GetName());
strcpy(skp->name, sep->arg[1]);
strcpy(skp->name, character_name.c_str());
skp->adminrank = c->Admin();
worldserver.SendPacket(&kickPlayerPack);
}

View File

@ -5,47 +5,81 @@ extern WorldServer worldserver;
void command_flag(Client *c, const Seperator *sep)
{
if (sep->arg[2][0] == 0) {
if (!c->GetTarget() || (c->GetTarget() && c->GetTarget() == c)) {
c->UpdateAdmin();
c->Message(Chat::White, "Refreshed your admin flag from DB.");
}
else if (c->GetTarget() && c->GetTarget() != c && c->GetTarget()->IsClient()) {
c->GetTarget()->CastToClient()->UpdateAdmin();
c->Message(Chat::White, "%s's admin flag has been refreshed.", c->GetTarget()->GetName());
c->GetTarget()->Message(Chat::White, "%s refreshed your admin flag.", c->GetName());
int arguments = sep->argnum;
if (!arguments) {
auto target = c->GetTarget() && c->GetTarget()->IsClient() ? c->GetTarget()->CastToClient() : c;
if (target != c) {
c->Message(
Chat::White,
fmt::format(
"Status level has been refreshed for {}.",
target->GetCleanName()
).c_str()
);
target->Message(
Chat::White,
fmt::format(
"Your status level has been refreshed by {}.",
c->GetCleanName()
).c_str()
);
} else {
c->Message(Chat::White, "Your status level has been refreshed.");
}
target->UpdateAdmin();
return;
}
else if (!sep->IsNumber(1) || atoi(sep->arg[1]) < -2 || atoi(sep->arg[1]) > 255 || strlen(sep->arg[2]) == 0) {
c->Message(Chat::White, "Usage: #flag [status] [acctname]");
if (
!sep->IsNumber(1) ||
strlen(sep->arg[2]) == 0
) {
c->Message(Chat::White, "Usage: #flag [Status] [Account Name]");
return;
}
else if (c->Admin() < commandChangeFlags) {
//this check makes banning players by less than this level
//impossible, but i'll leave it in anyways
auto status = std::stoi(sep->arg[1]);
if (status < -2 || status > 255) {
c->Message(Chat::White, "The lowest a status level can go is -2 and the highest a status level can go is 255.");
return;
}
std::string account_name = sep->argplus[2];
auto account_id = database.GetAccountIDByChar(account_name.c_str());
if (c->Admin() < commandChangeFlags) { //this check makes banning players by less than this level impossible, but i'll leave it in anyways
c->Message(Chat::White, "You may only refresh your own flag, doing so now.");
c->UpdateAdmin();
}
else {
if (atoi(sep->arg[1]) > c->Admin()) {
c->Message(Chat::White, "You cannot set people's status to higher than your own");
}
else if (atoi(sep->arg[1]) < 0 && c->Admin() < commandBanPlayers) {
c->Message(Chat::White, "You have too low of status to suspend/ban");
}
else if (!database.SetAccountStatus(sep->argplus[2], atoi(sep->arg[1]))) {
c->Message(Chat::White, "Unable to set GM Flag.");
} else {
if (status > c->Admin()) {
c->Message(
Chat::White,
fmt::format(
"You cannot set someone's status level to {} because your status level is only {}.",
status,
c->Admin()
).c_str()
);
} else if (status < 0 && c->Admin() < commandBanPlayers) {
c->Message(Chat::White, "Your status level is not high enough to ban or suspend.");
} else if (!database.SetAccountStatus(account_name, status)) {
c->Message(Chat::White, "Failed to set status level.");
}
else {
c->Message(Chat::White, "Set GM Flag on account.");
std::string user;
std::string loginserver;
ParseAccountString(sep->argplus[2], user, loginserver);
ParseAccountString(account_name, user, loginserver);
ServerPacket pack(ServerOP_FlagUpdate, 6);
*((uint32 *) pack.pBuffer) = database.GetAccountIDByName(user.c_str(), loginserver.c_str());
*((int16 *) &pack.pBuffer[4]) = atoi(sep->arg[1]);
account_id = database.GetAccountIDByName(account_name, loginserver);
ServerPacket pack(ServerOP_FlagUpdate, sizeof(ServerFlagUpdate_Struct));
ServerFlagUpdate_Struct *sfus = (ServerFlagUpdate_Struct *) pack.pBuffer;
sfus->account_id = account_id;
sfus->admin = status;
worldserver.SendPacket(&pack);
}
}

View File

@ -2,20 +2,32 @@
void command_ipban(Client *c, const Seperator *sep)
{
if (sep->arg[1] == 0) {
c->Message(Chat::White, "Usage: #ipban [xxx.xxx.xxx.xxx]");
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #ipban [IP]");
return;
}
else {
if (database.AddBannedIP(sep->arg[1], c->GetName())) {
c->Message(
Chat::White,
"%s has been successfully added to the banned_ips table by %s",
sep->arg[1],
c->GetName());
}
else {
c->Message(Chat::White, "IPBan Failed (IP address is possibly already in the table?)");
}
std::string ip = sep->arg[1];
if (ip.empty()) {
c->Message(Chat::White, "Usage: #ipban [IP]");
return;
}
if (database.AddBannedIP(ip, c->GetName())) {
c->Message(
Chat::White,
fmt::format(
"IP '{}' has been successfully banned.",
ip
).c_str()
);
} else {
c->Message(
Chat::White,
"IP '{}' has failed to be banned, the IP address may already be in the table.",
ip
);
}
}

View File

@ -5,32 +5,37 @@ extern WorldServer worldserver;
void command_kick(Client *c, const Seperator *sep)
{
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #kick [charname]");
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #kick [Character Name]");
return;
}
else {
Client *client = entity_list.GetClientByName(sep->arg[1]);
if (client != 0) {
if (client->Admin() <= c->Admin()) {
client->Message(Chat::White, "You have been kicked by %s", c->GetName());
auto outapp = new EQApplicationPacket(OP_GMKick, 0);
client->QueuePacket(outapp);
client->Kick("Ordered kicked by command");
c->Message(Chat::White, "Kick: local: kicking %s", sep->arg[1]);
}
}
else if (!worldserver.Connected()) {
c->Message(Chat::White, "Error: World server disconnected");
}
else {
auto pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
ServerKickPlayer_Struct *skp = (ServerKickPlayer_Struct *) pack->pBuffer;
strcpy(skp->adminname, c->GetName());
strcpy(skp->name, sep->arg[1]);
skp->adminrank = c->Admin();
worldserver.SendPacket(pack);
safe_delete(pack);
std::string character_name = sep->arg[1];
auto client = entity_list.GetClientByName(character_name.c_str());
if (client) {
if (client->Admin() <= c->Admin()) {
auto outapp = new EQApplicationPacket(OP_GMKick, 0);
client->QueuePacket(outapp);
client->Kick("Ordered kicked by command");
c->Message(
Chat::White,
fmt::format(
"{} has been kicked from the server.",
character_name
).c_str()
);
}
} else if (!worldserver.Connected()) {
c->Message(Chat::White, "The world server is currently disconnected.");
} else {
auto pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
ServerKickPlayer_Struct *skp = (ServerKickPlayer_Struct *) pack->pBuffer;
strcpy(skp->adminname, c->GetName());
strcpy(skp->name, character_name.c_str());
skp->adminrank = c->Admin();
worldserver.SendPacket(pack);
safe_delete(pack);
}
}

View File

@ -5,20 +5,19 @@ extern WorldServer worldserver;
void command_setlsinfo(Client *c, const Seperator *sep)
{
if (sep->argnum != 2) {
c->Message(Chat::White, "Format: #setlsinfo email password");
}
else {
auto pack = new ServerPacket(
ServerOP_LSAccountUpdate,
sizeof(ServerLSAccountUpdate_Struct));
ServerLSAccountUpdate_Struct *s = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
s->useraccountid = c->LSAccountID();
strn0cpy(s->useraccount, c->AccountName(), 30);
strn0cpy(s->user_email, sep->arg[1], 100);
strn0cpy(s->userpassword, sep->arg[2], 50);
worldserver.SendPacket(pack);
c->Message(Chat::White, "Login Server update packet sent.");
int arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #setlsinfo [Email] [Password]");
return;
}
auto pack = new ServerPacket(ServerOP_LSAccountUpdate, sizeof(ServerLSAccountUpdate_Struct));
auto s = (ServerLSAccountUpdate_Struct *) pack->pBuffer;
s->useraccountid = c->LSAccountID();
strn0cpy(s->useraccount, c->AccountName(), 30);
strn0cpy(s->user_email, sep->arg[1], 100);
strn0cpy(s->userpassword, sep->arg[2], 50);
worldserver.SendPacket(pack);
c->Message(Chat::White, "Your email and local loginserver password have been set.");
}

View File

@ -2,28 +2,50 @@
void command_setpass(Client *c, const Seperator *sep)
{
if (sep->argnum != 2) {
c->Message(Chat::White, "Format: #setpass accountname password");
int arguments = sep->argnum;
if (arguments < 2) {
c->Message(Chat::White, "Usage: #setpass [Account Name] [Password]");
return;
}
else {
std::string user;
std::string loginserver;
ParseAccountString(sep->arg[1], user, loginserver);
int16 tmpstatus = 0;
uint32 tmpid = database.GetAccountIDByName(user.c_str(), loginserver.c_str(), &tmpstatus);
if (!tmpid) {
c->Message(Chat::White, "Error: Account not found");
}
else if (tmpstatus > c->Admin()) {
c->Message(Chat::White, "Cannot change password: Account's status is higher than yours");
}
else if (database.SetLocalPassword(tmpid, sep->arg[2])) {
c->Message(Chat::White, "Password changed.");
}
else {
c->Message(Chat::White, "Error changing password.");
}
std::string account_name;
std::string loginserver;
ParseAccountString(sep->arg[1], account_name, loginserver);
int16 status = 0;
auto account_id = database.GetAccountIDByName(account_name, loginserver, &status);
if (!account_id) {
c->Message(
Chat::White,
fmt::format(
"Account {} not found.",
account_name
).c_str()
);
return;
}
if (status > c->Admin()) {
c->Message(
Chat::White,
fmt::format(
"You cannot change the password for Account {} as its status is higher than yours.",
account_name
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Password {} changed for Account {}.",
(
database.SetLocalPassword(account_id, sep->arg[2]) ?
"successfully" :
"failed"
),
account_name
).c_str()
);
}

View File

@ -2555,7 +2555,7 @@ void QuestManager::whisper(const char *message) {
std::string mob_name = owner->GetCleanName();
std::string new_message = fmt::format("{} whispers, '{}'", mob_name, message);
initiator->Message(315, new_message.c_str());
initiator->Message(Chat::EchoChat1, new_message.c_str());
}
int QuestManager::getlevel(uint8 type)