static function upload_image($photo_name, $path, $w, $h) { if (is_uploaded_file($_FILES[$photo_name]['tmp_name'])) { $f_name = ""; $a = md5(date('U') . $_FILES[$photo_name]["name"]); $ext = strtolower(array_pop(explode(".", $_FILES[$photo_name]["name"]))); $f_name = $path . "/big/" . $a . "." . $ext; $thumb_name = $path . "/thumb/" . $a . "." . $ext; if ($f_name != "") { if (move_uploaded_file($_FILES[$photo_name]["tmp_name"], $f_name)) { $size = getimagesize($f_name); if ($size[0] > $size[1]) { $width = $w; $height = round($width * ($size[1] / $size[0])); } else { $height = $h; $width = round($height * ($size[0] / $size[1])); } if ($size[0] > 1000 || $size[1] > 1000) { exec('mogrify -resize ' . $width * 3 . 'x' . $height * 3 . ' ' . $f_name); } if (engine::resize_image($f_name, $thumb_name, intval($width), intval($height))) { return $a . "." . $ext; } return 'error'; } return 'error'; } return 'error'; } return 'error'; }