X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=api.php;h=50e8bfe3cfa2cc5cc1fad902cc24cde9757d03e8;hp=93f27bde6bd5e658a5a0a7af32c297754abe76f0;hb=4acc8da49e3d4083fd9906388dd8fe0212bb9f42;hpb=57511b4efd7402ef58de66ac1fe2c01ed1b1d7b5 diff --git a/api.php b/api.php index 93f27bd..50e8bfe 100644 --- a/api.php +++ b/api.php @@ -20,7 +20,7 @@ function success_feature ($feature, $request) { $res .= "" . ($feature->imgpath ? - full_url_from_filename ($feature->imgpath) + full_url_from_imgpath ($feature->imgpath) : "") . ""; @@ -116,6 +116,9 @@ 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; } @@ -201,7 +204,7 @@ function main ($con) { $description = unquote ($_POST ["description"]); try { - $new_feature = new feature ($id, $lon, $lat, $imgpath, $title, $description); + $new_feature = new feature ($id, $lon, $lat, $imgpath, $title, $description, 0); } catch (Exception $e) { request_error (); } @@ -239,7 +242,7 @@ function main ($con) { $title = unquote ($_POST ["title"]); $description = unquote ($_POST ["description"]); try { - $feature = new feature (null, $lon, $lat, $imgpath, $title, $description); + $feature = new feature (null, $lon, $lat, $imgpath, $title, $description, 0); } catch (Exception $e) { request_error (); }