Codice PHP:
<?php
$domain = "www.dxblade.tk";
$authorized_referers = "dxblade.altervista.org,localhost";
$accept_void_referers = true;
$folder = "imgs/";
$usesessions=true;
$authorized_extensions = "gif,jpeg,jpg,png";
//-------------- code
$auth_refs = explode (",", $authorized_referers);
$auth_exts = explode (",", $authorized_extensions);
$img = $_GET['i'];
$pos = strrpos ($img, ".");
$pos++;
if ($pos === false) {
echo "NOT FOUND!";
exit();
}
$extension = substr ($img, $pos);
$ok_ext=false;
foreach ($auth_exts as $ext) {
if ($ext==$extension) $ok_ext=true;
}
if ($ok_ext==false) {
$im = @imagecreate(160, 50);
$background_color = imagecolorallocate($im, 0, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 2, 5, 5, "Image Not Found", $text_color);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 3, 5, 30, $domain, $text_color);
if (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im, "", 0.5);
} elseif (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagewbmp")) {
header("Content-type: image/vnd.wap.wbmp");
imagewbmp($im);
}
imagedestroy($im);
exit();
}
if (isset ($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
$referer = str_replace ("http://", "", $referer);
$referer = str_replace ("www.", "", $referer);
$ok_ref=false;
foreach ($auth_refs as $ref){
$pos = strpos ($referer, $ref);
if ($pos===0) $ok_ref = true;
}
if ($ok_ref == false) {
$im = @imagecreate(160, 50);
$background_color = imagecolorallocate($im, 0, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 2, 5, 5, "This image is property of", $text_color);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 3, 5, 30, $domain, $text_color);
if (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im, "", 0.5);
} elseif (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagewbmp")) {
header("Content-type: image/vnd.wap.wbmp");
imagewbmp($im);
}
imagedestroy($im);
exit();
}
} elseif ($accept_void_referers == false) {
$im = @imagecreate(160, 50);
$background_color = imagecolorallocate($im, 0, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 2, 5, 5, "This image is property of", $text_color);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 3, 5, 30, $domain, $text_color);
if (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im, "", 0.5);
} elseif (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagewbmp")) {
header("Content-type: image/vnd.wap.wbmp");
imagewbmp($im);
}
imagedestroy($im);
exit();
}
//if ($usesessions) {
//session_start();
// if (session_id()!="") {
// echo "session is ok";
// } else {
// echo "no session";
// }
//}
$img = $folder . $img;
$size = @getimagesize ($img);
$fp = @fopen ($img, "rb");
if ($size && $fp) {
header ("Content-type: " . $size['mime']);
fpassthru($fp);
exit();
} else {
$im = @imagecreate(160, 50);
$background_color = imagecolorallocate($im, 0, 255, 255);
$text_color = imagecolorallocate($im, 0, 0, 255);
imagestring($im, 2, 5, 5, "Image not found", $text_color);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 3, 5, 30, $domain, $text_color);
if (function_exists("imagegif")) {
header("Content-type: image/gif");
imagegif($im);
} elseif (function_exists("imagejpeg")) {
header("Content-type: image/jpeg");
imagejpeg($im, "", 0.5);
} elseif (function_exists("imagepng")) {
header("Content-type: image/png");
imagepng($im);
} elseif (function_exists("imagewbmp")) {
header("Content-type: image/vnd.wap.wbmp");
imagewbmp($im);
}
imagedestroy($im);
exit();
}