TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AccountActionIpLogger Class Reference

Public Member Functions

 AccountActionIpLogger ()
 
void OnAccountLogin (uint32 accountId) override
 
void OnFailedAccountLogin (uint32 accountId) override
 
void OnPasswordChange (uint32 accountId) override
 
void OnFailedPasswordChange (uint32 accountId) override
 
void OnEmailChange (uint32 accountId) override
 
void OnFailedEmailChange (uint32 accountId) override
 
void AccountIPLogAction (uint32 accountId, IPLoggingTypes aType)
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Additional Inherited Members

- Protected Member Functions inherited from AccountScript
 AccountScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

AccountActionIpLogger::AccountActionIpLogger ( )
inline
45 : AccountScript("AccountActionIpLogger") { }
AccountScript(const char *name)
Definition: ScriptMgr.cpp:1670

Member Function Documentation

void AccountActionIpLogger::AccountIPLogAction ( uint32  accountId,
IPLoggingTypes  aType 
)
inline
90  {
91  // Action IP Logger is only intialized if config is set up
92  // Else, this script isn't loaded in the first place: We require no config check.
93 
94  // We declare all the required variables
95  uint32 playerGuid = accountId;
96  std::string systemNote = "ERROR"; // "ERROR" is a placeholder here. We change it later.
97 
98  // With this switch, we change systemNote so that we have a more accurate phrasing of what type it is.
99  // Avoids Magicnumbers in SQL table
100  switch (aType)
101  {
102  case ACCOUNT_LOGIN:
103  systemNote = "Logged on Successful AccountLogin";
104  break;
105  case ACCOUNT_FAIL_LOGIN:
106  systemNote = "Logged on Failed AccountLogin";
107  break;
108  case ACCOUNT_CHANGE_PW:
109  systemNote = "Logged on Successful Account Password Change";
110  break;
112  systemNote = "Logged on Failed Account Password Change";
113  break;
115  systemNote = "Logged on Successful Account Email Change";
116  break;
118  systemNote = "Logged on Failed Account Email Change";
119  break;
120  /*case ACCOUNT_LOGOUT:
121  systemNote = "Logged on AccountLogout"; //Can not be logged
122  break;*/
123  // Neither should happen. Ever. Period. If it does, call Ghostbusters and all your local software defences to investigate.
124  case UNKNOWN_ACTION:
125  default:
126  systemNote = "ERROR! Unknown action!";
127  break;
128  }
129 
130  // Once we have done everything, we can insert the new log.
131  // Seeing as the time differences should be minimal, we do not get unixtime and the timestamp right now;
132  // Rather, we let it be added with the SQL query.
133  if (aType != ACCOUNT_FAIL_LOGIN)
134  {
135  // As we can assume most account actions are NOT failed login, so this is the more accurate check.
136  // For those, we need last_ip...
138 
139  stmt->setUInt32(0, playerGuid);
140  stmt->setUInt32(1, 0);
141  stmt->setUInt8(2, aType);
142  stmt->setUInt32(3, playerGuid);
143  stmt->setString(4, systemNote.c_str());
144  LoginDatabase.Execute(stmt);
145  }
146  else // ... but for failed login, we query last_attempt_ip from account table. Which we do with an unique query
147  {
149 
150  stmt->setUInt32(0, playerGuid);
151  stmt->setUInt32(1, 0);
152  stmt->setUInt8(2, aType);
153  stmt->setUInt32(3, playerGuid);
154  stmt->setString(4, systemNote.c_str());
155  LoginDatabase.Execute(stmt);
156  }
157  return;
158  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: action_ip_logger.cpp:24
Definition: action_ip_logger.cpp:29
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: action_ip_logger.cpp:27
Definition: action_ip_logger.cpp:25
Definition: action_ip_logger.cpp:39
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: LoginDatabase.h:100
Definition: LoginDatabase.h:101
Definition: action_ip_logger.cpp:28
Definition: action_ip_logger.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AccountActionIpLogger::OnAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

50  {
52  }
Definition: action_ip_logger.cpp:24
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89

+ Here is the call graph for this function:

void AccountActionIpLogger::OnEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

76  {
77  AccountIPLogAction(accountId, ACCOUNT_CHANGE_EMAIL); // ... they get logged by gm command logger anyway
78  }
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89
Definition: action_ip_logger.cpp:28

+ Here is the call graph for this function:

void AccountActionIpLogger::OnFailedAccountLogin ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

57  {
59  }
Definition: action_ip_logger.cpp:25
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89

+ Here is the call graph for this function:

void AccountActionIpLogger::OnFailedEmailChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

82  {
84  }
Definition: action_ip_logger.cpp:29
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89

+ Here is the call graph for this function:

void AccountActionIpLogger::OnFailedPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

69  {
71  }
Definition: action_ip_logger.cpp:27
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89

+ Here is the call graph for this function:

void AccountActionIpLogger::OnPasswordChange ( uint32  accountId)
inlineoverridevirtual

Reimplemented from AccountScript.

63  {
65  }
void AccountIPLogAction(uint32 accountId, IPLoggingTypes aType)
Definition: action_ip_logger.cpp:89
Definition: action_ip_logger.cpp:26

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: