$max_x || $height > $max_y) {
$prop_x = $width / $max_x;
$prop_y = $height / $max_y;
$prop = ($prop_x>$prop_y)? $prop_x: $prop_y;
$width = round($width/$prop);
$height = round($height/$prop);
}
return "
";*/
//by default, just return img tag to original image
return "
";
}
function check_image($filename, $image_params) {
global $pics_maxh, $pics_maxw, $w_too_big_photo_height, $w_too_big_photo_width, $w_invalid_image;
$error = 0;
$error_text = "";
if ($image_params[2] <1 or $image_params[2]>3) {
//not an image
$error_text .= $w_invalid_image." code: ".$image_params[2];
$error = 1;
@unlink($filename);
} else if ($image_params[0]<1 or $image_params[0] > $pics_maxw) {
$error_text .= str_replace("~", $pics_maxw,
str_replace("*", $image_params[0], $w_too_big_photo_width));
$error = 1;
@unlink($filename);
} else if ($image_params[1]<1 or $image_params[1] > $pics_maxh) {
$error_text .= str_replace("~", $pics_maxh,
str_replace("*",$image_params[1], $w_too_big_photo_height));
$error = 1;
@unlink($filename);
}
return array($error, $error_text);
}
//remove all uploaded images which is older than 2 hours.
function remove_old_images() {
global $file_path;
if ($pic_dir = opendir($file_path."up/")) {
while (false !== ($file = readdir($pic_dir))) {
$f_und = strpos($file, "_");
$s_und = strpos($file, "_", $f_und+1);
$dot = strpos($file, ".");
if ($s_und>0 && $dot>$s_und) {
$creation_time = intval(substr($file, $s_und+1, $dot-$s_und-1));
if ($creation_time >0 && $creation_time