Text rotator based on IP

itmark

Regular Member
Joined
Aug 4, 2008
Messages
320
Reaction score
71
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.:)
 
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!
 
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.)
 
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 Man Just what I needed.:)
 
Back
Top