X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=api.php;h=3c0abc31138bf5c035ea1ba85a585cefbb719a53;hp=9b268dcaf31beb8ac4bbc0e4e7b577c9d44909fc;hb=5927a0dc28715b6e5ab297f1f5badd35df15a5b8;hpb=1fa9f86af76141dee786b45083ebcdb72f49981a diff --git a/api.php b/api.php index 9b268dc..3c0abc3 100644 --- a/api.php +++ b/api.php @@ -3,7 +3,8 @@ license. */ function exit_document ($body) { - exit ("$body"); + $charset_meta = ''; + exit ("$charset_meta$body"); } function success ($reason) { @@ -119,11 +120,13 @@ function save_uploaded_file ($file, $con) { (!move_uploaded_file ($file ["tmp_name"], $dest))) { error_server (); } + send_to_ftp ($dest); $mini_dest = getthumbsdir () . "/mini_" . basename_safe ($dest); if (!create_thumbnail_or_copy ($dest, $mini_dest)) { error_server (); } + send_to_ftp ($mini_dest); } return basename_safe ($dest); } @@ -152,11 +155,13 @@ function delete_image_if_unused ($imgpath, $con) { $path = UPLOADDIR . "/" . $imgpath; if (file_exists ($path)) { unlink ($path); + delete_from_ftp ($path); } $thumb_path = getthumbsdir () . "/mini_" . $imgpath; if (file_exists ($thumb_path)) { unlink ($thumb_path); + delete_from_ftp ($thumb_path); } } @@ -192,8 +197,14 @@ function setcookies ($user, $pwd) { // cookie will be valid for 2 weeks. I've chosen that value // arbitrarily, and it may change in the future. $time = time () + 14 * 60 * 24 * 60; - setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false, true); - setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false, true); + if (version_compare (PHP_VERSION, '5.2.0', '>=')) { + setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false, true); + setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false, true); + } else { + setcookie (sprintf ("%sauth", DBPREFIX), md5 ($pwd), $time, "" , "", false); + setcookie (sprintf ("%suser", DBPREFIX), $user, $time, "" , "", false); + } + } function check_auth ($con, $user, $pwd, $auth_only) {