Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    use PHP to display image on ebay?

    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???

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    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):

    http://www.php.net/manual/en/function.imagecreate.php

  • #3
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    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
    •