2 | | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
3 | | * |
4 | | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | | */ |
| 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
| 3 | * |
| 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
772 | | if(!*args) |
773 | | return false; |
774 | | |
775 | | ///- Get the command line arguments |
776 | | char *szAccount = strtok ((char*)args," "); |
777 | | char *szPassword1 = strtok (NULL," "); |
778 | | char *szPassword2 = strtok (NULL," "); |
779 | | |
780 | | if (!szAccount||!szPassword1 || !szPassword2) |
781 | | return false; |
782 | | |
783 | | std::string account_name = szAccount; |
784 | | if(!AccountMgr::normilizeString(account_name)) |
785 | | { |
786 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
787 | | SetSentErrorMessage(true); |
788 | | return false; |
789 | | } |
790 | | |
791 | | uint32 targetAccountId = accmgr.GetId(account_name); |
792 | | if (!targetAccountId) |
793 | | { |
794 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
795 | | SetSentErrorMessage(true); |
796 | | return false; |
797 | | } |
798 | | |
799 | | uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); |
800 | | |
801 | | /// m_session==NULL only for console |
802 | | uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; |
803 | | |
804 | | /// can set password only for target with less security |
805 | | /// This is also reject self apply in fact |
806 | | if (targetSecurity >= plSecurity) |
807 | | { |
808 | | SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); |
809 | | SetSentErrorMessage (true); |
810 | | return false; |
811 | | } |
812 | | |
813 | | if (strcmp(szPassword1,szPassword2)) |
814 | | { |
815 | | SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); |
816 | | SetSentErrorMessage (true); |
817 | | return false; |
818 | | } |
819 | | |
820 | | AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1); |
821 | | |
822 | | switch(result) |
823 | | { |
824 | | case AOR_OK: |
825 | | SendSysMessage(LANG_COMMAND_PASSWORD); |
826 | | break; |
827 | | case AOR_NAME_NOT_EXIST: |
828 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
829 | | SetSentErrorMessage(true); |
830 | | return false; |
831 | | case AOR_PASS_TOO_LONG: |
832 | | SendSysMessage(LANG_PASSWORD_TOO_LONG); |
833 | | SetSentErrorMessage(true); |
834 | | return false; |
835 | | default: |
836 | | SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); |
837 | | SetSentErrorMessage(true); |
838 | | return false; |
839 | | } |
840 | | |
841 | | return true; |
| 780 | if(!*args) |
| 781 | return false; |
| 782 | |
| 783 | ///- Get the command line arguments |
| 784 | char *szAccount = strtok ((char*)args," "); |
| 785 | char *szPassword1 = strtok (NULL," "); |
| 786 | char *szPassword2 = strtok (NULL," "); |
| 787 | |
| 788 | if (!szAccount||!szPassword1 || !szPassword2) |
| 789 | return false; |
| 790 | |
| 791 | std::string account_name = szAccount; |
| 792 | if(!AccountMgr::normilizeString(account_name)) |
| 793 | { |
| 794 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 795 | SetSentErrorMessage(true); |
| 796 | return false; |
| 797 | } |
| 798 | |
| 799 | uint32 targetAccountId = accmgr.GetId(account_name); |
| 800 | if (!targetAccountId) |
| 801 | { |
| 802 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 803 | SetSentErrorMessage(true); |
| 804 | return false; |
| 805 | } |
| 806 | |
| 807 | uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); |
| 808 | |
| 809 | /// m_session==NULL only for console |
| 810 | uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; |
| 811 | |
| 812 | /// can set password only for target with less security |
| 813 | /// This is also reject self apply in fact |
| 814 | if (targetSecurity >= plSecurity) |
| 815 | { |
| 816 | SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); |
| 817 | SetSentErrorMessage (true); |
| 818 | return false; |
| 819 | } |
| 820 | |
| 821 | if (strcmp(szPassword1,szPassword2)) |
| 822 | { |
| 823 | SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); |
| 824 | SetSentErrorMessage (true); |
| 825 | return false; |
| 826 | } |
| 827 | |
| 828 | AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1); |
| 829 | |
| 830 | switch(result) |
| 831 | { |
| 832 | case AOR_OK: |
| 833 | SendSysMessage(LANG_COMMAND_PASSWORD); |
| 834 | break; |
| 835 | case AOR_NAME_NOT_EXIST: |
| 836 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 837 | SetSentErrorMessage(true); |
| 838 | return false; |
| 839 | case AOR_PASS_TOO_LONG: |
| 840 | SendSysMessage(LANG_PASSWORD_TOO_LONG); |
| 841 | SetSentErrorMessage(true); |
| 842 | return false; |
| 843 | default: |
| 844 | SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); |
| 845 | SetSentErrorMessage(true); |
| 846 | return false; |
| 847 | } |
| 848 | |
| 849 | return true; |
2222 | | uint32 guild_count = 0; |
2223 | | result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); |
2224 | | if(result) |
2225 | | { |
2226 | | guild_count = (*result)[0].GetUInt32(); |
2227 | | delete result; |
2228 | | } |
2229 | | |
2230 | | result=CharacterDatabase.PQuery( |
2231 | | // 0 1 2 |
2232 | | "SELECT gi.item_guid, gi.guildid, guild.name " |
2233 | | "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", |
2234 | | item_id,uint32(count)); |
2235 | | |
2236 | | if(result) |
2237 | | { |
2238 | | do |
2239 | | { |
2240 | | Field *fields = result->Fetch(); |
2241 | | uint32 item_guid = fields[0].GetUInt32(); |
2242 | | uint32 guild_guid = fields[1].GetUInt32(); |
2243 | | std::string guild_name = fields[2].GetCppString(); |
2244 | | |
2245 | | char const* item_pos = "[in guild bank]"; |
2246 | | |
2247 | | PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); |
2248 | | } while (result->NextRow()); |
2249 | | |
2250 | | int64 res_count = result->GetRowCount(); |
2251 | | |
2252 | | delete result; |
2253 | | |
2254 | | if(count > res_count) |
2255 | | count-=res_count; |
2256 | | else if(count) |
2257 | | count = 0; |
2258 | | } |
2259 | | |
2260 | | if(inv_count+mail_count+auc_count+guild_count == 0) |
| 2231 | uint32 guild_count = 0; |
| 2232 | result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); |
| 2233 | if(result) |
| 2234 | { |
| 2235 | guild_count = (*result)[0].GetUInt32(); |
| 2236 | delete result; |
| 2237 | } |
| 2238 | |
| 2239 | result=CharacterDatabase.PQuery( |
| 2240 | // 0 1 2 |
| 2241 | "SELECT gi.item_guid, gi.guildid, guild.name " |
| 2242 | "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", |
| 2243 | item_id,uint32(count)); |
| 2244 | |
| 2245 | if(result) |
| 2246 | { |
| 2247 | do |
| 2248 | { |
| 2249 | Field *fields = result->Fetch(); |
| 2250 | uint32 item_guid = fields[0].GetUInt32(); |
| 2251 | uint32 guild_guid = fields[1].GetUInt32(); |
| 2252 | std::string guild_name = fields[2].GetCppString(); |
| 2253 | |
| 2254 | char const* item_pos = "[in guild bank]"; |
| 2255 | |
| 2256 | PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); |
| 2257 | } while (result->NextRow()); |
| 2258 | |
| 2259 | int64 res_count = result->GetRowCount(); |
| 2260 | |
| 2261 | delete result; |
| 2262 | |
| 2263 | if(count > res_count) |
| 2264 | count-=res_count; |
| 2265 | else if(count) |
| 2266 | count = 0; |
| 2267 | } |
| 2268 | |
| 2269 | if(inv_count+mail_count+auc_count+guild_count == 0) |
2315 | | { |
2316 | | Player* pl = m_session->GetPlayer(); |
2317 | | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
2318 | | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); |
2319 | | } |
2320 | | else |
2321 | | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", |
2322 | | go_id,uint32(count)); |
| 2324 | { |
| 2325 | Player* pl = m_session->GetPlayer(); |
| 2326 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
| 2327 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); |
| 2328 | } |
| 2329 | else |
| 2330 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", |
| 2331 | go_id,uint32(count)); |
2470 | | { |
2471 | | Player* pl = m_session->GetPlayer(); |
2472 | | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
2473 | | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); |
2474 | | } |
2475 | | else |
2476 | | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", |
2477 | | cr_id,uint32(count)); |
| 2479 | { |
| 2480 | Player* pl = m_session->GetPlayer(); |
| 2481 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
| 2482 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); |
| 2483 | } |
| 2484 | else |
| 2485 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", |
| 2486 | cr_id,uint32(count)); |
5156 | | time_t unbandate = time_t(fields[3].GetUInt64()); |
5157 | | bool active = false; |
5158 | | if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) |
5159 | | active = true; |
5160 | | bool permanent = (fields[1].GetUInt64() == (uint64)0); |
5161 | | std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); |
5162 | | PSendSysMessage(LANG_BANINFO_HISTORYENTRY, |
5163 | | fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); |
5164 | | }while (result->NextRow()); |
5165 | | |
5166 | | delete result; |
5167 | | return true; |
| 5162 | time_t unbandate = time_t(fields[3].GetUInt64()); |
| 5163 | bool active = false; |
| 5164 | if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) |
| 5165 | active = true; |
| 5166 | bool permanent = (fields[1].GetUInt64() == (uint64)0); |
| 5167 | std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); |
| 5168 | PSendSysMessage(LANG_BANINFO_HISTORYENTRY, |
| 5169 | fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); |
| 5170 | }while (result->NextRow()); |
| 5171 | |
| 5172 | delete result; |
| 5173 | return true; |
5172 | | if(!args) |
5173 | | return false; |
5174 | | |
5175 | | char* cIP = strtok ((char*)args, ""); |
5176 | | if(!cIP) |
5177 | | return false; |
5178 | | |
5179 | | if (!IsIPAddress(cIP)) |
5180 | | return false; |
5181 | | |
5182 | | std::string IP = cIP; |
5183 | | |
5184 | | loginDatabase.escape_string(IP); |
5185 | | QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); |
5186 | | if(!result) |
5187 | | { |
5188 | | PSendSysMessage(LANG_BANINFO_NOIP); |
5189 | | return true; |
5190 | | } |
5191 | | |
5192 | | Field *fields = result->Fetch(); |
5193 | | bool permanent = !fields[6].GetUInt64(); |
5194 | | PSendSysMessage(LANG_BANINFO_IPENTRY, |
5195 | | fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), |
5196 | | permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); |
5197 | | delete result; |
5198 | | return true; |
| 5178 | if(!args) |
| 5179 | return false; |
| 5180 | |
| 5181 | char* cIP = strtok ((char*)args, ""); |
| 5182 | if(!cIP) |
| 5183 | return false; |
| 5184 | |
| 5185 | if (!IsIPAddress(cIP)) |
| 5186 | return false; |
| 5187 | |
| 5188 | std::string IP = cIP; |
| 5189 | |
| 5190 | loginDatabase.escape_string(IP); |
| 5191 | QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); |
| 5192 | if(!result) |
| 5193 | { |
| 5194 | PSendSysMessage(LANG_BANINFO_NOIP); |
| 5195 | return true; |
| 5196 | } |
| 5197 | |
| 5198 | Field *fields = result->Fetch(); |
| 5199 | bool permanent = !fields[6].GetUInt64(); |
| 5200 | PSendSysMessage(LANG_BANINFO_IPENTRY, |
| 5201 | fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), |
| 5202 | permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); |
| 5203 | delete result; |
| 5204 | return true; |
5223 | | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
5224 | | |
5225 | | char* cFilter = strtok((char*)args, " "); |
5226 | | std::string filter = cFilter ? cFilter : ""; |
5227 | | loginDatabase.escape_string(filter); |
5228 | | |
5229 | | QueryResult* result; |
5230 | | |
5231 | | if(filter.empty()) |
5232 | | { |
5233 | | result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" |
5234 | | " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); |
5235 | | } |
5236 | | else |
5237 | | { |
5238 | | result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" |
5239 | | " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", |
5240 | | filter.c_str()); |
5241 | | } |
5242 | | |
5243 | | if (!result) |
5244 | | { |
5245 | | PSendSysMessage(LANG_BANLIST_NOACCOUNT); |
5246 | | return true; |
5247 | | } |
5248 | | |
5249 | | return HandleBanListHelper(result); |
| 5229 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
| 5230 | |
| 5231 | char* cFilter = strtok((char*)args, " "); |
| 5232 | std::string filter = cFilter ? cFilter : ""; |
| 5233 | loginDatabase.escape_string(filter); |
| 5234 | |
| 5235 | QueryResult* result; |
| 5236 | |
| 5237 | if(filter.empty()) |
| 5238 | { |
| 5239 | result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" |
| 5240 | " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); |
| 5241 | } |
| 5242 | else |
| 5243 | { |
| 5244 | result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" |
| 5245 | " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", |
| 5246 | filter.c_str()); |
| 5247 | } |
| 5248 | |
| 5249 | if (!result) |
| 5250 | { |
| 5251 | PSendSysMessage(LANG_BANLIST_NOACCOUNT); |
| 5252 | return true; |
| 5253 | } |
| 5254 | |
| 5255 | return HandleBanListHelper(result); |
5260 | | { |
5261 | | Field* fields = result->Fetch(); |
5262 | | uint32 accountid = fields[0].GetUInt32(); |
5263 | | |
5264 | | QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); |
5265 | | if(banresult) |
5266 | | { |
5267 | | Field* fields2 = banresult->Fetch(); |
5268 | | PSendSysMessage("%s",fields2[0].GetString()); |
5269 | | delete banresult; |
5270 | | } |
5271 | | } while (result->NextRow()); |
5272 | | } |
5273 | | // Console wide output |
5274 | | else |
5275 | | { |
5276 | | SendSysMessage(LANG_BANLIST_ACCOUNTS); |
5277 | | SendSysMessage("==============================================================================="); |
5278 | | SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER); |
5279 | | do |
5280 | | { |
5281 | | SendSysMessage("-------------------------------------------------------------------------------"); |
5282 | | Field *fields = result->Fetch(); |
5283 | | uint32 account_id = fields[0].GetUInt32 (); |
5284 | | |
5285 | | std::string account_name; |
5286 | | |
5287 | | // "account" case, name can be get in same quary |
5288 | | if(result->GetFieldCount() > 1) |
5289 | | account_name = fields[1].GetCppString(); |
5290 | | // "character" case, name need extract from another DB |
5291 | | else |
5292 | | accmgr.GetName (account_id,account_name); |
5293 | | |
5294 | | // No SQL injection. id is uint32. |
5295 | | QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); |
5296 | | if (banInfo) |
5297 | | { |
5298 | | Field *fields2 = banInfo->Fetch(); |
5299 | | do |
5300 | | { |
5301 | | time_t t_ban = fields2[0].GetUInt64(); |
5302 | | tm* aTm_ban = localtime(&t_ban); |
5303 | | |
5304 | | if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) |
5305 | | { |
5306 | | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
5307 | | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
5308 | | fields2[2].GetString(),fields2[3].GetString()); |
5309 | | } |
5310 | | else |
5311 | | { |
5312 | | time_t t_unban = fields2[1].GetUInt64(); |
5313 | | tm* aTm_unban = localtime(&t_unban); |
5314 | | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
5315 | | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
5316 | | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
5317 | | fields2[2].GetString(),fields2[3].GetString()); |
5318 | | } |
5319 | | }while ( banInfo->NextRow() ); |
5320 | | delete banInfo; |
5321 | | } |
5322 | | }while( result->NextRow() ); |
5323 | | SendSysMessage("==============================================================================="); |
5324 | | } |
5325 | | |
5326 | | delete result; |
5327 | | return true; |
| 5266 | { |
| 5267 | Field* fields = result->Fetch(); |
| 5268 | uint32 accountid = fields[0].GetUInt32(); |
| 5269 | |
| 5270 | QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); |
| 5271 | if(banresult) |
| 5272 | { |
| 5273 | Field* fields2 = banresult->Fetch(); |
| 5274 | PSendSysMessage("%s",fields2[0].GetString()); |
| 5275 | delete banresult; |
| 5276 | } |
| 5277 | } while (result->NextRow()); |
| 5278 | } |
| 5279 | // Console wide output |
| 5280 | else |
| 5281 | { |
| 5282 | SendSysMessage(LANG_BANLIST_ACCOUNTS); |
| 5283 | SendSysMessage("==============================================================================="); |
| 5284 | SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER); |
| 5285 | do |
| 5286 | { |
| 5287 | SendSysMessage("-------------------------------------------------------------------------------"); |
| 5288 | Field *fields = result->Fetch(); |
| 5289 | uint32 account_id = fields[0].GetUInt32 (); |
| 5290 | |
| 5291 | std::string account_name; |
| 5292 | |
| 5293 | // "account" case, name can be get in same query |
| 5294 | if(result->GetFieldCount() > 1) |
| 5295 | account_name = fields[1].GetCppString(); |
| 5296 | // "character" case, name need extract from another DB |
| 5297 | else |
| 5298 | accmgr.GetName (account_id,account_name); |
| 5299 | |
| 5300 | // No SQL injection. id is uint32. |
| 5301 | QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); |
| 5302 | if (banInfo) |
| 5303 | { |
| 5304 | Field *fields2 = banInfo->Fetch(); |
| 5305 | do |
| 5306 | { |
| 5307 | time_t t_ban = fields2[0].GetUInt64(); |
| 5308 | tm* aTm_ban = localtime(&t_ban); |
| 5309 | |
| 5310 | if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) |
| 5311 | { |
| 5312 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
| 5313 | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
| 5314 | fields2[2].GetString(),fields2[3].GetString()); |
| 5315 | } |
| 5316 | else |
| 5317 | { |
| 5318 | time_t t_unban = fields2[1].GetUInt64(); |
| 5319 | tm* aTm_unban = localtime(&t_unban); |
| 5320 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
| 5321 | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
| 5322 | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
| 5323 | fields2[2].GetString(),fields2[3].GetString()); |
| 5324 | } |
| 5325 | }while ( banInfo->NextRow() ); |
| 5326 | delete banInfo; |
| 5327 | } |
| 5328 | }while( result->NextRow() ); |
| 5329 | SendSysMessage("==============================================================================="); |
| 5330 | } |
| 5331 | |
| 5332 | delete result; |
| 5333 | return true; |
5332 | | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
5333 | | |
5334 | | char* cFilter = strtok((char*)args, " "); |
5335 | | std::string filter = cFilter ? cFilter : ""; |
5336 | | loginDatabase.escape_string(filter); |
5337 | | |
5338 | | QueryResult* result; |
5339 | | |
5340 | | if(filter.empty()) |
5341 | | { |
5342 | | result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
5343 | | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" |
5344 | | " ORDER BY unbandate" ); |
5345 | | } |
5346 | | else |
5347 | | { |
5348 | | result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
5349 | | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") |
5350 | | " ORDER BY unbandate",filter.c_str() ); |
5351 | | } |
5352 | | |
5353 | | if(!result) |
5354 | | { |
5355 | | PSendSysMessage(LANG_BANLIST_NOIP); |
5356 | | return true; |
5357 | | } |
5358 | | |
5359 | | PSendSysMessage(LANG_BANLIST_MATCHINGIP); |
5360 | | // Chat short output |
5361 | | if(m_session) |
5362 | | { |
5363 | | do |
5364 | | { |
5365 | | Field* fields = result->Fetch(); |
5366 | | PSendSysMessage("%s",fields[0].GetString()); |
5367 | | }while (result->NextRow()); |
5368 | | } |
5369 | | // Console wide output |
5370 | | else |
5371 | | { |
5372 | | SendSysMessage(LANG_BANLIST_IPS);SendSysMessage("==============================================================================="); |
5373 | | SendSysMessage(LANG_BANLIST_IPS_HEADER); |
5374 | | do |
| 5338 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
| 5339 | |
| 5340 | char* cFilter = strtok((char*)args, " "); |
| 5341 | std::string filter = cFilter ? cFilter : ""; |
| 5342 | loginDatabase.escape_string(filter); |
| 5343 | |
| 5344 | QueryResult* result; |
| 5345 | |
| 5346 | if(filter.empty()) |
| 5347 | { |
| 5348 | result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
| 5349 | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" |
| 5350 | " ORDER BY unbandate" ); |
| 5351 | } |
| 5352 | else |
| 5353 | { |
| 5354 | result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
| 5355 | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") |
| 5356 | " ORDER BY unbandate",filter.c_str() ); |
| 5357 | } |
| 5358 | |
| 5359 | if(!result) |
| 5360 | { |
| 5361 | PSendSysMessage(LANG_BANLIST_NOIP); |
| 5362 | return true; |
| 5363 | } |
| 5364 | |
| 5365 | PSendSysMessage(LANG_BANLIST_MATCHINGIP); |
| 5366 | // Chat short output |
| 5367 | if(m_session) |
| 5368 | { |
| 5369 | do |
| 5370 | { |
| 5371 | Field* fields = result->Fetch(); |
| 5372 | PSendSysMessage("%s",fields[0].GetString()); |
| 5373 | } while (result->NextRow()); |
| 5374 | } |
| 5375 | // Console wide output |
| 5376 | else |
| 5377 | { |
| 5378 | SendSysMessage(LANG_BANLIST_IPS); |
| 5379 | SendSysMessage("==============================================================================="); |
| 5380 | SendSysMessage(LANG_BANLIST_IPS_HEADER); |
| 5381 | do |
5377 | | Field *fields = result->Fetch(); |
5378 | | time_t t_ban = fields[1].GetUInt64(); |
5379 | | tm* aTm_ban = localtime(&t_ban); |
5380 | | if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) |
5381 | | { |
5382 | | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
5383 | | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
5384 | | fields[3].GetString(), fields[4].GetString()); |
5385 | | } |
5386 | | else |
5387 | | { |
5388 | | time_t t_unban = fields[2].GetUInt64(); |
5389 | | tm* aTm_unban = localtime(&t_unban); |
5390 | | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
5391 | | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
5392 | | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
5393 | | fields[3].GetString(), fields[4].GetString()); |
5394 | | } |
5395 | | }while( result->NextRow() ); |
5396 | | SendSysMessage("==============================================================================="); |
| 5384 | Field *fields = result->Fetch(); |
| 5385 | time_t t_ban = fields[1].GetUInt64(); |
| 5386 | tm* aTm_ban = localtime(&t_ban); |
| 5387 | if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) |
| 5388 | { |
| 5389 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
| 5390 | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
| 5391 | fields[3].GetString(), fields[4].GetString()); |
| 5392 | } |
| 5393 | else |
| 5394 | { |
| 5395 | time_t t_unban = fields[2].GetUInt64(); |
| 5396 | tm* aTm_unban = localtime(&t_unban); |
| 5397 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
| 5398 | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
| 5399 | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
| 5400 | fields[3].GetString(), fields[4].GetString()); |
| 5401 | } |
| 5402 | }while( result->NextRow() ); |
| 5403 | SendSysMessage("==============================================================================="); |
5487 | | } |
5488 | | |
5489 | | if(!accmgr.GetName(account_id,account_name)) |
5490 | | { |
5491 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
5492 | | SetSentErrorMessage(true); |
5493 | | return false; |
5494 | | } |
5495 | | |
5496 | | char* guid_str = NULL; |
5497 | | char* name_str = strtok(NULL, " "); |
5498 | | |
5499 | | std::string name; |
5500 | | if(name_str) |
5501 | | { |
5502 | | name = name_str; |
5503 | | // normalize the name if specified and check if it exists |
5504 | | if(!normalizePlayerName(name)) |
5505 | | { |
5506 | | PSendSysMessage(LANG_INVALID_CHARACTER_NAME); |
5507 | | SetSentErrorMessage(true); |
5508 | | return false; |
5509 | | } |
5510 | | |
5511 | | if(!ObjectMgr::IsValidName(name,true)) |
5512 | | { |
5513 | | PSendSysMessage(LANG_INVALID_CHARACTER_NAME); |
5514 | | SetSentErrorMessage(true); |
| 5502 | } |
| 5503 | |
| 5504 | if(!accmgr.GetName(account_id,account_name)) |
| 5505 | { |
| 5506 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 5507 | SetSentErrorMessage(true); |
| 5508 | return false; |
| 5509 | } |
| 5510 | |
| 5511 | char* guid_str = NULL; |
| 5512 | char* name_str = strtok(NULL, " "); |
| 5513 | |
| 5514 | std::string name; |
| 5515 | if(name_str) |
| 5516 | { |
| 5517 | name = name_str; |
| 5518 | // normalize the name if specified and check if it exists |
| 5519 | if(!normalizePlayerName(name)) |
| 5520 | { |
| 5521 | PSendSysMessage(LANG_INVALID_CHARACTER_NAME); |
| 5522 | SetSentErrorMessage(true); |
5524 | | { |
5525 | | guid = atoi(guid_str); |
5526 | | if(!guid) |
5527 | | { |
5528 | | PSendSysMessage(LANG_INVALID_CHARACTER_GUID); |
5529 | | SetSentErrorMessage(true); |
5530 | | return false; |
5531 | | } |
5532 | | |
5533 | | if(objmgr.GetPlayerAccountIdByGUID(guid)) |
5534 | | { |
5535 | | PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid); |
5536 | | SetSentErrorMessage(true); |
5537 | | return false; |
5538 | | } |
5539 | | } |
5540 | | |
5541 | | switch(PlayerDumpReader().LoadDump(file, account_id, name, guid)) |
5542 | | { |
5543 | | case DUMP_SUCCESS: |
5544 | | PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); |
5545 | | break; |
5546 | | case DUMP_FILE_OPEN_ERROR: |
5547 | | PSendSysMessage(LANG_FILE_OPEN_FAIL,file); |
5548 | | SetSentErrorMessage(true); |
5549 | | return false; |
5550 | | case DUMP_FILE_BROKEN: |
5551 | | PSendSysMessage(LANG_DUMP_BROKEN,file); |
5552 | | SetSentErrorMessage(true); |
5553 | | return false; |
5554 | | case DUMP_TOO_MANY_CHARS: |
5555 | | PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); |
5556 | | SetSentErrorMessage(true); |
5557 | | return false; |
5558 | | default: |
5559 | | PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); |
5560 | | SetSentErrorMessage(true); |
5561 | | return false; |
5562 | | } |
| 5539 | { |
| 5540 | guid = atoi(guid_str); |
| 5541 | if(!guid) |
| 5542 | { |
| 5543 | PSendSysMessage(LANG_INVALID_CHARACTER_GUID); |
| 5544 | SetSentErrorMessage(true); |
| 5545 | return false; |
| 5546 | } |
| 5547 | |
| 5548 | if(objmgr.GetPlayerAccountIdByGUID(guid)) |
| 5549 | { |
| 5550 | PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid); |
| 5551 | SetSentErrorMessage(true); |
| 5552 | return false; |
| 5553 | } |
| 5554 | } |
| 5555 | |
| 5556 | switch(PlayerDumpReader().LoadDump(file, account_id, name, guid)) |
| 5557 | { |
| 5558 | case DUMP_SUCCESS: |
| 5559 | PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); |
| 5560 | break; |
| 5561 | case DUMP_FILE_OPEN_ERROR: |
| 5562 | PSendSysMessage(LANG_FILE_OPEN_FAIL,file); |
| 5563 | SetSentErrorMessage(true); |
| 5564 | return false; |
| 5565 | case DUMP_FILE_BROKEN: |
| 5566 | PSendSysMessage(LANG_DUMP_BROKEN,file); |
| 5567 | SetSentErrorMessage(true); |
| 5568 | return false; |
| 5569 | case DUMP_TOO_MANY_CHARS: |
| 5570 | PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); |
| 5571 | SetSentErrorMessage(true); |
| 5572 | return false; |
| 5573 | default: |
| 5574 | PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); |
| 5575 | SetSentErrorMessage(true); |
| 5576 | return false; |
| 5577 | } |
6113 | | ///- Get the accounts with GM Level >0 |
6114 | | QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); |
6115 | | if(result) |
6116 | | { |
6117 | | SendSysMessage(LANG_GMLIST); |
6118 | | SendSysMessage("========================"); |
6119 | | SendSysMessage(LANG_GMLIST_HEADER); |
6120 | | SendSysMessage("========================"); |
6121 | | |
6122 | | ///- Circle through them. Display username and GM level |
6123 | | do |
6124 | | { |
6125 | | Field *fields = result->Fetch(); |
6126 | | PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); |
6127 | | } while( result->NextRow() ); |
6128 | | |
6129 | | PSendSysMessage("========================"); |
6130 | | delete result; |
6131 | | } |
6132 | | else |
6133 | | PSendSysMessage(LANG_GMLIST_EMPTY); |
6134 | | return true; |
| 6127 | ///- Get the accounts with GM Level >0 |
| 6128 | QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); |
| 6129 | if(result) |
| 6130 | { |
| 6131 | SendSysMessage(LANG_GMLIST); |
| 6132 | SendSysMessage("========================"); |
| 6133 | SendSysMessage(LANG_GMLIST_HEADER); |
| 6134 | SendSysMessage("========================"); |
| 6135 | |
| 6136 | ///- Circle through them. Display username and GM level |
| 6137 | do |
| 6138 | { |
| 6139 | Field *fields = result->Fetch(); |
| 6140 | PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); |
| 6141 | }while( result->NextRow() ); |
| 6142 | |
| 6143 | PSendSysMessage("========================"); |
| 6144 | delete result; |
| 6145 | } |
| 6146 | else |
| 6147 | PSendSysMessage(LANG_GMLIST_EMPTY); |
| 6148 | return true; |
6148 | | ///- Get the command line arguments |
6149 | | char *szAcc = strtok((char*)args," "); |
6150 | | char *szExp = strtok(NULL," "); |
6151 | | |
6152 | | if(!szAcc) |
6153 | | return false; |
6154 | | |
6155 | | std::string account_name; |
6156 | | uint32 account_id; |
6157 | | |
6158 | | if(!szExp) |
6159 | | { |
6160 | | Player* player = getSelectedPlayer(); |
6161 | | if(!player) |
6162 | | return false; |
6163 | | |
6164 | | account_id = player->GetSession()->GetAccountId(); |
6165 | | accmgr.GetName(account_id,account_name); |
6166 | | szExp = szAcc; |
6167 | | } |
6168 | | else |
6169 | | { |
6170 | | ///- Convert Account name to Upper Format |
6171 | | account_name = szAcc; |
6172 | | if(!AccountMgr::normilizeString(account_name)) |
6173 | | { |
6174 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
6175 | | SetSentErrorMessage(true); |
6176 | | return false; |
6177 | | } |
6178 | | |
6179 | | account_id = accmgr.GetId(account_name); |
6180 | | if(!account_id) |
6181 | | { |
6182 | | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
6183 | | SetSentErrorMessage(true); |
6184 | | return false; |
6185 | | } |
6186 | | } |
6187 | | |
6188 | | int lev=atoi(szExp); //get int anyway (0 if error) |
6189 | | if(lev < 0) |
6190 | | return false; |
6191 | | |
6192 | | // No SQL injection |
6193 | | loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); |
6194 | | PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); |
6195 | | return true; |
| 6162 | ///- Get the command line arguments |
| 6163 | char *szAcc = strtok((char*)args," "); |
| 6164 | char *szExp = strtok(NULL," "); |
| 6165 | |
| 6166 | if(!szAcc) |
| 6167 | return false; |
| 6168 | |
| 6169 | std::string account_name; |
| 6170 | uint32 account_id; |
| 6171 | |
| 6172 | if(!szExp) |
| 6173 | { |
| 6174 | Player* player = getSelectedPlayer(); |
| 6175 | if(!player) |
| 6176 | return false; |
| 6177 | |
| 6178 | account_id = player->GetSession()->GetAccountId(); |
| 6179 | accmgr.GetName(account_id,account_name); |
| 6180 | szExp = szAcc; |
| 6181 | } |
| 6182 | else |
| 6183 | { |
| 6184 | ///- Convert Account name to Upper Format |
| 6185 | account_name = szAcc; |
| 6186 | if(!AccountMgr::normilizeString(account_name)) |
| 6187 | { |
| 6188 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 6189 | SetSentErrorMessage(true); |
| 6190 | return false; |
| 6191 | } |
| 6192 | |
| 6193 | account_id = accmgr.GetId(account_name); |
| 6194 | if(!account_id) |
| 6195 | { |
| 6196 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
| 6197 | SetSentErrorMessage(true); |
| 6198 | return false; |
| 6199 | } |
| 6200 | } |
| 6201 | |
| 6202 | int lev=atoi(szExp); //get int anyway (0 if error) |
| 6203 | if(lev < 0) |
| 6204 | return false; |
| 6205 | |
| 6206 | // No SQL injection |
| 6207 | loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); |
| 6208 | PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); |
| 6209 | return true; |
6201 | | ///- Get the command line arguments |
6202 | | char* name_str = strtok((char*)args, " "); |
6203 | | char* msg_str = strtok(NULL, ""); |
6204 | | |
6205 | | if(!name_str || !msg_str) |
6206 | | return false; |
6207 | | |
6208 | | std::string name = name_str; |
6209 | | |
6210 | | if(!normalizePlayerName(name)) |
6211 | | return false; |
6212 | | |
6213 | | ///- Find the player and check that he is not logging out. |
6214 | | Player *rPlayer = objmgr.GetPlayer(name.c_str()); |
6215 | | if(!rPlayer) |
6216 | | { |
6217 | | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
6218 | | SetSentErrorMessage(true); |
6219 | | return false; |
6220 | | } |
6221 | | |
6222 | | if(rPlayer->GetSession()->isLogingOut()) |
6223 | | { |
6224 | | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
6225 | | SetSentErrorMessage(true); |
6226 | | return false; |
6227 | | } |
6228 | | |
6229 | | ///- Send the message |
6230 | | //Use SendAreaTriggerMessage for fastest delivery. |
6231 | | rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str); |
6232 | | rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); |
6233 | | |
6234 | | //Confirmation message |
6235 | | PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str); |
6236 | | return true; |
| 6215 | ///- Get the command line arguments |
| 6216 | char* name_str = strtok((char*)args, " "); |
| 6217 | char* msg_str = strtok(NULL, ""); |
| 6218 | |
| 6219 | if(!name_str || !msg_str) |
| 6220 | return false; |
| 6221 | |
| 6222 | std::string name = name_str; |
| 6223 | |
| 6224 | if(!normalizePlayerName(name)) |
| 6225 | return false; |
| 6226 | |
| 6227 | ///- Find the player and check that he is not logging out. |
| 6228 | Player *rPlayer = objmgr.GetPlayer(name.c_str()); |
| 6229 | if(!rPlayer) |
| 6230 | { |
| 6231 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
| 6232 | SetSentErrorMessage(true); |
| 6233 | return false; |
| 6234 | } |
| 6235 | |
| 6236 | if(rPlayer->GetSession()->isLogingOut()) |
| 6237 | { |
| 6238 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
| 6239 | SetSentErrorMessage(true); |
| 6240 | return false; |
| 6241 | } |
| 6242 | |
| 6243 | ///- Send the message |
| 6244 | //Use SendAreaTriggerMessage for fastest delivery. |
| 6245 | rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str); |
| 6246 | rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); |
| 6247 | |
| 6248 | //Confirmation message |
| 6249 | PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str); |
| 6250 | return true; |
6263 | | if(!*args) return false; |
6264 | | Player *player = getSelectedPlayer(); |
6265 | | |
6266 | | if(!player) |
6267 | | { |
6268 | | PSendSysMessage(LANG_NO_PLAYER); |
6269 | | SetSentErrorMessage(true); |
6270 | | return false; |
6271 | | } |
6272 | | |
6273 | | std::string gender = (char*)args; |
6274 | | uint32 displayId = player->GetNativeDisplayId(); |
6275 | | |
6276 | | if(gender == "male") // MALE |
6277 | | { |
6278 | | if(player->getGender() == GENDER_MALE) |
6279 | | { |
6280 | | PSendSysMessage("%s is already male", player->GetName()); |
6281 | | SetSentErrorMessage(true); |
6282 | | return false; |
6283 | | } |
6284 | | |
6285 | | // Set gender |
6286 | | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); |
6287 | | // Change display ID |
6288 | | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
6289 | | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
6290 | | |
6291 | | ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); |
6292 | | PSendSysMessage("Gender changed for %s", player->GetName()); |
6293 | | return true; |
6294 | | } |
6295 | | else if(gender == "female") // FEMALE |
6296 | | { |
6297 | | if(player->getGender() == GENDER_FEMALE) |
6298 | | { |
6299 | | PSendSysMessage("%s is already female", player->GetName()); |
6300 | | SetSentErrorMessage(true); |
6301 | | return false; |
6302 | | } |
6303 | | |
6304 | | // Set gender |
6305 | | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); |
6306 | | // Change display ID |
6307 | | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
6308 | | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
6309 | | |
6310 | | ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); |
6311 | | PSendSysMessage("Gender changed for %s", player->GetName()); |
6312 | | return true; |
6313 | | } |
6314 | | else |
6315 | | { |
6316 | | PSendSysMessage("You must use male or female as gender."); |
6317 | | SetSentErrorMessage(true); |
6318 | | return false; |
6319 | | } |
6320 | | |
6321 | | return true; |
| 6277 | if(!*args) return false; |
| 6278 | Player *player = getSelectedPlayer(); |
| 6279 | |
| 6280 | if(!player) |
| 6281 | { |
| 6282 | PSendSysMessage(LANG_NO_PLAYER); |
| 6283 | SetSentErrorMessage(true); |
| 6284 | return false; |
| 6285 | } |
| 6286 | |
| 6287 | std::string gender = (char*)args; |
| 6288 | uint32 displayId = player->GetNativeDisplayId(); |
| 6289 | |
| 6290 | if(gender == "male") // MALE |
| 6291 | { |
| 6292 | if(player->getGender() == GENDER_MALE) |
| 6293 | { |
| 6294 | PSendSysMessage("%s is already male", player->GetName()); |
| 6295 | SetSentErrorMessage(true); |
| 6296 | return false; |
| 6297 | } |
| 6298 | |
| 6299 | // Set gender |
| 6300 | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); |
| 6301 | // Change display ID |
| 6302 | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
| 6303 | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
| 6304 | |
| 6305 | ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); |
| 6306 | PSendSysMessage("Gender changed for %s", player->GetName()); |
| 6307 | return true; |
| 6308 | } |
| 6309 | else if(gender == "female") // FEMALE |
| 6310 | { |
| 6311 | if(player->getGender() == GENDER_FEMALE) |
| 6312 | { |
| 6313 | PSendSysMessage("%s is already female", player->GetName()); |
| 6314 | SetSentErrorMessage(true); |
| 6315 | return false; |
| 6316 | } |
| 6317 | |
| 6318 | // Set gender |
| 6319 | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); |
| 6320 | // Change display ID |
| 6321 | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
| 6322 | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
| 6323 | |
| 6324 | ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); |
| 6325 | PSendSysMessage("Gender changed for %s", player->GetName()); |
| 6326 | return true; |
| 6327 | } |
| 6328 | else |
| 6329 | { |
| 6330 | PSendSysMessage("You must use male or female as gender."); |
| 6331 | SetSentErrorMessage(true); |
| 6332 | return false; |
| 6333 | } |
| 6334 | |
| 6335 | return true; |