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

Text rotator based on IP

Discussion in 'Cloaking and Content Generators' started by itmark, Jan 8, 2009.

  1. itmark

    itmark Junior Member

    Joined:
    Aug 4, 2008
    Messages:
    102
    Likes Received:
    19
    I am looking for a simple php script that can rotate text based on IP(Computer IP).

    I got a site and if you look at the site it should rotate between 2 different texts. But if a blocked IP user look at the page will see a specific piece of text.

    Just like cloaking but a simple one I can copy into a wordpress blog and it should only change a piece of the site not the hole site.

    Something like this but the option to say that if these ips enter the site show ex. nr1 text.


    <?
    $text[]="1";
    $text[]="2";
    $text[]="3";
    $text[]="4";
    $text[]="5";


    // Print the random text
    echo $text[rand(0,count($text)-1)];


    ?>

    So a IP cloaking script with text rotator.:)
     
  2. zone69

    zone69 Junior Member

    Joined:
    Nov 24, 2008
    Messages:
    196
    Likes Received:
    1,290
    You can grap the source IP and display the text in a switch/case statement like below.

    Code:
    switch ($_SERVER['HTTP_REFERER']){
    	case "24.24.24.24":
    		echo "whatever for 24.24.24.24"; 
                    break;
            case "1.1.1.1":
                   echo "whatever for 1.1.1.1";
                   break;
    	default:
                    echo "whatever -  if IP not in above cases";
                    break;
    }
    
    Hope that helps!
     
    • Thanks Thanks x 2
  3. drkenneth

    drkenneth Executive VIP

    Joined:
    Nov 13, 2008
    Messages:
    285
    Likes Received:
    176
    Occupation:
    Developer/Entrepreneur
    Location:
    USA
    If you wanted to get fancy you could use a SQL backend that logs all visitors and thus is able to rotate the ad each individual IP sees thus maximizing your coverage for the ads. This is also good if you have a large blocked IP list for easy scalability. (So you're not always editing PHP / having a LONG php script. A simple SQL select statement is much faster than a 100 condition php case statement.)
     
  4. itmark

    itmark Junior Member

    Joined:
    Aug 4, 2008
    Messages:
    102
    Likes Received:
    19
    Thanks Man Just what I needed.:)