$res .= "<imgurl>" .
($feature->imgpath ?
- full_url_from_filename ($feature->imgpath)
+ full_url_from_imgpath ($feature->imgpath)
: "") .
"</imgurl>";
error ("notimage");
}
+function delete_from_ftp ($file) {
+ $ftp_conn = ftp_connect (FTPSERVER);
+ $login = ftp_login ($ftp_conn, FTPUSER, FTPPASS);
+ if ((!$ftp_conn) || (!$login)) {
+ server_error ();
+ }
+ $target = sprintf ("%s/%s", FTPIMGDIR, basename ($file));
+ $deleted = ftp_delete ($ftp_conn, $target);
+
+ if (!$deleted) {
+ server_error ();
+ }
+ ftp_close ($ftp_conn);
+}
+
+function send_to_ftp ($file) {
+ $ftp_conn = ftp_connect (FTPSERVER);
+ $login = ftp_login ($ftp_conn, FTPUSER, FTPPASS);
+ if ((!$ftp_conn) || (!$login)) {
+ server_error ();
+ }
+ $dest = sprintf ("%s/%s", FTPIMGDIR, basename ($file));
+ $upload = ftp_put ($ftp_conn, $dest, $file, FTP_BINARY);
+
+ if (!$upload) {
+ server_error ();
+ }
+ ftp_close ($ftp_conn);
+}
+
function save_uploaded_file ($file, $con) {
$dest = "";
if (isset ($file) && ($file ["error"] != UPLOAD_ERR_NO_FILE)) {
(!move_uploaded_file ($file ["tmp_name"], $dest))) {
server_error ();
}
+ send_to_ftp ($dest);
}
- 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;
}
$path = UPLOADDIR . "/" . $imgpath;
if (file_exists($path)) {
unlink ($path);
+ delete_from_ftp ($path);
return true;
} else {
return false;
while ($counter < 1000) {
if (!file_exists ($filename) &&
- !($con->imgpath_exists (basename ($filename)))) {
+ !($con->imgpath_exists (basename_safe ($filename)))) {
return $filename;
} else {
$counter++;
$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 ();
}
$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 ();
}