Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "constants.h"
- #include "config.h"
- #include "utils.h"
- #include "desc_client.h"
- #include "desc_manager.h"
- #include "buffer_manager.h"
- #include "packet.h"
- #include "protocol.h"
- #include "char.h"
- #include "char_manager.h"
- #include "item.h"
- #include "item_manager.h"
- #include "cmd.h"
- #include "shop.h"
- #include "shop_manager.h"
- #include "safebox.h"
- #include "regen.h"
- #include "battle.h"
- #include "exchange.h"
- #include "questmanager.h"
- #include "profiler.h"
- #include "messenger_manager.h"
- #include "party.h"
- #include "p2p.h"
- #include "affect.h"
- #include "guild.h"
- #include "guild_manager.h"
- #include "log.h"
- #include "banword.h"
- #include "empire_text_convert.h"
- #include "unique_item.h"
- #include "building.h"
- #include "locale_service.h"
- #include "gm.h"
- #include "spam.h"
- #include "ani.h"
- #include "motion.h"
- #include "OXEvent.h"
- #include "locale_service.h"
- #include "HackShield.h"
- #include "XTrapManager.h"
- #include "DragonSoul.h"
- extern void SendShout(const char * szText, BYTE bEmpire);
- extern int g_nPortalLimitTime;
- static int __deposit_limit()
- {
- return (1000*10000); // 1ΓµΈΈ
- }
- void SendBlockChatInfo(LPCHARACTER ch, int sec)
- {
- if (sec <= 0)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Γ¤ΖΓ ±έΑφ »σΕΒΐΤ΄Ο΄Ω."));
- return;
- }
- long hour = sec / 3600;
- sec -= hour * 3600;
- long min = (sec / 60);
- sec -= min * 60;
- char buf[128+1];
- if (hour > 0 && min > 0)
- snprintf(buf, sizeof(buf), LC_TEXT("%d ½Γ°£ %d ΊΠ %d ΓΚ µΏΎΘ Γ¤ΖΓ±έΑφ »σΕΒΐΤ΄Ο΄Ω"), hour, min, sec);
- else if (hour > 0 && min == 0)
- snprintf(buf, sizeof(buf), LC_TEXT("%d ½Γ°£ %d ΓΚ µΏΎΘ Γ¤ΖΓ±έΑφ »σΕΒΐΤ΄Ο΄Ω"), hour, sec);
- else if (hour == 0 && min > 0)
- snprintf(buf, sizeof(buf), LC_TEXT("%d ΊΠ %d ΓΚ µΏΎΘ Γ¤ΖΓ±έΑφ »σΕΒΐΤ΄Ο΄Ω"), min, sec);
- else
- snprintf(buf, sizeof(buf), LC_TEXT("%d ΓΚ µΏΎΘ Γ¤ΖΓ±έΑφ »σΕΒΐΤ΄Ο΄Ω"), sec);
- ch->ChatPacket(CHAT_TYPE_INFO, buf);
- }
- EVENTINFO(spam_event_info)
- {
- char host[MAX_HOST_LENGTH+1];
- spam_event_info()
- {
- ::memset( host, 0, MAX_HOST_LENGTH+1 );
- }
- };
- typedef boost::unordered_map<std::string, std::pair<unsigned int, LPEVENT> > spam_score_of_ip_t;
- spam_score_of_ip_t spam_score_of_ip;
- EVENTFUNC(block_chat_by_ip_event)
- {
- spam_event_info* info = dynamic_cast<spam_event_info*>( event->info );
- if ( info == NULL )
- {
- sys_err( "block_chat_by_ip_event> <Factor> Null pointer" );
- return 0;
- }
- const char * host = info->host;
- spam_score_of_ip_t::iterator it = spam_score_of_ip.find(host);
- if (it != spam_score_of_ip.end())
- {
- it->second.first = 0;
- it->second.second = NULL;
- }
- return 0;
- }
- bool SpamBlockCheck(LPCHARACTER ch, const char* const buf, const size_t buflen)
- {
- extern int g_iSpamBlockMaxLevel;
- if (ch->GetLevel() < g_iSpamBlockMaxLevel)
- {
- spam_score_of_ip_t::iterator it = spam_score_of_ip.find(ch->GetDesc()->GetHostName());
- if (it == spam_score_of_ip.end())
- {
- spam_score_of_ip.insert(std::make_pair(ch->GetDesc()->GetHostName(), std::make_pair(0, (LPEVENT) NULL)));
- it = spam_score_of_ip.find(ch->GetDesc()->GetHostName());
- }
- if (it->second.second)
- {
- SendBlockChatInfo(ch, event_time(it->second.second) / passes_per_sec);
- return true;
- }
- unsigned int score;
- const char * word = SpamManager::instance().GetSpamScore(buf, buflen, score);
- it->second.first += score;
- if (word)
- sys_log(0, "SPAM_SCORE: %s text: %s score: %u total: %u word: %s", ch->GetName(), buf, score, it->second.first, word);
- extern unsigned int g_uiSpamBlockScore;
- extern unsigned int g_uiSpamBlockDuration;
- if (it->second.first >= g_uiSpamBlockScore)
- {
- spam_event_info* info = AllocEventInfo<spam_event_info>();
- strlcpy(info->host, ch->GetDesc()->GetHostName(), sizeof(info->host));
- it->second.second = event_create(block_chat_by_ip_event, info, PASSES_PER_SEC(g_uiSpamBlockDuration));
- sys_log(0, "SPAM_IP: %s for %u seconds", info->host, g_uiSpamBlockDuration);
- LogManager::instance().CharLog(ch, 0, "SPAM", word);
- SendBlockChatInfo(ch, event_time(it->second.second) / passes_per_sec);
- return true;
- }
- }
- return false;
- }
- enum
- {
- TEXT_TAG_PLAIN,
- TEXT_TAG_TAG, // ||
- TEXT_TAG_COLOR, // |cffffffff
- TEXT_TAG_HYPERLINK_START, // |H
- TEXT_TAG_HYPERLINK_END, // |h ex) |Hitem:1234:1:1:1|h
- TEXT_TAG_RESTORE_COLOR,
- };
- int GetTextTag(const char * src, int maxLen, int & tagLen, std::string & extraInfo)
- {
- tagLen = 1;
- if (maxLen < 2 || *src != '|')
- return TEXT_TAG_PLAIN;
- const char * cur = ++src;
- if (*cur == '|') // ||΄Β |·Ξ Η¥½ΓΗΡ΄Ω.
- {
- tagLen = 2;
- return TEXT_TAG_TAG;
- }
- else if (*cur == 'c') // color |cffffffffblahblah|r
- {
- tagLen = 2;
- return TEXT_TAG_COLOR;
- }
- else if (*cur == 'H') // hyperlink |Hitem:10000:0:0:0:0|h[ΐΜΈ§]|h
- {
- tagLen = 2;
- return TEXT_TAG_HYPERLINK_START;
- }
- else if (*cur == 'h') // end of hyperlink
- {
- tagLen = 2;
- return TEXT_TAG_HYPERLINK_END;
- }
- return TEXT_TAG_PLAIN;
- }
- void GetTextTagInfo(const char * src, int src_len, int & hyperlinks, bool & colored)
- {
- colored = false;
- hyperlinks = 0;
- int len;
- std::string extraInfo;
- for (int i = 0; i < src_len;)
- {
- int tag = GetTextTag(&src[i], src_len - i, len, extraInfo);
- if (tag == TEXT_TAG_HYPERLINK_START)
- ++hyperlinks;
- if (tag == TEXT_TAG_COLOR)
- colored = true;
- i += len;
- }
- }
- int ProcessTextTag(LPCHARACTER ch, const char * c_pszText, size_t len)
- {
- return 0;//BETEKINT
Advertisement
Add Comment
Please, Sign In to add comment