<?php 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;
} ?>
|
|