Can I stamp my site's logo on every pic that's hotlinked?

Discussion in 'Site & Server Administration' started by Bauli, Dec 27, 2007.

  1. #1
    I have a LOT of hotlinkers, and I dont want to stop them. I just want to stamp my url on every image that's hotlinked.
    Is it possible to do this only on hotlinked images?
     
    Bauli, Dec 27, 2007 IP
  2. Soskel

    Soskel Guest

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes.......
     
    Soskel, Dec 27, 2007 IP
  3. Bauli

    Bauli Peon

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    really? do you know how? Or what software does this?
     
    Bauli, Dec 27, 2007 IP
  4. scriptman

    scriptman Peon

    Messages:
    175
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You could do this using mod_rewrite and PHP.

    Have a rewriterule with the conditions that the file has an image extension, and that the referrer is not blank but does not contain your domain name.

    If a request matches this, then it rewrites the relative directory to your watermarking script, which transforms the image as necessary. I would want to write in a simple caching system to lower your CPU usage if your image were hotlinked in a high traffic area (such as a forum signature or avatar).

    Here's something to get you started on the rewriterule: http://www.clockwatchers.com/htaccess_images.html

    ...And here's some useful info on watermarking images in PHP: http://www.phpit.net/article/image-manipulation-php-gd-part2/3/

    Combine the two, write a simple caching system, and you should have a pretty solid little system going.
     
    scriptman, Dec 30, 2007 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    I get confused when people refer to cache systems. It makes it sound like somthing extra that needs to be done.

    Have two image directories, one that contains raw images and another that contains watermarked images.

    Within the watermarked images folder, catch 404 errors with a script that looks in the raw images folder & attempts to generate & save a watermarked version of the raw image if there's not one already.

    That way all that's being done with most requests is a referer check followed by a rewrite. Then if an image doesn't exist attempt to generate it then serve that, otherwise send a 404 image.

    Not really a cache per-say. But an exception catcher.
     
    joebert, Dec 30, 2007 IP
  6. scriptman

    scriptman Peon

    Messages:
    175
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Joebert, that is essentially what I had in mind but I like your 404 checking idea - it would lower CPU usage in the long run by avoiding having to echo out the image data via PHP on every load. More efficient than the raw data echoing I had in mind.
     
    scriptman, Dec 30, 2007 IP
  7. reshadat

    reshadat Active Member

    Messages:
    194
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Oh great idea! I'll be developing a script soon! thanks for such a great idea!!!!!
     
    reshadat, Dec 31, 2007 IP