Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Thanked 0 Times in 0 Posts

    use PHP to display image on ebay?


    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("/",$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">

    what have i done wrong???

  2. #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    In order for a PHP script to "pose" as an image, you have to echo first an image header, and then crank out an image. And by cranking out an image, I mean an actual image, not an <img> tag.

    For an example of what I'm talking about, see this page in the PHP manual (Example #1):


  3. #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Philadelphia, PA, USA
    Thanked 258 Times in 254 Posts
    If you don't need anything user-specific written to an image on the fly and only need to display various static images, you could use readfile():

    PHP Code:
    $img './images/image.png';

    header'Content-type: image/png' );
    header'Content-length: ' filesize$img ) );
    header'Content-Disposition: attachment; filename="' basename$img ) . '"' );

    readfile$img ); 
    You could then define the source file for $img using the visitor's IP address.
    Last edited by kbluhm; 05-18-2011 at 02:33 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts