Forum Moderators: coopster

Message Too Old, No Replies

display images using PHP in ebay

         

m223

8:27 am on May 17, 2011 (gmt 0)

10+ Year Member



hi,

I currently display images on ebay with a simple image tag, that is hosted on my server,

I want to have it so that a range of IPs see a different image than someone outside of this particular IP range

i have tried...

<?
$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/144.1.1.1/",$visitor)) {

print "<img src=http://example.com/SYDN.jpg width=30 height=15><br>";
} else {
print "<img src=http://example.com/MELB.jpg width=30 height=15><br>";
};
?>

this seems to work in a browser, but when i use
<IMG SRC="http://example.com">
in ebay i just get the little box with a red x in it,

i know this is possible as i have used the following to display visitors flags in other auctions

<A HREF="http://www.hostip.info">
<IMG SRC="http://api.hostip.info/flag.php" BORDER="0" ALT="IP Address Lookup">
</A>

what have i done wrong?

m223

11:44 am on May 17, 2011 (gmt 0)

10+ Year Member



ok i am closer now, i have the pictures showing for 1 IP using:
<?
$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/144.1.1.1/",$visitor)) {
header('Location: http://example.com/SYDN.jpg');
} else {
header('Location: http://example.com/MELB.jpg');
};
?>

but i want this to work for a range of IPs, eg 144.1.1.1 - 143.2.2.3

I am so close!

StoutFiles

12:15 pm on May 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<?
$visitor = $_SERVER['REMOTE_ADDR'];
$first_three = substr($visitor, 0, 3); //ex: 144.1.1.1 becomes 144
if (($first_three >= 143) || ($first_three <= 144)) {
header('Location: http://example.com/SYDN.jpg');
} else {
header('Location: http://example.com/MELB.jpg');
};
?>

m223

8:03 am on May 18, 2011 (gmt 0)

10+ Year Member



Hi,

thanks for that, but it didnt seem to work for me,
what if i want to redirect every thing from
123.2.40.* 0 123.2.80.*