-
Notifications
You must be signed in to change notification settings - Fork 1
/
Database.h
70 lines (64 loc) · 1.82 KB
/
Database.h
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
#ifndef DATABASE_H
#define DATABASE_H
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include "config.cpp"
#include "Torrent.h"
#include "AnnounceInfo.h"
#include <math.h>
#include "Logger.h"
#include <boost/algorithm/string.hpp>
/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
class Database
{
public:
Database(Logger*);
~Database();
std::string insertClientInfo(const std::vector<std::string*> &vectorOfArrays);
Torrent getTorrent(std::string infoHash);
std::string getErrorMessage();
private:
Logger *logger;
sql::Driver* driver;
sql::Connection* con;
sql::PreparedStatement* pstmt;
sql::ResultSet* res;
std::string errorMessage = "Unknown Error.";
AnnounceInfo* annInfo;
std::string decode(std::string str);
std::string urlDecode(std::string);
std::vector<int> getTorrentData(std::string infoHash);
std::vector<Peer*> getPeers(std::string infoHash);
int parseEventString(std::string);
double calcBonusPoints(uint64_t torrentSizeBytes, int newSeedMinutes, int numberOfSeeders, int totalSeedTimeMinutes);
bool getUserId();
bool userCanLeech();
bool getClientId(bool recursive);
bool createClient();
bool updateClient();
bool updateUserBonusPoints(int newSeedMinutes);
bool updateTorrent();
bool torrentExists();
bool ipaIsBanned();
bool getIpaId(bool recursive);
bool createIpAddress();
bool updateUserTorrentTotals(int newSeedMinutes);
bool createUserTorrentTotals();
bool updateClientTorrents();
bool createClientTorrent();
bool setOldUploadAndDownload();
};
#endif