81 lines
1.1 KiB
C++
Executable File
81 lines
1.1 KiB
C++
Executable File
/*
|
|
* This file is a part of Winix
|
|
* and is not publicly distributed
|
|
*
|
|
* Copyright (c) 2012-2014, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include "ipban.h"
|
|
#include "functions.h"
|
|
#include "core/sessionmanager.h"
|
|
|
|
|
|
|
|
namespace Winix
|
|
{
|
|
|
|
|
|
namespace Fun
|
|
{
|
|
|
|
IPBanFun::IPBanFun()
|
|
{
|
|
fun.url = L"ipban";
|
|
}
|
|
|
|
|
|
|
|
bool IPBanFun::HasAccess()
|
|
{
|
|
return cur->session->puser && cur->session->puser->super_user;
|
|
}
|
|
|
|
|
|
|
|
void IPBanFun::MakePost()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void IPBanFun::MakeGet()
|
|
{
|
|
if( cur->request->IsParam(L"removeip") )
|
|
{
|
|
if( cur->request->ParamValue(L"removeip") == L"all" )
|
|
{
|
|
session_manager->ClearIPBanList();
|
|
cur->session->ip_ban = 0;
|
|
}
|
|
else
|
|
{
|
|
int cur_ip = 0;
|
|
|
|
if( cur->session->ip_ban )
|
|
cur_ip = cur->session->ip_ban->ip;
|
|
|
|
AssignString(cur->request->ParamValue(L"removeip"), tmp_ip_str);
|
|
int ip = (int)inet_addr(tmp_ip_str.c_str());
|
|
session_manager->RemoveIPBan(ip);
|
|
|
|
if( cur->session->ip_ban && cur_ip == ip )
|
|
cur->session->ip_ban = 0;
|
|
}
|
|
|
|
system->RedirectToLastFunction();
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace Winix
|
|
|