here is something i wrote to only allow premium users see the pics on my site.
<?php
include("settings.php");
Header( "Content-type: image/jpeg");
$item_id = eregi_replace("[0-9]","",$item_id);
$type = "_small";
if($action == "show_big") $type = "";
if($premium_user=="yes" && $item_id) {
$image = imagecreatefromjpeg($extra_item_image_root.$item_id.$type.".jpg");
} else {
$image = imagecreate(200,200);
$maroon = ImageColorAllocate($image,100,0,0);
$white = ImageColorAllocate($image,255,255,255);
$green = ImageColorAllocate($image,0,100,0);
$red = ImageColorAllocate($image,100,0,0);
ImageFilledRectangle($image,0,0,200,200,$white);
ImageRectangle($image,10,10,190,190,$maroon);
ImageString($image,15,30,85,'non-premium user',$green);
ImageString($image,15,40,115,'access denied',$red);
}
Imagejpeg($image);
ImageDestroy($image);
?>