-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
forum_user_handler.hpp
92 lines (71 loc) · 3.21 KB
/
forum_user_handler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright (C) 2008 - 2018 by Thomas Baumhauer <thomas.baumhauer@NOSPAMgmail.com>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
#include "server/common/user_handler.hpp"
#include "server/common/dbconn.hpp"
#include <vector>
#include <memory>
#include <ctime>
// The [user_handler] section in the server configuration
// file could look like this:
//
//[user_handler]
// db_name=phpbb3
// db_host=localhost
// db_user=root
// db_password=secret
// db_users_table=users
// db_banlist_table=banlist
// db_extra_table=extra_data
//[/user_handler]
/**
* A user_handler implementation to link the server with a phpbb3 forum.
*/
class fuh : public user_handler {
public:
fuh(const config& c);
bool login(const std::string& name, const std::string& password, const std::string& seed);
/**
* Needed because the hashing algorithm used by phpbb requires some info
* from the original hash to recreate the same hash
*
* Return an empty string if an error occurs
*/
std::string extract_salt(const std::string& name);
void user_logged_in(const std::string& name);
bool user_exists(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);
ban_info user_is_banned(const std::string& name, const std::string& addr);
std::string user_info(const std::string& name);
bool use_phpbb_encryption() const { return true; }
std::string get_uuid();
std::string get_tournaments();
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);
void db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location);
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& current_user);
void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version);
void db_set_oos_flag(const std::string& uuid, int game_id);
void async_test_query(boost::asio::io_service& io_service, int limit);
private:
dbconn conn_;
std::string db_users_table_;
std::string db_extra_table_;
int mp_mod_group_;
std::string get_hash(const std::string& user);
std::time_t get_lastlogin(const std::string& user);
std::time_t get_registrationdate(const std::string& user);
bool is_inactive(const std::string& user);
void set_lastlogin(const std::string& user, const std::time_t& lastlogin);
bool is_user_in_group(const std::string& name, int group_id);
};