fix ip bans and generally make it work correctly
This commit is contained in:
parent
6a38e50c4f
commit
fa72e87e34
@ -31,12 +31,13 @@ DBManager::DBManager() :
|
|||||||
bool DBManager::isIPBanned(QHostAddress ip)
|
bool DBManager::isIPBanned(QHostAddress ip)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT DURATION FROM BANS WHERE IP = ? ORDER BY TIME DESC");
|
query.prepare("SELECT TIME FROM BANS WHERE IP = ? ORDER BY TIME DESC");
|
||||||
query.addBindValue(ip.toString());
|
query.addBindValue(ip.toString());
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.first()) {
|
if (query.first()) {
|
||||||
long long duration = getBanDuration(ip);
|
long long duration = getBanDuration(ip);
|
||||||
long long ban_time = query.value(0).toLongLong();
|
long long ban_time = query.value(0).toLongLong();
|
||||||
|
qDebug() << ban_time << "duration:" << duration;
|
||||||
if (duration == -2)
|
if (duration == -2)
|
||||||
return true;
|
return true;
|
||||||
long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch();
|
long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||||
@ -69,7 +70,7 @@ bool DBManager::isHDIDBanned(QString hdid)
|
|||||||
QString DBManager::getBanReason(QHostAddress ip)
|
QString DBManager::getBanReason(QHostAddress ip)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT REASON FROM BANS WHERE IP = ?");
|
query.prepare("SELECT REASON FROM BANS WHERE IP = ? ORDER BY TIME DESC");
|
||||||
query.addBindValue(ip.toString());
|
query.addBindValue(ip.toString());
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.first()) {
|
if (query.first()) {
|
||||||
@ -83,7 +84,7 @@ QString DBManager::getBanReason(QHostAddress ip)
|
|||||||
QString DBManager::getBanReason(QString hdid)
|
QString DBManager::getBanReason(QString hdid)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT REASON FROM BANS WHERE HDID = ?");
|
query.prepare("SELECT REASON FROM BANS WHERE HDID = ? ORDER BY TIME DESC");
|
||||||
query.addBindValue(hdid);
|
query.addBindValue(hdid);
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.first()) {
|
if (query.first()) {
|
||||||
@ -97,7 +98,7 @@ QString DBManager::getBanReason(QString hdid)
|
|||||||
long long DBManager::getBanDuration(QString hdid)
|
long long DBManager::getBanDuration(QString hdid)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT DURATION FROM BANS WHERE HDID = ?");
|
query.prepare("SELECT DURATION FROM BANS WHERE HDID = ? ORDER BY TIME DESC");
|
||||||
query.addBindValue(hdid);
|
query.addBindValue(hdid);
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.first()) {
|
if (query.first()) {
|
||||||
@ -111,7 +112,7 @@ long long DBManager::getBanDuration(QString hdid)
|
|||||||
long long DBManager::getBanDuration(QHostAddress ip)
|
long long DBManager::getBanDuration(QHostAddress ip)
|
||||||
{
|
{
|
||||||
QSqlQuery query;
|
QSqlQuery query;
|
||||||
query.prepare("SELECT DURATION FROM BANS WHERE IP = ?");
|
query.prepare("SELECT DURATION FROM BANS WHERE IP = ? ORDER BY TIME DESC");
|
||||||
query.addBindValue(ip.toString());
|
query.addBindValue(ip.toString());
|
||||||
query.exec();
|
query.exec();
|
||||||
if (query.first()) {
|
if (query.first()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user