added: locales to fun_ipban.html

changed: cosmetic changes in IPBanContainer




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@904 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2012-10-27 10:14:07 +00:00
parent 9ef3736989
commit 8033ac66c4
9 changed files with 74 additions and 32 deletions

View File

@ -366,6 +366,7 @@ void App::ProcessRequest()
// simple operations which should not throw an exception
templates.RequestEnd();
cur.request->Clear();
cur.session->ClearOnEndRequest();
cur.session = session_manager.GetTmpSession();
log << logendrequest;
}

View File

@ -88,8 +88,6 @@ void IPBanContainer::Clear()
// to be less or equal to soft_max_size
void IPBanContainer::RemoveOldRecords()
{
PrintTab();
size_t to_remove = 0;
if( ipban_tab.size() >= soft_max_size )
@ -97,35 +95,22 @@ void IPBanContainer::RemoveOldRecords()
if( to_remove > 0 )
{
log << log4 << "we are going to remove: " << to_remove << " records" << logend;
sort_helper_tab.resize(ipban_tab.size());
for(size_t i=0 ; i<ipban_tab.size() ; ++i)
sort_helper_tab[i] = i;
std::sort(sort_helper_tab.begin(), sort_helper_tab.end(), SortByLastUsedHelper(this));
PrintTab2();
sort_helper_tab.resize(to_remove);
std::sort(sort_helper_tab.begin(), sort_helper_tab.end());
PrintTab2();
while( to_remove-- > 0 )
{
log << log4 << "removing record index: " << sort_helper_tab[to_remove] << ", last_used: ";
PT::Date date(ipban_tab[sort_helper_tab[to_remove]].last_used);
log << date << logend;
ipban_tab.erase(ipban_tab.begin() + sort_helper_tab[to_remove]);
}
log << log4 << "after removing we have: " << logend;
PrintTab();
}
}
// for debug purposes
void IPBanContainer::PrintTab()
{
log << log4 << "ipban_tab (size: " << ipban_tab.size() << ")" << logend;
@ -142,6 +127,8 @@ void IPBanContainer::PrintTab()
}
}
// for debug purposes
void IPBanContainer::PrintTab2()
{
log << log4 << "sort_helper_tab (size: " << sort_helper_tab.size() << ")" << logend;

View File

@ -85,3 +85,10 @@ void Session::Clear(bool clear_plugin_data)
}
// clearing some variables when a request is ended (just for safety)
void Session::ClearOnEndRequest()
{
// ip_ban list can be sorted by SessionManager (in the special thread)
ip_ban = 0;
}

View File

@ -32,6 +32,7 @@ struct Session
void SetTimesTo(time_t time);
void Clear(bool clear_plugin_data = true);
void ClearOnEndRequest();
// 0 - means that there is a temporary session

View File

@ -544,7 +544,7 @@ ipban.o: ../notify/templatesnotify.h ../core/users.h ../core/ugcontainer.h
ipban.o: ../core/lastcontainer.h ../core/mounts.h ../core/mountparser.h
ipban.o: ../core/crypt.h ../core/users.h ../core/groups.h ../core/group.h
ipban.o: ../core/loadavg.h ../core/image.h ../core/threadmanager.h
ipban.o: ../core/timezones.h ../core/synchro.h
ipban.o: ../core/timezones.h ../core/synchro.h ../core/sessionmanager.h
last.o: last.h functionbase.h ../core/item.h ../../pikotools/space/space.h
last.o: ../../pikotools/textstream/types.h ../../pikotools/date/date.h
last.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h

View File

@ -48,12 +48,21 @@ void IPBanFun::MakeGet()
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();

View File

@ -1,21 +1,21 @@
<div class="winix">
<h1>IP Banned</h1>
<h1>{ipban_header}</h1>
[if ipban_tab]
<table>
<tr>
<th>Id</th>
<th>IP address</th>
<th>login failures</th>
<th>Login allowed</th>
<th>Ban level</th>
<th>Active flag</th>
<th>Last used</th>
<th>Expires</th>
<th>Remove</th>
<th>{ipban_col_id}</th>
<th>{ipban_col_ip_address}</th>
<th>{ipban_col_login_failures}</th>
<th>{ipban_col_login_allowed}</th>
<th>{ipban_col_ban_level}</th>
<th>{ipban_col_active_flag}</th>
<th>{ipban_col_last_used}</th>
<th>{ipban_col_expires}</th>
<th>{ipban_col_remove}</th>
</tr>
[for ipban_tab]
@ -24,23 +24,23 @@
<td>[ipban_tab_id]</td>
<td>[ipban_tab_ip]</td>
<td>[ipban_tab_incorrect_login]</td>
<td>[if ipban_tab_is_logging_allowed]yes[else]no[end]</td>
<td>[if ipban_tab_is_logging_allowed]{ipban_loggin_allowed}[else]{ipban_loggin_not_allowed}[end]</td>
<td>[ipban_tab_ban_level]</td>
<td>[if ipban_tab_has_active_flag]yes[end]</td>
<td>[if ipban_tab_has_active_flag]{ipban_has_active_flag}[end]</td>
<td>[ipban_tab_last_used]</td>
<td>[ipban_tab_expires]</td>
<td><a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:[ipban_tab_ip]">remove</a></td>
<td><a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:[ipban_tab_ip]">{ipban_remove_ip}</a></td>
</tr>
[end]
</table>
<p>
<a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:all">Remove all IP's from the list</a>
<a href="[doc_base_url][dir][if item_is][item_url]/[end]ipban/removeip:all">{ipban_remove_all_ip}</a>
</p>
[else]
<p>There are not any IP addresses banned at the moment.</p>
<p>{ipban_ban_list_empty}</p>
[end]
</div>

View File

@ -152,6 +152,25 @@ ls_header = Directory listing
ls_pictures_in_dir = Pictures in directory
ls_no_picture = There are not any pictures in this directory
ipban_header = IP Banned
ipban_col_id = Id
ipban_col_ip_address = IP address
ipban_col_login_failures = login failures
ipban_col_login_allowed = Login allowed
ipban_col_ban_level = Ban level
ipban_col_active_flag = Active flag
ipban_col_last_used = Last used
ipban_col_expires = Expires
ipban_col_remove = Remove
ipban_loggin_allowed = yes
ipban_loggin_not_allowed = no
ipban_has_active_flag = yes
ipban_remove_ip = remove
ipban_remove_all_ip = Remove all IP's from the list
ipban_ban_list_empty = There are not any IP addresses banned at the moment.
man_header = Man
man_winix_funcions = Winix functions
man_ezc_functions = EZC templates functions

View File

@ -156,6 +156,24 @@ ls_pictures_in_dir = Obrazy w katalogu
ls_no_picture = W tym katalogu nie ma żadnego obrazu
ipban_header = Lista zbanowanych adresów IP
ipban_col_id = L.p.
ipban_col_ip_address = adres IP
ipban_col_login_failures = nieprawidłowe logowania
ipban_col_login_allowed = możliwe logowanie
ipban_col_ban_level = Rodzaj banu
ipban_col_active_flag = Flaga active
ipban_col_last_used = Ostatnio używany
ipban_col_expires = Wygasza
ipban_col_remove = Usuń
ipban_loggin_allowed = tak
ipban_loggin_not_allowed = nie
ipban_has_active_flag = tak
ipban_remove_ip = usuń
ipban_remove_all_ip = Usuń wszystkie adresy IP z listy
ipban_ban_list_empty = W tej chwili nie ma żadnych zbanowanych adresów IP.
meta_header = Meta
form_meta_legend = Formularz zmiany meta informacji