<?php
require ('authentication_manager.php');
?>
<?php

/* 屏蔽IP */
/* 162100源码 - 162100.com */


if (POWER < 4) {
  err('该命令必须以管理员身份登陆！请重登陆。');
}


$_REQUEST['ips'] = trim($_REQUEST['ips'])."\n";
$_REQUEST['ips'] = preg_replace("/[\r\n]+/", "\n", $_REQUEST['ips']);
if (!preg_match("/^(\d+\.\d+\.\d+\.(\d+|\*)\n)+$/m", $_REQUEST['ips'])) {
  err('请填有效的IP数据！格式为：*.*.*.*。只能数字、.、换行符、* 填写。用回车键分开IP，即一行填一个IP。');
}

$_REQUEST['ips'] = trim($_REQUEST['ips']);
$arr = @explode("\n", $_REQUEST['ips']);
$arr = array_unique($arr);
$arr = array_filter($arr);

if (!isset($sql['db_err'])) {
  db_conn();
}
if ($sql['db_err'] != '') {
  err($sql['db_err']);
}

foreach ($arr as $v) {
  if(preg_match('/^\d+\.\d+\.\d+\.(\d+|\*)$/', $v)) {
    mysql_query('REPLACE INTO `'.$sql['pref'].''.$sql['data']['承载上传数据的表名'].'` (`title`,`text`,`type`,`date`) VALUES ("'.$v.'","","ip",DATE_ADD(UTC_TIMESTAMP(), INTERVAL '.floatval($web['time_pos']).' HOUR))', $db);
  }
}

if ($_REQUEST['m'] == 1) {
  err('<script> alert("屏蔽成功！"); </script>。');
}
alert('IP屏蔽成功', 'webmaster_central.php?get=ip');


?>