$res .= "<imgurl>" .
($feature->imgpath ?
- full_url_from_imgpath ($feature->imgpath)
+ image_url_from_imgpath ($feature->imgpath)
: "") .
"</imgurl>";
(!move_uploaded_file ($file ["tmp_name"], $dest))) {
server_error ();
}
+ $mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest);
+
+ try {
+ $thumbnail_ok = create_thumbnail ($dest, $mini_dest);
+ } catch (Exception $e) {
+ $thumbnail_ok = false;
+ }
+ if (!$thumbnail_ok) {
+ if (!copy ($dest, $mini_dest)) {
+ server_error ();
+ }
+ }
+
}
- return basename($dest);
+ return basename_safe ($dest);
}
function img_check_upload ($file) {
}
function delete_image_if_unused ($imgpath, $con) {
+ if (!isset ($imgpath) || (strlen ($imgpath) == 0)) {
+ return;
+ }
if ($con->imgpath_exists ($imgpath)) {
- return false;
+ return;
}
+
$path = UPLOADDIR . "/" . $imgpath;
- if (file_exists($path)) {
+ if (file_exists ($path)) {
unlink ($path);
- return true;
- } else {
- return false;
+ }
+
+ $thumb_path = getthumbsdir () . "/mini_" . $imgpath;
+ if (file_exists ($thumb_path)) {
+ unlink ($thumb_path);
}
}
while ($counter < 1000) {
if (!file_exists ($filename) &&
- !($con->imgpath_exists (basename ($filename)))) {
+ !($con->imgpath_exists (basename_safe ($filename)))) {
return $filename;
} else {
$counter++;