different content for ip ranges

Discussion in 'PHP' started by kewlchat, Jan 10, 2008.

  1. #1
    Ok im trying to block traffic from certian ip ranges.. and anyway i still want the users to be able to see my bidvertiser ads and some content.. but not all content.. so i made this..

    <?php
    function checkIP($ip_to_match, $ip_array) {


    if (is_array($ip_array)) {


    foreach ($ip_array as $ip) {


    if (strstr($ip_to_match, $ip) && strpos($ip_to_match, $ip)==0) {
    return true;
    }
    }
    }

    return false;
    }

    $ban_array = array(
    '216.47.55.141',
    '72.47.147',
    '62',
    '62',
    '24',
    '84',
    '81',
    '82',
    '83',
    '86',
    '12',
    '125',
    '149',
    '89'

    );

    if (checkIP($_SERVER['REMOTE_ADDR'], $ban_array)) {
    echo "This page is not accessable for users in your area. .";
    exit;
    }
    ?>

    see where it says echo "This page is not accessable for users in your area. .";

    I want to place some bidvertiser code there but with out editing the code :)
     
    kewlchat, Jan 10, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    "with out editing the code". That's impossible ....?!
     
    jayshah, Jan 14, 2008 IP
  3. py2kjr

    py2kjr Peon

    Messages:
    91
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if (checkIP($_SERVER['REMOTE_ADDR'], $ban_array)) {
    echo "This page is not accessable for users in your area. .";
    ?>
    STANDARD CODE CAN GO HERE AS YOU CAN CLOSE PHP IN THE MIDDLE OF
    LOOPS OR CONDITIONAL TESTS AND RESUME LATER
    <?php

    exit;
    }
    ?>
     
    py2kjr, Jan 14, 2008 IP