Jul 052011
 

When making the badges I always use javascript. This tutorial shows you how to use the GD library to dynamically create simple badges on your site.

Basically, image generation is done in three steps:

  • allocating an image
  • drawing into the allocated space
  • releasing the allocated data in picture format to the browser

[cfields]badgegd[/cfields]

As usual, obtaining client Ip Address simply by calling this php predefined variable, this time we will also trying to support for IPv6. One drawback, i still don’t know how to resize canvas to be fit with text if overflown, dynamically. Ie: the long IPv6 address.

<?php echo $_SERVER["REMOTE_ADDR"]; ?>

Continue reading »

Aug 182010
 

how to prevent image hotlinking with nginx?
this will return 403 error when someone trying to use image directly from oursite.

location ~* (\.jpg|\.png|\.gif|\.jpeg|\.png)$ {
 valid_referers none blocked www.example.com example.com;
 if ($invalid_referer) {
    return 403;
 }
}

or we can change every images which hotlinked with our custom banner.

valid_referers  none blocked  www.example.com  example.com;
if ($invalid_referer) {
    rewrite ^/images/(.*)\.(gif|jpg|jpeg|png)$ http://www.example.com/banner.jpg last
}