A class to handle the non-SQL logic for connecting to the phpbb forum database. More...
#include <forum_user_handler.hpp>
Public Member Functions | |
fuh (const config &c) | |
Reads wesnothd's config for the data needed to initialize this class and dbconn. More... | |
bool | login (const std::string &name, const std::string &password) |
Retrieves the player's hashed password from the phpbb forum database and checks if it matches the hashed password sent by the client. More... | |
std::string | extract_salt (const std::string &name) |
Needed because the hashing algorithm used by phpbb requires some info from the original hash to recreate the same hash. More... | |
void | user_logged_in (const std::string &name) |
Sets the last login time to the current time. More... | |
bool | user_exists (const std::string &name) |
long | get_forum_id (const std::string &name) |
bool | user_is_active (const std::string &name) |
bool | user_is_moderator (const std::string &name) |
void | set_is_moderator (const std::string &name, const bool &is_moderator) |
Sets or unsets whether the player should be considered a moderator in the extra table. More... | |
ban_info | user_is_banned (const std::string &name, const std::string &addr) |
std::string | user_info (const std::string &name) |
std::string | get_uuid () |
std::string | get_tournaments () |
void | async_get_and_send_game_history (boost::asio::io_service &io_service, wesnothd::server &s, wesnothd::player_iterator player, int player_id, int offset, std::string &search_game_name, int search_content_type, std::string &search_content) |
Runs an asynchronous query to fetch the user's game history data. More... | |
void | db_insert_game_info (const std::string &uuid, int game_id, const std::string &version, const std::string &name, int reload, int observers, int is_public, int has_password) |
Inserts game related information. More... | |
void | db_update_game_end (const std::string &uuid, int game_id, const std::string &replay_location) |
Update the game related information when the game ends. More... | |
void | db_insert_game_player_info (const std::string &uuid, int game_id, const std::string &username, int side_number, int is_host, const std::string &faction, const std::string &version, const std::string &source, const std::string ¤t_user, const std::string &leaders) |
Inserts player information per side. More... | |
unsigned long long | db_insert_game_content_info (const std::string &uuid, int game_id, const std::string &type, const std::string &name, const std::string &id, const std::string &addon_id, const std::string &addon_version) |
Inserts information about the content being played. More... | |
void | db_set_oos_flag (const std::string &uuid, int game_id) |
Sets the OOS flag in the database if wesnothd is told by a client it has detected an OOS error. More... | |
void | async_test_query (boost::asio::io_service &io_service, int limit) |
A simple test query for running a query asynchronously. More... | |
bool | db_topic_id_exists (int topic_id) |
Checks whether a forum thread with topic_id exists. More... | |
void | db_insert_addon_info (const std::string &instance_version, const std::string &id, const std::string &name, const std::string &type, const std::string &version, bool forum_auth, int topic_id, const std::string uploader) |
Inserts information about an uploaded add-on into the database. More... | |
unsigned long long | db_insert_login (const std::string &username, const std::string &ip, const std::string &version) |
Inserts into the database for when a player logs in. More... | |
void | db_update_logout (unsigned long long login_id) |
Updates the database for when a player logs out. More... | |
void | get_users_for_ip (const std::string &ip, std::ostringstream *out) |
Searches for all players that logged in using the ip address. More... | |
void | get_ips_for_user (const std::string &username, std::ostringstream *out) |
Searches for all ip addresses used by the player. More... | |
std::string | get_user_email (const std::string &user) |
void | db_update_addon_download_count (const std::string &instance_version, const std::string &id, const std::string &version) |
Increments the download count for this add-on for the specific version. More... | |
bool | db_is_user_primary_author (const std::string &instance_version, const std::string &id, const std::string &username) |
Checks whether the provided username is the primary author of the add-on. More... | |
bool | db_is_user_secondary_author (const std::string &instance_version, const std::string &id, const std::string &username) |
Checks whether the provided username is a secondary author of the add-on. More... | |
void | db_delete_addon_authors (const std::string &instance_version, const std::string &id) |
Removes the authors information from addon_author for a particular addon and version. More... | |
void | db_insert_addon_authors (const std::string &instance_version, const std::string &id, const std::string &primary_author, const std::vector< std::string > &secondary_authors) |
Inserts rows for the primary and secondary authors for a particular addon and version. More... | |
bool | db_do_any_authors_exist (const std::string &instance_version, const std::string &id) |
Checks whether any author information exists for a particular addon and version, since if there's no author information then of course no primary or secondary authors will ever be found. More... | |
Public Member Functions inherited from user_handler | |
user_handler () | |
virtual | ~user_handler () |
Private Member Functions | |
std::string | get_hashed_password_from_db (const std::string &user) |
std::chrono::system_clock::time_point | get_lastlogin (const std::string &user) |
std::chrono::system_clock::time_point | get_registrationdate (const std::string &user) |
Private Attributes | |
dbconn | conn_ |
An instance of the class responsible for executing the queries and handling the database connection. More... | |
std::string | db_users_table_ |
The name of the phpbb users table. More... | |
std::string | db_extra_table_ |
The name of the extras custom table, not part of a phpbb database. More... | |
int | mp_mod_group_ |
The group ID of the forums MP Moderators group. More... | |
Additional Inherited Members | |
Public Types inherited from user_handler | |
enum | BAN_TYPE { BAN_NONE = 0 , BAN_IP = 1 , BAN_USER = 2 , BAN_EMAIL = 3 } |
Ban type values. More... | |
A class to handle the non-SQL logic for connecting to the phpbb forum database.
Definition at line 28 of file forum_user_handler.hpp.
fuh::fuh | ( | const config & | c | ) |
Reads wesnothd's config for the data needed to initialize this class and dbconn.
|
virtual |
Runs an asynchronous query to fetch the user's game history data.
The result is then posted back to the main boost::asio thread to be sent to the requesting player.
io_service | The boost io_service to use to post the query results back to the main boost::asio thread. |
s | The server instance the player is connected to. |
player | The player iterator used to communicate with the player's client. |
player_id | The forum ID of the player to get the game history for. |
offset | Where to start returning rows to the client from the query results. |
search_game_name | Query for games matching this name. Supports leading and/or trailing wildcards. |
search_content_type | The content type to query for (ie: scenario) |
search_content | Query for games using this content ID. Supports leading and/or trailing wildcards. |
Implements user_handler.
|
virtual |
A simple test query for running a query asynchronously.
The main point is that it takes a meaningful amount of time to complete so that it's easy to see that multiple are running at once and are finishing out of order.
io_service | The boost io_service to use to post the query results back to the main boost::asio thread. |
limit | How many recursions to make in the query. |
Implements user_handler.
|
virtual |
Removes the authors information from addon_author for a particular addon and version.
instance_version | Which major version this is for (1.16, 1.17, etc). |
id | The ID of the add-on. |
Implements user_handler.
|
virtual |
Checks whether any author information exists for a particular addon and version, since if there's no author information then of course no primary or secondary authors will ever be found.
instance_version | Which major version this is for (1.16, 1.17, etc). |
id | The ID of the add-on. |
Implements user_handler.
|
virtual |
Inserts rows for the primary and secondary authors for a particular addon and version.
instance_version | Which major version this is for (1.16, 1.17, etc). |
id | The ID of the add-on. |
primary_author | The primary author of the add-on. |
secondary_authors | The secondary authors of the add-on. |
Implements user_handler.
|
virtual |
Inserts information about an uploaded add-on into the database.
instance_version | The version of campaignd the add-on was uploaded to. |
id | The add-on's ID (aka directory name). |
name | The add-on's name from the pbl. |
type | The add-on's type from the pbl. |
version | The add-on's version from the pbl. |
forum_auth | Whether the provided author and password should be matched a forum account or not. |
topic_id | The forum topic ID of the add-on's feedback thread, 0 if not present. |
uploader | The person uploading this version of the add-on. |
Implements user_handler.
|
virtual |
Inserts information about the content being played.
uuid | The value returned by get_uuid(). |
game_id | The game's db_id. |
type | The add-on content's type (ie: era, scenario, etc). |
name | The name of the content. |
id | The id of the content. |
addon_id | The id of the addon that the content is from. |
addon_version | The version of the add-on. |
Implements user_handler.
|
virtual |
Inserts game related information.
uuid | The value returned by get_uuid(). |
game_id | The game's db_id. |
version | The version of wesnothd running this game. |
name | The game's name as entered by the user. |
reload | Whether this game was loaded from the save of a previous game. |
observers | Whether observers are allowed. |
is_public | Whether the game's replay will be publicly available. |
has_password | Whether the game has a password. |
Implements user_handler.
|
virtual |
Inserts player information per side.
uuid | The value returned by get_uuid(). |
game_id | The game's db_id. |
username | The username of the player who owns this side. |
side_number | This side's side number. |
is_host | Whether this player is the host. |
faction | The name of this side's faction. |
version | The version of Wesnoth this player is using. |
source | The source where this player downloaded Wesnoth (ie: Steam, SourceForge, etc). |
current_user | The player currently in control of this side. |
leaders | The comma-delimited list of leader unit types for that side. |
Implements user_handler.
|
virtual |
Inserts into the database for when a player logs in.
username | The username of who logged in. The username is converted to lower case when inserting in order to allow index usage when querying. |
ip | The ip address of who logged in. |
version | The version of the client that logged in. |
Implements user_handler.
|
virtual |
Checks whether the provided username is the primary author of the add-on.
instance_version | Which major version this is for (1.16, 1.17, etc). |
id | The ID of the add-on. |
username | The username attempting to do something with the add-on. |
Implements user_handler.
|
virtual |
Checks whether the provided username is a secondary author of the add-on.
instance_version | Which major version this is for (1.16, 1.17, etc). |
id | The ID of the add-on. |
username | The username attempting to do something with the add-on. |
Implements user_handler.
|
virtual |
Sets the OOS flag in the database if wesnothd is told by a client it has detected an OOS error.
uuid | The value returned by get_uuid(). |
game_id | The game's db_id. |
Implements user_handler.
|
virtual |
Checks whether a forum thread with topic_id exists.
topic_id | The topic id to check for. |
Implements user_handler.
|
virtual |
Increments the download count for this add-on for the specific version.
instance_version | The version of campaignd the add-on was uploaded to. |
id | The add-on's ID (aka directory name). |
version | The version of the add-on being downloaded. May not be the most recent version. |
Implements user_handler.
|
virtual |
Update the game related information when the game ends.
uuid | The value returned by get_uuid(). |
game_id | The game's db_id. |
replay_location | The location of the game's publicly available replay. |
Implements user_handler.
|
virtual |
Updates the database for when a player logs out.
login_id | The generated ID that uniquely identifies the row to be updated. |
Implements user_handler.
|
virtual |
Needed because the hashing algorithm used by phpbb requires some info from the original hash to recreate the same hash.
Implements user_handler.
|
virtual |
name | The player's username. |
Implements user_handler.
|
private |
user | The player's username. |
|
virtual |
Searches for all ip addresses used by the player.
The username is converted to lower case to allow a case insensitive select query to be executed while still using an index. The '' wildcard can be used to search for partial usernames.
username | The username to search for. |
out | Where to output the results. |
Implements user_handler.
|
private |
user | The player's username. |
|
private |
user | The player's username. |
|
virtual |
Implements user_handler.
|
virtual |
user | The player's username. |
Implements user_handler.
|
virtual |
Searches for all players that logged in using the ip address.
The '' wildcard can be used to search for partial ip addresses.
ip | The ip address to search for. |
out | Where to output the results. |
Implements user_handler.
|
virtual |
Implements user_handler.
|
virtual |
Retrieves the player's hashed password from the phpbb forum database and checks if it matches the hashed password sent by the client.
name | The username used to login. |
password | The hashed password sent by the client. |
Implements user_handler.
|
virtual |
Sets or unsets whether the player should be considered a moderator in the extra table.
name | The player's username. |
is_moderator | The moderator value to set. |
Implements user_handler.
|
virtual |
name | The player's username. |
Implements user_handler.
|
virtual |
name | The player's username. |
Implements user_handler.
|
virtual |
name | The player's username. |
Implements user_handler.
|
virtual |
name | The player's username. |
addr | The IP address being checked. |
Implements user_handler.
|
virtual |
name | The player's username. |
Implements user_handler.
|
virtual |
Sets the last login time to the current time.
name | The player's username. |
Implements user_handler.
|
private |
An instance of the class responsible for executing the queries and handling the database connection.
Definition at line 329 of file forum_user_handler.hpp.
|
private |
The name of the extras custom table, not part of a phpbb database.
Definition at line 333 of file forum_user_handler.hpp.
|
private |
The name of the phpbb users table.
Definition at line 331 of file forum_user_handler.hpp.
|
private |
The group ID of the forums MP Moderators group.
Definition at line 335 of file forum_user_handler.hpp.