Aokromes

report spam mangos

Oct 29th, 2011
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.49 KB | None | 0 0
  1. diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
  2. index 8812701..ca3da21 100644
  3. --- a/src/game/MiscHandler.cpp
  4. +++ b/src/game/MiscHandler.cpp
  5. @@ -1336,7 +1336,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
  6.      data << uint8(0);
  7.      SendPacket(&data);
  8.  
  9. -    sLog.outDebug("REPORT SPAM: type %u, guid %u, unk1 %u, unk2 %u, unk3 %u, unk4 %u, message %s", spam_type, GUID_LOPART(spammer_guid), unk1, unk2, unk3, unk4, description.c_str());
  10. +    std::string spamer_name;
  11. +    objmgr.GetPlayerNameByGUID(spammer_guid, spamer_name);
  12. +    
  13. +    sLog.outSpam("Spamer: %s (Guid %u) , Message : %s , Reporter : %s", spamer_name.c_str() ,GUID_LOPART(spammer_guid) , description.c_str(), GetPlayerName());
  14.  }
  15.  
  16.  void WorldSession::HandleRealmStateRequestOpcode( WorldPacket & recv_data )
  17. diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
  18. index 2c6ca91..c708457 100644
  19. --- a/src/mangosd/mangosd.conf.dist.in
  20. +++ b/src/mangosd/mangosd.conf.dist.in
  21. @@ -251,6 +251,10 @@ AddonChannel = 1
  22.  #        Default: 0 - don't include dumping chars to log
  23.  #                 1 - include dumping chars to log
  24.  #
  25. +#    SpamLogFile
  26. +#        Spam Log file for logging player reported spams
  27. +#        Default: "" (disabled)
  28. +#
  29.  #    GmLogFile
  30.  #        GM Log file of gm commands
  31.  #        Default: "" (Disable)
  32. @@ -296,6 +300,7 @@ DBErrorLogFile = "DBErrors.log"
  33.  CharLogFile = "Char.log"
  34.  CharLogTimestamp = 0
  35.  CharLogDump = 0
  36. +SpamlogFile = "spam.log"
  37.  GmLogFile = ""
  38.  GmLogTimestamp = 0
  39.  GmLogPerAccount = 0
  40. diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
  41. index f5d0513..45c0e1a 100644
  42. --- a/src/shared/Log.cpp
  43. +++ b/src/shared/Log.cpp
  44. @@ -37,7 +37,7 @@ enum LogType
  45.  const int LogType_count = int(LogError) +1;
  46.  
  47.  Log::Log() :
  48. -    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
  49. +    raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), spamlog(NULL),
  50.      dberLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false)
  51.  {
  52.      Initialize();
  53. @@ -228,6 +228,7 @@ void Log::Initialize()
  54.  
  55.      dberLogfile = openLogFile("DBErrorLogFile",NULL,"a");
  56.      raLogfile = openLogFile("RaLogFile",NULL,"a");
  57. +    spamlog = openLogFile("SpamlogFile", NULL, "a");
  58.  
  59.      // Main log file settings
  60.      m_includeTime  = sConfig.GetBoolDefault("LogTime", false);
  61. @@ -725,6 +726,38 @@ void Log::outRALog(    const char * str, ... )
  62.      fflush(stdout);
  63.  }
  64.  
  65. +void Log::outSpam( const char * msg, ... )
  66. +{
  67. +    if( !msg ) return;
  68. +
  69. +    if(m_colored)
  70. +        SetColor(false,m_colors[LogError]);
  71. +
  72. +    if(m_includeTime)
  73. +        outTime();
  74. +
  75. +    va_list ap;
  76. +    va_start(ap, msg);
  77. +    vfprintf( stderr, msg, ap );
  78. +    va_end(ap);
  79. +
  80. +    if(m_colored)
  81. +        ResetColor(false);
  82. +
  83. +    fprintf( stderr, "\n" );
  84. +    if(spamlog)
  85. +    {
  86. +        outTimestamp(spamlog);
  87. +        fprintf(spamlog, "Reported spam:" );
  88. +        va_start(ap, msg);
  89. +        vfprintf(spamlog, msg, ap);
  90. +        fprintf(spamlog, "\n" );
  91. +        va_end(ap);
  92. +        fflush(spamlog);
  93. +    }
  94. +    fflush(stderr);
  95. +}
  96. +
  97.  void outstring_log(const char * str, ...)
  98.  {
  99.      if( !str )
  100. diff --git a/src/shared/Log.h b/src/shared/Log.h
  101. index 391a93d..bc071e2 100644
  102. --- a/src/shared/Log.h
  103. +++ b/src/shared/Log.h
  104. @@ -79,6 +79,11 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
  105.          if (raLogfile != NULL)
  106.              fclose(raLogfile);
  107.          raLogfile = NULL;
  108. +        
  109. +           if (spamlog != NULL)
  110. +            fclose(spamlog);
  111. +        raLogfile = NULL;
  112. +
  113.      }
  114.      public:
  115.          void Initialize();
  116. @@ -107,6 +112,8 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
  117.                                                              // any log level
  118.          void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
  119.          void outRALog( const char * str, ... )       ATTR_PRINTF(2,3);
  120. +        void outSpam( const char * msg, ... )       ATTR_PRINTF(2,3);
  121. +
  122.          void SetLogLevel(char * Level);
  123.          void SetLogFileLevel(char * Level);
  124.          void SetColor(bool stdout_stream, Color color);
  125. @@ -123,6 +130,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ZThrea
  126.          FILE* openGmlogPerAccount(uint32 account);
  127.  
  128.          FILE* raLogfile;
  129. +      FILE* spamlog;
  130.          FILE* logfile;
  131.          FILE* gmLogfile;
  132.          FILE* charLogfile;
Advertisement
Add Comment
Please, Sign In to add comment