<?

function ban_ip ($ip, $time, $msg)
{
global $mysql;
$msg = iconv('utf-8', 'windows-1251', $msg);
$msg=substr($msg, 0, 512);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg=stripslashes(htmlspecialchars($msg));
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);
if (isset($_POST['tr'])){$msg=translit($msg);}
$msg=eregi_replace("((https?|ftp)://[[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&amp;._=/~%#]*(\\?[[:alnum:]?+&amp;_=/%#]*)?)?)", "<a href='\\1'>\\1</a>", $msg);
$timeban=time()+$time;
mysql_query("INSERT INTO `$mysql[pref]ban` (time, ip, prich) values('$timeban', '$ip', '$msg');");
}


function ban_user ($id, $time, $msg, $st)
{
global $post_user,$mysql;
if ($st==1){$post_user['ban_k']++;}
$msg = iconv('utf-8', 'windows-1251', $msg);
$msg=substr($msg, 0, 512);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg=stripslashes(htmlspecialchars($msg));
$msg=str_replace("\r\n","<br />",$msg);
$msg=str_replace("\r","<br />",$msg);
$msg=str_replace("\n","<br />",$msg);
if (isset($_POST['tr'])){$msg=translit($msg);}
$msg=eregi_replace("((https?|ftp)://[[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&amp;._=/~%#]*(\\?[[:alnum:]?+&amp;_=/%#]*)?)?)", "<a href='\\1'>\\1</a>", $msg);
$timeban=time()+$time;
mysql_query("UPDATE `$mysql[pref]users` SET `ban_st` = '$st', `ban_t` = '$timeban', `ban_k` = '$post_user[ban_k]', `ban_pr` = '$msg' WHERE `id` = '$id';");
}

?>
