Calling PHP through an image?

Discussion in 'PHP' started by arbos, May 8, 2006.

  1. #1
    I've seen this more and more lately. Whether it be PNG, or JPEGS people are calling what looks like to be a PHP file or some other type of script through an image.

    For example something like this
    <a href="http://www.example.com/" target="_blank">
    <embed src="http://www.example.com/x/sample.jpg" border="0" height="0" width="0">
    </a> 
    PHP:
    How does something like this work?
     
    arbos, May 8, 2006 IP
  2. frisby

    frisby Well-Known Member

    Messages:
    1,378
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Here you don't call any php code... :rolleyes:
     
    frisby, May 8, 2006 IP
  3. madkad

    madkad Active Member

    Messages:
    1,686
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    90
    #3
    do you mean them images that show info on but are images?

    like the ones that say your ip etc etc
     
    madkad, May 8, 2006 IP
  4. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #4
    Here you are :

    
         header("Accept-Ranges: bytes");
         header("Cache-Control:");
         header("Pragma:");
         header("Content-Length: $len");
         header("Connection: close");
         header("Content-Type: image/png");
         header("Content-Disposition: inline; Filename=image.png");
         readfile($IMAGE);
    
    PHP:
     
    Nikolas, May 8, 2006 IP
  5. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #5
    Does the image have to be png?
     
    piniyini, May 8, 2006 IP
  6. Nikolas

    Nikolas Well-Known Member

    Messages:
    1,022
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    150
    #6
    You can use whatever you like.

    Just change the headers and the filename (actually the filename is not neccesery but it may be needed by some browsers)
     
    Nikolas, May 8, 2006 IP
  7. arbos

    arbos Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks this is what I figured.

    For the people that didn't clearly get what I asked I'll try and explain it again...sorry for the mess up there.

    Basically fooling the page into thinking you are calling an image file when it really is running a PHP script. It's something I see being done on alot of trackers...and just wondered how it was done.
     
    arbos, May 8, 2006 IP