Miracle
23-03-2007, 17:09
* Dành cho web chạy php
Vì một lý do nào đó, chúng ta không muốn người ta dùng Proxy để truy cập vào cái web của bạn, nhất là các site ecommerce. Vậy phải làm sao để ngăn nó. Tôi có cách như sau.
bạn save cái đoạn code bên dưới thành file checkproxy.php
<?php
$addr = $_SERVER['REMOTE_ADDR'];
$raddr = explode('.', $addr);
$raddr = $raddr[3].'.'.$raddr[2].'.'.$raddr[1].'.'.$raddr[0];
$ip['opm'] = gethostbyname($raddr.'.opm.blitzed.org');
$ip['njabl'] = gethostbyname($raddr.'.dnsbl.njabl.org');
$ip['akill'] = gethostbyname($raddr.'.dnsbl.winbots.org');
$ip['virbl'] = gethostbyname($raddr.'.virbl.dnsbl.bit.nl');
$ip['ircahbl'] = gethostbyname($raddr.'.ircbl.ahbl.org');
$ip['sectoor'] = gethostbyname($raddr.'.tor.dnsbl.sectoor.de');
$ip['torahbl'] = gethostbyname($raddr.'.tor.ahbl.org');
$ip['no-more-funn'] = gethostbyname($raddr.'.no-more-funn.moensted.dk');
$ip['sorbs'] = gethostbyname($raddr.'.dnsbl.sorbs.net');
if ($ip['opm'] == $raddr.'.opm.blitzed.org') { $ip['opm'] = "...n"; }
if ($ip['njabl'] == $raddr.'.dnsbl.njabl.org') { $ip['njabl'] = "...n"; }
if ($ip['akill'] == $raddr.'.dnsbl.winbots.org') { $ip['akill'] = "...n"; }
if ($ip['virbl'] == $raddr.'.virbl.dnsbl.bit.nl') { $ip['virbl'] = "...n"; }
if ($ip['ircahbl'] == $raddr.'.ircbl.ahbl.org') { $ip['ircahbl'] = "...n"; }
if ($ip['sectoor'] == $raddr.'.tor.dnsbl.sectoor.de') { $ip['sectoor'] = "...n"; }
if ($ip['torahbl'] == $raddr.'.tor.ahbl.org') { $ip['torahbl'] = "...n"; }
if ($ip['no-more-funn'] == $raddr.'.no-more-funn.moensted.dk') { $ip['no-more-funn'] = "...n"; }
if ($ip['sorbs'] == $raddr.'.dnsbl.sorbs.net') { $ip['sorbs'] = "...n"; }
$ip['opm'] = explode('.', $ip['opm']);
$ip['njabl'] = explode('.', $ip['njabl']);
$ip['akill'] = explode('.', $ip['akill']);
$ip['virbl'] = explode('.', $ip['virbl']);
$ip['ircahbl'] = explode('.', $ip['ircahbl']);
$ip['sectoor'] = explode('.', $ip['sectoor']);
$ip['torahbl'] = explode('.', $ip['torahbl']);
$ip['no-more-funn'] = explode('.', $ip['no-more-funn']);
$ip['sorbs'] = explode('.', $ip['sorbs']);
$ip['opm'] = $ip['opm'][3];
$ip['njabl'] = $ip['njabl'][3];
$ip['akill'] = $ip['akill'][3];
$ip['virbl'] = $ip['virbl'][3];
if ($ip['ircahbl'] == 'n') { $ip['ircahbl'] = "You Aren't Listed."; }
if ($ip['sectoor'] == 'n') { $ip['sectoor'] = "You Aren't Listed."; }
if ($ip['torahbl'] == 'n') { $ip['torahbl'] = "You Aren't Listed."; }
if ($ip['no-more-funn'] == 'n') { $ip['no-more-funn'] = "You Aren't Listed."; }
if ($ip['sorbs'] == 'n') { $ip['sorbs'] = "You Aren't Listed."; }
if (($ip['njabl'] != '9') and ($ip['njabl'] != "You Aren't Listed.")) { $ip['njabl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['akill'] != '1') and ($ip['akill'] != "You Aren't Listed.")) { $ip['akill'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sectoor'] != '1') and ($ip['sectoor'] != "You Aren't Listed.")) { $ip['sectoor'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['torahbl'] != '2') and ($ip['torahbl'] != "You Aren't Listed.")) { $ip['torahbl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['no-more-funn'] != '10') and ($ip['no-more-funn'] != "You Aren't Listed.")) { $ip['no-more-funn'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sorbs'] != '2') and ($ip['sorbs'] != '3') and ($ip['sorbs'] != '4') and ($ip['sorbs'] != "You Aren't Listed.")) { $ip['sorbs'] = "Invalid Reply (You Aren't Listed)"; }
if (is_numeric($ip['opm'])) { $listed = 1; }
if (is_numeric($ip['njabl'])) { $listed = 1; }
if (is_numeric($ip['akill'])) { $listed = 1; }
if (is_numeric($ip['virbl'])) { $listed = 1; }
if (is_numeric($ip['ircahbl'])) { $listed = 1; }
if (is_numeric($ip['sectoor'])) { $listed = 1; }
if (is_numeric($ip['torahbl'])) { $listed = 1; }
if (is_numeric($ip['no-more-funn'])) { $listed = 1; }
if (is_numeric($ip['sorbs'])) { $listed = 1; }
if ($listed == 1) { die("Your ip, ".$addr.", is listed in one or more of the proxy/abusive lists we check."); }
?>
Sau đó bạn dán đoạn code như sau vào ngay đầu file php của bạn muốn check:
include("/path/to/your/checkproxy.php");
Vì một lý do nào đó, chúng ta không muốn người ta dùng Proxy để truy cập vào cái web của bạn, nhất là các site ecommerce. Vậy phải làm sao để ngăn nó. Tôi có cách như sau.
bạn save cái đoạn code bên dưới thành file checkproxy.php
<?php
$addr = $_SERVER['REMOTE_ADDR'];
$raddr = explode('.', $addr);
$raddr = $raddr[3].'.'.$raddr[2].'.'.$raddr[1].'.'.$raddr[0];
$ip['opm'] = gethostbyname($raddr.'.opm.blitzed.org');
$ip['njabl'] = gethostbyname($raddr.'.dnsbl.njabl.org');
$ip['akill'] = gethostbyname($raddr.'.dnsbl.winbots.org');
$ip['virbl'] = gethostbyname($raddr.'.virbl.dnsbl.bit.nl');
$ip['ircahbl'] = gethostbyname($raddr.'.ircbl.ahbl.org');
$ip['sectoor'] = gethostbyname($raddr.'.tor.dnsbl.sectoor.de');
$ip['torahbl'] = gethostbyname($raddr.'.tor.ahbl.org');
$ip['no-more-funn'] = gethostbyname($raddr.'.no-more-funn.moensted.dk');
$ip['sorbs'] = gethostbyname($raddr.'.dnsbl.sorbs.net');
if ($ip['opm'] == $raddr.'.opm.blitzed.org') { $ip['opm'] = "...n"; }
if ($ip['njabl'] == $raddr.'.dnsbl.njabl.org') { $ip['njabl'] = "...n"; }
if ($ip['akill'] == $raddr.'.dnsbl.winbots.org') { $ip['akill'] = "...n"; }
if ($ip['virbl'] == $raddr.'.virbl.dnsbl.bit.nl') { $ip['virbl'] = "...n"; }
if ($ip['ircahbl'] == $raddr.'.ircbl.ahbl.org') { $ip['ircahbl'] = "...n"; }
if ($ip['sectoor'] == $raddr.'.tor.dnsbl.sectoor.de') { $ip['sectoor'] = "...n"; }
if ($ip['torahbl'] == $raddr.'.tor.ahbl.org') { $ip['torahbl'] = "...n"; }
if ($ip['no-more-funn'] == $raddr.'.no-more-funn.moensted.dk') { $ip['no-more-funn'] = "...n"; }
if ($ip['sorbs'] == $raddr.'.dnsbl.sorbs.net') { $ip['sorbs'] = "...n"; }
$ip['opm'] = explode('.', $ip['opm']);
$ip['njabl'] = explode('.', $ip['njabl']);
$ip['akill'] = explode('.', $ip['akill']);
$ip['virbl'] = explode('.', $ip['virbl']);
$ip['ircahbl'] = explode('.', $ip['ircahbl']);
$ip['sectoor'] = explode('.', $ip['sectoor']);
$ip['torahbl'] = explode('.', $ip['torahbl']);
$ip['no-more-funn'] = explode('.', $ip['no-more-funn']);
$ip['sorbs'] = explode('.', $ip['sorbs']);
$ip['opm'] = $ip['opm'][3];
$ip['njabl'] = $ip['njabl'][3];
$ip['akill'] = $ip['akill'][3];
$ip['virbl'] = $ip['virbl'][3];
if ($ip['ircahbl'] == 'n') { $ip['ircahbl'] = "You Aren't Listed."; }
if ($ip['sectoor'] == 'n') { $ip['sectoor'] = "You Aren't Listed."; }
if ($ip['torahbl'] == 'n') { $ip['torahbl'] = "You Aren't Listed."; }
if ($ip['no-more-funn'] == 'n') { $ip['no-more-funn'] = "You Aren't Listed."; }
if ($ip['sorbs'] == 'n') { $ip['sorbs'] = "You Aren't Listed."; }
if (($ip['njabl'] != '9') and ($ip['njabl'] != "You Aren't Listed.")) { $ip['njabl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['akill'] != '1') and ($ip['akill'] != "You Aren't Listed.")) { $ip['akill'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sectoor'] != '1') and ($ip['sectoor'] != "You Aren't Listed.")) { $ip['sectoor'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['torahbl'] != '2') and ($ip['torahbl'] != "You Aren't Listed.")) { $ip['torahbl'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['no-more-funn'] != '10') and ($ip['no-more-funn'] != "You Aren't Listed.")) { $ip['no-more-funn'] = "Invalid Reply (You Aren't Listed)"; }
if (($ip['sorbs'] != '2') and ($ip['sorbs'] != '3') and ($ip['sorbs'] != '4') and ($ip['sorbs'] != "You Aren't Listed.")) { $ip['sorbs'] = "Invalid Reply (You Aren't Listed)"; }
if (is_numeric($ip['opm'])) { $listed = 1; }
if (is_numeric($ip['njabl'])) { $listed = 1; }
if (is_numeric($ip['akill'])) { $listed = 1; }
if (is_numeric($ip['virbl'])) { $listed = 1; }
if (is_numeric($ip['ircahbl'])) { $listed = 1; }
if (is_numeric($ip['sectoor'])) { $listed = 1; }
if (is_numeric($ip['torahbl'])) { $listed = 1; }
if (is_numeric($ip['no-more-funn'])) { $listed = 1; }
if (is_numeric($ip['sorbs'])) { $listed = 1; }
if ($listed == 1) { die("Your ip, ".$addr.", is listed in one or more of the proxy/abusive lists we check."); }
?>
Sau đó bạn dán đoạn code như sau vào ngay đầu file php của bạn muốn check:
include("/path/to/your/checkproxy.php");