CREATE TABLE `banned_ip` (
`id` INT(25) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`ip` VARCHAR(25) NOT NULL ,
`reason` TEXT NOT NULL)
Config.php에php와 mysql을 사용하여 효율적으로 IP를 금지 하시겠습니까?
<?php
// config
$config['host'] = "localhost"; // host name of your mysql server
$config['user'] = "username"; // your mysql username
$config['pass'] = "password"; // your mysql password
$config['db'] = "database"; // the database your table is in.
// the @ sign is an error supressor, meaning we can use our own error messages, this connects and selects db
@mysql_connect("$config[host]","$config[user]","$config[pass]")
or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");
@mysql_select_db("$config[db]")
or die("There was an error connecting to the database, MySql said:<br />".mysql_error()."");
?>
Ban.php
<?php
include("connect.php");
$ip = $_SERVER['REMOTE_ADDR'];
$find_ip = mysql_query("SELECT * FROM banned_ip WHERE ip='$ip'");
$ban = mysql_fetch_array($find_ip);
if($ip == $ban['ip']){
die("You are banned from this site!");
else {
echo "Your Were not Banned";
$sql = "INSERT INTO user(ip) VALUES('$ip')";
}
?>
내가 뭐하는 거지 것은이 금지하거나되지 않으면 IP에 대한 내 데이터베이스를 확인합니다. 금지되지 않은 경우, 그에게 "너의 금지되지 않았다"라는 메시지를 보여주고 그를 금지시킨다.
데이터베이스에 IP 저장. 그리고 그가 현장에 다시 오면, "당신은이 사이트에서 금지되었습니다!"라고 표시됩니다.
이렇게하면 각 IP에 내 콘텐츠에 한 번만 액세스 할 수 있습니다. 이 스크립트가 효과가 있습니까? 이 스크립트는 나를 위해 작동하지 않습니다. 내 IP를 금지하는 것이 아니라 내 콘텐츠를 계속 보여줍니다.
IP로 금지하지 마십시오. 그렇게하면 일반적으로 NAT 또는 아웃 바운드 방화벽 뒤에있는 학교, 회사 또는 홈 네트워크의 모든 사용자가 차단 될 때 차단됩니다. –
반복적 인 악용 또는 금지 회피가 감지 된 경우에만 IP로 금지하지 마십시오. – Tibor
완전히 신뢰할 수있는 방법은 아니지만 user-agent를 IP와 결합하여 조금 좁힐 수 있습니다. 선택한 모든 방법은 사용자 계정을 완전히 금지하지 않는 한 교활한 사용자가 우회 할 수 있습니다. –