Jei galima perimsiu estafetę iš brukalo. Taigi, kaip ir viskas tvarkoj būtų, naudoju sha1 hash'ą, bet kai ateiną laikas tikrinti prisijungusio čiūvo IP su užbanintais, visa ta magija neįvyksta :(. Forumo lenta tokia kaip šitam forume, apačioj nupeistinau functions.php dalį atsakingą už IP tikrinimą.
// Check whether the connecting user is banned (and delete any expired bans while we're at it)
//
function check_bans()
{
global $db, $pun_config, $lang_common, $pun_user, $pun_bans;
// Admins aren't affected
if ($pun_user['g_id'] == PUN_ADMIN || !$pun_bans)
return;
// Add a dot at the end of the IP address to prevent banned address 192.168.0.5 from matching e.g. 192.168.0.50
$user_ip = sha1(get_remote_address());
$bans_altered = false;
foreach ($pun_bans as $cur_ban)
{
// Has this ban expired?
if ($cur_ban['expire'] != '' && $cur_ban['expire'] <= time())
{
$db->query('DELETE FROM '.$db->prefix.'bans WHERE id='.$cur_ban['id']) or error('Unable to delete expired ban', __FILE__, __LINE__, $db->error());
$bans_altered = true;
continue;
}
if ($cur_ban['username'] != '' && !strcasecmp($pun_user['username'], $cur_ban['username']))
{
$db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
}
if ($cur_ban['ip'] != '')
{
$cur_ban_ips = explode(' ', $cur_ban['ip']);
for ($i = 0; $i < count($cur_ban_ips); ++$i)
{
$cur_ban_ips[$i] = $cur_ban_ips[$i].'.';
if (substr($user_ip, 0, strlen($cur_ban_ips[$i])) == $cur_ban_ips[$i])
{
$db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
}
}
}
}
// If we removed any expired bans during our run-through, we need to regenerate the bans cache
if ($bans_altered)
{
require_once PUN_ROOT.'include/cache.php';
generate_bans_cache();
}
}
Ašai pakeičiau tik vieną eilutę iš $user_ip = get_remote_address(); į $user_ip = sha1(get_remote_address());, bet jaučiu to negana. Lentelėj bans ip adresai taip pat į sha1 hashus transformuoti. Tai gal kas protingesnis mato kame čia reikalas? Dėkui.