X-Git-Url: https://dev.renevier.net/gitweb.cgi?p=syp.git;a=blobdiff_plain;f=api.php;h=7895dadec249500bbd5cea178bd76c3421bdc5d4;hp=bb89c55d924e572ae048d443e89f739738683991;hb=a42abf4f24b4ba9fc5ad84b39c74e1b7a446934e;hpb=756e90840f47c110d346c863238375bb59a10475 diff --git a/api.php b/api.php index bb89c55..7895dad 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) { @@ -254,6 +255,7 @@ function main ($con) { if ($_POST ["keep_img"] == "yes") { $imgpath = $feature->imgpath; } else { + error_request (); $imgpath = save_uploaded_file ($_FILES ["image_file"], $con); } @@ -294,6 +296,7 @@ function main ($con) { success_feature ($new_feature, "update"); break; case "add": + error_request (); $imgpath = save_uploaded_file ($_FILES ["image_file"], $con); $lon = $_POST ["lon"]; @@ -313,6 +316,7 @@ function main ($con) { success_feature ($feature, "add"); break; case "del": + error_request (); $id = $_POST ["fid"]; $feature = $con->getfeature ($id); if (!isset ($feature)) { @@ -335,6 +339,7 @@ function main ($con) { success_delete_feature ($feature); case "changepass": + error_request (); $currpass = unquote ($_POST ["pass_current"]); if (!$con->checkpwdmd5 ($user, md5 ($currpass))) { error_wrongpass (); @@ -343,12 +348,16 @@ function main ($con) { try { $con->setpwd ($user, $newpass); } catch (Exception $e) { + if ($e->getMessage () == anydbConnection::err_query) { + error_request (); + } error_server (); } setcookies ($user, $newpass); success_changepass ($user); break; case "newuser": + error_request (); if ($user != "admin") { error_unauthorized (); } @@ -363,6 +372,9 @@ function main ($con) { try { $con->setpwd ($newuser_name, $newuser_password); } catch (Exception $e) { + if ($e->getMessage () == anydbConnection::err_query) { + error_request (); + } error_server (); } success_newuser ($newuser_name);