Hi. I have made a simple PHP script to check for banned IPs and redirect the banned ones to a certain URL, then redirect the other non banned IPs to a different URL. What I am now trying to do is make the script be able to randomly redirect the non banned ones to one of 5 or so URLs that I have. For example. I have a number of different affiliate offers for a free credit report and I want to send each non banned IPs to a randomly chosen URL so each affiliate offer will get some traffic and hopefully some sales.
PHP Gurus, Please Help with my script.
8
Hi. I have made a simple PHP script to check for banned IPs and redirect the banned ones to a certain URL, then redirect the other non banned IPs to a different URL. What I am now trying to do is make the script be able to randomly redirect the non banned ones to one of 5 or so URLs that I have.
For example. I have a number of different affiliate offers for a free credit report and I want to send each non banned IPs to a randomly chosen URL so each affiliate offer will get some traffic and hopefully some sales.
Below is the code I have already written. If someone could help show me how to make it do the random URL thing, I would appreciate it.
For example. I have a number of different affiliate offers for a free credit report and I want to send each non banned IPs to a randomly chosen URL so each affiliate offer will get some traffic and hopefully some sales.
Below is the code I have already written. If someone could help show me how to make it do the random URL thing, I would appreciate it.
Code:
<?php
$banned_ip = array();
$banned_ip[] = '204.96.148.3';
$banned_ip[] = '205.162.217.141';
foreach($banned_ip as $banned)
{
$ip = $_SERVER['REMOTE_ADDR'];
if($ip == $banned)
{
header("location: hxxp://you-are-banned.com");
die();//abort the script on redirect. just in case.
}
}
//if we got this far, their IP is obviously not banned
//this is where I would like it to have numerous URLs to randomly send each visitor to one of them
header("location: hxxp://freecreditreport1.com");
?> - gcornelisse
- tufats
- [1] reply
- gcornelisse
- Jenniferlinn Banned
- thehypnoguy2
- [1] reply
- Bruce Hearder
- Bruce Hearder
Next Topics on Trending Feed
-
8