If you have a message board which allows people to post inline images with the IMG tag, you can use this function to run a few checks on the remote image. Simply pass it the URI to the image, and it checks the file exits; that it is a recognised image format; and that it is smaller than a predeterminted size. This stops mischief-makers linkng your page to a 4TB file.
Download
View Source (print view)
Rating : 4.7
Views : 322
function validate_image($l, $maxsize = 20000) {
// Check for the existance and hopefully the size and type of that
// image. We'll return an HTML string if successful, and an integer if
// not. Returns true if the image is okay, false if not
$ret = true;
if (!$ih = @fopen($l, "r"))
$ret = false;
// Looks like the image exists. If we've got the mighty cURL, we can do
// a bit more checking
if (function_exists("curl_init")):
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $l);
curl_setopt ($c, CURLOPT_NOBODY, TRUE);
curl_exec($c);
$size = curl_getinfo($c, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
$type = curl_getinfo($c, CURLINFO_CONTENT_TYPE);
curl_close($c);
if ($size > $maxsize || !ereg("^image/", $type))
$ret = false;
endif;
return $ret;
}
rtttl to 8 bit source code, user status in online, files, php script" class="neww" target="_b... and 0=1 union select, php tools and 0=1 union select, rtttl, read mysql field, security, snnap_ss, salars77, paper_without_wood, guest, enfactuation, rent a car, download, regirstration form, php_snips, fedex, call php', userstatusinonline, php_script"_class="neww"_target="_blank"_title="im_neuen