Code: Select all
<?php
// secret image directory
$sDir = "images/blabla/";
// clean the $img variable up
$img = stripslashes(ltrim(rtrim($img)));
// create absolute path to image
$fDir = $sDir.$img;
// These are the allowable content types
$allowExt = array("gif","jpg","png");
// sites to allow
$allowSite = array("carbon3.net","www.carbon3.net");
if(file_exists($fDir)) {
if(!in_array($HTTP_REFERER,$allowSite)) {
echo "Site not allowed";
die();
// check if the content is allowable according to the array();
if(!in_array(substr($img,-3),$allowExt)) {
echo "Invalid image name/extension";
die();
}
else {
$fType = substr($img,-3);
// change the jpg ext. to jpeg
if($fType == "jpg") $fType = "jpeg";
// define the content type
Header("Content-type: image/$fType");
$fp = @fopen($fDir,"rb");
// display the output
fpassthru($fp);
fclose($fp);
}
}
}
else {
echo "File does not exist";
die();
}I know it finds the image..but still throwa out that error.
The array has the correct site in etc, and everything else seams to corospond..so anyhelp on fixing this would be GRAND!