Post: Blocking ips off of your site. via array + blocks proxies
05-10-2011, 01:18 AM #1
(adsbygoogle = window.adsbygoogle || []).push({});
Originally posted by 039

Okay, I'm going to show you how to block ips. The ips will be pulled from an array. An example of this array is
$block_ip = array("ip","ip","ip");
$ip_proxy=$_SERVER ["HTTP_X_FORWARDED_FOR"];

now use the if statement to actually block it
if (in_array ($_SERVER['REMOTE_ADDR'], $block_ip)) {
echo "You have been blocked from viewing any material on this website.";
exit();

now end the statement and add php tags

<?php
$ip_proxy=$_SERVER ["HTTP_X_FORWARDED_FOR"];
$block_ip = array("IP", "IP", "IP");
if (in_array ($_SERVER['REMOTE_ADDR'], $block_ip)) {
echo "You have been blocked from viewing any material on this website.";
exit();
}
?>

now we need to include the file. to do this, add this:
<?php
include("FILENAME.php"); ?

add this to the beginning of your code on whatever site you're doing

finished product:

<?php
$ip_proxy=$_SERVER ["HTTP_X_FORWARDED_FOR"];
$block_ip = array("IP", "IP", "IP");
if (in_array ($_SERVER['REMOTE_ADDR'], $block_ip)) {
echo "You have been blocked from viewing any material on this website.";
exit();
}
?>

If you've used this right, it can be very beneficial!
Now that pesky moron can't view your site anymore. Hope this helped =)


source You must login or register to view this content.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo