1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

dont show image to certain ip address

Discussion in 'BlackHat Lounge' started by nonai, Jan 7, 2015.

  1. nonai

    nonai Power Member

    Joined:
    Oct 10, 2013
    Messages:
    524
    Likes Received:
    64
    I have a picture on my website which is a clickable link.

    when someone from a certain ip address visits my website (let's say their ip address is 106.44.48.81)
    I dont want this picture to show up for them.

    how can i do this?
     
  2. VoidITSolutions

    VoidITSolutions BANNED BANNED

    Joined:
    Apr 5, 2013
    Messages:
    164
    Likes Received:
    44
    You pretty much need PHP or another scripting language.
    There are options in Javascript to obtain IP information via Java but not all browsers support it.

    In PHP:
    Code:
    <?php
        $bad_ips = array("106.44.48.81", "ipaddress2", "etc");
        $match = false;
    
        foreach ($bad_ips as $bad_ip) {
            if ($_SERVER["REMOTE_ADDR"] === $bad_ip) {
                $match = true;
            }
        }
    
        if ($match == false) {
    ?>
            <img src="http://www.blah.com/image.png" />
    <?php
        }
    ?>
    
     
    • Thanks Thanks x 2
    Last edited: Jan 8, 2015
  3. The Scarlet Pimp

    The Scarlet Pimp Senior Member

    Joined:
    Apr 2, 2008
    Messages:
    884
    Likes Received:
    3,324
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    this will also do it, but with less coding. :D
    (keep in mind that ip numbers often change!)

    Code:
    <?php 
    $ip = $_SERVER['REMOTE_ADDR'];
    if ($ip != '106.44.48.81') {
    echo '<img src=picture.jpg>';
    }
    ?>
    
     
  4. VoidITSolutions

    VoidITSolutions BANNED BANNED

    Joined:
    Apr 5, 2013
    Messages:
    164
    Likes Received:
    44
    Exactly, keep in mind IP numbers often change. Or people may want to block more than one.
    I'm not sure quite what you added to this thread other than a smart-ass comment.

    Especially since it would be COPY AND PASTE. I just don't get the point and ya, it aggravates me.

    I thought of the dumbed-down version you had and thought to myself "Hey, maybe some other people could use this" so I figured take my time to put in code that anyone can use/adjust so what exactly is your aim here?

    Here's a better one if for some reason less lines makes us special even though the OP would just copy/paste and modify the IP information -
    Code:
    <?php if ($_SERVER['REMOTE_ADDR'] !== "106.44.48.81") {echo "<I'm an ass>";} ?>
    

     
    Last edited: Jan 8, 2015
  5. VoidITSolutions

    VoidITSolutions BANNED BANNED

    Joined:
    Apr 5, 2013
    Messages:
    164
    Likes Received:
    44
    OP, if you need any assistance beyond my initial reply, I'm happy to help.
    I can set you up with some code to match whatever IP Addresses you'd like or even IP ranges.
    I don't want anything in exchange, just offering a hand.

    If so PM me.